QMCPACK
DualAllocatorAliases.hpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2021 QMCPACK developers.
6 //
7 // Filef developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
8 //
9 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
10 //////////////////////////////////////////////////////////////////////////////////////
11 // -*- C++ -*-
12 /** @file
13  * These allocators are to make code that should be
14  * generic with the respect to accelerator code flavor actually so,
15  * but only through configuration time switches.
16  * A DualAllocator as in DualAllocator.hpp constructed of a Host and Device allocator
17  * or a OMPallocator which leverages the OMP runtime magic to map host and implicit device data
18  * if offload is enabled or is just a host allocator otherwise.
19  */
20 
21 #ifndef QMCPLUSPLUS_DUAL_ALLOCATOR_ALIASES_HPP
22 #define QMCPLUSPLUS_DUAL_ALLOCATOR_ALIASES_HPP
23 
24 #include "PinnedAllocator.h"
25 #if (defined(ENABLE_CUDA) || defined(ENABLE_SYCL)) && !defined(ENABLE_OFFLOAD)
26 #include "DualAllocator.hpp"
27 #if defined(ENABLE_CUDA)
28 namespace qmcplusplus
29 {
30  template<typename T>
31  using UnpinnedDualAllocator = DualAllocator<T, CUDAAllocator<T>, aligned_allocator<T>>;
32  template<typename T>
33  using PinnedDualAllocator = DualAllocator<T, CUDAAllocator<T>, PinnedAlignedAllocator<T>>;
34  template<typename T>
35  using DeviceAllocator = CUDAAllocator<T>;
36 }
37 #elif defined(ENABLE_SYCL)
38 namespace qmcplusplus
39 {
40  template<typename T>
41  using UnpinnedDualAllocator = DualAllocator<T, SYCLAllocator<T>, aligned_allocator<T>>;
42  template<typename T>
43  using PinnedDualAllocator = DualAllocator<T, SYCLAllocator<T>, PinnedAlignedAllocator<T>>;
44  template<typename T>
45  using DeviceAllocator = SYCLAllocator<T>;
46 }
47 #else
48 #error unhandled platform
49 #endif
50 
51 #else // ENABLE_OFFLOAD or no CUDA or SYCL
53 namespace qmcplusplus
54 {
55  template<typename T>
57  template<typename T>
59  template<typename T>
61 }
62 #endif
63 
64 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
OffloadDeviceAllocator< T > DeviceAllocator
OffloadPinnedAllocator< T > PinnedDualAllocator
OMPallocator is an allocator with fused device and dualspace allocator functionality.
OffloadAllocator< T > UnpinnedDualAllocator