Skip to content

Draft: Modernise CMake configuration, use built-in CUDA support

Stephan Hageboeck requested to merge hageboeck_moderniseCMake into master

Here, the CMake configuration is modernised, in particular related to CUDA.

If all goes well, users will do one of three things, depending on what they want:

Just VecGeom VecGeom with CUDA VecGeom with CUDA, writing their own CUDA kernels that call vecgeom cuda functions
Configure cmake < vecgeom > cmake -DENABLE_CUDA=On < vecgeom > cmake -DENABLE_CUDA=On < vecgeom >
Use target_link_libraries(MyLib PUBLIC vecgeom) target_link_libraries(MyLib PUBLIC vecgeomcuda_shared) target_link_libraries(MyLib PUBLIC vecgeomcuda_static)

More details:

  • Remove CMake code related to FindCUDA. Use native cuda support instead.
  • Rename vecgeomcuda --> vecgeomcuda_shared
  • Remove many of the old nvcc compiler flags, as these seem to be unnecessary with cuda 11
  • Replace all manual NVCC variables with CMAKE_CUDA_FLAGS_ or CMAKE_CUDA_STANDARD and similar.
  • Compile all cuda sources only once by placing them in an object library. The object files from this go into both the shared and the static cuda library afterwards.
  • Remove the cudauserlib. This library seemed to be a stub collecting cuda object files from different places. The relevant cuda files can instead be compiled directly into the relevant executables.
  • Add INTERFACE link dependency from the vecgeom cuda libraries to vecgeom. Like this, users choose the cuda libraries they want (static/shared), and the rest is figured out automatically by CMake.
  • Remove all test code from vecgeomcuda_*. The cuda part of test executables can be compiled directly with the tests.
  • Fix how VecGeom finds ROOT
  • Fix gdml config
  • Remove all cuda dependencies from libvecgeom. There were some explicit cuda calls in libvecgeom, which made it depend on cuda. Now, all those calls happen in backend/cuda/Interface.cpp, so only libvecgeomcuda_* depend on cuda.

NOTE 1

This doesn't mean that libvecgeom with CUDA enabled is usable. Once the CUDA interface is switched on, one is forced to link against either vecgeomcuda_shared or vecgeomcuda_static.

NOTE 2

The shared cuda library does not contain linkable device functions. If users of the library write device code that calls vecgeom functions, one must explicitly link against the static cuda library.

This addresses VECGEOM-577 and VECGEOM-558

Merge request reports