| 383 | | MPICH2 can be configured with two sets of compiler flags: CFLAGS, |
| 384 | | CXXFLAGS, FFLAGS, F90FLAGS (abbreviated as xFLAGS) and |
| 385 | | MPICH2LIB_CFLAGS, MPICH2LIB_CXXFLAGS, MPICH2LIB_FFLAGS, |
| 386 | | MPICH2LIB_F90FLAGS (abbreviated as MPICH2LIB_xFLAGS) for compilation; |
| 387 | | LDFLAGS and MPICH2LIB_LDFLAGS for linking. All these flags can be set |
| 388 | | as part of configure command or through environment variables. |
| 389 | | (CPPFLAGS stands for C preprocessor flags, which should NOT be set) |
| 390 | | |
| 391 | | Both xFLAGS and MPICH2LIB_xFLAGS affect the compilation of the MPICH2 |
| 392 | | libraries. However, only xFLAGS are appended to MPI wrapper scripts, |
| 393 | | mpicc and friends. |
| 394 | | |
| 395 | | MPICH2 libraries are built with default compiler optimization, -O2, |
| 396 | | which can be modified by --enable-fast configure option. For |
| 397 | | instance, --disable-fast disables the default optimization option. |
| 398 | | --enable-fast=O<n> sets default compiler optimization as -O<n>. For |
| 399 | | more details of --enable-fast, see the output of "configure --help". |
| 400 | | Any other complicated optimization flags for MPICH2 libraries have to |
| 401 | | be set throught MPICH2LIB_xFLAGS. CFLAGS and friends are empty by |
| 402 | | default. |
| 403 | | |
| 404 | | For example, to build a "production" MPICH2 environment with -O3 for all |
| 405 | | language bindings, one can simply do |
| | 383 | MPICH2 allows several sets of compiler flags to be used. The first |
| | 384 | three sets are configure-time options for MPICH2, while the fourth is |
| | 385 | only relevant when compiling applications with mpicc and friends. |
| | 386 | |
| | 387 | 1. CFLAGS, CXXFLAGS, FFLAGS, F90FLAGS and LDFLAGS (abbreviated as |
| | 388 | xFLAGS): Setting these flags would result in the MPICH2 library being |
| | 389 | compiled/linked with these flags and the flags internally being used |
| | 390 | in mpicc and friends. |
| | 391 | |
| | 392 | 2. MPICH2LIB_CFLAGS, MPICH2LIB_CXXFLAGS, MPICH2LIB_FFLAGS, |
| | 393 | MPICH2LIB_F90FLAGS and MPICH2LIB_LDFLAGS (abbreviated as |
| | 394 | MPICH2LIB_xFLAGS): Setting these flags would result in the MPICH2 |
| | 395 | library being compiled/linked with these flags. However, these flags |
| | 396 | will *not* be used by mpicc and friends. |
| | 397 | |
| | 398 | 3. MPICH2_MAKE_CFLAGS: Setting these flags would result in MPICH2's |
| | 399 | configure tests to not use these flags, but the makefile's to use |
| | 400 | them. This is a temporary hack for certain cases that advanced |
| | 401 | developers might be interested in which break existing configure tests |
| | 402 | (e.g., -Werror) and are not recommended for regular users. |
| | 403 | |
| | 404 | 4. MPICH2_MPICC_FLAGS, MPICH2_MPICXX_FLAGS, MPICH2_MPIF77_FLAGS, |
| | 405 | MPICH2_MPIF90_FLAGS and MPICH2_LDFLAGS (abbreviated as |
| | 406 | MPICH2_MPIX_FLAGS): These flags do *not* affect the compilation of the |
| | 407 | MPICH2 library itself, but will be internally used by mpicc and |
| | 408 | friends. |
| | 409 | |
| | 410 | |
| | 411 | +--------------------------------------------------------------------+ |
| | 412 | | | | | |
| | 413 | | | MPICH2 library | mpicc and friends | |
| | 414 | | | | | |
| | 415 | +--------------------+----------------------+------------------------+ |
| | 416 | | | | | |
| | 417 | | xFLAGS | Yes | Yes | |
| | 418 | | | | | |
| | 419 | +--------------------+----------------------+------------------------+ |
| | 420 | | | | | |
| | 421 | | MPICH2LIB_xFLAGS | Yes | No | |
| | 422 | | | | | |
| | 423 | +--------------------+----------------------+------------------------+ |
| | 424 | | | | | |
| | 425 | | MPICH2_MAKE_xFLAGS | Yes | No | |
| | 426 | | | | | |
| | 427 | +--------------------+----------------------+------------------------+ |
| | 428 | | | | | |
| | 429 | | MPICH2_MPIX_FLAGS | No | Yes | |
| | 430 | | | | | |
| | 431 | +--------------------+----------------------+------------------------+ |
| | 432 | |
| | 433 | |
| | 434 | All these flags can be set as part of configure command or through |
| | 435 | environment variables. (CPPFLAGS stands for C preprocessor flags, |
| | 436 | which should NOT be set) |
| | 437 | |
| | 438 | |
| | 439 | Default flags |
| | 440 | -------------- |
| | 441 | By default, MPICH2 automatically adds certain compiler optimizations |
| | 442 | to MPICH2LIB_CFLAGS. The currently used optimization level is -O2. |
| | 443 | |
| | 444 | ** IMPORTANT NOTE: Remember that this only affects the compilation of |
| | 445 | the MPICH2 library and is not used in the wrappers (mpicc and friends) |
| | 446 | that are used to compile your applications or other libraries. |
| | 447 | |
| | 448 | This optimization level can be changed with the --enable-fast option |
| | 449 | passed to configure. For example, to build an MPICH2 environment with |
| | 450 | -O3 for all language bindings, one can simply do: |