XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
space_settings.hpp
Go to the documentation of this file.
1 #ifndef SPACE_SETTINGS_HPP
2 #define SPACE_SETTINGS_HPP
3 #include <Kokkos_Core.hpp>
4 #include <vector>
5 // Declare the memory and execution spaces.
6 #ifdef USE_GPU
7 // 4 eventual possible GPU options: Cuda, Hip, Sycl, OpenMP+
8 #ifdef USE_CUDA
9 using MemSpace = Kokkos::CudaSpace;
10 using ExSpace = Kokkos::Cuda;
11 #elif defined(USE_HIP)
12 using MemSpace = Kokkos::Experimental::HIPSpace;
13 using ExSpace = Kokkos::Experimental::HIP;
14 #elif defined(USE_SYCL)
15 using MemSpace = Kokkos::Experimental::SYCLDeviceUSMSpace;
16 using ExSpace = Kokkos::Experimental::SYCL;
17 #elif defined(USE_OMPT)
18 using MemSpace = Kokkos::Experimental::OpenMPTargetSpace;
19 using ExSpace = Kokkos::Experimental::OpenMPTarget;
20 #else
21 #error USE_GPU is on, but no Kokkos backend specified
22 #endif
23 
24 #else
25 // USE_GPU undefined
26 using MemSpace = Kokkos::HostSpace;
27 #ifdef USE_OMP
28 using ExSpace = Kokkos::OpenMP;
29 #elif defined(USE_SERIAL)
30 using ExSpace = Kokkos::Serial;
31 #else
32 #error No CPU backend specified (USE_OMP or USE_SERIAL)
33 #endif
34 
35 #endif
36 
37 #ifndef USE_CUDA
38 // Native cuda min/max is used with cuda since std library is not available
39 // Otherwise, use std min/max.
40 using std::min;
41 using std::max;
42 using std::abs;
43 #endif
44 
45 using DeviceType = Kokkos::Device<ExSpace,MemSpace>;
46 
47 // Designate a CPU-specific Memory and Execution space
48 using HostMemSpace = Kokkos::HostSpace;
49 #ifdef USE_OMP
50 using HostExSpace = Kokkos::OpenMP;
51 #elif defined(USE_SERIAL)
52 using HostExSpace = Kokkos::Serial;
53 #endif
54 using HostType = Kokkos::Device<HostExSpace,HostMemSpace>;
55 
56 
57 // Default Kokkos behavior is that a kernel cannot be launched until the previous one is complete (essentially a fence)
58 // HintLightWeight removes this fence and is necessary to allow asynchronous CPU/GPU kernels.
59 namespace Opt = Kokkos::Experimental;
60 constexpr static const Kokkos::Experimental::WorkItemProperty::HintLightWeight_t Async = Kokkos::Experimental::WorkItemProperty::HintLightWeight;
61 
62 // SPACE_SETTINGS_HPP
63 #endif
Kokkos::CudaSpace MemSpace
Definition: space_settings.hpp:9
Kokkos::Device< HostExSpace, HostMemSpace > HostType
Definition: space_settings.hpp:54
Kokkos::Cuda ExSpace
Definition: space_settings.hpp:10
Kokkos::HostSpace HostMemSpace
Definition: space_settings.hpp:48
static constexpr const Kokkos::Experimental::WorkItemProperty::HintLightWeight_t Async
Definition: space_settings.hpp:60
Kokkos::Device< ExSpace, MemSpace > DeviceType
Definition: space_settings.hpp:45
Kokkos::OpenMP HostExSpace
Definition: space_settings.hpp:50