Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature_joss_submission
Browse files Browse the repository at this point in the history
  • Loading branch information
freifrauvonbleifrei committed Nov 17, 2023
2 parents 8d5e190 + 46127fe commit c45b3a2
Show file tree
Hide file tree
Showing 78 changed files with 2,171 additions and 1,835 deletions.
12 changes: 5 additions & 7 deletions examples/combi_example/TaskExample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TaskExample : public Task {
*/
TaskExample(const LevelVector& l, const std::vector<BoundaryType>& boundary, real coeff,
LoadModel* loadModel, real dt, size_t nsteps,
std::vector<int> p = std::vector<int>(0),
const std::vector<int>& p = std::vector<int>(0),
FaultCriterion* faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})))
: Task(l, boundary, coeff, loadModel, faultCrit),
dt_(dt),
Expand All @@ -31,7 +31,7 @@ class TaskExample : public Task {
dfg_(NULL) {}

void init(CommunicatorType lcomm,
std::vector<IndexVector> decomposition = std::vector<IndexVector>()) {
const std::vector<IndexVector>& decomposition = std::vector<IndexVector>()) {
assert(!initialized_);
assert(dfg_ == NULL);

Expand Down Expand Up @@ -108,8 +108,6 @@ class TaskExample : public Task {
void run(CommunicatorType lcomm) {
assert(initialized_);

int lrank = theMPISystem()->getLocalRank();

auto elements = dfg_->getData();
// TODO if your Example uses another data structure, you need to copy
// the data from elements to that data structure
Expand Down Expand Up @@ -152,9 +150,9 @@ class TaskExample : public Task {
dfg_->gatherFullGrid(fg, r);
}

DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int n = 0) override { return *dfg_; }
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t n = 0) override { return *dfg_; }

const DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int n = 0) const override { return *dfg_; }
const DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t n = 0) const override { return *dfg_; }

static real myfunction(std::vector<real>& coords, real t) {
real u = std::cos(M_PI * t);
Expand Down Expand Up @@ -183,7 +181,7 @@ class TaskExample : public Task {

// new variables that are set by manager. need to be added to serialize
real dt_;
size_t nsteps_;
size_t nsteps_ = 0;
std::vector<int> p_;

// pure local variables that exist only on the worker processes
Expand Down
14 changes: 6 additions & 8 deletions examples/combi_example_faults/TaskExample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TaskExample: public Task {
*/
TaskExample(DimType dim, const LevelVector& l, const std::vector<BoundaryType>& boundary,
real coeff, LoadModel* loadModel, real dt, size_t nsteps,
std::vector<int> p = std::vector<int>(0),
const std::vector<int>& p = std::vector<int>(0),
FaultCriterion* faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})))
: Task(l, boundary, coeff, loadModel, faultCrit),
dt_(dt),
Expand All @@ -33,7 +33,7 @@ class TaskExample: public Task {
combiStep_(0),
dfg_(NULL) {}

void init(CommunicatorType lcomm, std::vector<IndexVector> decomposition = std::vector<IndexVector>()) {
void init(CommunicatorType lcomm, const std::vector<IndexVector>& decomposition = std::vector<IndexVector>()) {
assert(!initialized_);
assert(dfg_ == NULL);

Expand Down Expand Up @@ -110,9 +110,6 @@ class TaskExample: public Task {
void run(CommunicatorType lcomm) {
assert(initialized_);

int globalRank = theMPISystem()->getGlobalRank();
int lrank = theMPISystem()->getLocalRank();

/* pseudo timestepping to demonstrate the behaviour of your typical
* time-dependent simulation problem. */
auto elements = dfg_->getData();
Expand Down Expand Up @@ -147,11 +144,12 @@ class TaskExample: public Task {
dfg_->gatherFullGrid(fg, r);
}

DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int n) override {
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t n) override {
return *dfg_;
}

const DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int n) const override{
const DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t n) const override{
assert(n == 0);
return *dfg_;
}

Expand Down Expand Up @@ -200,7 +198,7 @@ class TaskExample: public Task {

// new variables that are set by manager. need to be added to serialize
real dt_;
size_t nsteps_;
size_t nsteps_ = 0;
size_t stepsTotal_;
std::vector<int> p_;

Expand Down
2 changes: 1 addition & 1 deletion examples/combi_workers_only/combi_example_worker_only.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int main(int argc, char** argv) {
interpolationCoords = broadcastParameters::getCoordinatesFromRankZero(
interpolationCoordsFile, theMPISystem()->getWorldComm());

if (interpolationCoords.size() != 1e5) {
if (interpolationCoords.size() != static_cast<size_t>(1e5)) {
sleep(1);
throw std::runtime_error("not enough interpolation coordinates");
}
Expand Down
11 changes: 5 additions & 6 deletions examples/distributed_advection/TaskAdvection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TaskAdvection : public Task {
*/
TaskAdvection(const LevelVector& l, const std::vector<BoundaryType>& boundary, real coeff,
LoadModel* loadModel, real dt, size_t nsteps,
std::vector<int> p = std::vector<int>(0),
const std::vector<int>& p = std::vector<int>(0),
FaultCriterion* faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})))
: Task(l, boundary, coeff, loadModel, faultCrit),
dt_(dt),
Expand All @@ -42,17 +42,16 @@ class TaskAdvection : public Task {
initialized_(false),
stepsTotal_(0),
dfg_(nullptr) {
for (const auto& b : boundary) {
for ([[maybe_unused]] const auto& b : boundary) {
assert(b == 1);
}
}

void init(CommunicatorType lcomm,
std::vector<IndexVector> decomposition = std::vector<IndexVector>()) override {
const std::vector<IndexVector>& decomposition = std::vector<IndexVector>()) override {
assert(!initialized_);
assert(dfg_ == NULL);

auto lrank = theMPISystem()->getLocalRank();
DimType dim = this->getDim();
const LevelVector& l = this->getLevelVector();

Expand Down Expand Up @@ -105,7 +104,7 @@ class TaskAdvection : public Task {
// swap at the end of each time step
auto& u_dot_dphi = *phi_;
auto const ElementVector = dfg_->getData();
for (unsigned int d = 0; d < this->getDim(); ++d) {
for (DimType d = 0; d < this->getDim(); ++d) {
static std::vector<int> subarrayExtents;
std::vector<CombiDataType> phi_ghost{};
dfg_->exchangeGhostLayerUpward(d, subarrayExtents, phi_ghost);
Expand Down Expand Up @@ -183,7 +182,7 @@ class TaskAdvection : public Task {
dfg_->gatherFullGrid(fg, r);
}

DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int n = 0) override { return *dfg_; }
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t n = 0) override { return *dfg_; }

void setZero() override {
dfg_->setZero();
Expand Down
10 changes: 5 additions & 5 deletions examples/distributed_third_level/TaskAdvection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TaskAdvection : public Task {
*/
TaskAdvection(const LevelVector& l, const std::vector<BoundaryType>& boundary, real coeff,
LoadModel* loadModel, real dt, size_t nsteps,
std::vector<int> p = std::vector<int>(0),
const std::vector<int>& p = std::vector<int>(0),
FaultCriterion* faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})))
: Task(l, boundary, coeff, loadModel, faultCrit),
dt_(dt),
Expand All @@ -42,13 +42,13 @@ class TaskAdvection : public Task {
initialized_(false),
stepsTotal_(0),
dfg_(nullptr) {
for (const auto& b : boundary) {
for ([[maybe_unused]] const auto& b : boundary) {
assert(b == 1);
}
}

void init(CommunicatorType lcomm,
std::vector<IndexVector> decomposition = std::vector<IndexVector>()) override {
const std::vector<IndexVector>& decomposition = std::vector<IndexVector>()) override {
assert(!initialized_);
assert(dfg_ == NULL);

Expand Down Expand Up @@ -157,7 +157,7 @@ class TaskAdvection : public Task {
}
// iterate the lowest layer and update the values, compensating for the wrong update
// before
assert(numLocalElements / dfg_->getLocalSizes()[d] == phi_ghost.size());
assert(static_cast<size_t>(numLocalElements) / dfg_->getLocalSizes()[d] == phi_ghost.size());
const auto& stride = fullOffsetsInThisDimension;
const IndexType jump = stride * dfg_->getLocalSizes()[d];
const IndexType numberOfPolesHigherDimensions = numLocalElements / jump;
Expand Down Expand Up @@ -235,7 +235,7 @@ class TaskAdvection : public Task {
dfg_->gatherFullGrid(fg, r);
}

DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int n = 0) override { return *dfg_; }
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t n = 0) override { return *dfg_; }

void setZero() override {
dfg_->setZero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char** argv) {
bool evalMCError = cfg.get<bool>("application.mcerror", false);
uint16_t numberOfFileParts = cfg.get<uint16_t>("io.numberParts", 1);

theMPISystem()->initOuputGroupComm(numberOfFileParts);
theMPISystem()->initOutputGroupComm(numberOfFileParts);

// read in third level parameters if available
std::string thirdLevelHost, thirdLevelSSHCommand = "";
Expand Down Expand Up @@ -166,7 +166,7 @@ int main(int argc, char** argv) {
interpolationCoords = broadcastParameters::getCoordinatesFromRankZero(
interpolationCoordsFile, theMPISystem()->getWorldComm());

if (interpolationCoords.size() != 1e5) {
if (interpolationCoords.size() != static_cast<size_t>(1e5)) {
sleep(1);
throw std::runtime_error("not enough interpolation coordinates");
}
Expand Down
12 changes: 5 additions & 7 deletions examples/distributed_third_level/tools/worker_only_io_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char** argv) {
nsteps = cfg.get<size_t>("application.nsteps");
bool evalMCError = cfg.get<bool>("application.mcerror", false);
uint16_t numberOfFileParts = cfg.get<uint16_t>("io.numberParts", 1);
theMPISystem()->initOuputGroupComm(numberOfFileParts);
theMPISystem()->initOutputGroupComm(numberOfFileParts);

// read in third level parameters if available
std::string thirdLevelHost, thirdLevelSSHCommand = "";
Expand All @@ -86,8 +86,7 @@ int main(int argc, char** argv) {
MIDDLE_PROCESS_EXCLUSIVE_SECTION std::cout << "running in file-based third level mode"
<< std::endl;
} else {
MIDDLE_PROCESS_EXCLUSIVE_SECTION std::cout << "running in file-based local mode"
<< std::endl;
MIDDLE_PROCESS_EXCLUSIVE_SECTION std::cout << "running in file-based local mode" << std::endl;
}

// periodic boundary conditions
Expand Down Expand Up @@ -239,13 +238,12 @@ int main(int argc, char** argv) {
readSparseGridFile =
"dsg_" + std::to_string((systemNumber + 1) % 2) + "_step" + std::to_string(i);
std::string readSparseGridFileToken = readSparseGridFile + "_token.txt";
OUTPUT_GROUP_EXCLUSIVE_SECTION {
}
OUTPUT_GROUP_EXCLUSIVE_SECTION {}

} else {
readSparseGridFile = writeSparseGridFile;
OUTPUT_GROUP_EXCLUSIVE_SECTION {
worker.waitForTokenFile(writeSparseGridFileToken);
OUTPUT_GROUP_EXCLUSIVE_SECTION {
worker.waitForTokenFile(writeSparseGridFileToken);
Stats::startEvent("read SG");
int numRead = worker.readReduce(readSparseGridFile, true);
Stats::stopEvent("read SG");
Expand Down
4 changes: 2 additions & 2 deletions examples/gene_distributed/src/GeneTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void GeneTask::decideToKill(){ //toDo check if combiStep should be included in t
/**
* This routine initializes GeneTask; currently it only sets a bool value.
*/
void GeneTask::init(CommunicatorType lcomm, std::vector<IndexVector> decomposition){
void GeneTask::init(CommunicatorType lcomm, const std::vector<IndexVector>& decomposition){
// if( dfg_ == NULL ){
// dfg_ = new OwningDistributedFullGrid<CombiDataType>( dim_, l_, lcomm,
// this->getBoundary(), p_, false);
Expand Down Expand Up @@ -247,7 +247,7 @@ void GeneTask::getFullGrid( FullGrid<CombiDataType>& fg, RankType lroot,
/**
* This routine returns the local part of the fullgrid
*/
DistributedFullGrid<complex>& GeneTask::getDistributedFullGrid(int specie){
DistributedFullGrid<complex>& GeneTask::getDistributedFullGrid(size_t specie) override {
return *dfgVector_[specie];
}

Expand Down
13 changes: 7 additions & 6 deletions examples/gene_distributed/src/GeneTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GeneTask : public combigrid::Task {
public:
GeneTask(DimType dim, const LevelVector& l, const std::vector<BoundaryType>& boundary, real coeff,
LoadModel* loadModel, std::string& path, real dt, real combitime, size_t nsteps,
real shat, real lx, int ky0_ind, std::vector<int> p = std::vector<int>(0),
real shat, real lx, int ky0_ind, const std::vector<int>& p = std::vector<int>(0),
FaultCriterion* faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})),
IndexType numSpecies = 1, bool GENE_Global = false, bool GENE_Linear = true,
size_t checkpointFrequency = 1, size_t offsetForDiagnostics = 0);
Expand All @@ -57,20 +57,21 @@ class GeneTask : public combigrid::Task {
*/
void changeDir(CommunicatorType lcomm);

//void init(CommunicatorType lcomm);
// void init(CommunicatorType lcomm);

/**
* This method initializes the task
* lcomm is the local communicator of the process group.
* decomposition is the spatial decomposition of the component grid
*/
void init(CommunicatorType lcomm, std::vector<IndexVector> decomposition = std::vector<IndexVector>());
void init(CommunicatorType lcomm,
const std::vector<IndexVector>& decomposition = std::vector<IndexVector>());

/**
* This method returns the decomposition of the grid of the specified species
*/
std::vector<IndexVector> getDecomposition(int species){
return dfgVector_[species]->getDecomposition();
std::vector<IndexVector> getDecomposition(int species) {
return dfgVector_[species]->getDecomposition();
}

/**
Expand Down Expand Up @@ -108,7 +109,7 @@ class GeneTask : public combigrid::Task {
/**
* Returns the distributed full grid of the specified specie
*/
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int specie);
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t specie);

/*
* Convert fg to GeneGrid and scatter over processes of pgroup. The fullgrid
Expand Down
2 changes: 1 addition & 1 deletion examples/gene_distributed/tools/testBoundaryZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using namespace combigrid;


void testBoundaryZ(FullGrid<CombiDataType>& fg, std::string filePrefix ){
void testBoundaryZ(FullGrid<CombiDataType>& fg, const std::string& filePrefix ){
const double tol = 1e-15;

MultiArrayRef6 fgData = createMultiArrayRef<CombiDataType,6>( fg );
Expand Down
4 changes: 2 additions & 2 deletions examples/gene_distributed_linear/src/GeneTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void GeneTask::decideToKill(){ //toDo check if combiStep should be included in t
/**
* This routine initializes GeneTask; currently it only sets a bool value.
*/
void GeneTask::init(CommunicatorType lcomm, std::vector<IndexVector> decomposition){
void GeneTask::init(CommunicatorType lcomm, const std::vector<IndexVector>& decomposition){
// if( dfg_ == NULL ){
// dfg_ = new DistributedFullGrid<CombiDataType>( dim_, l_, lcomm,
// this->getBoundary(), p_, false);
Expand Down Expand Up @@ -279,7 +279,7 @@ void GeneTask::getFullGrid( FullGrid<CombiDataType>& fg, RankType lroot,
/**
* This routine returns the local part of the fullgrid
*/
DistributedFullGrid<complex>& GeneTask::getDistributedFullGrid(int specie){
DistributedFullGrid<complex>& GeneTask::getDistributedFullGrid(size_t specie) override {
return *dfgVector_[specie];
}

Expand Down
13 changes: 7 additions & 6 deletions examples/gene_distributed_linear/src/GeneTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GeneTask : public combigrid::Task {
public:
GeneTask(DimType dim, const LevelVector& l, const std::vector<BoundaryType>& boundary, real coeff,
LoadModel* loadModel, std::string& path, real dt, real combitime, size_t nsteps,
real shat, real lx, int ky0_ind, std::vector<int> p = std::vector<int>(0),
real shat, real lx, int ky0_ind, const std::vector<int>& p = std::vector<int>(0),
FaultCriterion* faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})),
IndexType numSpecies = 1, bool GENE_Global = false, bool GENE_Linear = true);

Expand All @@ -51,20 +51,21 @@ class GeneTask : public combigrid::Task {
*/
void changeDir(CommunicatorType lcomm);

//void init(CommunicatorType lcomm);
// void init(CommunicatorType lcomm);

/**
* This method initializes the task
* lcomm is the local communicator of the process group.
* decomposition is the spatial decomposition of the component grid
*/
void init(CommunicatorType lcomm, std::vector<IndexVector> decomposition = std::vector<IndexVector>());
void init(CommunicatorType lcomm,
const std::vector<IndexVector>& decomposition = std::vector<IndexVector>());

/**
* This method returns the decomposition of the grid of the specified species
*/
std::vector<IndexVector> getDecomposition(int species){
return dfgVector_[species]->getDecomposition();
std::vector<IndexVector> getDecomposition(int species) {
return dfgVector_[species]->getDecomposition();
}

/**
Expand Down Expand Up @@ -102,7 +103,7 @@ class GeneTask : public combigrid::Task {
/**
* Returns the distributed full grid of the specified specie
*/
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(int specie);
DistributedFullGrid<CombiDataType>& getDistributedFullGrid(size_t specie);

/*
* Convert fg to GeneGrid and scatter over processes of pgroup. The fullgrid
Expand Down
Loading

0 comments on commit c45b3a2

Please sign in to comment.