You are not logged in.
I'm trying to use mpi library, but I'm having a bit of trouble.
Here's the source code of my mpi_hello_world.c file:
#include <stdio.h>
#include <string.h>
#include <mpi.h>
const int MAX_STRING = 100;
int main(void) {
char greeting[MAX_STRING];
int comm_sz;
int my_rank;
int q;
MPI_Init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD, &comm_sz);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if(my_rank != 0){
sprintf(greeting, "Greetings from process %d of %d!", my_rank, comm_sz);
MPI_Send(greeting, strlen(greeting) + 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
} else {
printf("Greetings form process %d of %d!\n", my_rank, comm_sz);
for(q = 1; q < comm_sz; q++) {
MPI_Recv(greeting, MAX_STRING, MPI_CHAR, q, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("%s\n", greeting);
}
}
MPI_Finalize();
return 0;
}I'm compiling it with:
mpicc -g -Wall -o mpi_hello_world mpi_hello_world.cAnd running it with:
mpiexec -n 1 ./mpi_hello_worldAnd the error message I get, is the following:
[battlestar:01596] *** Process received signal ***
[battlestar:01596] Signal: Segmentation fault (11)
[battlestar:01596] Signal code: Address not mapped (1)
[battlestar:01596] Failing at address: (nil)
[battlestar:01596] [ 0] /usr/lib/libpthread.so.0(+0xf1e0) [0x7f576107f1e0]
[battlestar:01596] [ 1] /usr/lib/openmpi/libmpi.so.1(ompi_comm_cid_init+0x25) [0x7f5761e0db45]
[battlestar:01596] [ 2] /usr/lib/openmpi/libmpi.so.1(ompi_mpi_init+0xed8) [0x7f5761e24ad8]
[battlestar:01596] [ 3] /usr/lib/openmpi/libmpi.so.1(PMPI_Init+0x168) [0x7f5761e44a58]
[battlestar:01596] [ 4] ./mpi_hello_world(main+0x67) [0x400b73]
[battlestar:01596] [ 5] /usr/lib/libc.so.6(__libc_start_main+0xf5) [0x7f5760ce4a15]
[battlestar:01596] [ 6] ./mpi_hello_world() [0x400a49]
[battlestar:01596] *** End of error message ***
--------------------------------------------------------------------------
mpiexec noticed that process rank 0 with PID 1596 on node battlestar exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
Does anyone have any idea of why this is happening?
I couldn't find much about on OpenMPI's mailing list.
Last edited by kuroikizu (2013-03-21 04:19:37)
Offline
Your code works for me.
~ >>> mpicc -g -Wall -o mpi_hello_world mpi_hello_world.c
~ >>> mpiexec -n 1 ./mpi_hello_world
Greetings form process 0 of 1!
~ >>> Please check that you have openssh package installed.
.
Last edited by karabaja4 (2013-03-18 18:27:58)
Offline
Please check that you have openssh package installed.
I already had openssh installed, but thanks for your help!
But I managed to solve the problem and make it work.
I had OpenMPI installed from its source I got from openmpi.org.
I then uninstalled it and got the version from the arch's official repositories.
Now it works!
Offline