Results 1 to 7 of 7

Thread: error -13 when I using clCreateSubBuffer

  1. #1
    Banned
    Join Date
    Oct 2013
    Posts
    15

    error -13 when I using clCreateSubBuffer

    hi!! I have this code:

    cl_mem* subbufferCPU=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    cl_mem* subbufferhnsi=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    cl_mem* subbufferhnli=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    cl_mem* subbuffersalida_sumsi=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    cl_mem* subbuffersalida_sumli=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    cl_mem* subbuffersalida_bpf_i_rectif=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    for (int t=0; t<sizebuffer;t++)
    {
    subbufferCPU[t] = clCreateSubBuffer(buffer_entrada, 0,CL_BUFFER_CREATE_TYPE_REGION, &cpuSubBuffer[t], &errores);
    subbufferhnsi[t] = clCreateSubBuffer(buffer_hnsi, 0,CL_BUFFER_CREATE_TYPE_REGION, &hnsiSubBuffer[t], &errores);
    subbufferhnli[t] = clCreateSubBuffer(buffer_hnli, 0,CL_BUFFER_CREATE_TYPE_REGION, &hnliSubBuffer[t], &errores);
    subbuffersalida_sumsi[t] = clCreateSubBuffer(buffer_salida_sumsi, 0,CL_BUFFER_CREATE_TYPE_REGION, &salida_sumsiSubBuffer[t], &errores);
    subbuffersalida_sumli[t] = clCreateSubBuffer(buffer_salida_sumli, 0,CL_BUFFER_CREATE_TYPE_REGION, &salida_sumliSubBuffer[t], &errores);
    subbuffersalida_bpf_i_rectif[t] = clCreateSubBuffer(buffer_salida_bpf_i_rectif, 0,CL_BUFFER_CREATE_TYPE_REGION, &salida_bpf_i_rectifSubBuffer[t], &errores);
    }

    the problem is:
    when t=0, errores =0, but, when t=1, errores =-13 and I don't know why. Please help me???

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Posts
    29
    Can you shrink your code to the simplest case where the error still pops up? This will help us and especially you to find the source of the error much quicker.

  3. #3
    Banned
    Join Date
    Oct 2013
    Posts
    15
    Quote Originally Posted by MaximS View Post
    Can you shrink your code to the simplest case where the error still pops up? This will help us and especially you to find the source of the error much quicker.
    with this code i have the same problem:

    cl_mem* subbufferCPU=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);
    cl_buffer_region region;
    region={0,10000*sizeof(float)};
    size_t size=0;
    for (int t=0; t<sizebuffer;t++)
    {
    subbufferCPU[t] = clCreateSubBuffer(buffer_entrada, 0,CL_BUFFER_CREATE_TYPE_REGION, &region, &errores);
    size+=10000;
    regio.origin=size*sizeof(float);
    }
    t=0 or t =2 or t=4, errores =0, but, when t=1 or t=3 or t=5, errores =-13 . Please help me???

  4. #4
    Senior Member
    Join Date
    Oct 2012
    Posts
    105
    -13 is the value of the error CL_MISALIGNED_SUB_BUFFER_OFFSET.
    As explained in the specification of clCreateSubBuffer(), the origin of the sub-buffer must be aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value.
    10000*sizeof(float) is probably not a multiple of CL_DEVICE_MEM_BASE_ADDR_ALIGN on your device.

  5. #5
    Banned
    Join Date
    Oct 2013
    Posts
    15
    Quote Originally Posted by utnapishtim View Post
    -13 is the value of the error CL_MISALIGNED_SUB_BUFFER_OFFSET.
    As explained in the specification of clCreateSubBuffer(), the origin of the sub-buffer must be aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value.
    10000*sizeof(float) is probably not a multiple of CL_DEVICE_MEM_BASE_ADDR_ALIGN on your device.
    Hi again!! I use this line to align:
    clGetDeviceInfo(info[deviceCPU].device_id, CL_DEVICE_MEM_BASE_ADDR_ALIGN,0,NULL,NULL);
    and this is the code :

    int sizebuffer=(length/512);
    cl_buffer_region region;
    region.size=10000*sizeof(float);
    region.origin=0;

    cl_mem* subBuffer_Entrada=(cl_mem *)malloc(sizeof(cl_mem)*sizebuffer);

    size_t sizeEntrada=0;

    for (int t=0;t<sizebuffer; t++)
    {
    subBuffer_Entrada[t] = clCreateSubBuffer(buffer_entrada,0,CL_BUFFER_CREAT E_TYPE_REGION, &region, &errores);
    sizeEntrada+=10000;
    region.origin=sizeEntrada*sizeof(float);
    }
    for my is aligned, but in the odd numbers I continuous having the error -13. What can I do?

  6. #6
    Senior Member
    Join Date
    Oct 2012
    Posts
    105
    Calling clGetDeviceInfo() with CL_DEVICE_MEM_BASE_ADDR_ALIGN returns the size of a memory page.

    region.origin must then be aligned to this value.

  7. #7
    Banned
    Join Date
    Oct 2013
    Posts
    15
    I resolved the problem. thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •