File: BVHTest.cpp

package info (click to toggle)
vecgeom 1.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,928 kB
  • sloc: cpp: 88,717; ansic: 6,894; python: 1,035; sh: 582; sql: 538; makefile: 29
file content (66 lines) | stat: -rw-r--r-- 1,503 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "VecGeom/base/Global.h"

#ifdef VECGEOM_GDML
#include "Frontend.h" // VecGeom/gdml/Frontend.h
#endif

#include "VecGeom/management/BVHManager.h"
#include "VecGeom/management/GeoManager.h"
#include "VecGeom/management/CudaManager.h"

#include <cstdio>
#include <cstdlib>

#include <err.h>

using namespace vecgeom;

void check_host_bvh(int id)
{
  if (auto bvh = BVHManager::GetBVH(id)) bvh->Print();
}

void check_device_bvh(int id);

int main(int argc, char **argv)
{
#ifdef VECGEOM_GDML
  bool verbose   = false;
  bool validate  = false;
  double mm_unit = 0.1;

  if (argc == 1) errx(ENOENT, "No input GDML file");

  const char *filename = argv[1];

  if (!filename || !vgdml::Frontend::Load(filename, validate, mm_unit, verbose))
    errx(EBADF, "Cannot open file '%s'", filename);

  auto &geoManager  = GeoManager::Instance();
  auto &cudaManager = CudaManager::Instance();

  if (!geoManager.IsClosed()) errx(1, "Geometry not closed");

  BVHManager::Init();

  cudaManager.LoadGeometry(geoManager.GetWorld());
  cudaManager.Synchronize();

  auto gpu_world = cudaManager.world_gpu();

  if (!gpu_world) errx(EFAULT, "Invalid world pointer on GPU: %p", gpu_world);

  BVHManager::DeviceInit();

  for (auto item : geoManager.GetLogicalVolumesMap()) {
    if (item.second->GetDaughters().size() > 0) {
      printf("Host:   ");
      check_host_bvh(item.first);
      printf("Device: ");
      check_device_bvh(item.first);
      printf("\n");
    }
  }
#endif
  return EXIT_SUCCESS;
}