Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
dfcdc0a
First attempt
markusbattarbee May 11, 2020
3f97feb
Changed ioread to not complain about single LB value on readin
markusbattarbee May 12, 2020
5fbea60
Merge branch 'dev' into three-dimensional-weights
markusbattarbee Sep 28, 2021
5dde4e7
cleanup, support restarts with both vector and scalar LBweight values
markusbattarbee Sep 28, 2021
0ef3aa2
Provide dccrg communication weight
lkotipal Feb 15, 2023
84cc0b4
Scale LB weight to time everywhere
lkotipal Feb 28, 2023
5d93ed0
Better Vlasov neighbors
lkotipal Mar 3, 2023
0ca9608
Parameter for HIER
lkotipal Jun 1, 2023
d1591df
Revert "Parameter for HIER"
lkotipal Jun 13, 2023
23f30cf
Dummy commit for CI
lkotipal Jun 1, 2023
f6ca52e
Dummy
lkotipal Jun 13, 2023
0ac5e73
Hypergraph branch submodule
lkotipal Feb 8, 2024
a6d0aef
Fix errors in merge
lkotipal Feb 8, 2024
7b874e6
LB algorithm for CI
lkotipal Feb 8, 2024
6054a54
Move stencil initialization before load balancing
lkotipal Feb 8, 2024
7ea579d
Change partitioning neighborhood
lkotipal Feb 8, 2024
1a55ec5
Parametrize partitioning neighborhood
lkotipal Feb 9, 2024
a1c7d5d
Correct submodule version
lkotipal Feb 9, 2024
aeb6bb7
Remove orphaned parameter
lkotipal Feb 9, 2024
6891d6a
Update submodule
lkotipal Feb 12, 2024
9a61f21
Multi-neighborhood partitioning
lkotipal Feb 12, 2024
70d0702
Attempt to fix crashes, remove debug message
lkotipal Feb 12, 2024
6864a87
Update submodule
lkotipal Feb 12, 2024
418cb14
Use RIB by default
lkotipal Feb 13, 2024
89b6197
Output reducer for system boundary communication
lkotipal Feb 26, 2024
e794fc6
Per-cell partitioning neighborhoods
lkotipal Feb 26, 2024
e951630
Merge remote-tracking branch 'markusbattarbee/three-dimensional-weigh…
lkotipal Mar 21, 2024
a7bb565
Better multi-weight support
lkotipal Apr 5, 2024
0edcc75
Submodule update
lkotipal Apr 16, 2024
5d9a192
Default weight dimension 1
lkotipal Apr 16, 2024
af2e100
Submodule update
lkotipal Apr 17, 2024
afb2cb2
Merge branch 'hypergraph-3d-weights' into hypergraph
lkotipal Apr 17, 2024
05441b6
Merge branch 'dev' into hypergraph
lkotipal Apr 17, 2024
c3f2ab0
Write LB weight when writing all DROs
lkotipal Apr 17, 2024
1a1ceb7
Change LB approach after initialization
lkotipal Jun 6, 2024
0a42980
Merge branch 'dev' into hypergraph
lkotipal Nov 26, 2024
a53b551
Manual revert of multi-dimensional cell weights
lkotipal Nov 26, 2024
3292e97
Don't initialize stencils twice
lkotipal Nov 26, 2024
8274fcf
Merge branch 'dev' into hypergraph
lkotipal May 20, 2025
4bc21f4
Clarifying comment
lkotipal May 20, 2025
f85825d
Attempted fix of issue where default partitioning neighborhood doesn'…
lkotipal May 20, 2025
e06ab00
Enum neighborhood ids
lkotipal May 22, 2025
aab31e2
Remove deprecated function
lkotipal May 22, 2025
c5f3fa6
Remove deprecated variables
lkotipal May 26, 2025
9cfe3a6
Remove sysboundaries communication flag
lkotipal May 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datareduction/datareducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void initializeDataReducers(DataReducer * outputReducer, DataReducer * diagnosti
}
if(P::systemWriteAllDROs || lowercase == "lbweight" || lowercase == "vg_lbweight" || lowercase == "vg_loadbalanceweight" || lowercase == "vg_loadbalance_weight") {
// Load balance metric for LB debugging
outputReducer->addOperator(new DRO::DataReductionOperatorCellParams("vg_loadbalance_weight",CellParams::LBWEIGHTCOUNTER,1));
outputReducer->addOperator(new DRO::DataReductionOperatorCellParams("vg_loadbalance_weight",CellParams::LBWEIGHTCOUNTER, 1));
outputReducer->addMetadata(outputReducer->size()-1,"","","$\\mathrm{LB weight}$","");
if(!P::systemWriteAllDROs) {
continue;
Expand Down Expand Up @@ -3664,7 +3664,7 @@ void initializeDataReducers(DataReducer * outputReducer, DataReducer * diagnosti
}
}
if(P::diagnosticWriteAllDROs || lowercase == "lbweight" || lowercase == "vg_lbweight" || lowercase == "vg_loadbalanceweight" || lowercase == "vg_loadbalance_weight" || lowercase == "loadbalance_weight") {
Comment thread
lkotipal marked this conversation as resolved.
diagnosticReducer->addOperator(new DRO::DataReductionOperatorCellParams("vg_loadbalance_weight",CellParams::LBWEIGHTCOUNTER,1));
diagnosticReducer->addOperator(new DRO::DataReductionOperatorCellParams("vg_loadbalance_weight",CellParams::LBWEIGHTCOUNTER, 1));
if(!P::diagnosticWriteAllDROs) {
continue;
}
Expand Down
45 changes: 41 additions & 4 deletions grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ using namespace std;

extern Logger logFile;

void initVelocityGridGeometry(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);
void initSpatialCellCoordinates(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);
void initializeStencils(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);

Expand Down Expand Up @@ -143,11 +142,24 @@ void initializeGrids(
sysBoundaries.isPeriodic(2))
.initialize(comm)
.set_geometry(geom_params);

mpiGrid.set_load_balance_norm(P::loadBalanceNorm);

for (const auto& [key, value] : P::loadBalanceOptions) {
mpiGrid.set_partitioning_option(key, value);
}

mpiGrid.set_partitioning_option("LB_APPROACH", "PARTITION");

// Hypergraph partitioning needs stencils initialized
initializeStencils(mpiGrid);
dccrgTimer.stop();

phiprof::Timer refineTimer {"Refine spatial cells"};
// We need this first as well
recalculateLocalCellsCache(mpiGrid);

setPartitioningNeighborhoods(mpiGrid);

if (!P::isRestart) {
// Note call to project.refineSpatialCells below
if (P::amrMaxSpatialRefLevel > 0 && project.refineSpatialCells(mpiGrid)) {
Expand All @@ -166,13 +178,17 @@ void initializeGrids(
}
}
refineTimer.stop();
initializeStencils(mpiGrid);

mpiGrid.set_partitioning_option("OBJ_WEIGHTS_COMPARABLE", "1");

for (const auto& [key, value] : P::loadBalanceOptions) {
mpiGrid.set_partitioning_option(key, value);
}
phiprof::Timer initialLBTimer {"Initial load-balancing"};
if (myRank == MASTER_RANK) logFile << "(INIT): Starting initial load balance." << endl << writeVerbose;

// TODO: do we really need two initial LB?
setPartitioningNeighborhoods(mpiGrid);
mpiGrid.balance_load(); // Direct DCCRG call, recalculate cache afterwards
recalculateLocalCellsCache(mpiGrid);

Expand Down Expand Up @@ -316,7 +332,7 @@ void initializeGrids(
} else if (P::writeFullBGB) {
// If, instead of starting a regular simulation, we are only writing out the background field, it is enough to set a dummy load balance value of 1 here.
for (size_t i=0; i<cells.size(); ++i) {
mpiGrid[cells[i]]->parameters[CellParams::LBWEIGHTCOUNTER] = 1;
mpiGrid[cells[i]]->parameters[CellParams::LBWEIGHTCOUNTER] = 1.0;
}
}

Expand Down Expand Up @@ -398,6 +414,8 @@ void initializeGrids(
P::dt = P::bailout_min_dt;
}

mpiGrid.set_partitioning_option("LB_APPROACH", P::loadBalanceOptions.count("LB_APPROACH") ? P::loadBalanceOptions["LB_APPROACH"] : "REPARTITION");

// With all cell data in place, make preparations for translation
prepareAMRLists(mpiGrid);
initialStateTimer.stop();
Expand Down Expand Up @@ -475,6 +493,24 @@ void setFaceNeighborRanks( dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>&
}
}

void setPartitioningNeighborhoods(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid) {
const vector<CellID>& cells = getLocalCells();
for (auto& cell : cells){
mpiGrid.clear_partitioning_neighborhoods(cell);
for (auto neighborhood : P::partitioningNeighborhoods) {
// TODO: for now, layer 1 cells communicate in the extended neighborhood
// If this is ever fixed, SYSBOUNDRIES_NEIGHBORHOOD_ID needs a case
if (neighborhood == Neighborhoods::SYSBOUNDARIES_EXTENDED) {
if (mpiGrid[cell]->sysBoundaryLayer == 1 || mpiGrid[cell]->sysBoundaryLayer == 2) {
mpiGrid.add_partitioning_neighborhood(cell, neighborhood);
}
} else {
mpiGrid.add_partitioning_neighborhood(cell, neighborhood);
}
}
}
}

void balanceLoad(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid, SysBoundary& sysBoundaries, FsGrid<fsgrids::technical, FS_STENCIL_WIDTH> & technicalGrid, bool doTranslationLists){
// Invalidate cached cell lists
Parameters::meshRepartitioned = true;
Expand All @@ -488,6 +524,7 @@ void balanceLoad(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid, S
deallocTimer.stop();

//set weights based on each cells LB weight counter
setPartitioningNeighborhoods(mpiGrid);
const vector<CellID>& cells = getLocalCells();
for (size_t i=0; i<cells.size(); ++i){
// Set cell weight. We could use different counters or number of blocks if different solvers are active.
Expand Down
2 changes: 2 additions & 0 deletions grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void initializeGrids(
Project& project
);

void setPartitioningNeighborhoods(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);

/*!
\brief Balance load

Expand Down
22 changes: 22 additions & 0 deletions ioread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,28 @@ bool readIonosphereNodeVariable(
return true;
}

/*!
\brief read length of SpatialGrid vector variable
\param file The ParallelReader file to use
\param variableName Name of the variable to check
*/
int readVectorSize(vlsv::ParallelReader& file,
const std::string& variableName){
uint64_t arraySize;
uint64_t vectorSize;
vlsv::datatype::type dataType;
uint64_t byteSize;
list<pair<string,string> > attribs;
attribs.push_back(make_pair("name",variableName));
attribs.push_back(make_pair("mesh","SpatialGrid"));

if (file.getArrayInfo("VARIABLE",attribs,arraySize,vectorSize,dataType,byteSize) == false) {
logFile << "(RESTART) ERROR: Failed to read " << endl << write;
return -1;
}
return (int)vectorSize;
}

Comment thread
lkotipal marked this conversation as resolved.
/*!
\brief Read in state from a vlsv file in order to restart simulations
\param mpiGrid Vlasiator's grid
Expand Down
17 changes: 16 additions & 1 deletion parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ bool P::isRestart = false;
int P::writeAsFloat = false;
int P::writeRestartAsFloat = false;
string P::loadBalanceAlgorithm = string("");
std::vector<int> P::partitioningNeighborhoods {};
std::map<std::string, std::string> P::loadBalanceOptions;
int P::loadBalanceNorm {1};
uint P::rebalanceInterval = numeric_limits<uint>::max();

vector<string> P::outputVariableList;
Expand Down Expand Up @@ -404,8 +406,11 @@ bool P::addParameters() {
RP::add("vlasovsolver.GhostTranslateExtent","Stencil size in all-local ghost translation (default: VLASOV_STENCIL_WIDTH+1",0);

// Load balancing parameters
RP::add("loadBalance.algorithm", "Load balancing algorithm to be used", string("RCB"));
RP::add("loadBalance.algorithm", "Load balancing algorithm to be used", string("RIB"));
RP::addComposing("loadBalance.partitioning_neighborhood", "Neighborhood ID for (hyper)graph partitioning, see definitions.h");
RP::add("loadBalance.tolerance", "Load imbalance tolerance", string("1.05"));
RP::add("loadBalance.weight_dim", "Dimension of object weight", string("1"));
RP::add("loadBalance.norm", "Norm to use for cell weights in load balance, default 1-norm (sum)", 1);
RP::add("loadBalance.rebalanceInterval", "Load rebalance interval (steps)", 10);

RP::addComposing("loadBalance.optionKey", "Zoltan option key. Has to be matched by loadBalance.optionValue.");
Expand Down Expand Up @@ -1058,10 +1063,20 @@ void Parameters::getParameters() {
}
// Get load balance parameters
RP::get("loadBalance.algorithm", P::loadBalanceAlgorithm);
RP::get("loadBalance.partitioning_neighborhood", P::partitioningNeighborhoods);

if (P::partitioningNeighborhoods.empty()) {
P::partitioningNeighborhoods.push_back(Neighborhoods::FULL);
}

loadBalanceOptions["IMBALANCE_TOL"] = "";
RP::get("loadBalance.tolerance", loadBalanceOptions["IMBALANCE_TOL"]);
RP::get("loadBalance.norm", P::loadBalanceNorm);
RP::get("loadBalance.rebalanceInterval", P::rebalanceInterval);

loadBalanceOptions["OBJ_WEIGHT_DIM"] = "";
RP::get("loadBalance.weight_dim", loadBalanceOptions["OBJ_WEIGHT_DIM"]);

std::vector<std::string> loadBalanceKeys;
std::vector<std::string> loadBalanceValues;
RP::get("loadBalance.optionKey", loadBalanceKeys);
Expand Down
2 changes: 2 additions & 0 deletions parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ struct Parameters {
in the Lorentz force and in the field solver.*/

static std::string loadBalanceAlgorithm; /*!< Algorithm to be used for load balance.*/
static std::vector<int> partitioningNeighborhoods; /*!< Partitioning neighborhood for (hyper)graph.*/
static std::map<std::string, std::string> loadBalanceOptions; // Other Load balancing options
static int loadBalanceNorm; // Norm to use for cell weights
static uint rebalanceInterval; /*!< Load rebalance interval (steps). */
static bool prepareForRebalance; /**< If true, propagators should measure their time consumption in preparation
* for mesh repartitioning.*/
Expand Down
2 changes: 1 addition & 1 deletion submodules/dccrg
Submodule dccrg updated 1 files
+324 −116 dccrg.hpp