Skip to content

Commit

Permalink
Merge pull request fmihpc#926 from hokkanen/fs-split-update
Browse files Browse the repository at this point in the history
Add support for DCCRG/FSgrid split feature (requires support from DCCRG and FSgrid)
  • Loading branch information
ursg authored Apr 23, 2024
2 parents fe5b092 + b3110a8 commit a74d1d9
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 31 deletions.
8 changes: 7 additions & 1 deletion datareduction/datareductionoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ namespace DRO {
lambda(perBGrid,EGrid,EHallGrid,EGradPeGrid,momentsGrid,dPerBGrid,dMomentsGrid,BgBGrid,volGrid,technicalGrid);

std::array<FsGridTools::FsIndex_t,3>& gridSize = technicalGrid.getLocalSize();
int vectorSize = varBuffer.size() / (gridSize[0]*gridSize[1]*gridSize[2]);
int vectorSize;

// Check if there is anything to write (eg, we are a non-FS process)
if (gridSize[0]*gridSize[1]*gridSize[2] == 0)
vectorSize = 0;
else
vectorSize = varBuffer.size() / (gridSize[0]*gridSize[1]*gridSize[2]);

if(writeAsFloat) {
// Convert down to 32bit floats to save output space
Expand Down
14 changes: 5 additions & 9 deletions grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,11 @@ void balanceLoad(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid, S
//set weights based on each cells LB weight counter
const vector<CellID>& cells = getLocalCells();
for (size_t i=0; i<cells.size(); ++i){
//Set weight. If acceleration is enabled then we use the weight
//counter which is updated in acceleration, otherwise we just
//use the number of blocks.
// if (P::propagateVlasovAcceleration)
mpiGrid.set_cell_weight(cells[i], mpiGrid[cells[i]]->parameters[CellParams::LBWEIGHTCOUNTER]);
// else
// mpiGrid.set_cell_weight(cells[i], mpiGrid[cells[i]]->get_number_of_all_velocity_blocks());
//reset counter
//mpiGrid[cells[i]]->parameters[CellParams::LBWEIGHTCOUNTER] = 0.0;
// Set cell weight. We could use different counters or number of blocks if different solvers are active.
// 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]);
}

phiprof::Timer initLBTimer {"dccrg.initialize_balance_load"};
Expand Down
30 changes: 14 additions & 16 deletions iowrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,19 @@ bool writeDataReducer(const dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>&
}
}

if( success ) {
if( dataReducer.getName(dataReducerIndex).find("fg_", 0) == 0 ) {
// Write fsgrid data
phiprof::Timer writeFsTimer {"writeFsGrid"};
success = dataReducer.writeFsGridData(perBGrid,EGrid,EHallGrid,EGradPeGrid,momentsGrid,dPerBGrid,dMomentsGrid,BgBGrid,volGrid, technicalGrid, "fsgrid", dataReducerIndex, vlsvWriter, writeAsFloat);
writeFsTimer.stop();

} else if( dataReducer.getName(dataReducerIndex).find("ig_", 0) == 0 ) {
// Or maybe it will be writing ionosphere data?
phiprof::Timer writeIonosphereTimer {"writeIonosphere"};
success |= dataReducer.writeIonosphereGridData(SBC::ionosphereGrid, "ionosphere", dataReducerIndex, vlsvWriter);
writeIonosphereTimer.stop();
} else {
// If the data reducer didn't want to write fg or ig data, maybe it will be happy writing dccrg data
if( (writeAsFloat == true && dataType.compare("float") == 0) && dataSize == sizeof(double) ) {
double * varBuffer_double = reinterpret_cast<double*>(varBuffer);
//Declare smaller varbuffer:
Expand Down Expand Up @@ -417,25 +428,13 @@ bool writeDataReducer(const dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>&
delete[] varBuffer_smaller;
varBuffer_smaller = NULL;
} else {
// Write reduced data to file if DROP was successful:
// Write reduced data to file if DROP was successful:
phiprof::Timer writeArrayTimer {"writeArray"};
if (vlsvWriter.writeArray("VARIABLE",attribs, dataType, cells.size(), vectorSize, dataSize, varBuffer) == false) {
success = false;
logFile << "(MAIN) writeGrid: ERROR failed to write datareductionoperator data to file!" << endl << writeVerbose;
}
}

} else {
// If the data reducer didn't want to write dccrg data, maybe it will be happy
// dumping data straight from fsgrid into our file.
phiprof::Timer writeFsTimer {"writeFsGrid"};
success = dataReducer.writeFsGridData(perBGrid,EGrid,EHallGrid,EGradPeGrid,momentsGrid,dPerBGrid,dMomentsGrid,BgBGrid,volGrid, technicalGrid, "fsgrid", dataReducerIndex, vlsvWriter, writeAsFloat);
writeFsTimer.stop();

// Or maybe it will be writing ionosphere data?
phiprof::Timer writeIonosphereTimer {"writeIonosphere"};
success |= dataReducer.writeIonosphereGridData(SBC::ionosphereGrid, "ionosphere", dataReducerIndex, vlsvWriter);
writeIonosphereTimer.stop();
}

// Check if the DataReducer wants to write paramters to the output file
Expand Down Expand Up @@ -940,8 +939,7 @@ bool writeFsGridMetadata(FsGrid< fsgrids::technical, FS_STENCIL_WIDTH> & technic
vlsvWriter.writeArray("MESH_DOMAIN_SIZES", xmlAttributes, 1, 2, &meshDomainSize[0]);

// how many MPI ranks we wrote from
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
int size = technicalGrid.getSize();
vlsvWriter.writeParameter("numWritingRanks", &size);

// Save the FSgrid decomposition
Expand Down
2 changes: 1 addition & 1 deletion submodules/dccrg
Submodule dccrg updated 1 files
+19 −3 dccrg.hpp
2 changes: 1 addition & 1 deletion submodules/fsgrid
Submodule fsgrid updated 1 files
+179 −43 fsgrid.hpp
1 change: 0 additions & 1 deletion vlasovsolver/cpu_trans_map_amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ bool trans_map_1d_amr(const dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartes
/***********************/
// return if there's no cells to propagate
if(localPropagatedCells.size() == 0) {
cout << "Returning because of no cells" << endl;
return false;
}

Expand Down
1 change: 0 additions & 1 deletion vlasovsolver/cpu_trans_pencils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ void flagSpatialCellsForAmrCommunication(const dccrg::Dccrg<SpatialCell,dccrg::C

// return if there's no cells to flag
if(localPropagatedCells.size() == 0) {
std::cerr<<"Warning! Pencils flagSpatialCellsForAmrCommunication found no cells to propagate!"<<std::endl;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion vlasovsolver/cpu_trans_pencils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ bool do_translate_cell(spatial_cell::SpatialCell* SC);

// grid.cpp calls this function to both find seed cells and build pencils for all dimensions
void prepareSeedIdsAndPencils(const dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);
// grid.cpp calls this function to both find seed cells and build pencils
// find seed cells and build pencils for one dimension
void prepareSeedIdsAndPencils(const dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
const uint dimension);

Expand Down

0 comments on commit a74d1d9

Please sign in to comment.