OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
BunchStateHandler.cpp
Go to the documentation of this file.
2
3#include "Ippl.h"
4#include "Utilities/Options.h"
5
6#include <functional>
7
8namespace {
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
25
27 momentsDirty = Options::aggressiveStateSync ? syncOr(true) : true;
28}
29
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
39std::shared_ptr<BunchStateHandler::ContainerState> BunchStateHandler::registerContainer() {
40 auto state = std::make_shared<ContainerState>();
41 registered_m.emplace_back(state);
42 return state;
43}
44
std::vector< std::weak_ptr< ContainerState > > registered_m
void setFirstRepartition(bool v)
std::shared_ptr< ContainerState > registerContainer()
Allocate a new per-container slot and return a strong reference to it. The handler itself retains onl...
bool aggressiveStateSync
Definition Options.cpp:111