Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Cluster hangs/shows error while executing simple MPI program in C
From: Justin Joseph (justinjoseph911_at_[hidden])
Date: 2013-03-05 10:50:15


Cluster hangs/shows error while executing simple MPI program in C I am trying to run a simple MPI program(multiple array addition), it runs perfectly in my PC but simply hangs or shows the following error in the cluster. I am using open mpi and the following command to execute . mpirun -machinefile machine -np 4 ./array_sum error code: [[22877,1],0][btl_tcp_endpoint.c:638:mca_btl_tcp_endpoint_complete_connect] connect() to 192.168.122.1 failed: Connection refused (111) #include<mpi.h>#include<stdio.h>#include<stdlib.h>#include<string.h>#definegroup MPI_COMM_WORLD #defineroot 0#definesize 100intmain(intargc,char*argv[]){intno_tasks,task_id,i;MPI_Init(&argc,&argv);MPI_Comm_size(group,&no_tasks);MPI_Comm_rank(group,&task_id);intarr1[size],arr2[size],local1[size],local2[size];if(task_id==root){for(i=0;i<size;i++){arr1[i]=arr2[i]=i;}}MPI_Scatter(arr1,size/no_tasks,MPI_INT,local1,size/no_tasks,MPI_INT,root,group);MPI_Scatter(arr2,size/no_tasks,MPI_INT,local2,size/no_tasks,MPI_INT,root,group);for(i=0;i<size/no_tasks;i++){local1[i]+=local2[i];}MPI_Gather(local1,size/no_tasks,MPI_INT,arr1,size/no_tasks,MPI_INT,root,group);if(task_id==root){printf("The Array Sum Is\n");for(i=0;i<size;i++){printf("%d ",arr1[i]);}}MPI_Finalize();return0;}