use better communicator creation

This commit is contained in:
Max Lübke 2021-01-28 15:16:35 +01:00
parent b96131fa71
commit b85575a69b

View File

@ -100,22 +100,13 @@ int main(int argc, char *argv[]) {
/*Create custom Communicator with all processes except 0 (the master) for DHT /*Create custom Communicator with all processes except 0 (the master) for DHT
* storage*/ * storage*/
// only needed if strategy == 0, but done anyway
MPI_Group dht_group, group_world;
MPI_Comm dht_comm; MPI_Comm dht_comm;
int *process_ranks;
// make a list of processes in the new communicator if (world_rank == 0) {
process_ranks = (int *)malloc(world_size * sizeof(int)); MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, world_rank, &dht_comm);
for (int I = 1; I < world_size; I++) process_ranks[I - 1] = I; } else {
MPI_Comm_split(MPI_COMM_WORLD, 1, world_rank, &dht_comm);
// get the group under MPI_COMM_WORLD }
MPI_Comm_group(MPI_COMM_WORLD, &group_world);
// create the new group
MPI_Group_incl(group_world, world_size - 1, process_ranks, &dht_group);
// create the new communicator
MPI_Comm_create(MPI_COMM_WORLD, dht_group, &dht_comm);
free(process_ranks); // cleanup
// cout << "Done"; // cout << "Done";
// if (cmdl[{"help", "h"}]) { // if (cmdl[{"help", "h"}]) {
@ -580,15 +571,14 @@ int main(int argc, char *argv[]) {
r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));"; r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));";
R.parseEval(r_vis_code); R.parseEval(r_vis_code);
cout << "CPP: Done! Results are stored as R objects into <" << params.out_dir cout << "CPP: Done! Results are stored as R objects into <"
<< "/timings.rds>" << endl; << params.out_dir << "/timings.rds>" << endl;
/*exporting results and profiling data*/ /*exporting results and profiling data*/
// std::string r_vis_code; // std::string r_vis_code;
// r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));"; // r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));";
// R.parseEval(r_vis_code); // R.parseEval(r_vis_code);
} } else { /*This is executed by the workers*/
else { /*This is executed by the workers*/
ChemWorker worker(&params, R, grid, dht_comm); ChemWorker worker(&params, R, grid, dht_comm);
// worker.prepareSimulation(dht_comm); // worker.prepareSimulation(dht_comm);
worker.loop(); worker.loop();