Changeset 6f89000 in sasmodels


Ignore:
Timestamp:
Sep 24, 2016 5:51:20 PM (3 years ago)
Author:
Paul Kienzle <pkienzle@…>
Children:
d3e3c46a
Parents:
52ec91e
Message:

Allow other processes to run during long computations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    ra557a99 r6f89000  
    5454import warnings 
    5555import logging 
     56import time 
    5657 
    5758import numpy as np  # type: ignore 
     
    557558        #call_details.show(values) 
    558559        # Call kernel and retrieve results 
    559         last_call = None 
    560         step = 100 
     560        wait_for = None 
     561        last_nap = time.clock() 
     562        step = 1000000//self.q_input.nq + 1 
    561563        for start in range(0, call_details.num_eval, step): 
    562564            stop = min(start + step, call_details.num_eval) 
    563565            #print("queuing",start,stop) 
    564566            args[1:3] = [np.int32(start), np.int32(stop)] 
    565             last_call = [kernel(self.queue, self.q_input.global_size, 
    566                                 None, *args, wait_for=last_call)] 
     567            wait_for = [kernel(self.queue, self.q_input.global_size, None, 
     568                               *args, wait_for=wait_for)] 
     569            if stop < call_details.num_eval: 
     570                # Allow other processes to run 
     571                wait_for[0].wait() 
     572                current_time = time.clock() 
     573                if current_time - last_nap > 0.5: 
     574                    time.sleep(0.05) 
     575                    last_nap = current_time 
    567576        cl.enqueue_copy(self.queue, self.result, self.result_b) 
    568577        #print("result", self.result) 
Note: See TracChangeset for help on using the changeset viewer.