If I'm posting this LAM MPI question to the wrong mailing list, please let me
know.
I'm trying to perform interthread communication with MPI using lam-7.0.4 on a
Beowolf cluster. I have two threads trying to swap messages each using one
MPI_Send and one MPI_Recv. The problem is neither thread's MPI_Recv completes.
Any thoughts?
Thanks for your time,
-Lucas
-----
#include <stdio.h>
#include <mpi.h>
#include <unistd.h>
#include <pthread.h>
void *thread_one(void *args)
{
MPI_Status status;
printf("thread_one MPI_Recv tag 250...\n");
MPI_Recv(NULL, 0, MPI_BYTE, 0, 250, MPI_COMM_WORLD, &status);
printf("thread_one MPI_Send tag 925...\n");
MPI_Send(NULL, 0, MPI_BYTE, 0, 925, MPI_COMM_WORLD);
printf("thread_one OK!\n");
return NULL;
}
void *thread_two(void *args)
{
MPI_Status status;
printf("thread_two MPI_Send tag 250...\n");
MPI_Send(NULL, 0, MPI_BYTE, 0, 250, MPI_COMM_WORLD);
printf("thread_two MPI_Recv tag 925...\n");
MPI_Recv(NULL, 0, MPI_BYTE, 0, 925, MPI_COMM_WORLD, &status);
printf("thread_two OK!\n");
return NULL;
}
int main(int argc, char **argv)
{
MPI_Init(NULL, NULL);
pthread_t foo;
pthread_create(&foo, 0, thread_one, 0);
pthread_create(&foo, 0, thread_two, 0);
sleep(5);
printf("time's up!\n");
MPI_Finalize();
return 0;
}
-----
[lfinn_at_master test]$ mpirun -np 1 ./a.out
thread_one MPI_Recv tag 250...
thread_two MPI_Send tag 250...
thread_two MPI_Recv tag 925...
time's up!
-----
|