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.