src
HeterogeneousCore
AlpakaInterface
interface
AllocatorPolicy.h
Go to the documentation of this file.
1
#ifndef HeterogeneousCore_AlpakaInterface_interface_AllocatorPolicy_h
2
#define HeterogeneousCore_AlpakaInterface_interface_AllocatorPolicy_h
3
4
#include <alpaka/alpaka.hpp>
5
6
namespace
cms::alpakatools
{
7
8
// Which memory allocator to use
9
// - Synchronous: (device and host) cudaMalloc/hipMalloc and cudaMallocHost/hipMallocHost
10
// - Asynchronous: (device only) cudaMallocAsync (requires CUDA >= 11.2)
11
// - Caching: (device and host) caching allocator
12
enum class
AllocatorPolicy
{
Synchronous
= 0,
Asynchronous
= 1,
Caching
= 2 };
13
14
template
<
typename
TDev,
typename
= std::enable_if_t<alpaka::isDevice<TDev>>>
15
constexpr
inline
AllocatorPolicy
allocator_policy
=
AllocatorPolicy::Synchronous
;
16
17
#if defined ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED || defined ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED
18
template
<>
19
constexpr
inline
AllocatorPolicy
allocator_policy<alpaka::DevCpu> =
20
#if !defined ALPAKA_DISABLE_CACHING_ALLOCATOR
21
AllocatorPolicy::Caching
;
22
#else
23
AllocatorPolicy::Synchronous
;
24
#endif
25
#endif // defined ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED || defined ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED
26
27
#if defined ALPAKA_ACC_GPU_CUDA_ENABLED
28
template
<>
29
constexpr
inline
AllocatorPolicy
allocator_policy<alpaka::DevCudaRt> =
30
#if !defined ALPAKA_DISABLE_CACHING_ALLOCATOR
31
AllocatorPolicy::Caching
;
32
#elif CUDA_VERSION >= 11020 && !defined ALPAKA_DISABLE_ASYNC_ALLOCATOR
33
AllocatorPolicy::Asynchronous
;
34
#else
35
AllocatorPolicy::Synchronous
;
36
#endif
37
#endif // ALPAKA_ACC_GPU_CUDA_ENABLED
38
39
#if defined ALPAKA_ACC_GPU_HIP_ENABLED
40
template
<>
41
constexpr
inline
AllocatorPolicy
allocator_policy<alpaka::DevHipRt> =
42
#if !defined ALPAKA_DISABLE_CACHING_ALLOCATOR
43
AllocatorPolicy::Caching
;
44
#elif HIP_VERSION >= 50400000 && !defined ALPAKA_DISABLE_ASYNC_ALLOCATOR
45
AllocatorPolicy::Asynchronous
;
46
#else
47
AllocatorPolicy::Synchronous
;
48
#endif
49
#endif // ALPAKA_ACC_GPU_HIP_ENABLED
50
51
}
// namespace cms::alpakatools
52
53
#endif // HeterogeneousCore_AlpakaInterface_interface_AllocatorPolicy_h
cms::alpakatools::AllocatorPolicy::Caching
ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr
if constexpr(n > 3)
Definition:
BrokenLine.h:164
cms::alpakatools
Definition:
HcalRecoParamWithPulseShapeHost.h:11
cms::alpakatools::AllocatorPolicy::Synchronous
cms::alpakatools::AllocatorPolicy
AllocatorPolicy
Definition:
AllocatorPolicy.h:12
cms::alpakatools::AllocatorPolicy::Asynchronous
cms::alpakatools::allocator_policy
constexpr AllocatorPolicy allocator_policy
Definition:
AllocatorPolicy.h:15
Generated for CMSSW Reference Manual by
1.8.14