Own atomic functions

I never managed to understand why atomic functions are not supported for other data types… I want support for unsigned char.
Without being a programming expert, I took a look on the code, and I didn’t saw any special commands that explain how they serialize memory writes etc It was very simple.

So, I was thinking whether it is possible to write my own atomic function.
Is this possible? Or I’ll end up with a simple function, without the benefits of an atomic?
Do I have to rebuild the whole CUDA library?

Where are you looking at the implementations of these functions? sm_11_atomic_functions.h?


That header file is mostly just a wrapper for the fundamental hardware atomic ops in device 1.1+ GPUs. It’s hard to have the hardware perform atomic float ops because floating point math takes more pipeline cycles and you’d need more logic to “hold” the original memory for more clock ticks in order to get the final addition or whatever updated. Integer math has a shorter pipeline (one tick??).

But there are ways to roll your own atomics… not as efficiently as the hardware, but with more flexibility. See source here:

From what I understand the above example is only for use with shared memory. I want access to global memory.

Thanks anyway!