Blame doc/namepub/namepub.tex

Packit Service c5cf8c
\documentclass{article}
Packit Service c5cf8c
\usepackage{graphics}
Packit Service c5cf8c
\usepackage{code}
Packit Service c5cf8c
Packit Service c5cf8c
%hyperref - do not remove this comment
Packit Service c5cf8c
Packit Service c5cf8c
\begin{document}
Packit Service c5cf8c
\title{A Name Publishing Interface for MPICH}
Packit Service c5cf8c
\author{William Gropp}
Packit Service c5cf8c
\maketitle
Packit Service c5cf8c
Packit Service c5cf8c
\section{Introduction}
Packit Service c5cf8c
Packit Service c5cf8c
MPI defines a set of routines for exchanging data with other MPI
Packit Service c5cf8c
programs.  The intent of these is to allow MPI applications to 
Packit Service c5cf8c
exchange the data that is needed for the \code{port} argument in the
Packit Service c5cf8c
\code{MPI_Comm_connect} and \code{MPI_Comm_accept} calls.  
Packit Service c5cf8c
Packit Service c5cf8c
\section{The MPI Name Publishing Routines}
Packit Service c5cf8c
MPI provides three routines to allow MPI applications to exchange the
Packit Service c5cf8c
\emph{port names} that are used to connect two running MPI
Packit Service c5cf8c
applications.  These routines are shown below in a modified C binding;
Packit Service c5cf8c
\code{const} is used to indicate input arguments and array notation is
Packit Service c5cf8c
used instead of pointer notation for character strings (this follows
Packit Service c5cf8c
the MPICH coding recommendations).
Packit Service c5cf8c
\begin{verbatim}
Packit Service c5cf8c
MPI_Publish_name( const char service_name[], const MPI_Info info, 
Packit Service c5cf8c
                  const char port_name[] )
Packit Service c5cf8c
Packit Service c5cf8c
MPI_Unpublish_name( const char service_name[], 
Packit Service c5cf8c
                    const MPI_Info info, 
Packit Service c5cf8c
                    const char port_name[] )
Packit Service c5cf8c
Packit Service c5cf8c
MPI_Lookup_name( const char service_name[], const MPI_Info info, 
Packit Service c5cf8c
                 char port_name[MPI_MAX_PORT_NAME] )
Packit Service c5cf8c
\end{verbatim}
Packit Service c5cf8c
In these routines, the \code{port_name} is the name returned by
Packit Service c5cf8c
\code{MPI_Open_port}.  
Packit Service c5cf8c
The \code{service_name} is a name chosen by the
Packit Service c5cf8c
applications as the name that all related applications will use to
Packit Service c5cf8c
look up the \code{port_name}.
Packit Service c5cf8c
The \code{info} argument is used to pass any necessary information to
Packit Service c5cf8c
the name publishing system (the reason for this will become clear in
Packit Service c5cf8c
Section~\ref{sec:sample-impls}). 
Packit Service c5cf8c
Packit Service c5cf8c
\section{Why Another Interface?}
Packit Service c5cf8c
An alternative to developing another interface is to extend the
Packit Service c5cf8c
process management interface (PMI).  An advantage to this is that the
Packit Service c5cf8c
MPI process already has a connection to the outside world, used by the
Packit Service c5cf8c
PMI interface to implement the PMI put/get interface.  Thus, an
Packit Service c5cf8c
extension to the PMI interface could support the name publishing
Packit Service c5cf8c
routines (an extension is needed because the MPI name publishing
Packit Service c5cf8c
routines are independent, not collective).
Packit Service c5cf8c
Packit Service c5cf8c
To see why another interface is needed, consider the situation in
Packit Service c5cf8c
Figure~\ref{fig:multiple-pm}.  In this Figure, two MPI programs, each
Packit Service c5cf8c
started by a different process manager, wish to connect.  For example,
Packit Service c5cf8c
one MPI job may be run on a batch system (the PBS job in this example)
Packit Service c5cf8c
and one on an interactive visualization cluster.
Packit Service c5cf8c
Packit Service c5cf8c
\begin{figure}
Packit Service c5cf8c
\centerline{\includegraphics{twopm.eps}}
Packit Service c5cf8c
\caption{Two MPI applications using name publishing with two different
Packit Service c5cf8c
process managers}\label{fig:multiple-pm}
Packit Service c5cf8c
\end{figure}
Packit Service c5cf8c
Packit Service c5cf8c
To implement this scenario, it is necessary to separate the name
Packit Service c5cf8c
publishing interface from the process management interface.  
Packit Service c5cf8c
Of course, in a scenario in which there are two MPI jobs using the
Packit Service c5cf8c
same process manager, the process manager could provide the name
Packit Service c5cf8c
service.  The proposed interface allows implementations use either a
Packit Service c5cf8c
separate service or the process manager
Packit Service c5cf8c
Packit Service c5cf8c
\section{A Proposed Interface}
Packit Service c5cf8c
\label{sec:name-interface}
Packit Service c5cf8c
Packit Service c5cf8c
The interface described here provides all the services necessary for
Packit Service c5cf8c
implementing the MPI name servie routines.  In order to provide a hook
Packit Service c5cf8c
for the name service implementation to initialize, there are separate
Packit Service c5cf8c
initializating and finalize calls.  These can, for example, open a
Packit Service c5cf8c
connection to a name service.  The initialization call returns a
Packit Service c5cf8c
handle of type \code{MPID_NS_Handle} that is used in all of the other
Packit Service c5cf8c
calls.  As in other MPI calls, the free routine takes a pointer to the
Packit Service c5cf8c
handle so that the handle can be set to null when the free routine
Packit Service c5cf8c
succeeds.  Each of these routines returns either \code{MPI_SUCCESS} or
Packit Service c5cf8c
a valid MPI error code; implementations may either use the MPICH
Packit Service c5cf8c
error code mechanism or, for external packages, use the MPI routines
Packit Service c5cf8c
for adding error codes and classes.
Packit Service c5cf8c
Packit Service c5cf8c
\begin{verbatim}
Packit Service c5cf8c
int MPID_NS_Create( const MPIR_Info *, MPID_NS_Handle * )
Packit Service c5cf8c
int MPID_NS_Publish( MPID_NS_Handle, const MPIR_Info *,
Packit Service c5cf8c
                     const char service_name[], const char port[] )
Packit Service c5cf8c
int MPID_NS_Lookup( MPID_NS_Handle, const MPIR_Info *,
Packit Service c5cf8c
                    const char service_name[], char port[] )
Packit Service c5cf8c
int MPID_NS_Unpublish( MPID_NS_Handle, const MPIR_Info *,
Packit Service c5cf8c
                       const char service_name[] )
Packit Service c5cf8c
int MPID_NS_Free( MPID_NS_Handle * )
Packit Service c5cf8c
\end{verbatim}
Packit Service c5cf8c
Packit Service c5cf8c
These calls make use of the \code{MPIR_Info} pointer (a pointer to the
Packit Service c5cf8c
info object passed into the MPI name publisher routines) to provide other
Packit Service c5cf8c
information that the name service may require.
Packit Service c5cf8c
Predefined \code{MPI_Info} keys and values for name service are:
Packit Service c5cf8c
\begin{description}
Packit Service c5cf8c
\item[\code{NAMEPUB\_CONTACT}]Value is a string providing contact
Packit Service c5cf8c
  information for the name service.  This may be an IP address or
Packit Service c5cf8c
  something else (see below).
Packit Service c5cf8c
\item[\code{NAMEPUB\_CREDENTIAL}]Value is a string providing
Packit Service c5cf8c
  credentials for accessing the name service.  The exact format is
Packit Service c5cf8c
  specified by the name service.  See also \code{NAMEPUB_USER}.
Packit Service c5cf8c
\item[\code{NAMEPUB\_EXPIRE}]Value is an integer, represented as a
Packit Service c5cf8c
  string, that specifies an expiration time in seconds from the time
Packit Service c5cf8c
  that a name is published.
Packit Service c5cf8c
\item[\code{NAMEPUB\_IP}]Value is the IP address as a string, usually
Packit Service c5cf8c
  in ``hostname:port'' format.  This is an alternative to
Packit Service c5cf8c
  \code{NAMEPUB_CONTACT}. 
Packit Service c5cf8c
\item[\code{NAMEPUB\_IP\_FROM\_ENV}]Value is the name of an environment
Packit Service c5cf8c
  variable whose value has the same meaning as the \code{NAMEPUB_IP}
Packit Service c5cf8c
  info key. 
Packit Service c5cf8c
\item[\code{NAMEPUB\_REFCOUNT}]Value is an integer, represented as a
Packit Service c5cf8c
  string, giving the number of times a value can
Packit Service c5cf8c
  be looked up before being deleted from the name service.  Set only
Packit Service c5cf8c
  on \code{MPI_Publish_name}.
Packit Service c5cf8c
\item[\code{NAMEPUB\_USER}]Value is a string giving the user name.
Packit Service c5cf8c
\end{description}
Packit Service c5cf8c
Two of these info parameters make slight changes to the semantics of
Packit Service c5cf8c
the name publishing routines by providing a way to cause names to
Packit Service c5cf8c
expire without an explicit call to \code{MPI_UNPUBLISH_NAME}.
Packit Service c5cf8c
However, the benefit of these in terms of ensuring that the name
Packit Service c5cf8c
service does not become clogged with old names outweighs the MPI
Packit Service c5cf8c
requirement that \code{MPI_Info} parameters make no changes to the
Packit Service c5cf8c
semantics of the routines.  
Packit Service c5cf8c
Packit Service c5cf8c
\section{A Few Possible Implementations}
Packit Service c5cf8c
\label{sec:sample-impls}
Packit Service c5cf8c
This section outlines three possible implementations.
Packit Service c5cf8c
Packit Service c5cf8c
\subsection{LDAP}
Packit Service c5cf8c
\label{sec:namepub-ldap}
Packit Service c5cf8c
The Lightweight Directory Access Protocol (LDAP) \cite{ldap} is a
Packit Service c5cf8c
standard for providing general name lookup services.  Open source
Packit Service c5cf8c
implementations of LDAP are available; at many locations, an LDAP
Packit Service c5cf8c
server may already be running.  The following sketches the routines
Packit Service c5cf8c
from OpenLDAP that can be used to implement the name interface.
Packit Service c5cf8c
Packit Service c5cf8c
\begin{description}
Packit Service c5cf8c
\item[\code{MPID\_NS\_Create}]Use \code{ldap_open} to access the ldap server
Packit Service c5cf8c
\item[\code{MPID\_NS\_Publish}]Use \code{ldap_add_s} to insert the name
Packit Service c5cf8c
\item[\code{MPID\_NS\_Lookup}]Use \code{ldap_search_s}, \code{ldap_first_entry}, and
Packit Service c5cf8c
  \code{ldap_get_values} to access the entry
Packit Service c5cf8c
\item[\code{MPID\_NS\_Unpublish}]Use \code{ldap_modify_s} to remove the name
Packit Service c5cf8c
\item[\code{MPID\_NS\_Free}]Use \code{ldap_unbind_s} and \code{ldap_memfree}
Packit Service c5cf8c
\end{description}
Packit Service c5cf8c
Packit Service c5cf8c
\subsection{File}
Packit Service c5cf8c
\label{sec:namepub-file}
Packit Service c5cf8c
If all MPI processes share a single filesystem, a simple
Packit Service c5cf8c
implementation of the name service can use the file system.  
Packit Service c5cf8c
In this design, each value is placed into a separate file whose name
Packit Service c5cf8c
include the key; this avoids
Packit Service c5cf8c
any problems with concurrent updates to a single file.
Packit Service c5cf8c
\begin{description}
Packit Service c5cf8c
\item[\code{MPID\_NS\_Create}]Create a structure to hold the names of all files created.
Packit Service c5cf8c
\item[\code{MPID\_NS\_Publish}]Create a file using a name containing the user, contact
Packit Service c5cf8c
  string, and the key.  The text of the file is the value of the name.
Packit Service c5cf8c
  Save the file name in the name service structure.  Protection is
Packit Service c5cf8c
  provided by the file system.
Packit Service c5cf8c
\item[\code{MPID\_NS\_Unpublish}]Unlink (remote) the file; remove the file name from
Packit Service c5cf8c
  the name service structure.
Packit Service c5cf8c
\item[\code{MPID\_NS\_Lookup}]For the filename using the same rule in publish and read
Packit Service c5cf8c
  the file.
Packit Service c5cf8c
\item[\code{MPID\_NS\_Free}]Remove all of the created files.
Packit Service c5cf8c
\end{description}
Packit Service c5cf8c
Packit Service c5cf8c
Some of the features, such as \code{NAMEPUB_EXPIRE}, are not supported
Packit Service c5cf8c
by this interface.  The info key \code{NAMEPUB_CONTACT} can be used to
Packit Service c5cf8c
specify the directory into which the files will be placed.
Packit Service c5cf8c
Packit Service c5cf8c
\end{document}