Reputation: 971
I'm working to understand signal handling in OpenMPI. I read that "Open MPI will forward SIGUSR1 and SIGUSR2 from mpiexec to the other processes". My question is that is this feature enabled by default installation.
The scenario is that one MPI process raises a SIGUSR1, which has to be detected by 'orted' which is then forwarded to other processes.
In my test code, I define a custom signal handler for SIGUSR1 and register this signal handler accordingly. I send a signal by using kill() or raise(). I assume that ORTE daemon will receive this signal and has to forward this signal to the remaining processes.
// test.c
void handle_signal(int signal){
if(SIGNAL==SIGUSR1)
printf("received SIGUSR1 signal \n");
}
int main(){
MPI_Init(NULL, NULL);
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
signal(SIGUSR1, handle_signal);
if(my_rank == 1) // process with rank 1 raises SIGUSR1
kill(getpid(), SIGUSR1);
MPI_Finalize();
return 0;
}
If I run this as mpirun -np 3 ./test
I would expect to have the statement printed twice from the other two processes. But when I run this code, it only prints once, and that too from ORTE HNP, unlike the application processes. Do I need to call any other API on orted explicitly pass this signal, so that the application processes receive the SIGUSR1.
- Marc
Upvotes: 0
Views: 607
Reputation: 22670
You cannot use signal forwarding the way you describe:
Open MPI will forward SIGUSR1 and SIGUSR2 from mpiexec to the other processes
You can't just send a signal to yourself, you would have to find the mpiexec
process. This process can run on a different node, so you cannot easily send a signal to it anyway.
I cannot think of a reasonable way to really interrupt other MPI ranks like that, except for MPI_Abort
, which is probably not what you want. Depending on your actual goal, you probably have to chose from asynchronous point to point communication, one-side communication or threads.
Upvotes: 1