Changeset 6e5b2a7 in sasmodels


Ignore:
Timestamp:
Sep 30, 2016 5:31:12 AM (8 years ago)
Author:
ajj
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2222134
Parents:
0bef47b
git-author:
Paul Kienzle <pkienzle@…> (09/30/16 05:31:12)
git-committer:
Andrew Jackson <andrew.jackson@…> (09/30/16 05:31:12)
Message:

ticket 363: Allow other processes to run during long computations (#9)

  • Allow other processes to run during long computations

( erroneous branch: fixing the tests in pringle model and Revert "and fixing the tests in pringle model".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    ra557a99 r6e5b2a7  
    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.