OpenCL atomic_add

Hi,
I was trying to get atomic_add() working but just get the following compilation error

Error: Failed to build program executable!
ptxas application ptx input, line 20; error : Label expected for argument 0 of instruction ‘call’
ptxas application ptx input, line 20; error : Call target not recognized
ptxas application ptx input, line 20; error : Function ‘atomic_add’ not declared in this scope
ptxas application ptx input, line 20; error : Call target not recognized
ptxas application ptx input, line 21; error : Unknown symbol ‘atomic_add’
ptxas application ptx input, line 21; error : Label expected for forward reference of ‘atomic_add’
ptxas fatal : Ptx assembly aborted due to errors

I have a C2050 GPU and CUDA 4.1 installed.

My kernel is

#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable
#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable
#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable

__kernel void atomicGlobal(__global int *num) {

atomic_add(num,2);

}

I don’t think I should need the #pragma bits but they make no difference either
way. My device lists the following extensions

Device has extensions: cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64

I get basically the same sort of erros for whichever atomic I try and use atomic_inc() etc.


jason

There is some weridness with atomics between 1.0 and 1.1 you might try using “atom_add” not “atomic_add”. they changed everything except 64bit to use “atomic” in 1.1.