QMCPACK
test_CUDAallocator.cpp
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) 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 #include "catch.hpp"
14 
15 #include <memory>
16 #include <iostream>
17 #include "CUDA/CUDAruntime.hpp"
18 #include "CUDA/CUDAallocator.hpp"
19 #include "OhmmsPETE/OhmmsVector.h"
20 
21 namespace qmcplusplus
22 {
23 TEST_CASE("CUDA_allocators", "[CUDA]")
24 {
25  { // CUDAManagedAllocator
28  cudaErrorCheck(cudaPointerGetAttributes(&attr, vec.data()), "cudaPointerGetAttributes failed!");
29 #if (CUDART_VERSION >= 10000 || HIP_VERSION_MAJOR >= 6)
30  REQUIRE(attr.type == cudaMemoryTypeManaged);
31 #endif
32  }
33  { // CUDAAllocator
36  cudaErrorCheck(cudaPointerGetAttributes(&attr, vec.data()), "cudaPointerGetAttributes failed!");
37 #if (CUDART_VERSION >= 10000 || HIP_VERSION_MAJOR >= 6)
38  REQUIRE(attr.type == cudaMemoryTypeDevice);
39 #else
40  REQUIRE(attr.memoryType == cudaMemoryTypeDevice);
41 #endif
42  }
43  { // CUDAHostAllocator
46  cudaErrorCheck(cudaPointerGetAttributes(&attr, vec.data()), "cudaPointerGetAttributes failed!");
47 #if (CUDART_VERSION >= 10000 || HIP_VERSION_MAJOR >= 6)
48  REQUIRE(attr.type == cudaMemoryTypeHost);
49 #else
50  REQUIRE(attr.memoryType == cudaMemoryTypeHost);
51 #endif
52  }
53 #if !defined(QMC_DISABLE_HIP_HOST_REGISTER)
54  { // CUDALockedPageAllocator
57  cudaErrorCheck(cudaPointerGetAttributes(&attr, vec.data()), "cudaPointerGetAttributes failed!");
58 #if (CUDART_VERSION >= 10000 || HIP_VERSION_MAJOR >= 6)
59  REQUIRE(attr.type == cudaMemoryTypeHost);
60 #else
61  REQUIRE(attr.memoryType == cudaMemoryTypeHost);
62 #endif
64  }
65 #endif
66  { // CUDALockedPageAllocator zero size and copy constructor
69  }
70 }
71 
72 } // namespace qmcplusplus
#define cudaMemoryTypeDevice
Definition: cuda2hip.h:113
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
#define cudaPointerGetAttributes
Definition: cuda2hip.h:110
#define cudaMemoryTypeHost
Definition: cuda2hip.h:112
TEST_CASE("complex_helper", "[type_traits]")
handle CUDA/HIP runtime selection.
#define cudaMemoryTypeManaged
Definition: cuda2hip.h:114
this file provides three C++ memory allocators using CUDA specific memory allocation functions...
REQUIRE(std::filesystem::exists(filename))
cudaErrorCheck(cudaMemcpyAsync(dev_lu.data(), lu.data(), sizeof(decltype(lu)::value_type) *lu.size(), cudaMemcpyHostToDevice, hstream), "cudaMemcpyAsync failed copying log_values to device")
Declaraton of Vector<T,Alloc> Manage memory through Alloc directly and allow referencing an existing ...
#define cudaPointerAttributes
Definition: cuda2hip.h:111