CMS 3D CMS Logo

atomicMaxPair.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_AlpakaCore_interface_atomicMaxPair_h
2 #define HeterogeneousCore_AlpakaCore_interface_atomicMaxPair_h
3 #include <alpaka/alpaka.hpp>
4 
7 
8 // Note: Does not compile with ALPAKA_FN_ACC on ROCm
9 template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>, typename F>
10 ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void atomicMaxPair(const TAcc& acc,
11  unsigned long long int* address,
12  std::pair<unsigned int, float> value,
13  F comparator) {
14 #if defined(__CUDA_ARCH__) or defined(__HIP_DEVICE_COMPILE__)
15  unsigned long long int val = (static_cast<unsigned long long int>(value.first) << 32) + __float_as_uint(value.second);
16  unsigned long long int ret = *address;
17  while (comparator(value,
18  std::pair<unsigned int, float>{static_cast<unsigned int>(ret >> 32 & 0xffffffff),
19  __uint_as_float(ret & 0xffffffff)})) {
20  unsigned long long int old = ret;
21  if ((ret = atomicCAS(address, old, val)) == old)
22  break;
23  }
24 #else
25  unsigned long long int val =
26  (static_cast<unsigned long long int>(value.first) << 32) + edm::bit_cast<unsigned int>(value.second);
27  unsigned long long int ret = *address;
28  while (comparator(value,
29  std::pair{static_cast<unsigned int>(ret >> 32 & 0xffffffff),
30  edm::bit_cast<float>(static_cast<unsigned int>(ret & 0xffffffff))})) {
31  unsigned long long int old = ret;
32  if ((ret = alpaka::atomicCas(acc, address, old, val)) == old)
33  break;
34  }
35 #endif // __CUDA_ARCH__ or __HIP_DEVICE_COMPILE__
36 }
37 
38 #endif // HeterogeneousCore_AlpakaCore_interface_atomicMaxPair_h
T1 atomicCAS(T1 *address, T1 compare, T2 val)
Definition: cudaCompat.h:36
ret
prodAgent to be discontinued
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE void atomicMaxPair(const TAcc &acc, unsigned long long int *address, std::pair< unsigned int, float > value, F comparator)
Definition: atomicMaxPair.h:10
Definition: value.py:1
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163