12#ifndef ARCANE_ACCELERATOR_COMMONCUDHIPATOMICIMPL_H
13#define ARCANE_ACCELERATOR_COMMONCUDHIPATOMICIMPL_H
32namespace Arcane::Accelerator::impl
38template <
typename DataType, enum eAtomicOperation>
41template <
typename DataType>
43template <
typename DataType>
45template <
typename DataType>
53 static ARCCORE_DEVICE
void apply(
int*
ptr,
int v)
64 static ARCCORE_DEVICE
void apply(
int*
ptr,
int v)
75 static ARCCORE_DEVICE
void apply(
int*
ptr,
int v)
88 static_assert(
sizeof(
Int64) ==
sizeof(
long long int),
"Bad pointer size");
89 ::atomicAdd((
unsigned long long int*)
ptr, v);
101 unsigned long long int*
address_as_ull =
reinterpret_cast<unsigned long long int*
>(
ptr);
114 ::atomicMax((
long long int*)
ptr, v);
127 unsigned long long int*
address_as_ull =
reinterpret_cast<unsigned long long int*
>(
ptr);
140 ::atomicMin((
long long int*)
ptr, v);
149preArch60atomicAdd(
double* address,
double val)
151 unsigned long long int*
address_as_ull = (
unsigned long long int*)address;
165atomicMaxDouble(
double* address,
double val)
167 unsigned long long int*
address_as_ull = (
unsigned long long int*)address;
176 }
while (assumed != old);
178 return __longlong_as_double(old);
181__device__
inline double
182atomicMinDouble(
double* address,
double val)
184 unsigned long long int* address_as_ull = (
unsigned long long int*)address;
185 unsigned long long int old = *address_as_ull, assumed;
189 double assumed_as_double = __longlong_as_double(assumed);
190 old = atomicCAS(address_as_ull, assumed,
191 __double_as_longlong(val < assumed_as_double ? val : assumed_as_double));
193 }
while (assumed != old);
195 return __longlong_as_double(old);
203 static ARCCORE_DEVICE
void apply(
double*
ptr,
double v)
205#if __CUDA_ARCH__ >= 600
208 preArch60atomicAdd(
ptr, v);
218 static ARCCORE_DEVICE
void apply(
double*
ptr,
double v)
220 atomicMaxDouble(
ptr, v);
229 static ARCCORE_DEVICE
void apply(
double*
ptr,
double v)
231 atomicMinDouble(
ptr, v);
Lecteur des fichiers de maillage via la bibliothèque LIMA.
eAtomicOperation
Type d'opération atomique supportée.
std::int64_t Int64
Type entier signé sur 64 bits.