Changeset 300a2f7 in sasmodels
- Timestamp:
- Aug 18, 2016 11:30:23 AM (8 years ago)
- 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:
- 4f3dd42
- Parents:
- 6dc78e4
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelcl.py
rbde38b5 r300a2f7 281 281 warnings.warn("the environment variable 'PYOPENCL_CTX' might not be set correctly") 282 282 283 def compile_program(self, name, source, dtype, fast =False):284 # type: (str, str, np.dtype, bool ) -> cl.Program283 def compile_program(self, name, source, dtype, fast, timestamp): 284 # type: (str, str, np.dtype, bool, float) -> cl.Program 285 285 """ 286 286 Compile the program for the device in the given context. 287 287 """ 288 # Note: PyOpenCL caches based on md5 hash of source, options and device 289 # so we don't really need to cache things for ourselves. I'll do so 290 # anyway just to save some data munging time. 288 291 key = "%s-%s%s"%(name, dtype, ("-fast" if fast else "")) 292 # Check timestamp on program 293 program, program_timestamp = self.compiled.get(key, (None, np.inf)) 294 if program_timestamp < timestamp: 295 del self.compiled[key] 289 296 if key not in self.compiled: 290 297 context = self.get_context(dtype) … … 293 300 program = compile_model(self.get_context(dtype), 294 301 str(source), dtype, fast) 295 self.compiled[key] = program 296 return self.compiled[key] 297 298 def release_program(self, name): 299 # type: (str) -> None 300 """ 301 Free memory associated with the program on the device. 302 """ 303 if name in self.compiled: 304 self.compiled[name].release() 305 del self.compiled[name] 302 self.compiled[key] = (program, timestamp) 303 return program 306 304 307 305 def _get_default_context(): … … 399 397 if self.program is None: 400 398 compile_program = environment().compile_program 399 timestamp = generate.timestamp(self.info) 401 400 self.program = compile_program( 402 401 self.info.name, 403 402 self.source['opencl'], 404 403 self.dtype, 405 self.fast) 404 self.fast, 405 timestamp) 406 406 variants = ['Iq', 'Iqxy', 'Imagnetic'] 407 407 names = [generate.kernel_name(self.info, k) for k in variants] … … 421 421 """ 422 422 if self.program is not None: 423 environment().release_program(self.info.name)424 423 self.program = None 425 424 -
sasmodels/sasview_model.py
rbde38b5 r300a2f7 115 115 Load a custom model given the model path. 116 116 """ 117 #print("load custom", path) 117 118 kernel_module = custom.load_custom_kernel_module(path) 118 119 try:
Note: See TracChangeset
for help on using the changeset viewer.