Skip to content

Refactor AdePT into transport library and G4Integration library #516

@SeverinDiederichs

Description

@SeverinDiederichs

The goal is to refactor AdePT such that that the transport and the Geant4 integration are cleanly separated.
Today, AdePT is build as a single library, with the CUDA implementation living in headers, leading to very few translation units that suck in a huge amount of code. This original design was done to avoid cuda linking issues. Since the introduction of cuda_rdc into AdePT, this is not needed anymore and two clean and separated libraries can be created.

The core problems are that
AdePTTrackingManager, AdePTGeant4Integration, and AsyncAdePTTransport mix many responsibilities:

  • The AsyncAdePTTransport depends on the AdePTGeant4Integration leading to the G4 dependency of the transport.
  • initialization and upload to the GPU are interleaved
  • the GPU step processing is not as clearly separated as it should

This makes the code hard to read and hard to test in isolation, as nothing can be initialized on device without the full G4 initialization. This leads to code duplication when trying to test certain parts, see the testField.

The long-term target is to have two libraries:

  • AdePT_core
    • owns GPU steering and kernels, device upload, retrieving of scoring and hits
    • depends on CUDA, VecGeom, and G4HepEm
    • must not depend on Geant4 tracking/reconstruction APIs
  • AdePT_g4integration
    • owns AdePTTrackingManager, AdePTGeant4Integration, geometry preparation, Geant4 reconstruction, and treatment of returned tracks
    • depends on Geant4 and AdePT_core

Therefore, the refactor is planned as follows:

  • Move per-thread AdePTGeant4Integration ownership to AdePTTrackingManager
  • Move Geant4 logic out of AsyncAdePTTransport
  • Split geometry into:
    • metadata build on the Geant4 side
    • plain shared data objects
    • device upload on the core side
  • Replace large responsibilities (e.g., AdePTGeant4Integration or PerEventScoringImpl.cuh with smaller, targeted pieces.

The overall goal is to be able to test many parts of the code in isolation.

A series of PRs will be created and linked to the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleaningimproves code clarity, readability or otherplanPlanning issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions