Unsupported operation while compiling atomicMin

Hi everyone,

I am getting this error message “Error: unsupported operation” while trying to compile this piece of code :

int a = 20;
int b = 30;
atomicMin(&b, a-3);//the log trace points out to this line

The official doc states clearly that CUDA supports :

int atomicMin(int* address, int val);

I would like also to stress that I am using this code snippet within the body of a kernel. Is that the reason why I am getting this “Unsupported operation” error? If so how can I circumvent this problem (Id o need to calculate the min of two integers within the kernel since I am unable to make a host call for std::min from the device)?

Could anyone please point me to the error source here? Thank you.

An atomic operation must be done either on global or shared memory.


(read the first sentence)


int b = 30;

is neither. It is in the local memory space. Atomics are unsupported on local memory.

You don’t need atomics to calculate things when using only a single thread. The nature of local memory usage is that it is visible only to a single thread. To find the minimum of two values in local memory associated with a particular thread, CUDA provides suitable functions for you.

It should be sufficient to do:

int a = 20;
int b = 30;
b = min(b, a-3);

@Robert_Crovella : Thank you!