Their library is good for CUDA. Maybe soon we can use the library in OpenCL.
clEnqueueWriteImage segmentation fault
Labels: OpenCL 2 commentsI got segmentation fault at clEnqueueWriteImage, but could not find any mistake in the arguments.
Eventually I tried just writing range {1,1,1} but still got error. Thus it was obviously that something other caused the segmentation fault, and it was clCreateImage!
I created a large image (1024x1024x1024) with format UNORM_INT8 of RGBA. I still don't know why this size exceeded the limit, and why nVidia's OpenCL library didn't return error when I called clCreateImage.
In the end I used this size 512x512x512 and it worked fine. Strange thing +1.
Posted by MiGi at 8:26 PM
OpenCL buffer usage
Labels: OpenCL 1 commentsOpenCL buffer creation is too tedious and every time takes me lot of my time figuring out why it doesn't work. Here is some notes I learned after working on several hours.
__constant Limitation
Cannot set a large buffer as __constant in kernel arguments. nVidia GPU will be erroneous reading the buffer(but not showing error message! But you get wrong values!) because constant values are in local registers which cannot contain large array.
Solution: Use __global instead. To enhance performance, use CL_READ_ONLY in clCreateBuffer. This will increase the speed a lot.
Data Re-usage
If you have an array being changed in OpenCL kernel, and will be re-used next time running the kernel, it's not efficient if you just create a CL_READ_WRITE buffer.
Solution: Instead, create two buffers, CL_READ_ONLY, CL_WRITE_ONLY, and set them __global in the kernel arguments. After each round the host copy (clCopyBuffer) the written buffer back to the read-only buffer.In other words, never use CL_READ_WRITE! That will turn parallelism down to be serialized!
* Revision: I used CL_READ_WRITE in the end and found that it worked well, to hold my previous state and re-usable in the next clExecuteNDRangeKernel call. This saves time copying buffers. I am not sure why it ran slowly before. Maybe the updated driver or I am aware of buffer coalescing.
Posted by MiGi at 8:56 AM
nVidia Driver 196.21
Labels: OpenCL 0 commentsNoticed that nVidia has released new drivers couple of weeks ago. But for the 9400M on my laptop it's still 195.xx. Sad...
Currently nVidia's openCL runs slowly. It's slower than the same task implemented by GLSL on the same graphics card. I'm really wondering when the efficiency will be better, or never...
Posted by MiGi at 4:53 PM
Diseño e iconos por N.Design Studio | A Blogger por Blog and Web