Skip to content

Timeclass work branch for sorting out the mess - #1271

Draft
alhom wants to merge 209 commits into
fmihpc:devfrom
alhom:timeclass-mpi
Draft

alhom wants to merge 209 commits into
fmihpc:devfrom
alhom:timeclass-mpi

Conversation

@alhom

@alhom alhom commented Apr 27, 2026

Copy link
Copy Markdown
Member

A draft pull request of the quite WIP timeclasses, for poring over and porting code in a controlled manner to a fresh PR (todo).

markusbattarbee and others added 30 commits November 4, 2022 20:42
…-implemented translation flags, not bug-free yet (hangs after a while)
…ired for loger unidirectional searches (up to VLASOV_STENCIL_WIDTH+1 neighbours). This version crashes with a std::out_of_range on a map. Making the main Vlasov neighbourhood huge (pm6 in every direction) did not fix that...
…d dt, calculations and datareducers implemented.
…ing to fix small discrepancies in acceleration, but this might be floating-point precision issues with dt
veetihaaja and others added 28 commits June 24, 2025 10:04
…erformance for a long time. Rule of five additions; not sure if const copy constructors are actually good here
…erformance for a long time. Rule of five additions; not sure if const copy constructors are actually good here
…erence issue, dt issue is still and it was not the uint cast

@alhom alhom left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A bunch of notes from going through the timeclasses codebase, down to grid.cpp.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Mostly for diagnostics. Depends on having some new CellParams available.

continue;
}
}
if(P::systemWriteAllDROs || lowercase == "timeclass_rank" || lowercase == "vg_timeclass_rank") {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

_rank things we can dispense with - these were an earlier development iteration that was surpassed by new halo definitions.

continue;
}
}
if(P::diagnosticWriteAllDROs || lowercase == "perturbedvolb" || lowercase == "vg_b_perturbed_vol") {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Unnecessary

continue;
}
}
if(P::diagnosticWriteAllDROs || lowercase == "vg_p" || lowercase == "p") {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unnecessary

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adding diagnostics for timeghost block counting (re: memory footprint)

// "\n";
// for(auto tc:timeclasses_handled){
for (int tc = 0; tc <= P::maxTimeclass; tc++){ // Filter to necessary tcs - adjustVelocityBlocks comms need COMM-WORLD yet
adjustVelocityBlocks(mpiGrid, cells, true, popID, tc);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to be squinted at wrt. hashmap troubles

Comment thread common.h
TIME_V, /*!< Current time of the cell due to timeclass timestepping*/
TIMESTEP_V, /*!< Current timestep of the cell due to timeclass timestepping - obs float precision*/
TIMESTEP_FRACTIONAL_V, /*!< Current timestep of the cell due to timeclass timestepping*/
TIMECLASS_RANK, /*!< timeclass of this rank*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

_RANK not needed

Comment thread common.h
VLASOV_SOLVER_Z_GHOST, /*!< up to third(PPM+ghost) neighbor in z face directions */
VLASOV_SOLVER_GHOST, /*!< all required neighbors for ghost translation */
VLASOV_SOLVER_GHOST_REQNEIGH, /*!< all ghost translation neighbors which require own neighbor information */
VLASOV_SOLVER_TIMEGHOST_EXACT_HALO,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

"EXACT", or those ones that have full translation even in ghost regions.

Comment thread common.h
VLASOV_SOLVER_GHOST, /*!< all required neighbors for ghost translation */
VLASOV_SOLVER_GHOST_REQNEIGH, /*!< all ghost translation neighbors which require own neighbor information */
VLASOV_SOLVER_TIMEGHOST_EXACT_HALO,
VLASOV_SOLVER_TIMEGHOST_OUTER_HALO,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Outer halo are only translation sources, copied over and accelerated to correct time.

Comment thread grid.cpp
for (size_t popID=0; popID<getObjectWrapper().particleSpecies.size(); ++popID) {
// Set active population
SpatialCell::setCommunicatedSpecies(popID);
for (int timeclass = 0; timeclass <= P::currentMaxTimeclass; ++timeclass) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is now communicating everything, see where and how to select only for modified timeclasses.

Comment thread grid.cpp
mpiGrid.set_initial_length(grid_length)
.set_load_balancing_method(&P::loadBalanceAlgorithm[0])
.set_neighborhood_length(neighborhood_size)
.set_neighborhood_length(neighborhood_size+4)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This to be checked

Comment thread grid.cpp
// if (P::propagateVlasovAcceleration)
// When using the FS-SPLIT functionality, Jaro Hokkanen reported issues with using the regular
// CellParams::LBWEIGHTCOUNTER, so use of blockscounts + 1 might be required.
mpiGrid.set_cell_weight(cells[i], (Real)1 + mpiGrid[cells[i]]->parameters[CellParams::LBWEIGHTCOUNTER] * ((int)pow(P::timeclassLBmantissa, mpiGrid[cells[i]]->parameters[CellParams::TIMECLASS])));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ad-hoc tuning parameter for LB here

Comment thread grid.cpp
const vector<CellID>& localCells = getLocalCells();
prepareGhostTranslationCellLists(mpiGrid,localCells);

prepareGhostTranslationCellLists(mpiGrid, localCells, ghostTranslate_source, ghostTranslate_active);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

NB here as well ghostTranslate vs timeghost below

Comment thread grid.cpp
const vector<CellID>& localCells = getLocalCells();
std::cerr << __FILE__<<":" << __LINE__ <<"\n";
const vector<CellID> remote_cells = mpiGrid.get_remote_cells_on_process_boundary(Neighborhoods::FULL);
mpiGrid.really_force_update_cell_neighborhoods(remote_cells);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Likely unnecessary

Comment thread grid.cpp
}
}

if (timeclass == P::currentMaxTimeclass){

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just diagnostics

Comment thread grid.cpp
phiprof::Timer timeclassOuter {"Stencils init, timeclass, outer"};
std::vector<neigh_t> neighborhood_outer;

for(auto n : neighborhood){

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a horrible loop and should just loop over timeclassOuterHaloExtent+timeclassExactHaloExtent.

Comment thread iowrite.cpp

// vmesh::VelocityBlockContainer<vmesh::LocalID> emptyvmesh& = vmesh::VelocityBlockContainer<vmesh::LocalID>();
// Write velocity block IDs for all timeghosts
for(int timeclass = 0; timeclass <= P::currentMaxTimeclass; timeclass++){

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This loop writes VDFs to population_timeclass for diagnostics.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To check proper restart handling.

Comment thread ioread.cpp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Needs ghost VDF support for readGrid

Comment thread parameters.cpp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Trivial merges

Comment thread vlasiator.cpp
// }

// }
if(P::tc_test_type == 1){

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The test types here have some archeological layering.

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.

4 participants