Unverified Commit 473bf15f authored by nv-dlasalle's avatar nv-dlasalle Committed by GitHub
Browse files

[Bugfix] Disable non-atomic atomic operations (#4117)

* Disable non-atomic atomic operations

* Improve error message

* Make error message more friendly
parent 9a6f2924
...@@ -80,12 +80,18 @@ static __device__ __forceinline__ unsigned short int atomicCASshort( ...@@ -80,12 +80,18 @@ static __device__ __forceinline__ unsigned short int atomicCASshort(
unsigned short int *address, unsigned short int *address,
unsigned short int compare, unsigned short int compare,
unsigned short int val) { unsigned short int val) {
#if (defined(CUDART_VERSION) && (CUDART_VERSION > 10000)) static_assert(CUDART_VERSION >= 10000, "Requires at least CUDA 10");
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__) >= 700) #if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__) >= 700)
return atomicCAS(address, compare, val); return atomicCAS(address, compare, val);
#endif // (defined(__CUDA_ARCH__) && (__CUDA_ARCH__) >= 700) #else
#endif // (defined(CUDART_VERSION) && (CUDART_VERSION > 10000)) (void)address;
(void)compare;
(void)val;
printf("Atomic operations are not supported for half precision (FP16) "
"on this GPU.\n");
__trap();
return val; return val;
#endif // (defined(__CUDA_ARCH__) && (__CUDA_ARCH__) >= 700)
} }
#define DEFINE_ATOMIC(NAME) \ #define DEFINE_ATOMIC(NAME) \
...@@ -260,9 +266,12 @@ __device__ __forceinline__ half AtomicAdd<half>(half* addr, half val) { ...@@ -260,9 +266,12 @@ __device__ __forceinline__ half AtomicAdd<half>(half* addr, half val) {
#if __CUDA_ARCH__ >= 700 #if __CUDA_ARCH__ >= 700
return atomicAdd(addr, val); return atomicAdd(addr, val);
#else #else
half old = *addr; (void)addr;
*addr = half(float(old) + float(val)); (void)val;
return old; printf("Atomic operations are not supported for half precision (FP16) "
"on this GPU.\n");
__trap();
return val;
#endif // __CUDA_ARCH__ >= 700 #endif // __CUDA_ARCH__ >= 700
} }
#endif // defined(CUDART_VERSION) && CUDART_VERSION >= 10000 #endif // defined(CUDART_VERSION) && CUDART_VERSION >= 10000
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment