cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

amcelroy
Adept I

clEnqueueWriteBufferRect crashes 7970

Howdy folks,

Ran into a nasty issue and was wondering if I could get some help.  OpenCL device is an AMD7970 running Catalyst 13.4 release.  As the title of the post states, I'm either crashing the OS or causing a driver display timeout when trying to use  clEnqueueWriteBufferRect. 

This thread (http://devgurus.amd.com/thread/160312) seems to be along a similar vein, but the thread author reported the issue fixed at the end. A basic example of the code causing the problem is:

#include <CL/cl.h>

void main(){

  int Width = 4096;

  int Height = 1;

  int Depth = 1;

  int Error = 0;

  float *WriteData = new float[Width*Height*Depth];

  float *ReadData = new float[Width*Height*Depth];

  for(int i = 0; i < Width*Height*Depth; i++){

  WriteData = i;

  }

  cl_context Context;

  cl_command_queue Queue;

  /*****YOU MUST SETUP A DEVICE HERE*****/

  /****END DEVICE SETUP*****/

  size_t Region[3] = {sizeof(float)*Width, Height, Depth};

  size_t DevOrigin[3] = {0, 0, 0};

  size_t HostOrigin[3] = {0, 0, 0};

  cl_mem DeviceTestData = clCreateBuffer(Context, CL_MEM_READ_WRITE, sizeof(float)*Width*Height*Depth, NULL, NULL);

  Error = clEnqueueWriteBufferRect(Queue, DeviceTestData, true, DevOrigin, HostOrigin, Region, 0, 0, 0, 0, WriteData, NULL, NULL, NULL);

  Error = clEnqueueReadBufferRect(Queue, DeviceTestData, true, DevOrigin, HostOrigin, Region, 0, 0, 0, 0, ReadData, NULL, NULL, NULL);    

}

As noted in the code, please setup your device however needed.  Save your work though!

Thanks,

Austin

0 Likes
7 Replies
amcelroy
Adept I

Update:  The AMD OpenCL drivers on the Intel i5-2400 processor works perfectly and doesn't freeze/crash.

0 Likes

Thanks for the report. I will try it at my end, and report the results.

0 Likes
amcelroy
Adept I

Hey sorry to bump a post and bug folks,

Were you able to reproduce the error?  If not, can I give you more info or does anyone have any suggestions?

Thanks,

Austin

0 Likes

its been little busy these days, so there is this lag. I will give you some update today.

0 Likes

Looks like the hang is happening when we try to read/write the complete buffer using the *Rect API. Forwarding that to Engg team. you can use clEnqueueWriteBuffer for this purpose as of now. Seems to be windows only issue.

The following code works for me:

size_t Region[3] = {sizeof(float)*(Width - 1), Height, Depth};

    size_t DevOrigin[3] = {0, 0, 0};

    size_t HostOrigin[3] = {0, 0, 0};

    cl_mem DeviceTestData = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float)*Width*Height*Depth, NULL, &Error);

    if(Error)

    {

    std::cout << "CreateBuffer returns:" << Error;

    exit(1);

    }

    Error = clEnqueueWriteBufferRect(commandQueue, DeviceTestData, CL_TRUE, DevOrigin, HostOrigin, Region, Width * sizeof(float), Width * Height * sizeof(float), Width * sizeof(float), Width * Height * sizeof(float), WriteData, NULL, NULL, NULL);

    if(Error)

    {

    std::cout << "WriteBufferRect returns:" << Error;

    exit(1);

    }

    //Region[0] = sizeof(float)*(Width - 1), Region[1] = Height, Region[2] = Depth;

    Error = clEnqueueReadBufferRect(commandQueue, DeviceTestData, true, DevOrigin, HostOrigin, Region, 0, 0, 0, 0, ReadData, NULL, NULL, NULL);  

    if(Error)

    {

    std::cout << "ReadBufferRect returns:" << Error;

    exit(1);

    }

Found another potential bug.  Using a 5x5x5 the last slice isn't copied using AMD OpenCL platform on an Intel processor.  Sorry, no AMD processor to test one.


You should be happy to know that NVIDIA didn't even bother to implement clEnqueueWriteBufferRect, which is definately the best way to get data on and off the card!


Thanks for confirming the issue on the 7970 and coming up with a work around.


Austin

0 Likes

Nevermind, everything is working proper with the AMD Platform on the Intel processer.  Bug was on my end.  Marking as closed since the AMD 7970 issue is confirmed as an issue and will be fixed.