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
@krzywon krzywon self-requested a review December 16, 2025 15:17
Copy link
Collaborator

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

Seems reasonable. Tested locally and the warnings are suppressed.

Side question - with the new argument in compile_program(), what consequences are there for dependent packages? Calls to the method are handled internally, but should we note this change in release notes, just in case?

@pkienzle
Copy link
Contributor Author

There is no reason to directly call compile_program() from outside of kernelcl.py

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.

3 participants