Firefly Open Source Community

Title: Linux/OpenCL: crash when reading memory from device [Print This Page]

Author: patricka    Time: 7/21/2021 22:36
Title: Linux/OpenCL: crash when reading memory from device
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:


  1.       // creation
  2.        float * data = new float[ARRAY_SIZE];
  3.        float * result = new float[ARRAY_SIZE];
  4.        cl_mem memObjects[2];
  5.         memObjects[0] = clCreateBuffer(
  6.                 context,
  7.                 CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
  8.                 sizeof(float) * ARRAY_SIZE,
  9.                 data,
  10.                 NULL);
  11.         memObjects[1] = clCreateBuffer(
  12.                 context,
  13.                 CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
  14.                 sizeof(float) * ARRAY_SIZE,
  15.                 NULL,
  16.                 NULL);

  17. (...)
  18.         // processing
  19. (...)
  20.         errNum = clEnqueueReadBuffer(
  21.                 commandQueue,
  22.                 memObjects[1],
  23.                 CL_TRUE,
  24.                 0,
  25.                 ARRAY_SIZE * sizeof(float),
  26.                 result,
  27.                 0,
  28.                 NULL,
  29.                 NULL);

Copy the code


Thank you very much.




Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) Powered by Discuz! X3.1