File indexing completed on 2026-09-10 09:29:09
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 template <typename Real_t>
0019 inline std::vector<BVH<Real_t> *> hBVH;
0020 #ifdef VECGEOM_ENABLE_CUDA
0021 template <typename Real_t>
0022 inline __device__ BVH<Real_t> *dBVH;
0023 #endif
0024
0025
0026 #define VECGEOM_BVHMANAGER_DEVICE
0027
0028
0029
0030
0031
0032 class BVHManager {
0033
0034
0035
0036 #ifdef VECGEOM_BVH_SINGLE
0037 using Real_t = float;
0038 #else
0039 using Real_t = double;
0040 #endif
0041
0042 public:
0043 BVHManager() = delete;
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 static void Init();
0056
0057
0058 static cuda::BVH<Real_t> const *DeviceInit();
0059
0060
0061 static cuda::BVH<Real_t> const *GetDeviceBVH();
0062
0063 VECCORE_ATT_HOST_DEVICE
0064 static BVH<Real_t> const *GetBVH(int id)
0065 {
0066 #ifdef VECCORE_CUDA_DEVICE_COMPILATION
0067 return &cuda::dBVH<Real_t>[id];
0068 #else
0069 return hBVH<Real_t>[id];
0070 #endif
0071 }
0072
0073 VECCORE_ATT_HOST_DEVICE
0074 static BVH<Real_t> const *GetBVH(LogicalVolume const *v) { return GetBVH(v->id()); }
0075 };
0076
0077 }
0078 }
0079
0080 #endif