Dear Joao, the problem is that, You do not use the &reqs[i] correctly in the MPI_Send -- reqs[0] will not be initialized; but wait for in MPI_Waitall...
Change: rc = MPI_Isend(&a , 1 , MPI_INT , i , 0 , MPI_COMM_WORLD , &reqs[i]); to rc = MPI_Isend(&a , 1 , MPI_INT , i , 0 , MPI_COMM_WORLD , &reqs[i-1]); and it will work. These kind of buglets can be very neatly found using the memchecker component using valgrind, which is implemented in the upcoming OpenMPI-1.3. Please check the FAQ on: http://www.open-mpi.org/faq/?category=debugging on how to use and what errors to find... I attached the program with a bit of cleanups (e.g. why do You need MPI_ANY_SOURCE in the recv on the workers...). With best regards, Rainer On Freitag, 27. Juni 2008, Joao Marcelo wrote: > Hi, > > I'm starting to code with MPI and decided to use openmpi. I'm using > Ubuntu Linux with GCC version 4.2.3 and OpenMPI 1.2.5 (distribution > package). The output of "ompi_info -- all" is attached. I'm also > sending a copy of the source code I'm trying to run. > > What I'm trying to do is selecting process with rank 0 as the main > process, which you send data to all others processes with non-blocking > MPI_Isend. After all functions calls are performed, it will wait with > MPI_Waitall() and the print a ending message. The compile command is : > > $ mpicc.openmpi -fopenmp mpi.c -o mpi > > And I'm running with : > > $ mpirun.openmpi -np 2 ./mpi > > The problem is that after the output below, the processes halt, > without the ending message. > > jmhal@galileo:~/$ mpirun.openmpi -np 2 ./mpi > Main process: 0. > 1 - received value, rc value: 100 0 > > If I start more processes, for example 3, this what I get: > > jmhal@galileo:~/$ mpirun.openmpi -np 3 ./mpi > Main process: 0. > End. > 1 - received value, rc value: 100 0 > 2 - received value, rc value: 100 0 > [galileo:15807] *** Process received signal *** > [galileo:15807] Signal: Segmentation fault (11) > [galileo:15807] Signal code: Address not mapped (1) > [galileo:15807] Failing at address: 0xd > [galileo:15807] [ 0] [0xb7f2a440] > [galileo:15807] [ 1] /usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so > [0xb7b49da8] [galileo:15807] [ 2] > /usr/lib/libmpi.so.0(mca_pml_base_close+0x90) [0xb7efd830] [galileo:15807] > [ 3] /usr/lib/libmpi.so.0(ompi_mpi_finalize+0x1d6) [0xb7ec48d6] > [galileo:15807] [ 4] /usr/lib/libmpi.so.0(PMPI_Finalize+0x56) [0xb7ee27d6] > [galileo:15807] [ 5] ./mpi(main+0x1bc) [0x8048a60] > [galileo:15807] [ 6] > /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0) [0xb7c47450] > [galileo:15807] [ 7] ./mpi [0x8048841] > [galileo:15807] *** End of error message *** > mpirun.openmpi noticed that job rank 0 with PID 15807 on node galileo > exited on signal 11 (Segmentation fault). > 2 additional processes aborted (not shown) > > > Which is ok since all messages were print, but what about the error > message? -- ---------------------------------------------------------------- Dipl.-Inf. Rainer Keller http://www.hlrs.de/people/keller HLRS Tel: ++49 (0)711-685 6 5858 Nobelstrasse 19 Fax: ++49 (0)711-685 6 5832 70550 Stuttgart email: kel...@hlrs.de Germany AIM/Skype:rusraink
#include <stdio.h> #include <stdlib.h> #include "mpi.h" #define ROOT 0 int main( int argc, char *argv[] ) { int numtasks, rank, rc; rc = MPI_Init(&argc,&argv); if (rc != MPI_SUCCESS) { printf ("Error starting MPI program. Terminating.\n"); MPI_Abort(MPI_COMM_WORLD, rc); } MPI_Comm_size(MPI_COMM_WORLD,&numtasks); MPI_Comm_rank(MPI_COMM_WORLD,&rank); if (rank == ROOT) { printf("Main process: %d.\n", rank); int a = 100; int i; MPI_Request *reqs; MPI_Status *stats; reqs = (MPI_Request *) malloc((numtasks - 1)*sizeof(MPI_Request)); stats = (MPI_Status *) malloc((numtasks - 1)*sizeof(MPI_Status)); for ( i = 1; i < numtasks; ++i){ /* * Being very picky, one should not use the *same* buffer * in two non-blocking communications * * The main problem however is that &reqs[i] is wrong: reqs[0] is * not initialized at all. * change to &reqs[i-1] works. */ rc = MPI_Isend(&a , 1 , MPI_INT , i , 0 , MPI_COMM_WORLD , &reqs[i-1]); } MPI_Waitall(numtasks - 1 , reqs , stats); free(reqs); free(stats); printf("End.\n"); } else { int b; int rc; MPI_Status status; rc = MPI_Recv( &b , 1 , MPI_INT, ROOT , 0, MPI_COMM_WORLD , &status); printf("%d - received value, rc value: %d %d\n", rank , b, rc); } MPI_Finalize(); return 0; }