Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Journeyman III

Cannot create (xor use!) sub-buffers for nonzero origins


Hello 🙂


I've struggled all the night against the bug. I'll try to describe precisely the problem...


Firstly, i'm on Linux. This bug appears on both 32 and 64 bit under Catalyst 11.12 and 11.11 (didn't test any other, because had some problems installing them :p), on Ubuntu or Arch (Chakra) Linux. And it appears with AMD-APP-SDK 2.6, 2.5. There is a similar problem with AMD-APP-SDK 2.4 ... I don't know if the problem comes from me or if i'm just the first to report it 🙂


Firstly, here's the buggy code

It is just about getting platform, devices, creating a context and allocating a buffer inside, and then creating a sub-buffer from the former.

AMD-APP-SDK 2.6 : Unknown error when the origin of the cl_region is not zero

AMD-APP-SDK 2.5 : cl_success when creating the sub-buffer, but CL_OUT_OF_RESOURCES when trying to read/write to it (last step of the code). did not test CPU.

AMD-APP-SDK 2.4 :  Same thing as before, but tested CPU. The same code works with my Intel Q9505.

In each case, all the tests from the SDK I've done work perfectly.

In every case, the code works well on my nvidia-card under the nvidia sdk... so the problem may not come from the code. 

Hope it helps and, if it's a bug, it will be fixed soon ! 

Edit : My graphic card is an HD5850

int main(int argc, char** argv) { static const int SIZE = 4; int err; float buffer[SIZE]; cl_device_id device_id; cl_context context; cl_command_queue commands; cl_program program; cl_kernel kernel; cl_mem input; cl_mem output; int i = 0; unsigned int count = SIZE; for(i = 0; i < count; i++) buffer = i; cl_platform_id platform; err = clGetPlatformIDs(1,&platform,NULL); if (err != CL_SUCCESS) { printf("Error: Failed to create a platform!\n", print_cl_errstring(err)); std::cout << print_cl_errstring(err) << std::endl; return EXIT_FAILURE; } int gpu = 1; err = clGetDeviceIDs(platform, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL); if (err != CL_SUCCESS) { printf("Error: Failed to create a device group!%s\n", print_cl_errstring(err)); return EXIT_FAILURE; } context = clCreateContext(0, 1, &device_id, NULL, NULL, &err); if (!context) { printf("Error: Failed to create a compute context!%s\n", print_cl_errstring(err)); return EXIT_FAILURE; } commands = clCreateCommandQueue(context, device_id, 0, &err); if (!commands) { printf("Error: Failed to create a command commands!%s\n", print_cl_errstring(err)); return EXIT_FAILURE; } input = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * count, NULL, NULL); cl_buffer_region region; region.origin = (size_t)sizeof(float); region.size = (size_t)2*sizeof(float); cl_mem sub= clCreateSubBuffer(input,CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, &region, &err); if(err!=CL_SUCCESS){ printf("Error: Failed to create SubBuffer! %s\n", print_cl_errstring(err)); return EXIT_FAILURE; } int temp = 0; err = clEnqueueReadBuffer(commands, sub, CL_TRUE, 0, sizeof(float), &temp, 0, NULL, NULL); if(err!=CL_SUCCESS){ printf("Error: Failed to read SubBuffer! %s\n", print_cl_errstring(err)); return EXIT_FAILURE; } std::cout << temp << std::endl; }

Tags (3)
1 Reply
Journeyman III

Cannot create (xor use!) sub-buffers for nonzero origins