Changeset 00afc15 in sasmodels


Ignore:
Timestamp:
Nov 9, 2018 2:55:32 PM (6 years ago)
Author:
pkienzle
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3199b17
Parents:
0be86aa
Message:

fix cuda tests

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    r0be86aa r00afc15  
    444444        variants = ['Iq', 'Iqxy', 'Imagnetic'] 
    445445        names = [generate.kernel_name(self.info, k) for k in variants] 
    446         handles = [getattr(program, k) for k in names] 
    447         self._kernels = {k: v for k, v in zip(variants, handles)} 
     446        functions = [getattr(program, k) for k in names] 
     447        self._kernels = {k: v for k, v in zip(variants, functions)} 
    448448        # keep a handle to program so GC doesn't collect 
    449449        self._program = program 
  • sasmodels/kernelcuda.py

    r7126c04 r00afc15  
    6363import time 
    6464import re 
     65import atexit 
    6566 
    6667import numpy as np  # type: ignore 
     
    138139    return ENV 
    139140 
     141def free_context(): 
     142    global ENV 
     143    if ENV is not None: 
     144        ENV.release() 
     145        ENV = None 
     146 
     147atexit.register(free_context) 
     148 
    140149def has_type(dtype): 
    141150    # type: (np.dtype) -> bool 
     
    341350        variants = ['Iq', 'Iqxy', 'Imagnetic'] 
    342351        names = [generate.kernel_name(self.info, k) for k in variants] 
    343         handles = [program.get_function(k) for k in names] 
    344         self._kernels = {k: v for k, v in zip(variants, kernels)} 
     352        functions = [program.get_function(k) for k in names] 
     353        self._kernels = {k: v for k, v in zip(variants, functions)} 
    345354        # keep a handle to program so GC doesn't collect 
    346355        self._program = program 
    347  
    348     def release(self): 
    349         # type: () -> None 
    350         """ 
    351         Free the resources associated with the model. 
    352         """ 
    353         if self.program is not None: 
    354             self.program = None 
    355  
    356     def __del__(self): 
    357         # type: () -> None 
    358         self.release() 
    359356 
    360357# TODO: check that we don't need a destructor for buffers which go out of scope 
     
    473470        kernel_args = [ 
    474471            np.uint32(self.q_input.nq), None, None, 
    475             details_b, values_b, self.q_input.q_b, self.result_b, 
     472            details_b, values_b, self.q_input.q_b, self._result_b, 
    476473            self._as_dtype(cutoff), 
    477474            np.uint32(effective_radius_type), 
     
    487484            stop = min(start + step, call_details.num_eval) 
    488485            #print("queuing",start,stop) 
    489             args[1:3] = [np.int32(start), np.int32(stop)] 
    490             kernel(*args, **grid) 
     486            kernel_args[1:3] = [np.int32(start), np.int32(stop)] 
     487            kernel(*kernel_args, **grid) 
    491488            if stop < call_details.num_eval: 
    492489                sync() 
     
    497494                    last_nap = current_time 
    498495        sync() 
    499         cuda.memcpy_dtoh(self.result, self.result_b) 
     496        cuda.memcpy_dtoh(self.result, self._result_b) 
    500497        #print("result", self.result) 
    501498 
  • sasmodels/model_test.py

    r5024a56 r00afc15  
    167167        # test using cuda if desired and available 
    168168        if 'cuda' in loaders and use_cuda(): 
    169             test_name = "%s-cuda"%model_name 
     169            test_name = "%s-cuda" % model_info.id 
    170170            test_method_name = "test_%s_cuda" % model_info.id 
    171171            # Using dtype=None so that the models that are only 
Note: See TracChangeset for help on using the changeset viewer.