Results 1 to 3 of 3

Thread: problem with atomic_cmpxchg

  1. #1
    Banned
    Join Date
    Oct 2013
    Posts
    15

    problem with atomic_cmpxchg

    Hi, I need to implement a semaphore, I write this code, but gives me error, the code is this:

    #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 Name(…..){
    volatile __global int *mutex;
    int id = get_global_id(0);
    int begin, end,cont;



    if (atomic_cmpxchg(&mutex, 0, 1) == 0)
    {


    if(id==0)
    {
    begin=0;
    end=4*M;
    cont=0;
    }
    else
    {
    begin=id*(2*M);
    end=begin+(4*M);
    if(end>length)
    end=length;
    cont=id*(4*M);
    }


    atomic_xchg(&mutex, 0);
    }

    …….
    }
    And the error is: CL_BUILD_PROGRAM_FAILURE
    Please Help Meeeeeeeeee

  2. #2
    Junior Member
    Join Date
    Dec 2010
    Posts
    4
    Try atomic_cmpxchg(mutex, ...)

  3. #3
    Banned
    Join Date
    Oct 2013
    Posts
    15
    thank you!!!! that resolve the problem!!!

Posting Permissions

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