Page 1 of 1
Calling MPI_Abort() from HOC
Posted: Sun Dec 10, 2023 11:05 am
by CCohen
Hello,
I'm wondering how to call MPI_Abort() from HOC, in the context of an MPI-run simulation on UNIX. The aim is to quit all hosts, including the master, without first receiving all returnable pc.working() calls. The following attempt, among others, did not work.
Charles
Code: Select all
system("MPI_Abort(MPI_COMM_WORLD, error_code)")
error_code = -1, 0, 1, etc.
Re: Calling MPI_Abort() from HOC
Posted: Fri Dec 15, 2023 1:36 pm
by hines
The internal wrapper for MPI_Abort is not exposed to the interpreter. You can do that with a mod file
Code: Select all
$ cat abrt.mod
NEURON {SUFFIX nothing}
VERBATIM
extern "C" { void nrnmpi_abort(int); }
ENDVERBATIM
PROCEDURE mpiabort(errcode) {
VERBATIM
{
nrnmpi_abort(int(_lerrcode));
}
ENDVERBATIM
}
Then, after nrnivmodl
Code: Select all
$ nrniv
NEURON -- VERSION 9.0a-109-g1009732c7 master (1009732c7) 2023-11-27
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2022
See http://neuron.yale.edu/neuron/credits
loading membrane mechanisms from x86_64/.libs/libnrnmech.so
Additional mechanisms from files
"abrt.mod"
oc>mpiabort(-3)
Aborted (core dumped)
Re: Calling MPI_Abort() from HOC
Posted: Wed Jan 03, 2024 10:56 am
by CCohen
Thank you very much, Michael.
Unfortunately, abrt.mod did not compile on nrn 8.2.2, the last version available at the NSG WebPortal. Would a backward-compatible fix be possible? Details on the compilation error follow.
Best regards,
Charles
Relevant compilation error on 8.2.2 on OSX:
Code: Select all
NEURON -- VERSION 8.2.2 release/8.2 (93d41fafd) 2022-12-15
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2022
See http://neuron.yale.edu/neuron/credits
...
-> Compiling abrt.c
abrt.c:150:8: error: expected identifier or '('
extern "C" { void nrnmpi_abort(int); }
^
abrt.c:156:5: warning: implicit declaration of function 'nrnmpi_abort' is
invalid in C99 [-Wimplicit-function-declaration]
nrnmpi_abort(int(_lerrcode));
^
abrt.c:156:18: error: expected expression
nrnmpi_abort(int(_lerrcode));
^
1 warning and 2 errors generated.
make: *** [abrt.o] Error 1
make: *** Waiting for unfinished jobs....
Re: Calling MPI_Abort() from HOC
Posted: Wed Jan 03, 2024 1:06 pm
by hines
Try
Code: Select all
NEURON {SUFFIX nothing}
VERBATIM
extern void nrnmpi_abort(int);
ENDVERBATIM
PROCEDURE mpiabort(errcode) {
VERBATIM
{
nrnmpi_abort((int)_lerrcode);
}
ENDVERBATIM
}
Re: Calling MPI_Abort() from HOC
Posted: Tue Feb 13, 2024 4:44 pm
by CCohen
Hi Michael,
The last version of abrt.mod, above, now compiles on 8.2.2. However, it does not abort anything but rather generates a segmentation violation in a test as you had performed (see below).
Charles
Code: Select all
NEURON -- VERSION 8.2.2 release/8.2 (93d41fafd) 2022-12-15
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2022
See http://neuron.yale.edu/neuron/credits
1
1
1
1
1
0
1
loading membrane mechanisms from ./lib/arm64/.libs/libnrnmech.so
Additional mechanisms from files
"abrt.mod"
oc>mpiabort(-1)
Segmentation violation
Backtrace:
2 libsystem_platform.dylib 0x00007fff57ce6f5a : _sigtramp()+26
3 ??? 0x00007ffee43c6268 0x0 + 140732727583336
4 libnrniv.dylib 0x000000010b9bd99a : _Z8hoc_callv()+266
5 libnrniv.dylib 0x000000010b9ba0d4 : _Z11hoc_executeP4Inst()+100
6 libnrniv.dylib 0x000000010b9cc19d : _Z13hoc_moreinputv()+1197
7 libnrniv.dylib 0x000000010b9cbc85 : _Z9hoc_main1iPPKcS1_()+261
8 libnrniv.dylib 0x000000010b87af1b : _Z16ivocmain_sessioniPPKcS1_i()+7451
9 nrniv 0x000000010b83ced3 : main()+179
10 libdyld.dylib 0x00007fff579d8015 : start()+1
11 ??? 0x0000000000000004 0x0 + 4
/Applications/NEURON//bin/nrniv: Aborting.
near line 1
mpiabort(-1)
^
mpiabort(-1)
oc>
Re: Calling MPI_Abort() from HOC
Posted: Tue Feb 13, 2024 5:51 pm
by hines
You didn't mention how you launched the program.
I'm guessing that you are running a NEURON version that dynamically loads mpi when you give it the -mpi arg. Otherwise the memory for nrnmpi_abort is NULL (hence the seg fault). Do you have a problem if you try
Code: Select all
mpiexec -n 1 nrniv -mpi -c 'mpiabort(-1)'