[MPICH] mpich2-1.0.5, ch3:ssm, pathscale on opteron

Darius Buntinas buntinas at mcs.anl.gov
Fri Jan 26 16:13:48 CST 2007


Hi Miguel,

I'm attaching a patch to nemesis to have it read the 
MPICH_INTERFACE_HOSTNAME variable.  Please let me know if it works, or if 
you have any trouble with this.

Darius

On Fri, 26 Jan 2007, Miguel Oliveira wrote:

> Anthony Chan wrote:
>>  http://email.osc.edu/pipermail/mpiexec/2006/000718.html
>>
>>  This suggests that -tranform-hostname was meant for MPICH1 originally.
>>  But newer version of mpiexec from OSC gets it to work with MPICH2/pmi.
>> 
>> http: //www.osc.edu/~pw/mpiexec/index.php
>> http: //www.osc.edu/~pw/mpiexec/index.php#Changes
>>
>>  Are you using the latest OSC mpiexec, version 0.82 ?
>>
>>  A.Chan
>> 
>
> I'm using the latest version (0.82).
>
> I've also checked that the environment variable MPICH_INTERFACE_HOSTNAME is 
> being set properly which it is.
> It looks like mpiexec is doing what is supposed to but ch3:nemesis is not 
> honoring this.
> Any ideas?
>
> All the best,
>
> MAO
>
>
>
-------------- next part --------------
Index: src/mpid/ch3/channels/nemesis/nemesis/net_mod/tcp_module/tcp_module_init.c
===================================================================
RCS file: /home/MPI/cvsMaster/mpich2-01/src/mpid/ch3/channels/nemesis/nemesis/net_mod/tcp_module/tcp_module_init.c,v
retrieving revision 1.32
diff -u -r1.32 tcp_module_init.c
--- src/mpid/ch3/channels/nemesis/nemesis/net_mod/tcp_module/tcp_module_init.c	8 Dec 2006 20:53:36 -0000	1.32
+++ src/mpid/ch3/channels/nemesis/nemesis/net_mod/tcp_module/tcp_module_init.c	26 Jan 2007 22:10:27 -0000
@@ -6,6 +6,13 @@
 
 #include "tcp_module_impl.h"
 
+static int getSockInterfaceAddr( int myRank, char *ifname, int maxIfname);
+/* We set dbg_ifname to 1 to help debug the choice of interface name
+   used when determining which interface to advertise to other
+   processes in getSockInterfaceAddr.
+ */
+static int dbg_ifname = 0;
+
 static MPID_nem_queue_t _free_queue;
 
 MPID_nem_queue_ptr_t MPID_nem_module_tcp_free_queue = 0;
@@ -52,7 +59,7 @@
 	{
 	    struct sockaddr_in temp;
 	    char               s[255];
-	    int                len2 = 255;
+	    const int          len2 = 255;
             int                low_port, high_port;
             
 	    nodes[grank].desc = socket(AF_INET, SOCK_STREAM, 0);
@@ -97,8 +104,8 @@
             MPIU_ERR_CHKANDJUMP2 (ret == -1, mpi_errno, MPI_ERR_OTHER, "**listen", "**listen %s %d", strerror (errno), errno);
 	  
 	    /* Put the key (machine name, port #, src , dest) with PMI */
-	    ret = gethostname(s, len2);
-            MPIU_ERR_CHKANDJUMP2 (ret == -1, mpi_errno, MPI_ERR_OTHER, "**sock_gethost", "**sock_gethost %s %d", strerror (errno), errno);
+            mpi_errno = getSockInterfaceAddr(MPID_nem_mem_region.rank, s, len2);
+            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 #ifdef TRACE
 	    fprintf(stderr,"[%i] ID :  %s_%d_%d_%d \n",MPID_nem_mem_region.rank,s,
 		    ntohs(nodes[grank].sock_id.sin_port),grank,MPID_nem_mem_region.rank);
@@ -424,4 +431,61 @@
     return MPI_SUCCESS;
 }
 
+#undef FUNCNAME
+#define FUNCNAME getSockInterfaceAddr
+#undef FCNAME
+#define FCNAME MPIDI_QUOTE(FUNCNAME)
+static int getSockInterfaceAddr( int myRank, char *ifname, int maxIfname)
+{
+    char *ifname_string;
+    int mpi_errno = MPI_SUCCESS;
+
+    /* Check for the name supplied through an environment variable */
+    ifname_string = getenv("MPICH_INTERFACE_HOSTNAME");
+    if (!ifname_string) {
+	/* See if there is a per-process name for the interfaces (e.g.,
+	   the process manager only delievers the same values for the 
+	   environment to each process */
+	char namebuf[1024];
+	MPIU_Snprintf( namebuf, sizeof(namebuf), 
+		       "MPICH_INTERFACE_HOSTNAME_R%d", myRank );
+	ifname_string = getenv( namebuf );
+	if (dbg_ifname && ifname_string) {
+	    fprintf( stdout, "Found interface name %s from %s\n", 
+		    ifname_string, namebuf );
+	    fflush( stdout );
+	}
+    }
+    else if (dbg_ifname) {
+	fprintf( stdout, 
+		 "Found interface name %s from MPICH_INTERFACE_HOSTNAME\n", 
+		 ifname_string );
+	fflush( stdout );
+    }
+	 
+    if (!ifname_string) {
+	int len;
+
+	/* If we have nothing, then use the host name */
+	mpi_errno = MPID_Get_processor_name(ifname, maxIfname, &len );
+        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+        
+	ifname_string = ifname;
+
+	/* If we didn't find a specific name, then try to get an IP address
+	   directly from the available interfaces, if that is supported on
+	   this platform.  Otherwise, we'll drop into the next step that uses 
+	   the ifname */
+    }
+    else {
+	/* Copy this name into the output name */
+	MPIU_Strncpy( ifname, ifname_string, maxIfname );
+    }
+
+ fn_exit:
+    return mpi_errno;
+ fn_fail:
+    goto fn_exit;
+}
+
 


More information about the mpich-discuss mailing list