Make use of atomicExch for atomicExchCustom

This commit is contained in:
Igor Babuschkin 2016-08-05 14:29:58 +01:00
parent eeb0d880ee
commit 9537e8b118

View File

@ -74,15 +74,9 @@ __device__ inline Type atomicExchCustom(Type* address, Type val) {
} }
template <> template <>
__device__ inline double atomicExchCustom<double>(double* address, double val) { __device__ inline double atomicExchCustom(double* address, double val) {
unsigned long long int* address_as_ull = (unsigned long long int*)address; unsigned long long int* address_as_ull = reinterpret_cast<unsigned long long int*>(address);
unsigned long long int old = *address_as_ull; return __longlong_as_double(atomicExch(address_as_ull, __double_as_longlong(val)));
unsigned long long int assumed;
do {
assumed = old;
old = atomicCAS(address_as_ull, assumed, __double_as_longlong(val));
} while (assumed != old);
return __longlong_as_double(old);
} }
#ifdef EIGEN_HAS_CUDA_FP16 #ifdef EIGEN_HAS_CUDA_FP16