OpenCL: Difference between revisions

No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 6: Line 6:
===Linux===
===Linux===
https://gist.github.com/Brainiarc7/dc80b023af5b4e0d02b33923de7ba1ed
https://gist.github.com/Brainiarc7/dc80b023af5b4e0d02b33923de7ba1ed
<pre>
sudo apt install ocl-icd-opencl-dev opencl-headers
sudo apt install opencl-c-headers opencl-clhpp-headers
</pre>


==Getting Started==
==Getting Started==
Line 242: Line 246:
</syntaxhighlight>
</syntaxhighlight>
}}
}}
===Python===
See [https://documen.tician.de/pyopencl/index.html pyopencl].


===Julia===
===Julia===
Line 264: Line 271:
==OpenGL Interop==
==OpenGL Interop==
Setting up OpenCL/OpenGL interop is fairly complicated and very hard to debug.   
Setting up OpenCL/OpenGL interop is fairly complicated and very hard to debug.   
You will also need to manage synchronizing OpenGL/OpenCL so that aren't accessing the same memory at the same time.   
You will also need to manage synchronizing OpenGL/OpenCL so they do not access the same memory at the same time.   
If you can, just use OpenGL compute shaders rather than OpenCL to simplify your life.
If you can, just use OpenGL compute shaders rather than OpenCL to simplify your life.


Line 271: Line 278:


In C++, you can use [https://github.khronos.org/OpenCL-CLHPP/classcl_1_1_image_g_l.html <code>cl::ImageGL</code>] to access textures in OpenGL.   
In C++, you can use [https://github.khronos.org/OpenCL-CLHPP/classcl_1_1_image_g_l.html <code>cl::ImageGL</code>] to access textures in OpenGL.   
Note that <code>cl::Image</code> and <code>cl::Buffer</code> are not the same thing. A buffer is a contiguous section of memory whereas an image is a mipmapped texture. Interchanging them will result in <code>CL_INVALID_MEM_OBJECT</code> errors or similar.
Note that <code>cl::Image</code> and <code>cl::Buffer</code> are not the same thing. Interchanging them will result in <code>CL_INVALID_MEM_OBJECT</code> errors or similar.
I recommend writing to a separate buffer and copying to images.
I recommend writing to a separate buffer and copying to images.


Line 283: Line 290:
==Advanced Topics==
==Advanced Topics==
====Local Memory v. Global Memory====
====Local Memory v. Global Memory====
[[Category:Programming languages]]
[[Category:GPU Programming languages]]