mpic++(1)

πŸ“¦
version 26.9 Β· 3 versions
, in arch rolling

πŸ’… mpic++ β€” Open MPI C++ wrapper compiler (yes bestie, it's a whole thing)

okay so real quick: this is the man page for mpic++, one of the Open MPI wrapper compilers. It's from the Open MPI manual, and honestly? It eats. Let's get into it 🫢


✨ SYNTAX ✨

mpic++ [-showme|-showme:compile|-showme:link] ...

that's the whole shape of it, bestie. simple. iconic. moving on πŸ’–


🌸 OPTIONS 🌸

  • --showme β€” this one's got variants (see all the ones below, they're literally right there). Not a single one of them actually invokes the underlying compiler β€” they just tell you what it would have done if you hadn't passed --showme. The plain --showme prints out the command line that would be executed to compile your program. > ⚠️ BUT β€” big note β€” if you pass a non-filename argument on the command line, -showme won't show you those extra flags at all. Like: mpic++ --showme and mpic++ --showme my_source.c both show all the wrapper-supplied flags. But mpic++ --showme -v only shows the underlying compiler name and -v. that's it. that's the tea πŸ’€
  • --showme:compile β€” spits out the compiler flags that would have been handed to the C++ compiler. that's it, that's the whole job ✨
  • --showme:link β€” same vibe, but the linker flags that would have gone to the C++ compiler.
  • --showme:command β€” outputs the underlying C++ compiler command (which may be one or more tokens β€” could be a whole little gang of tokens, no cap).
  • --showme:incdirs β€” outputs a space-delimited (but otherwise undecorated, raw, no-frills) list of directories the wrapper compiler would have given the underlying C++ compiler to say "hey relevant header files live here."
  • --showme:libdirs β€” same energy but for the underlying linker: a space-delimited, otherwise undecorated list of directories where relevant libraries chill.
  • --showme:libs β€” outputs a space-delimited (undecorated, again) list of library names the wrapper compiler would have used to link an application. for example: "mpi open-rte open-pal util" πŸ‘‘
  • --showme:version β€” outputs the version number of Open MPI. short, sweet, slays.
  • --showme:help β€” prints a brief usage help message. your little emergency handbook πŸŽ€

Also!! Go read the man page for your underlying C++ compiler for all the other options you can pass straight through mpic++. it's giving "the wrapper is just a doorway" iykyk.


πŸ¦‹ DESCRIPTION πŸ¦‹

So conceptually? The whole role of these commands is genuinely simple, bestie: they transparently add the relevant compiler and linker flags to your command line β€” the ones you need to compile / link Open MPI programs β€” and then they invoke the underlying compiler to actually do the work.

Because of that, these commands get called "wrapper" compilers all the time, and for good reason: they do not actually compile or link applications themselves. nope. They just add command line flags and invoke the back-end compiler. middle management, but make it useful πŸ’…

🧚 Background

Open MPI is made of three software layers: OPAL (Open Portable Access Layer), ORTE (Open Run-Time Environment), and OMPI (Open MPI). Each layer has wrapper compilers, and each layer's wrapper only links in the libraries relevant to that layer. Specifically, each layer provides:

  • OPAL β€” opalcc and opalc++
  • ORTE β€” ortecc and ortec++
  • OMPI β€” mpicc, mpic++, mpicxx, mpiCC (only on systems with case-senstive file systems), and mpifort (and its legacy/deprecated names mpif77 and mpif90). And just so you know: mpic++, mpicxx, and mpiCC all invoke the same underlying C++ compiler with the same options. All three exist purely as compatibility with other MPI implementations. same girl, three nicknames πŸ’–

πŸ“ Fortran Notes

The Fortran wrapper compiler for MPI β€” mpifort, plus its legacy/deprecated names mpif77 and mpif90 β€” can compile and link MPI applications that use any/all of the MPI Fortran bindings: mpif.h, the mpi module, and the mpi_f08 module (assuming Open MPI was installed with support for each of those Fortran bindings). Specifically: it is no longer necessary to use different wrapper compilers for apps using mpif.h vs. apps using the mpi module β€” just use mpifort for all your Fortran MPI applications. one wrapper to rule them all ✨

⚠️ Note though, bestie: the Fortran compiler may need extra command-line options to enforce a specific Fortran dialect. For example, in some versions of the IBM XLF compiler, if xlf90 is the underlying Fortran compiler, -qfixed may be necessary to compile fixed-format Fortran source files.

And finally β€” huge heads up β€” mpifort will be inoperative and will return an error on use if Fortran support was not built into the MPI layer. it will simply not be doing that πŸ™ˆ

🌈 Overview

mpic++ is a convenience wrapper for the underlying C++ compiler. Translating an Open MPI program requires linking the Open MPI-specific libraries, and those may not live in any of the standard search directories of ld(1). It also often requires including header files that may not be in a standard location either.

mpic++ passes its arguments to the underlying C++ compiler along with the -I, -L and -l options required by Open MPI programs.

The Open MPI Team strongly encourages using the wrapper compilers instead of trying to link to the Open MPI libraries manually. Why? Because it lets the specific implementation of Open MPI change without forcing changes to linker directives in users' Makefiles. And fr fr β€” the specific set of flags and libraries used by the wrapper compilers depends on how Open MPI was configured and built, so those values can change between different installations of the same version of Open MPI. πŸ‘‘

And honestly, since the wrappers are just thin shells on top of an underlying compiler, there are very, very few compelling reasons not to use mpic++. When it's not possible to use the wrappers directly, use the -showme:compile and -showme:link options to figure out what flags the wrappers would have used. like this:

shell$ cc -c file1.c `mpicc -showme:compile`

shell$ cc -c file2.c `mpicc -showme:compile`

shell$ cc file1.o file2.o `mpicc -showme:link` -o my_mpi_program

look at that. beautiful. no notes πŸ’œ


⭐ NOTES ⭐

It's possible to make the wrapper compilers multi-lib aware. Which means: the libraries and includes specified may differ based on the compiler flags you specify. For example, with the GNU compilers on Linux, a different library path may be used if -m32 is seen versus -m64 being seen. This is not the default behavior in a standard build, but it can be activated (for example, in a binary package providing both 32 and 64 bit support). More info lives here:

https://github.com/open-mpi/ompi/wiki/compilerwrapper3264

πŸŽ€ FILES πŸŽ€

The string that the wrapper compilers insert into the command line before invoking the underlying compiler is stored in a text file that Open MPI creates and installs to $pkgdata/mpic++-wrapper-data.txt, where $pkgdata is typically $prefix/share/openmpi, and $prefix is the top installation directory of Open MPI.

It is rarely necessary to edit this file, but you can peek at it to gain insight into what flags the wrappers are putting on the command line. lowkey fascinating 🧐


πŸ”₯ ENVIRONMENT VARIABLES πŸ”₯

By default, the wrappers use the compilers that were selected when Open MPI was configured. Those compilers were either found automatically by Open MPI's "configure" script, or selected by the user in the CC, CXX, F77, and/or FC environment variables before "configure" was invoked. On top of that, other arguments specific to the compiler may have been selected by configure.

You can selectively override these values either by editing the text files that hold this configuration info (see the FILES section, it's right up there ⬆️) or by setting selected environment variables of the form "OMPI_value".

The valid value names are:

  • CPPFLAGS β€” flags added when invoking the preprocessor (C or C++)
  • LDFLAGS β€” flags added when invoking the linker (C, C++, or Fortran)
  • LIBS β€” libraries added when invoking the linker (C, C++, or Fortran)
  • CC β€” C compiler
  • CFLAGS β€” C compiler flags
  • CXX β€” C++ compiler
  • CXXFLAGS β€” C++ compiler flags
  • FC β€” Fortran compiler
  • FCFLAGS β€” Fortran compiler flags

anyway that's the whole page, bestie. go compile something cute πŸ’–βœ¨ this one's from the gitclone source, version Unreleased developer copy β€” so yeah, it's a developer-copy moment, living on the edge, main character energy only πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from
  • arch rolling: nvhpc-comm-libs 26.9-1 Β· LicenseRef-NVIDIA-HPC-SDK
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms