CMS 3D CMS Logo

Functions
atomicMaxPair.h File Reference
#include <alpaka/alpaka.hpp>
#include "FWCore/Utilities/interface/bit_cast.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

Go to the source code of this file.

Functions

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>, typename F >
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)
 

Function Documentation

◆ atomicMaxPair()

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>, typename F >
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 at line 10 of file atomicMaxPair.h.

References cms::cudacompat::atomicCAS(), runTheMatrix::ret, and heppy_batch::val.

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::hcal::reconstruction::mahi::Kernel_prep1d_sameNumberOfSamples::operator()().

13  {
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 }
T1 atomicCAS(T1 *address, T1 compare, T2 val)
Definition: cudaCompat.h:36
ret
prodAgent to be discontinued
Definition: value.py:1