Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] Cluster hangs/shows error while executing simple MPI program in C
From: Ralph Castain (rhc_at_[hidden])
Date: 2013-03-05 11:02:42


The TCP messaging transport is trying to connect to a process on 192.168.122.1 and being blocked. Check for a firewall, ensure that the network it is trying to use is correct (you may need to specify an appropriate network with -mca btl_tcp_if_include, or exclude one)

On Mar 5, 2013, at 7:50 AM, Justin Joseph <justinjoseph911_at_[hidden]> wrote:

> 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>
> #define group MPI_COMM_WORLD
> #define root 0
> #define size 100
>
> int main(int argc,char *argv[])
> {
> int no_tasks,task_id,i;
> MPI_Init(&argc,&argv);
> MPI_Comm_size(group,&no_tasks);
> MPI_Comm_rank(group,&task_id);
> int arr1[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();
> return 0;
> }
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users