Results 1 to 2 of 2

Thread: More problems with atomic_cmpxchg, help!!!!

  1. #1
    Banned
    Join Date
    Oct 2013
    Posts
    15

    More problems with atomic_cmpxchg, help!!!!

    Hi, I have this section of code implemented:
    Main.cpp
    …………..
    int *mutex;
    cl_kernel kernel =clCreateKernel(programCPU, "namefunction", &ret);
    clSetKernelArg(kernel, 0, sizeof(int), & mutex);
    ………

    kernel.cl

    #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable

    #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable

    #pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable

    #pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable


    __kernel void namefunction(….., __global int *mutex)
    {


    ……………………
    if (atomic_cmpxchg(mutex, 0, 1) == 0)
    {
    if(cont2p>0)
    {
    if(cont==1)
    a[0]=5;
    else
    a[1]=a[0]+5;
    cont2p--;
    }
    atomic_xchg(mutex, 0);
    }
    ………………..
    }

    The problem is that it doesn't work. The buffer never changes the value. Someone help me please!!! For me this code is fine.

  2. #2
    Member
    Join Date
    Oct 2010
    Location
    Vancouver, Canada
    Posts
    66
    Note that in OpenCL 1.x you need to pass a cl_mem object to clSetKernelArg, not a raw pointer.

Posting Permissions

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