1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/// \file BVHManager.cpp
/// \author Guilherme Amadio
#include "VecGeom/management/BVHManager.h"
#include "VecGeom/management/GeoManager.h"
#include <vector>
namespace vecgeom {
#ifdef VECCORE_CUDA
inline
#endif
namespace cuda {
void *AllocateDeviceBVHBuffer(size_t n);
void FreeDeviceBVHBuffer();
VECCORE_ATT_DEVICE
BVH *GetDeviceBVH(int id);
} // namespace cuda
inline namespace VECGEOM_IMPL_NAMESPACE {
void BVHManager::Init()
{
std::vector<LogicalVolume const *> lvols;
GeoManager::Instance().GetAllLogicalVolumes(lvols);
// There may be volumes not used in the hierarchy, so the maximum index may be larger
hBVH.resize(GeoManager::Instance().GetLogicalVolumesMap().size());
for (auto logical_volume : lvols)
hBVH[logical_volume->id()] = logical_volume->GetDaughters().size() > 0 ? new BVH(*logical_volume) : nullptr;
}
#ifdef VECGEOM_CUDA_INTERFACE
void BVHManager::DeviceInit()
{
int n = hBVH.size();
BVH *ptr = (BVH *)vecgeom::cuda::AllocateDeviceBVHBuffer(n);
for (int id = 0; id < n; ++id) {
if (!hBVH[id]) continue;
hBVH[id]->CopyToGpu(&ptr[id]);
}
}
#endif
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom
|