Skip to content

Conversation

JuanGonzalezCaminero
Copy link
Contributor

@JuanGonzalezCaminero JuanGonzalezCaminero commented Oct 2, 2025

Adds the ENABLE_POWER_METER cmake option in order to do power consumption measurements.

If the option is enabled, we use the power meter library to launch a background thread taking measurements from CPU and GPU. The monitoring is started once AdePT initialization is finished, and ends when shutting down the application.

Note that if the option is enabled, simulations need to be run with root access, which is required in order to read the CPU's MSR registers.

Prior to Geant4 11.3 the specialized tracking managers were not deleted by Geant4. Since the power meter is stopped in the tracking manager destructor, this will lead to an error message in older geant4 versions when the program ends without joining the power meter thread. This should not cause a memory leak, since terminate() will be called on the unjoined thread.

@phsft-bot
Copy link

Can one of the admins verify this patch?

Copy link
Collaborator

@SeverinDiederichs SeverinDiederichs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

See minor comment to remove unused variable warning.

Can merge after we successfully ran it in the frameworks


AdePTTrackingManager::~AdePTTrackingManager()
{
auto tid = G4Threading::G4GetThreadId();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto tid = G4Threading::G4GetThreadId();

Unused variable that caused a warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants