Question

Today I stumbled over a post in stackoverflow (see also here):

We are developing opencl4py, higher level bindings. This project uses CFFI, so it works on Pypy.

The major issue we encountered with pyopencl is that 'import pyopencl' does OpenCL initialization and takes the whole virtual memory in case of NVIDIA driver, preventing from correct forking and effectively disabling multiprocessing (yes, we claim that using pyopencl disables multiprocessing at least with NVIDIA). opencl4py uses lazy OpenCL initialization, resolving this "import hell".

Later, it gained some nice features like super easy binary program caching, etc. Unfortunately, the documentation is somewhat brief. The best way to learn how it works is go through the tests.

As there is also pyOpenCL, I was woundering what the difference between these two packages is. Does anybody know where I can find an overview on the pro's and con's for these both packages?

Edit: To include benshope's comment as I would also be interested: what does "disable[s] multiprocessing" mean? Like, it can't run kernels on several devices at one time?

Was it helpful?

Solution

As far as I know, there is no such overview. I'll try to list some key points:

  • pyOpenCL is a mature project with a relatively large user base. There are tutorials, FAQ, etc. opencl4py appeared on 03/2014; no tutorials, FAQ and so on - only unit tests and docstrings.
  • pyOpenCL is a native cPython extension, whereas opencl4py uses cffi, so that it works on PyPy (pyOpenCL does NOT) and it does not require to be recompiled each time cPython changes version.
  • PyOpenCL has extras, such as random number generator and OpenGL interoperability.
  • opencl4py is extensively tested in Samsung production real world scenarios and is being actively developed.

what does "disable[s] multiprocessing" mean? Like, it can't run kernels on several devices at one time?

Of course, it can, I was trying to say that after importing pyopencl, os.fork() or multiprocessing.Process() lead to crashes inside NVIDIA OpenCL userspace library. It is always a bad idea of doing work during import.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top