Atomic operations aren't supported on jetson k1

I tried to compile the simplest device function using atomic operations

device void atomic_test(int a)
atomicAdd(&a, 2);

Compile it using nvcc -arch=sm_32 -o cuAdd

but during compilation I get following error

Error: unsupported operation

As I know, jetson shall support atomic operations, so it seems strange to me seeing such error.
Has anybody meet such problem and can help me?

if you are going to pass to atomic_test() an int, instead of an int*, a should be shared memory at least…?

I think, but I didn’t test, that the error is because the compiler doesn’t know where “int a” is located, in global memory, shared memory, local (private) memory, etc. Something like device void atomic_test(shared int *a) should work.

I tried your approach, but it doesn’t work.
I also tried such variant, where device variable is incremented

global void atomic_test()
int i = 0;
int tid = threadIdx.x;
if(tid < 10)
atomicAdd(&i, 1);

but error didn’t disappear, and during compilation I see previous
Error: unsupported operation

You cannot do atomics on local variables. In both of the examples you have posted, your variable i or a is local. (I think there would be no reason to have local atomics; there is no possibility for parallel access to a specific local variable; it can only be accessed by one CUDA thread.) atomic operations are possible on global or shared variables. Here are two examples using global variables:

This should work (compile):

__device__ int a;

__global__ void atomic_test()
  atomicAdd(&a, 1);

this should also work (compile):

__global__ void atomic_test(int *a)
  atomicAdd(a, 1);

I think it should be fairly obvious that your second example using i is clearly a local variable.

In your first example, any variable passed by value to a function:

__device__ void atomic_test(int a)

has local scope within that function. Changes to that variable within the function cannot show up in the calling environment, or be visible to other threads that may use that function. Therefore atomics don’t apply here (and wouldn’t make sense anyway).

Thanks! it works!