-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
silx.opencl: Avoid executing OpenCL kernels at import time #4088
Comments
+1 I really don't like this probing at import which silently creates contexts all over the place. I've had numerous issues in the past with it. The only advantage is that the "best" device is automatically picked (though "best" can be incorrect in certain cases). Perhaps this probing could be made optional with an environment variable, eg. |
I would be in favor of a Python API rather than an env. var. to control this. I'd keep the automatic selection as the default behavior (since it is a good default and it would otherwise break the compatibility). |
I am on it ... several path have been envisaged to mitigate this effect:
Only the first one is really tricky... |
BTW, there is silx.config which is used to custom some behaviors (mostly for plots), but it may be used here. Best to stick to built-in types there though. |
- make the OpenCL class a borg (i.e. instatiating it again is for free) - make atomic32/64 cached properties, evaluated at runtime rather than at import time - make the ocl object creation at runtime, not at import-time Overall the import time decreased from 2000ms to 200ms. close silx-kit#4088 PS: I hate the black formating.
First raised in #4077 (comment) :
Also, for advanced usage, 1it would be nice to be able to set the OpenCL platforms+devices to use to spare the probing of all platforms
The text was updated successfully, but these errors were encountered: