OPALX (Object Oriented Parallel Accelerator Library for Exascal)
master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
BunchStateHandler.cpp
Go to the documentation of this file.
1
#include "
PartBunch/BunchStateHandler.h
"
2
3
#include "Ippl.h"
4
#include "
Utilities/Options.h
"
5
6
#include <functional>
7
8
namespace
{
9
// Converge a local bool across all MPI ranks using logical-OR. Intentionally
10
// chosen over logical-AND so that any rank reporting the "set" state forces
11
// the whole bunch to adopt it: dirty wins over clean, unitless wins over
12
// physical, first-repartition wins over done.
13
inline
bool
syncOr(
bool
v) {
14
bool
out = v;
15
ippl::Comm->allreduce(v, out, 1, std::logical_or<bool>());
16
return
out;
17
}
18
}
// namespace
19
20
// -- BunchStateHandler::ContainerState -------------------------------------
21
22
void
BunchStateHandler::ContainerState::setUnitlessPositions
(
bool
v) {
23
unitlessPositions
=
Options::aggressiveStateSync
? syncOr(v) : v;
24
}
25
26
void
BunchStateHandler::ContainerState::markMomentsDirty
() {
27
momentsDirty =
Options::aggressiveStateSync
? syncOr(
true
) :
true
;
28
}
29
30
void
BunchStateHandler::ContainerState::markMomentsClean
() {
31
// With AGGRESSIVE_STATE_SYNC, "clear" only takes effect if every rank
32
// agrees the cache is clean; any rank still dirty keeps the whole bunch
33
// dirty.
34
momentsDirty =
Options::aggressiveStateSync
? syncOr(
false
) :
false
;
35
}
36
37
// -- BunchStateHandler -----------------------------------------------------
38
39
std::shared_ptr<BunchStateHandler::ContainerState>
BunchStateHandler::registerContainer
() {
40
auto
state = std::make_shared<ContainerState>();
41
registered_m
.emplace_back(state);
42
return
state;
43
}
44
45
void
BunchStateHandler::setFirstRepartition
(
bool
v) {
46
firstRepartition_m
=
Options::aggressiveStateSync
? syncOr(v) : v;
47
}
BunchStateHandler.h
Options.h
BunchStateHandler::registered_m
std::vector< std::weak_ptr< ContainerState > > registered_m
Definition
BunchStateHandler.h:113
BunchStateHandler::setFirstRepartition
void setFirstRepartition(bool v)
Definition
BunchStateHandler.cpp:45
BunchStateHandler::firstRepartition_m
bool firstRepartition_m
Definition
BunchStateHandler.h:115
BunchStateHandler::registerContainer
std::shared_ptr< ContainerState > registerContainer()
Allocate a new per-container slot and return a strong reference to it. The handler itself retains onl...
Definition
BunchStateHandler.cpp:39
Options::aggressiveStateSync
bool aggressiveStateSync
Definition
Options.cpp:111
BunchStateHandler::ContainerState::markMomentsClean
void markMomentsClean()
Definition
BunchStateHandler.cpp:30
BunchStateHandler::ContainerState::setUnitlessPositions
void setUnitlessPositions(bool v)
Definition
BunchStateHandler.cpp:22
BunchStateHandler::ContainerState::unitlessPositions
bool unitlessPositions
Definition
BunchStateHandler.h:70
BunchStateHandler::ContainerState::markMomentsDirty
void markMomentsDirty()
Definition
BunchStateHandler.cpp:26
src
PartBunch
BunchStateHandler.cpp
Generated on Mon Jun 1 2026 10:40:53 for OPALX (Object Oriented Parallel Accelerator Library for Exascal) by
1.9.8