AnsweredAssumed Answered

counter32_t (amd atomic counter)

Question asked by Anon5710 on May 17, 2012
Latest reply on May 17, 2012 by Anon5710

Hello i'm trying to implement an atomic counter.


I've got information from this post and the specification.


The specification says :

The Host initializes the atomic counter by passing a buffer object as an

    argument to the kernel. The counter initial value is taken from the first

    4 bytes of the buffer object. During the run of the kernel, the global

    buffer is not updated by the atomic operations done on the counter. At the

    end of the kernel’s run, the updated value of the counter is written to

    the buffer object.

  but it does not specify the type the buffer needs to have.

So , here's my kernel argements on the host side :


    cl_int *p;
    p = (int *)malloc(sizeof(cl_int));
    p[0] = 0;
    cl::Buffer index( context , CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR , sizeof(cl_int), p);

    //executing kernel
    kernel_func3(resultBuffer2, resultBuffer3, count, cl::__local(sizeof(cl_int)*REP*2*64),  cl::__local(sizeof(cl_int)*REP*2), resultBuffer2_index, p);


This compiles but segfaults inside the kernel_func3


i've tried to use the type counter32_t but it just return

counter32_t’ was not declared in this scope


How do i have to initialize to get amd atomic counter to work ?


Thanks kevin,