1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
|
.TH MPI_Init 3 "6/24/2006" "LAM/MPI 7.1.4" "LAM/MPI"
.SH NAME
MPI_Init \- Initialize the MPI execution environment
.SH SYNOPSIS
.nf
#include <mpi.h>
int MPI_Init(int *pargc, char ***pargv)
.fi
.SH INPUT PARAMETERS
.PD 0
.TP
.B pargc
- Pointer to the number of arguments
.PD 1
.PD 0
.TP
.B pargv
- Pointer to the argument vector
.PD 1
.SH NOTES
MPI specifies no command-line arguments but does allow an MPI
implementation to make use of them. LAM/MPI neither uses nor adds any
values to the
.I argc
and
.I argv
parameters. As such, it is legal to
pass
.I NULL
for both
.I argc
and
.I argv
in LAM/MPI.
Instead, LAM/MPI relies upon the
.I mpirun
command to pass
meta-information between nodes in order to start MPI programs (of
course, the LAM daemons must have previously been launched with the
.I lamboot
command). As such, every rank in
.I MPI_COMM_WORLD
will
receive the
.I argc
and
.I argv
that was specified with the
.I mpirun
command (either via the
.I mpirun
command line or an app schema) as
soon as
.I main
begins. See the
.I mpirun
(1) man page for more
information.
If
.I mpirun
is
.I not
used to start MPI programs, the resulting process
will be rank 0 in
.I MPI_COMM_WORLD
, and
.I MPI_COMM_WORLD
will have a
size of 1. This is known as a "singleton" MPI. It should be noted
that LAM daemons are still used for singleton MPI programs -
.I lamboot
must still have been successfully executed before running a singleton
process.
LAM/MPI takes care to ensure that the normal Unix process model of
execution is preserved: no extra threads or processes are forked from
the user's process. Instead, the LAM daemons are used for all
process management and meta-environment information. Consequently,
LAM/MPI places no restriction on what may be invoked before
.I MPI_INIT*
or after
.I MPI_FINALIZE
; this is
.I not
a safe assumption
for those attempting to write portable MPI programs - see "Portability
Concerns", below.
MPI mandates that the same thread must call
.I MPI_INIT
(or
.I MPI_INIT_THREAD
) and
.I MPI_FINALIZE
\&.
Note that the Fortran binding for this routine has only the error
return argument (
.I MPI_INIT(ierror)
).
Because the Fortran and C versions of
.I MPI_INIT
are different, there
is a restriction on who can call
.I MPI_INIT
\&.
The version (Fortran or
C) must match the main program. That is, if the main program is in C,
then the C version of
.I MPI_INIT
must be called. If the main program
is in Fortran, the Fortran version must be called.
LAM/MPI uses the value of argv[0] to identify a process in many of the
user-level helper applications (mpitask and mpimsg, for example).
Fortran programs are generally identified as
"LAM_MPI_Fortran_program". However, this name can be overridden for
Fortran programs by setting the environment variable
"LAM_MPI_PROCESS_NAME".
On exit from this routine, all processes will have a copy of the
argument list. This is
.I not required
by the MPI standard, and truely
portable codes should not rely on it. This is provided as a service
by this implementation (an MPI implementation is allowed to distribute
the command line arguments but is not required to).
.SH THREADING
Applications using
.I MPI_INIT
are effectively invoking
.I MPI_INIT_THREAD
with a requested thread support of
.I MPI_THREAD_SINGLE
\&.
However, this may be overridden with the
LAM_MPI_THREAD_LEVEL environment variable. If set, this variable
replaces the default
.I MPI_THREAD_SINGLE
value. The following values
are allowed
0: Corresponds to
.I MPI_THREAD_SINGLE
1: Corresponds to
.I MPI_THREAD_FUNNELED
2: Corresponds to
.I MPI_THREAD_SERIALIZED
3: Corresponds to
.I MPI_THREAD_MULTIPLE
See MPI_Init_thread(3) for more information on thread level support in
LAM/MPI.
.SH PREDEFINED ATTRIBUTES
LAM/MPI defines all required predefined attributes on
.I MPI_COMM_WORLD
\&.
Some values are LAM-specific, and require
explanation.
.I MPI_UNIVERSE_SIZE
This is an MPI-required attribute. It is set to an integer whose
value indicates how many CPUs LAM was booted with. See bhost(5) and
lamboot(1) for more details on how to specify multiple CPUs per node.
Note that this may be larger than the number of CPUs in
.I MPI_COMM_WORLD
\&.
.I LAM_UNIVERSE_NCPUS
This is a LAM-specific attribute -- it will not be defined in other
MPI implementations. It is actually just a synonym for
.I MPI_UNIVERSE_SIZE
-- it contains the number of CPUs in the current
LAM universe. Note that this may be larger than the number of CPUs in
.I MPI_COMM_WORLD
\&.
.I LAM_UNIVERSE_NNODES
This is a LAM-specific attribute -- it will not be defined in other
MPI implementations. It indicates the total number of nodes in the
current LAM universe (which may be different from the total number of
CPUs). Node that this may be larger than the number of nodes in
.I MPI_COMM_WORLD
\&.
.SH SIGNALS USED
The LAM implementation of MPI uses, by default,
.I SIGUSR2
\&.
This may
be changed when LAM is compiled, however, with the
.I --with-signal
command line switch to LAM's
.I configure
script. Consult your system
administrator to see if they specified a different signal when LAM was
installed.
LAM/MPI does not catch any other signals in user code, by default. If
a process terminates due to a signal, the mpirun will be notified of
this and will print out an appropriate error message and kill the rest
of the user MPI application.
This behavior can be overridden (mainly for historical reasons) with
the "-sigs" flag to
.I mpirun
\&.
When "-sigs" is used, LAM/MPI will
effectively transfer the signal-handling code from mpirun to the user
program. Signal handlers will be installed during
.I MPI_INIT
(or
.I MPI_INIT_THREAD
) for the purpose of printing error messages before
invoking the next signal handler. That is, LAM "chains" its signal
handler to be executed before the signal handler that was already set.
Therefore, it is safe for users to set their own signal handlers. If
they wish the LAM signal handlers to be executed as well, users should
set their handlers before
.I MPI_INIT*
is invoked.
LAM/MPI catches the following signals
.I SIGSEGV
,
.I SIGBUS
,
.I SIGFPE
,
.I SIGILL
All other signals are unused by LAM/MPI, and will be passed to their
respective signal handlers.
.SH PORTABILITY CONCERNS
Portable MPI programs
.I cannot
assume the same process model that LAM
uses (i.e., essentially the same as POSIX). MPI does not mandate
anything before
.I MPI_INIT
(or
.I MPI_INIT_THREAD
), nor anything after
.I MPI_FINALIZE
executes. Different MPI implementations make different
assumptions; some fork auxillary threads and/or processes to "help"
with the MPI run-time environment (this may interfere with the
constructors and destructors of global C++ objects, particularly in
the case where using atexit() or onexit(), for example). As such, if
you are writing a portable MPI program, you cannot make the same
assumptions that LAM/MPI does.
In general, it is safest to call
.I MPI_INIT
(or
.I MPI_INIT_THREAD
) as
soon as possible after
.I main
begins, and call
.I MPI_FINALIZE
immediately before the program is supposed to end. Consult the
documentation for each MPI implementation for their intialize and
finalize behavior.
.SH ERRORS
If an error occurs in an MPI function, the current MPI error handler
is called to handle it. By default, this error handler aborts the
MPI job. The error handler may be changed with
.I MPI_Errhandler_set
;
the predefined error handler
.I MPI_ERRORS_RETURN
may be used to cause
error values to be returned (in C and Fortran; this error handler is
less useful in with the C++ MPI bindings. The predefined error
handler
.I MPI::ERRORS_THROW_EXCEPTIONS
should be used in C++ if the
error value needs to be recovered). Note that MPI does
.I not
guarantee that an MPI program can continue past an error.
All MPI routines (except
.I MPI_Wtime
and
.I MPI_Wtick
) return an error
value; C routines as the value of the function and Fortran routines
in the last argument. The C++ bindings for MPI do not return error
values; instead, error values are communicated by throwing exceptions
of type
.I MPI::Exception
(but not by default). Exceptions are only
thrown if the error value is not
.I MPI::SUCCESS
\&.
Note that if the
.I MPI::ERRORS_RETURN
handler is set in C++, while
MPI functions will return upon an error, there will be no way to
recover what the actual error value was.
.PD 0
.TP
.B MPI_SUCCESS
- No error; MPI routine completed successfully.
.PD 1
.PD 0
.TP
.B MPI_ERR_OTHER
- This error class is associated with an error code
that indicates that an attempt was made to call
.I MPI_INIT
a second
time.
.I MPI_INIT
may only be called once in a program.
.PD 1
.PD 0
.TP
.B MPI_ERR_OTHER
- Other error; use
.I MPI_Error_string
to get more
information about this error code.
.PD 1
.SH SEE ALSO
MPI_Init_thread, MPI_Finalize, lamboot, mpirun, lamhalt, lamssi
.br
.SH MORE INFORMATION
For more information, please see the official MPI Forum web site,
which contains the text of both the MPI-1 and MPI-2 standards. These
documents contain detailed information about each MPI function (most
of which is not duplicated in these man pages).
.I http://www.mpi-forum.org/
.SH ACKNOWLEDGEMENTS
The LAM Team would like the thank the MPICH Team for the handy program
to generate man pages ("doctext" from
.I ftp://ftp.mcs.anl.gov/pub/sowing/sowing.tar.gz
), the initial
formatting, and some initial text for most of the MPI-1 man pages.
.SH LOCATION
init.c
|