Skip to content

Provide static and shared variants of libvecgeomcuda

Benjamin Morgan requested to merge bmorgan/shared-cuda-lib into master

This is an intermediate step towards !822 (closed) without the issues identified in that with the current implementation of the "RDC" approach. It effectively reproduces the behaviour of the old, vecgeom-hacked, FindCUDA module using native CMake CUDA support to provide

  • vecgeomcuda_static that is a "standard" CUDA static library that CUDA-using consumers can link/device link to.

  • vecgeomcuda that is a shared library that includes the CUDA objects plus the device link object.

    • CPU-only consumer code needs to link to this to resolve both the circular vecgeom<->vecgeomcuda dependency and the device symbols (without an additional device link being needed).
    • CUDA consumer code (i.e. using VecGeom __device__ or kernel interfaces) can link to this provided it also device links to vecgeomcuda_static. In CMake terms, this means
    add_executable(MyCUDA MyCUDA.cu)
    target_link_libraries(MyCUDA vecgeomcuda)
    target_link_options(MyCUDA $<DEVICE_LINK:$<TARGET_FILE:vecgeomcuda_static>)

This structure is compatible with the "RDC" approach, and has been tested in both AdePT and Celeritas and works without any changes to those codes being needed. VecGeom tests are also updated to account for these changes.

Due to the circular dependence in the libraries and the mix of static/shared, the vgdml library is no longer linked to either of the vecgeomcuda targets. It is left up to the consumer to link to the desired variant.

To make the structure/behaviour of the CUDA libraries clearer to downstream users, the README has been updated to describe the above and show what is needed to link appropriately. As part of this, the INSTALL file has be removed, and its contents merged into the README for clarity.

The VecGeomConfig file has been extended to provide more variables and components to assist CMake clients discover information/require features from an install.

This is not a complete replacement for !822 (closed), but restores the static/shared CUDA libs using the native CMake CUDA support and without breaking the target/link interface.

@gcosmo, this should be sufficient to allow a new VecGeom release!

Merge request reports