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
#include "
HeterogeneousCore/AlpakaInterface/interface/traits.h
"
7
8
namespace
cms::alpakatools
{
9
10
// Which memory allocator to use
11
// - Synchronous: (device and host) cudaMalloc/hipMalloc and cudaMallocHost/hipMallocHost
12
// - Asynchronous: (device only) cudaMallocAsync (requires CUDA >= 11.2)
13
// - Caching: (device and host) caching allocator
14
enum class
AllocatorPolicy
{
Synchronous
= 0,
Asynchronous
= 1,
Caching
= 2 };
15
16
template
<
typename
TDev,
typename
= std::enable_if_t<cms::alpakatools::is_device_v<TDev>>>
17
constexpr
inline
AllocatorPolicy
allocator_policy
=
AllocatorPolicy::Synchronous
;
18
19
#if defined ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED || defined ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED
20
template
<>
21
constexpr
inline
AllocatorPolicy
allocator_policy<alpaka::DevCpu> =
22
#if !defined ALPAKA_DISABLE_CACHING_ALLOCATOR
23
AllocatorPolicy::Caching
;
24
#else
25
AllocatorPolicy::Synchronous
;
26
#endif
27
#endif // defined ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED || defined ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED
28
29
#if defined ALPAKA_ACC_GPU_CUDA_ENABLED
30
template
<>
31
constexpr
inline
AllocatorPolicy
allocator_policy<alpaka::DevCudaRt> =
32
#if !defined ALPAKA_DISABLE_CACHING_ALLOCATOR
33
AllocatorPolicy::Caching
;
34
#elif CUDA_VERSION >= 11020 && !defined ALPAKA_DISABLE_ASYNC_ALLOCATOR
35
AllocatorPolicy::Asynchronous
;
36
#else
37
AllocatorPolicy::Synchronous
;
38
#endif
39
#endif // ALPAKA_ACC_GPU_CUDA_ENABLED
40
41
#if defined ALPAKA_ACC_GPU_HIP_ENABLED
42
template
<>
43
constexpr
inline
AllocatorPolicy
allocator_policy<alpaka::DevHipRt> =
44
#if !defined ALPAKA_DISABLE_CACHING_ALLOCATOR
45
AllocatorPolicy::Caching
;
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
cms::alpakatools
Definition:
PortableCollection.h:43
cms::alpakatools::AllocatorPolicy::Synchronous
cms::alpakatools::AllocatorPolicy
AllocatorPolicy
Definition:
AllocatorPolicy.h:14
traits.h
cms::alpakatools::AllocatorPolicy::Asynchronous
cms::alpakatools::allocator_policy
constexpr AllocatorPolicy allocator_policy
Definition:
AllocatorPolicy.h:17
Generated for CMSSW Reference Manual by
1.8.14