File indexing completed on 2025-09-14 09:09:42
0001
0002
0003
0004 #ifndef VECGEOM_MANAGEMENT_BVHMANAGER_H_
0005 #define VECGEOM_MANAGEMENT_BVHMANAGER_H_
0006
0007 #include "VecGeom/base/Config.h"
0008 #include "VecGeom/base/Cuda.h"
0009 #include "VecGeom/base/BVH.h"
0010 #include "VecGeom/volumes/LogicalVolume.h"
0011
0012 #ifdef VECGEOM_ENABLE_CUDA
0013 #include "VecGeom/backend/cuda/Interface.h"
0014 #endif
0015
0016 namespace vecgeom {
0017 inline namespace VECGEOM_IMPL_NAMESPACE {
0018 inline std::vector<BVH *> hBVH;
0019 #ifdef VECGEOM_ENABLE_CUDA
0020 inline __device__ BVH *dBVH;
0021 #endif
0022
0023
0024 #define VECGEOM_BVHMANAGER_DEVICE
0025
0026
0027
0028
0029
0030
0031 class BVHManager {
0032 public:
0033 BVHManager() = delete;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 static void Init();
0046
0047
0048 static cuda::BVH const *DeviceInit();
0049
0050
0051 static cuda::BVH const *GetDeviceBVH();
0052
0053 VECCORE_ATT_HOST_DEVICE
0054 static BVH const *GetBVH(int id)
0055 {
0056 #ifdef VECCORE_CUDA_DEVICE_COMPILATION
0057 return &cuda::dBVH[id];
0058 #else
0059 return hBVH[id];
0060 #endif
0061 }
0062
0063 VECCORE_ATT_HOST_DEVICE
0064 static BVH const *GetBVH(LogicalVolume const *v) { return GetBVH(v->id()); }
0065 };
0066
0067 }
0068 }
0069
0070 #endif