Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 7c297eb

Browse files
author
Nicolas Cornu
authored
No more check parameters from argc / argv but from the parser. Fix #184 (#407)
- no more check parameters from argc / argv but from the parser - remove nrn_music and simplify nrnmpi_init. - you should call nrnmpi_init only if you want to use mpi!
1 parent 2364d57 commit 7c297eb

File tree

4 files changed

+13
-47
lines changed

4 files changed

+13
-47
lines changed

coreneuron/apps/main1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ extern "C" void mk_mech_init(int argc, char** argv) {
433433

434434
#if NRNMPI
435435
if (corenrn_param.mpi_enable) {
436-
nrnmpi_init(1, &argc, &argv);
436+
nrnmpi_init(&argc, &argv);
437437
}
438438
#endif
439439

coreneuron/mpi/nrnmpi.cpp

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
4343
namespace coreneuron {
4444

4545
#if NRNMPI
46-
int nrnmusic;
47-
4846
MPI_Comm nrnmpi_world_comm;
4947
MPI_Comm nrnmpi_comm;
5048
MPI_Comm nrn_bbs_comm;
@@ -55,52 +53,23 @@ extern void nrnmpi_spike_initialize();
5553

5654
static int nrnmpi_under_nrncontrol_;
5755

58-
void nrnmpi_init(int nrnmpi_under_nrncontrol, int* pargc, char*** pargv) {
56+
void nrnmpi_init(int* pargc, char*** pargv) {
5957
nrnmpi_use = true;
60-
nrnmpi_under_nrncontrol_ = nrnmpi_under_nrncontrol;
61-
if (nrnmpi_under_nrncontrol_) {
62-
#if !ALWAYS_CALL_MPI_INIT
63-
bool b = false;
64-
/* this is not good. depends on mpirun adding at least one
65-
arg that starts with -p4 but that probably is dependent
66-
on mpich and the use of the ch_p4 device. We are trying to
67-
work around the problem that MPI_Init may change the working
68-
directory and so when not invoked under mpirun we would like to
69-
NOT call MPI_Init.
70-
*/
71-
for (int i = 0; i < *pargc; ++i) {
72-
if (strncmp("-p4", (*pargv)[i], 3) == 0) {
73-
b = true;
74-
break;
75-
}
76-
if (strcmp("--mpi", (*pargv)[i]) == 0) {
77-
b = true;
78-
break;
79-
}
80-
}
81-
if (nrnmusic) {
82-
b = true;
83-
}
84-
if (!b) {
85-
nrnmpi_use = false;
86-
nrnmpi_under_nrncontrol_ = 0;
87-
return;
88-
}
89-
#endif
90-
int flag = 0;
91-
MPI_Initialized(&flag);
58+
nrnmpi_under_nrncontrol_ = 1;
59+
60+
int flag = 0;
61+
MPI_Initialized(&flag);
9262

93-
if (!flag) {
63+
if (!flag) {
9464
#if defined(_OPENMP)
95-
int required = MPI_THREAD_FUNNELED;
96-
int provided;
97-
nrn_assert(MPI_Init_thread(pargc, pargv, required, &provided) == MPI_SUCCESS);
65+
int required = MPI_THREAD_FUNNELED;
66+
int provided;
67+
nrn_assert(MPI_Init_thread(pargc, pargv, required, &provided) == MPI_SUCCESS);
9868

99-
nrn_assert(required <= provided);
69+
nrn_assert(required <= provided);
10070
#else
101-
nrn_assert(MPI_Init(pargc, pargv) == MPI_SUCCESS);
71+
nrn_assert(MPI_Init(pargc, pargv) == MPI_SUCCESS);
10272
#endif
103-
}
10473
}
10574
grp_bbs = MPI_GROUP_NULL;
10675
grp_net = MPI_GROUP_NULL;

coreneuron/mpi/nrnmpidec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ extern int nrnmpi_bbsrecv(int source, bbsmpibuf* r);
7676
extern int nrnmpi_bbssendrecv(int dest, int tag, bbsmpibuf* s, bbsmpibuf* r);
7777

7878
/* from nrnmpi.cpp */
79-
extern void nrnmpi_init(int nrnmpi_under_nrncontrol, int* pargc, char*** pargv);
79+
extern void nrnmpi_init(int* pargc, char*** pargv);
8080
extern int nrnmpi_wrap_mpi_init(int* flag);
8181
extern void nrnmpi_finalize(void);
8282
extern void nrnmpi_terminate();

coreneuron/mpi/nrnmpiuse.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
5252
/* define to the dll path if you want to load automatically */
5353
#undef DLL_DEFAULT_FNAME
5454

55-
/* define if needed */
56-
#undef ALWAYS_CALL_MPI_INIT
57-
5855
/* Number of times to retry a failed open */
5956
#undef FILE_OPEN_RETRY
6057

0 commit comments

Comments
 (0)