chombo-discharge
Loading...
Searching...
No Matches
Enumerations | Functions
ParticleMemory Namespace Reference

Running totals of the memory held by particle data on this rank. More...

Enumerations

enum class  Kind { Container = 0 , Buffer = 1 , NumKinds = 2 }
 The kinds of particle memory tracked here. See the namespace documentation. More...
 

Functions

void raisePeak (std::atomic< std::size_t > &a_mark, const std::size_t a_value) noexcept
 Raise a high-water mark to a_value unless it is already at least that.
 
void addBytes (const Kind a_kind, const std::size_t a_bytes) noexcept
 Record an allocation.
 
void removeBytes (const Kind a_kind, const std::size_t a_bytes) noexcept
 Record a release.
 
std::size_t getBytes (const Kind a_kind) noexcept
 Get the bytes currently held by one kind.
 
std::size_t getPeak (const Kind a_kind) noexcept
 Get the high-water mark of one kind.
 
std::size_t getAllocatedBytes () noexcept
 Get the bytes currently held by particle data of every kind.
 
std::size_t getPeakBytes () noexcept
 Get the high-water mark across all kinds.
 

Detailed Description

Running totals of the memory held by particle data on this rank.

Chombo's memory tracking counts only allocations that pass through its Arena, i.e. BaseFab-backed mesh data. Particle storage never reaches it – ParticleSoA allocates with std::aligned_alloc and the exchange buffers are plain std::vector – so on a particle-heavy run the largest term in the footprint is invisible to overallMemoryUsage(). This namespace closes that gap.

The total is split by kind, because the two answer different questions and have different remedies:

A peak that is mostly Container means a rank is retaining capacity, and shrinking it is the fix. A peak that is mostly Buffer means too much is moved at once, and chunking the exchange is the fix. The summed total cannot tell them apart, which is the reason for the split.

Peaks are tracked per kind and for the total. The total peak is not the sum of the per-kind peaks, because the two need not peak at the same moment.

This is a companion to Chombo's Arena accounting rather than an independent facility, so it is compiled in and out with it: with USE_MT=FALSE the whole namespace is inert, the counters do not exist, and the memory report prints nothing. The functions are still declared, so that the allocation sites in ParticleSoA and ParticleContainer read the same either way and cannot fall out of step with each other behind a preprocessor guard.

Enumeration Type Documentation

◆ Kind

enum class ParticleMemory::Kind
strong

The kinds of particle memory tracked here. See the namespace documentation.

Enumerator
Container 

ParticleSoA arenas: capacity a rank is holding.

Buffer 

Flat exchange buffers: payload in flight.

NumKinds 

Number of kinds.

Function Documentation

◆ addBytes()

void ParticleMemory::addBytes ( const Kind  a_kind,
const std::size_t  a_bytes 
)
inlinenoexcept

Record an allocation.

Parameters
[in]a_kindWhich kind of particle memory this is.
[in]a_bytesSize of the allocation, in bytes.

◆ getAllocatedBytes()

std::size_t ParticleMemory::getAllocatedBytes ( )
inlinenoexcept

Get the bytes currently held by particle data of every kind.

Returns
Total bytes currently held.

◆ getBytes()

std::size_t ParticleMemory::getBytes ( const Kind  a_kind)
inlinenoexcept

Get the bytes currently held by one kind.

Parameters
[in]a_kindWhich kind.
Returns
Bytes currently held.

◆ getPeak()

std::size_t ParticleMemory::getPeak ( const Kind  a_kind)
inlinenoexcept

Get the high-water mark of one kind.

Parameters
[in]a_kindWhich kind.
Returns
Peak bytes held by that kind.

◆ getPeakBytes()

std::size_t ParticleMemory::getPeakBytes ( )
inlinenoexcept

Get the high-water mark across all kinds.

Returns
Peak total bytes.

◆ raisePeak()

void ParticleMemory::raisePeak ( std::atomic< std::size_t > &  a_mark,
const std::size_t  a_value 
)
inlinenoexcept

Raise a high-water mark to a_value unless it is already at least that.

The loop reloads on contention, because a competing thread may have raised the mark in the meantime; it exits as soon as the mark is at least a_value, so a thread that loses the race to a larger value simply stops.

Parameters
[in,out]a_markThe mark to raise.
[in]a_valueCandidate value.

◆ removeBytes()

void ParticleMemory::removeBytes ( const Kind  a_kind,
const std::size_t  a_bytes 
)
inlinenoexcept

Record a release.

Parameters
[in]a_kindWhich kind of particle memory this is.
[in]a_bytesSize of the release, in bytes. Must be what addBytes() was called with.