|
【General】
Linux/OpenCL: crash when reading memory from device
Posted at 7/21/2021 22:36:16
View:2412
|
Replies:0
Print
Only Author
[Copy Link]
1#
Last edited by patricka In 7/21/2021 22:38 Editor
Hello group,
I have written a simple test program that pushes a buffer in an OpenCL command queue, process it and returns it. Nothing fancy here...
The problem raises when I want to read back the result from the command queue. The call to function clEnqueueReadBuffer() crashes internally (no way to investigate what's happening inside the call). It seems that there is some memory corruption or wrong buffer definition, etc... This is also happening with any call like clEnqueueMapBuffer() or clEnqueueReadBuffer() even using images clEnqueueMapImage() or clEnqueueReadImage()...
This code works on other platforms... which makes this really intriguing...
Any idea? What can I possibly do wrong?
I can post the entire code if needed, but here is a summary for the buffers:
-
- // creation
- float * data = new float[ARRAY_SIZE];
- float * result = new float[ARRAY_SIZE];
- cl_mem memObjects[2];
- memObjects[0] = clCreateBuffer(
- context,
- CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
- sizeof(float) * ARRAY_SIZE,
- data,
- NULL);
- memObjects[1] = clCreateBuffer(
- context,
- CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
- sizeof(float) * ARRAY_SIZE,
- NULL,
- NULL);
- (...)
- // processing
- (...)
- errNum = clEnqueueReadBuffer(
- commandQueue,
- memObjects[1],
- CL_TRUE,
- 0,
- ARRAY_SIZE * sizeof(float),
- result,
- 0,
- NULL,
- NULL);
Copy the code
Thank you very much. |
|