77#include < cstdlib>
88#include < iostream>
99
10+ #include " ../CFE_config.hpp"
1011#include " ../Fortran_features/cabana_fortran_cpp_defs.h"
1112
1213// Length of loop for vectorization
1920#define VEC_LEN 1
2021#endif
2122
22- // Whether to use the GPU version
23- #ifndef USE_GPU
24- #define USE_GPU 0
23+ // Declare the memory and execution spaces.
24+ #ifdef USE_GPU
25+ using MemorySpace = Kokkos::CudaUVMSpace;
26+ using ExecutionSpace = Kokkos::Cuda;
27+ #else
28+ using MemorySpace = Kokkos::HostSpace;
29+ #ifdef USE_OMP
30+ using ExecutionSpace = Kokkos::OpenMP;
31+ #else
32+ using ExecutionSpace = Kokkos::Serial;
2533#endif
26-
27- // If using the CPU version, whether to use OpenMP
28- #ifndef USE_OMP
29- #define USE_OMP 1
3034#endif
3135
3236// Most particle routines can be written as a loop over particles.
3337// In the GPU case, launch a parallel_for over particles
3438// In the CPU case, launch a parallel_for over vectors
3539// The vector loop is currently inclusive of the ends, so if you ask to operate over
3640// particles 15-33 and your vector length is 16, you will operate over particle 1-48.
37- #if USE_GPU==1
41+ #ifdef USE_GPU
3842#define PARTICLE_OP (C_FUNC,F_FUNC ) \
3943 extern " C" int C_FUNC ( int sp, int np ); \
4044 extern " C" KOKKOS_FUNCTION void F_FUNC (local_particle_struct_t *, int , int ); \
@@ -97,19 +101,6 @@ struct local_particle_struct_t {
97101 long long int gid[VEC_LEN ];
98102};
99103
100- // Declare the memory and execution spaces.
101- #if USE_GPU == 1
102- using MemorySpace = Kokkos::CudaUVMSpace;
103- using ExecutionSpace = Kokkos::Cuda;
104- #else
105- using MemorySpace = Kokkos::HostSpace;
106- #if USE_OMP == 1
107- using ExecutionSpace = Kokkos::OpenMP;
108- #else
109- using ExecutionSpace = Kokkos::Serial;
110- #endif
111- #endif
112-
113104// Set the type and memory space for the particle AoSoA.
114105using ParticleList = Cabana::AoSoA<ParticleDataTypes,MemorySpace,VEC_LEN >;
115106
@@ -130,4 +121,3 @@ int particle_allocation(int num_particle)
130121}
131122
132123#include " particle_ops.h"
133-
0 commit comments