-
Notifications
You must be signed in to change notification settings - Fork 239
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
Segfault in clCreateFromGLBuffer on Arch64/Intel HD 5500/Beignet #117
Comments
I don't think beignet has GL interop just yet: https://cgit.freedesktop.org/cgit/?url=beignet/tree/docs/Beignet.mdwn#n204 |
Ah, didn't think to check since I wouldn't have expected a segfault for an unsupported API. I'm guessing that's ocl-icd's fault. Thanks! |
Looks like it is indeed ocl-icd's fault, since if I use beignet's libcl directly, I get:
which makes the problem a lot more clear. |
Ok, so Beignet does claim to implement clCreateFromGLTexture, but even though pyopencl.GLTexture is listed in the documentation, I see that in the code it just raises a NotImplementedError. So Beignet doesn't implement clCreateFromGLBuffer and pyopencl doesn't support clCreateFromGLTexture. Do you know what needs to be done to make pyopencl.GLTexture work? |
Hi,
@seanlynch : you say that Beignet does claim to implement clCreateFromGLTexture. Are you sure that cl_khr_gl_sharing is shown by Beignet? (I did not check) Because the availability of the symbol is not the good way to check the availability. So, from my point of view, users must correctly check the OpenCL functions they use (when they are not always available). There is the same kind of problems when functions from OpenCL 2.x are called with ICD supporting only OpenCL 1.x. Users (or run-times if they want to provide version agnostic support) must check the ICD version before calling version specific functions. |
I meant Beignet's documentation claims it:
It's quite possible that I was misreading what that meant. A developer has confirmed that Beignet does not in fact support clCreateFromGLTexture, and looking at the source code confirms that it is indeed not supported. It also looks like there's going to be a substantial amount of work involved since there needs to be support from the Mesa side because for some reason Intel has chosen to do their work outside of Mesa. At this point I'm trying to see if there's some undefined behavior that will let me share buffers/textures/images "by accident" (I have no idea how realistic that is but this slide deck gives me some hope) until Beignet gets support for cl_khr_gl_sharing. Otherwise I guess I'll just switch to GLSL. Perhaps I can do something similar to Reikna and generate both GLSL and OpenCL from the same templates. |
Actually I just discovered a decent fallback which should be fine on an integrated device since AFAICT it involves only a single copy that doesn't go over the PCI bus. Method 3 in https://software.intel.com/en-us/articles/opencl-and-opengl-interoperability-tutorial involves glMapBuffer, clCreateBuffer with CL_MEM_USE_HOST_PTR, clEnqueueMapBuffer, run kernel, clEnqueueUnmapMemObject, glUnmapBuffer, and glTexSubImage2D. I'll try this out tonight (California time) and see if it's a reasonable fallback until Beignet gets cl_khr_gl_sharing support. |
I'm trying to figure out how to share buffers between OpenCL and OpenGL, so I wrote a minimal test program just to make sure it worked. After recompiling PyOpenCL from git with --cl-enable-gl, pyopencl.has_gl() returns True, but the following program gives me a segfault at line 61. I've tried calling glFlush() in case it was a synchronization problem, but that did not help.
https://gist.github.com/seanlynch/f85846283fc712fd91ad
Stack trace:
Output of clinfo: https://gist.github.com/seanlynch/4c8b20c916fbab3c694b
Thanks for any help you can give me.
The text was updated successfully, but these errors were encountered: