mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 04:48:23 +01:00
use better communicator creation
This commit is contained in:
parent
b96131fa71
commit
b85575a69b
58
src/kin.cpp
58
src/kin.cpp
@ -100,22 +100,13 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/*Create custom Communicator with all processes except 0 (the master) for DHT
|
||||
* storage*/
|
||||
// only needed if strategy == 0, but done anyway
|
||||
MPI_Group dht_group, group_world;
|
||||
MPI_Comm dht_comm;
|
||||
int *process_ranks;
|
||||
|
||||
// make a list of processes in the new communicator
|
||||
process_ranks = (int *)malloc(world_size * sizeof(int));
|
||||
for (int I = 1; I < world_size; I++) process_ranks[I - 1] = I;
|
||||
|
||||
// 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
|
||||
if (world_rank == 0) {
|
||||
MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, world_rank, &dht_comm);
|
||||
} else {
|
||||
MPI_Comm_split(MPI_COMM_WORLD, 1, world_rank, &dht_comm);
|
||||
}
|
||||
// cout << "Done";
|
||||
|
||||
// if (cmdl[{"help", "h"}]) {
|
||||
@ -580,38 +571,37 @@ int main(int argc, char *argv[]) {
|
||||
r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));";
|
||||
R.parseEval(r_vis_code);
|
||||
|
||||
cout << "CPP: Done! Results are stored as R objects into <" << params.out_dir
|
||||
<< "/timings.rds>" << endl;
|
||||
cout << "CPP: Done! Results are stored as R objects into <"
|
||||
<< params.out_dir << "/timings.rds>" << endl;
|
||||
/*exporting results and profiling data*/
|
||||
|
||||
// std::string r_vis_code;
|
||||
// r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));";
|
||||
// R.parseEval(r_vis_code);
|
||||
}
|
||||
else { /*This is executed by the workers*/
|
||||
} else { /*This is executed by the workers*/
|
||||
ChemWorker worker(¶ms, R, grid, dht_comm);
|
||||
// worker.prepareSimulation(dht_comm);
|
||||
worker.loop();
|
||||
}
|
||||
}
|
||||
|
||||
cout << "CPP: finished, cleanup of process " << params.world_rank << endl;
|
||||
cout << "CPP: finished, cleanup of process " << params.world_rank << endl;
|
||||
|
||||
// if (params.dht_enabled) {
|
||||
// if (params.dht_strategy == 0) {
|
||||
// if (params.world_rank != 0) {
|
||||
// DHT_free(dht_object, NULL, NULL);
|
||||
// }
|
||||
// } else {
|
||||
// DHT_free(dht_object, NULL, NULL);
|
||||
// }
|
||||
// }
|
||||
// if (params.dht_enabled) {
|
||||
// if (params.dht_strategy == 0) {
|
||||
// if (params.world_rank != 0) {
|
||||
// DHT_free(dht_object, NULL, NULL);
|
||||
// }
|
||||
// } else {
|
||||
// DHT_free(dht_object, NULL, NULL);
|
||||
// }
|
||||
// }
|
||||
|
||||
// free(mpi_buffer);
|
||||
MPI_Finalize();
|
||||
// free(mpi_buffer);
|
||||
MPI_Finalize();
|
||||
|
||||
if (params.world_rank == 0) {
|
||||
if (params.world_rank == 0) {
|
||||
cout << "CPP: done, bye!" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user