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) 2019 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef QMCPLUSPLUS_PINNED_ALLOCATOR_H
14 #define QMCPLUSPLUS_PINNED_ALLOCATOR_H
15 
16 #include <memory>
17 #include "CPU/SIMD/aligned_allocator.hpp"
18 #ifdef ENABLE_CUDA
19 #include "CUDA/CUDAallocator.hpp"
20 #endif
21 
22 namespace qmcplusplus
23 {
24 
25 template<typename T>
26 #ifdef ENABLE_CUDA
27 using PinnedAllocator = CUDALockedPageAllocator<T>;
28 #else
29 using PinnedAllocator = std::allocator<T>;
30 #endif
31 
32 template<typename T, size_t ALIGN = QMC_SIMD_ALIGNMENT>
33 #ifdef ENABLE_CUDA
34 using PinnedAlignedAllocator = CUDALockedPageAllocator<T, aligned_allocator<T, ALIGN>>;
35 #else
36 using PinnedAlignedAllocator = aligned_allocator<T, ALIGN>;
37 #endif
38 
39 } // namespace qmcplusplus
40 
41 #endif
42