dimanche 19 avril 2015

MPI program send probleme

i have tested this sample code of MPI that i found in a beginner MPI tutorial in a small grid architecture of 2 machines (vmware). but it dosn't seem to work, i don't have response, it keep freezing. this is the MPI code in C:



#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {
// Initialize the MPI environment
MPI_Init(NULL, NULL);
// Find out rank, size
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);

// We are assuming at least 2 processes for this task
if (world_size < 2) {
fprintf(stderr, "World size must be greater than 1 for %s\n", argv[0]);
MPI_Abort(MPI_COMM_WORLD, 1);
}

int number;
if (world_rank == 0) {
// If we are rank 0, set the number to -1 and send it to process 1
number = -1;
MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
} else if (world_rank == 1) {
MPI_Recv(&number, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("Process 1 received number %d from process 0\n", number);
}
MPI_Finalize();
}


i have ssh taht work in booth the 2 nodes without password, i modified the /etc/hosts to add the hostname and ip addresse of the 2 machines, i installed openmpi and hydra in my ubuntu machines,i have nfs shared directory where i put the files, but can't fix the probleme. when i execute the program in my locale machine, it work, but when i execute the pogram in parallel, it freez:



root@ubuntu1:/mirror# mpicc test1.c -o test1
root@ubuntu1:/mirror# mpiexec -n 2 ./test1
Process 1 received number -1 from process 0
root@ubuntu1:/mirror# mpiexec -n 2 -f 1 ./test1
^C
=====================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 2
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
=====================================================================================
APPLICATION TERMINATED WITH THE EXIT STRING: Interrupt (signal 2)
root@ubuntu1-virtual-machine:/mirror#


if you have any idea of the source of the problem, i would be very thankful.


Aucun commentaire:

Enregistrer un commentaire