-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_mpi_quad.cpp
42 lines (33 loc) · 1.29 KB
/
main_mpi_quad.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "mpikesten.h"
#include "kestensimulation.h"
#include "main_shared.h"
int main(int argc, char** argv) {
// TODO more code sharing with kestensim main function
QuadParameters p = quad_params_from_arguments(argc, argv);
MPI_Init(nullptr, nullptr);
MpiInfo mpiInfo;
mpiInfo.MPI_Type_StructuralPlasticityEvent = register_structural_events_type();
mpiInfo.MPI_Type_Synapse = register_synapse_type();
mpiInfo.MPI_Type_ObservationTime = register_observation_time_type();
MPI_Comm_size(MPI_COMM_WORLD, &mpiInfo.world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpiInfo.rank);
mpiInfo.i_start = (mpiInfo.rank) * p.N_e / mpiInfo.world_size;
mpiInfo.i_end = (mpiInfo.rank + 1) * p.N_e / mpiInfo.world_size;
std::cout << mpiInfo << std::endl;
{
MpiKestenSim<QuadParameters, QuadStep> sim(p, mpiInfo);
while (sim.hasNextStep()) {
sim.doStep();
}
sim.afterLastStep();
sim.mpiSendAndCollectWeights();
sim.mpiSendAndCollectStrctEvents();
sim.mpiSendAndCollectInitialActive();
sim.mpiSendAndCollectObservationTimes();
if (mpiInfo.rank == 0) {
sim.mpiSaveResults();
}
} // delete MpiKestenSim on non-root nodes the moment they are done
MPI_Finalize();
return 0;
}