I have a problem using atomicAdd under CUDA 7. atomicAdd is defined for "int", "unsigned int" and "unsigned long long int" stating it uses "the 32 or 64 bit value".
In our code we use uint32_t and uint64_t for safety. However gcc defines this in the following way:
#if __WORDSIZE == 64
typedef unsigned long int uint64_t;
#else
__extension__
typedef unsigned long long int uint64_t;
#endif
So when I pass an uint64_t to atomicAdd it complains because it is not defined for "unsigned long int".
Is it save to assume uint64_t == long long int for CUDA compilation as stated in the programming guide?
To answer that for future reference:
There are 2 options: Either use a typedef to define 64 bit cuda types like:
And probably guard these by (boost-)
static_assertsto be the same size(of)Or as suggested by @Anastasiya Asadullayeva use a reinterpret_cast in the call which is better also guarded by a static_assert.