Skip to content

Conversation

@pkienzle
Copy link
Contributor

@pkienzle pkienzle commented Sep 19, 2025

Cache the kernels as well as the program so that we avoid the following RepeatedKernelRetrieval warning:

sasmodels/model_test.py::ellipsoid[opencl]
  /.../sasmodels/kernelcl.py:469: RepeatedKernelRetrieval: Kernel 'ellipsoid_Iqxy' has been retrieved more than once. Each retrieval creates a new, independent kernel, at possibly considerable expense. To avoid the expense, reuse the retrieved kernel instance. To avoid this warning, use cl.Kernel(prg, name).
    functions = [getattr(program, k) for k in names]

Note: this code is used by SasView

@DrPaulSharp DrPaulSharp force-pushed the fix-ocl-duplicate-kernel branch from 8fb43a9 to d2ceae8 Compare November 3, 2025 16:20
self.compiled[key] = (program, timestamp)
return program
kernels = [getattr(program, k) for k in kernel_names]
self.compiled[key] = (program, timestamp, kernels)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be failing with TypeError: unhashable type: 'list', and similarly in kernelcl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants