I have a simple mpi program to demonstrate my problem:
#include <stdio.h>
#include <mpi.h>
int main(int argc, char *argv[])
{
int rank, csize;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &csize);
printf("Hello from rank[%d/%d]\n", rank, csize);
MPI_Finalize();
}
After compiling, I can successfully launch the executable using mpirun
from the sbcl repl:
* (uiop:run-program '("mpirun" "-np" "10" "./hello_world") :output :string)
"Hello from rank[7/10]
Hello from rank[9/10]
Hello from rank[5/10]
Hello from rank[8/10]
Hello from rank[0/10]
Hello from rank[1/10]
Hello from rank[2/10]
Hello from rank[3/10]
Hello from rank[4/10]
Hello from rank[6/10]
"
NIL
0
However, when I run the same from within slime, the slime repl simply hangs. If I run the executable directly, rather than through the mpirun
launcher, then the everything runs fine:
CL-USER> (uiop:run-program '("./hello_world")
:output :string)
"Hello from rank[0/1]
"
NIL
0
I'm using sbcl-1.4.5 and slime 2.20 on a linux workstation. Does anyone have a solution to this problem or a starting point of where to look?
UPDATE:
The problem stems from emacs comint
mode, which slime is based on. I observer the same hanging behavior if I launch sbcl
via make-comint-in-buffer
and then use uiop:run-program
.
UPDATE2:
After reading up a bit on comint
mode, I was able to capture some output from the hanging process. This emacs lisp code:
(make-comint "foo" "mpirun" nil "-np" "1" "/home/ptb/programming/c/hello_world")
produces the follow error on the hung process:
[warn] Epoll MOD(1) on fd 14 failed. Old events were 6; read change was 0 (none); write change was 2 (del): Bad file descriptor
[warn] Epoll MOD(4) on fd 14 failed. Old events were 6; read change was 2 (del); write change was 0 (none): Bad file descriptor
Any ideas as to what this means?
I guess that this is a problem with redirected stdin/stdout in openmpi or libevent (there have been such problems in the past, e. g. bugzilla.redhat.com/show_bug.cgi?id=1235044). Which version of those do you use?