CMS 3D CMS Logo

Functions
atomicMaxF.h File Reference
#include <alpaka/alpaka.hpp>
#include "FWCore/Utilities/interface/bit_cast.h"

Go to the source code of this file.

Functions

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_HOST_ACC static ALPAKA_FN_INLINE float atomicMaxF (const TAcc &acc, float *address, float val)
 

Function Documentation

◆ atomicMaxF()

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_HOST_ACC static ALPAKA_FN_INLINE float atomicMaxF ( const TAcc &  acc,
float *  address,
float  val 
)
static

Definition at line 11 of file atomicMaxF.h.

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

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::hcalFastCluster_exotic(), ALPAKA_ACCELERATOR_NAMESPACE::hcalFastCluster_multiSeedIterative(), and ALPAKA_ACCELERATOR_NAMESPACE::hcalFastCluster_multiSeedParallel().

11  {
12 #if defined(__CUDA_ARCH__) or defined(__HIP_DEVICE_COMPILE__)
13  // GPU implementation uses __float_as_int / __int_as_float
14  int ret = __float_as_int(*address);
15  while (val > __int_as_float(ret)) {
16  int old = ret;
17  if ((ret = atomicCAS((int*)address, old, __float_as_int(val))) == old)
18  break;
19  }
20  return __int_as_float(ret);
21 #else
22  // CPU implementation uses edm::bit_cast
23  int ret = edm::bit_cast<int>(*address);
24  while (val > edm::bit_cast<float>(ret)) {
25  int old = ret;
26  if ((ret = alpaka::atomicCas(acc, (int*)address, old, edm::bit_cast<int>(val))) == old)
27  break;
28  }
29  return edm::bit_cast<float>(ret);
30 #endif // __CUDA_ARCH__ or __HIP_DEVICE_COMPILE__
31 }
T1 atomicCAS(T1 *address, T1 compare, T2 val)
Definition: cudaCompat.h:36
ret
prodAgent to be discontinued