MPI_INCLUDES="-I$MPICH_HOME/include"
if test "x$MPICH_HOME" = "x/usr"
then
- MPI_LIBS=""
+ MPI_LIBS="-lmpichcxx -lmpich -lopa -lmpl -lrt -lpthread"
else
- MPI_LIBS="-L$MPICH_HOME/lib"
+ MPI_LIBS="-L$MPICH_HOME/lib -lmpichcxx -lmpich -lopa -lmpl -lrt -lpthread"
fi
fi
AC_CHECK_HEADER(mpi.h,WITHMPICH="yes",WITHMPICH="no")
CPPFLAGS="$CPPFLAGS_old"
- if test "$WITHMPICH" = "yes";then
- LDFLAGS_old="$LDFLAGS"
- LDFLAGS="$MPI_LIBS $LDFLAGS"
- AC_CHECK_LIB(mpich,MPI_Init,WITHMPICH="yes",WITHMPICH="no")
- AC_CHECK_LIB(mpich,MPI_Publish_name,WITHMPI2="yes",WITHMPI2="no")
- LDFLAGS="$LDFLAGS_old"
- fi
+ LIBS_old="$LIBS"
+ LIBS="$MPI_LIBS $LIBS"
+ AC_CHECK_LIB(mpich,MPI_Init,WITHMPICH="yes",WITHMPICH="no")
+ AC_CHECK_LIB(mpich,MPI_Publish_name,WITHMPI2="yes",WITHMPI2="no")
+ LIBS="$LIBS_old"
+ AC_MSG_CHECKING(for mpich)
if test "$WITHMPICH" = "yes";then
- WITHMPI="yes"
mpi_ok=yes
- MPI_LIBS="$MPI_LIBS -lmpich"
+ mpi2_ok=$WITHMPI2
+ WITHMPI="yes"
+ CPPFLAGS="-DWITHMPICH $CPPFLAGS"
+ AC_MSG_RESULT(yes)
else
mpi_ok=no
+ mpi2_ok=no
+ WITHMPI=no
+ AC_MSG_RESULT(no)
fi
fi
#ifdef HAVE_MPI2
#ifdef WITHOPENMPI
- _pid_ompiServer = -1;
+ _pid_mpiServer = -1;
// the urifile name depends on pid of the process
std::stringstream urifile;
urifile << getenv("HOME") << "/.urifile_" << getpid();
std::set<pid_t>::const_iterator it;
for(it=thepids2.begin();it!=thepids2.end();it++)
if(thepids1.find(*it) == thepids1.end())
- _pid_ompiServer = *it;
- if(_pid_ompiServer < 0)
+ _pid_mpiServer = *it;
+ if(_pid_mpiServer < 0)
throw SALOME_Exception("Error when getting ompi-server id");
}
+#elif defined(WITHMPICH)
+ _pid_mpiServer = -1;
+ // get the pid of all hydra_nameserver
+ std::set<pid_t> thepids1 = getpidofprogram("hydra_nameserver");
+ // launch a new hydra_nameserver
+ std::string command;
+ command = "hydra_nameserver &";
+ int status=system(command.c_str());
+ if(status!=0)
+ throw SALOME_Exception("Error when launching hydra_nameserver");
+ // get the pid of all hydra_nameserver
+ std::set<pid_t> thepids2 = getpidofprogram("hydra_nameserver");
+ // my hydra_nameserver is the new one
+ std::set<pid_t>::const_iterator it;
+ for(it=thepids2.begin();it!=thepids2.end();it++)
+ if(thepids1.find(*it) == thepids1.end())
+ _pid_mpiServer = *it;
+ if(_pid_mpiServer < 0)
+ throw SALOME_Exception("Error when getting hydra_nameserver id");
#endif
#endif
#ifdef WITHOPENMPI
if( getenv("OMPI_URI_FILE") != NULL ){
// kill my ompi-server
- if( kill(_pid_ompiServer,SIGTERM) != 0 )
+ if( kill(_pid_mpiServer,SIGTERM) != 0 )
throw SALOME_Exception("Error when killing ompi-server");
// delete my urifile
int status=system("rm -f ${OMPI_URI_FILE}");
if(status!=0)
throw SALOME_Exception("Error when removing urifile");
}
+#elif defined(WITHMPICH)
+ // kill my hydra_nameserver
+ if( kill(_pid_mpiServer,SIGTERM) != 0 )
+ throw SALOME_Exception("Error when killing hydra_nameserver");
#endif
#endif
}
command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
command += getenv("OMPI_URI_FILE");
}
+#elif defined(WITHMPICH)
+ command += "-nameserver " + Kernel_Utils::GetHostname();
#endif
command += " SALOME_MPIContainer ";
}
o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
o << getenv("OMPI_URI_FILE");
}
+#elif defined(WITHMPICH)
+ o << "-nameserver " + Kernel_Utils::GetHostname();
#endif
if (isPythonContainer(params.container_name))
tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
tempOutputFile << getenv("OMPI_URI_FILE");
}
+#elif defined(WITHMPICH)
+ tempOutputFile << "-nameserver " + Kernel_Utils::GetHostname();
#endif
}
{
/* rank 0 try to be a server. If service is already published, try to be a cient */
MPI_Open_port(MPI_INFO_NULL, port_name);
- if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS )
+ if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS )
+ {
+ MESSAGE("[" << _numproc << "] I get the connection with " << service << " at " << port_name_clt << std::endl);
+ MPI_Close_port( port_name );
+ }
+ else if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS )
{
_srv[service] = true;
_port_name[service] = port_name;