shmemcc(1)

πŸŽ€ shmemcc(1) β€” the Open MPI glow-up edition πŸŽ€

okay bestie, pull up a chair because we're talking about shmemcc, aka the Open SHMEM C wrapper compiler, and honestly? she's iconic. she doesn't compile anything herself (more on that in a sec, it's giving "manager not maker"), she just makes your C compiler behave. πŸ’…


✨ NAME ✨

shmemcc β€” the Open SHMEM C wrapper compiler. that's her. that's the whole name. 🫢


✨ SYNTAX ✨

shmemcc [-showme|-showme:compile|-showme:link] ...

yeah it's short. don't let the brevity fool you, there's a LOT going on under the hood. πŸ’–


✨ OPTIONS ✨

  • --showme β€” okay so this one comes in several different variants (scroll down, they're all right here). none of the variants actually invoke the underlying compiler β€” they just tell you how the underlying compiler would have been invoked if you hadn't used --showme. the plain, basic --showme spits out the command line that would've been executed to compile the program. NOTE: if a non-filename argument gets passed on the command line, the -showme option will not display any additional flags. for example, both "shmemcc --showme" and "shmemcc --showme my_source.c" will show all the wrapper-supplied flags. but "shmemcc --showme -v" will only show the underlying compiler name and "-v". no cap, that trips people up. 😭
  • --showme:compile β€” outputs the compiler flags that would have been supplied to the C compiler. the little care package for compiling. πŸ’–
  • --showme:link β€” outputs the linker flags that would have been supplied to the C compiler. the care package for linking. 🫢
  • --showme:command β€” outputs the underlying C compiler command (which may be one or more tokens, so don't assume it's just one pretty word).
  • --showme:incdirs β€” outputs a space-delimited (but otherwise undecorated, so like, no frills, no extra ✨) list of directories that the wrapper compiler would have provided to the underlying C compiler to indicate where the relevant header files live. πŸ“
  • --showme:libdirs β€” outputs a space-delimited (again, undecorated) list of directories that the wrapper compiler would have handed to the underlying linker to say where the relevant libraries live. πŸ“š
  • --showme:libs β€” outputs a space-delimited (yep, undecorated) list of library names that the wrapper compiler would have used to link an application. for example: "mpi open-rte open-pal util". slay.
  • --showme:version β€” outputs the version number of Open MPI. ⭐
  • --showme:help β€” outputs a brief usage help message. the "hey bestie here's the vibe" of options. 🌸

also: go check the man page for your underlying C compiler for other options that can be passed through shmemcc. she's a conduit, not a gatekeeper. πŸ’œ


✨ DESCRIPTION ✨

conceptually, the role of these commands is genuinely so simple it's kind of adorable: transparently add the relevant compiler and linker flags to the user's command line that are necessary to compile / link Open SHMEM programs, and then invoke the underlying compiler to actually do the thing. πŸ¦‹

and because of that, these commands get called "wrapper" compilers all the time β€” because they do not actually compile or link applications themselves. they just sprinkle in the command line flags and invoke the back-end compiler. it's giving personal assistant energy. πŸ‘‘

🌈 Background 🌈

Open MPI is comprised of three software layers: OPAL (Open Portable Access Layer), ORTE (Open Run-Time Environment), and OMPI (Open MPI). there are wrapper compilers for each layer; each layer's wrapper only links in the libraries relevant for that layer. specifically, each layer provides the following wrapper compilers:

  • 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). note that mpic++, mpicxx, and mpiCC all invoke the same underlying C++ compiler with the same options. all are provided as compatibility with other MPI implementations. 🀝

🧚 Fortran Notes 🧚

the Fortran wrapper compiler for MPI (mpifort, and 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 these Fortran bindings). specifically: it is no longer necessary to use different wrapper compilers for applications that use mpif.h vs. applications that use the mpi module β€” just use mpifort for all Fortran MPI applications. one wrapper, all the vibes. πŸ’–

note, however, that the Fortran compiler may require additional 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. 🫠

finally, note that mpifort will be inoperative and will return an error on use if Fortran support was not built into the MPI layer. like, it will simply not work. that's a hard no. πŸ’€

⭐ Overview ⭐

shmemcc is a convenience wrapper for the underlying C compiler. translation of an Open SHMEM program requires the linkage of the Open SHMEM-specific libraries, which may not reside in one of the standard search directories of ld(1). it also often requires the inclusion of header files that may also not be found in a standard location. πŸ—ΊοΈ

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

the Open SHMEM Team strongly encourages using the wrapper compilers instead of attempting to link to the Open SHMEM libraries manually. this allows the specific implementation of Open SHMEM to change without forcing changes to linker directives in users' Makefiles. and for real, the specific set of flags and libraries used by the wrapper compilers depends on how Open SHMEM was configured and built; the values can change between different installations of the same version of Open SHMEM. πŸ‘€

and honestly, since the wrappers are simply thin shells on top of an underlying compiler, there are very, very few compelling reasons not to use shmemcc. when it is not possible to use the wrappers directly, the -showme:compile and -showme:link options should be used to determine what flags the wrappers would have used. for example:

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. chef's kiss. πŸ‘¨πŸ³πŸ’‹


✨ NOTES ✨

it is possible to make the wrapper compilers multi-lib aware. that is, the libraries and includes specified may differ based on the compiler flags specified (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 information can be found at:

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 created by Open SHMEM and installed to $pkgdata/shmemcc-wrapper-data.txt, where $pkgdata is typically $prefix/share/openmpi, and $prefix is the top installation directory of Open SHMEM. πŸ“„

it is rarely necessary to edit this file, but it can be examined to gain insight into what flags the wrappers are placing on the command line. peek, don't touch. πŸ™ˆ


✨ ENVIRONMENT VARIABLES ✨

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

these values can be selectively overridden by either editing the text files containing this configuration information (see the FILES section, bestie, I literally just told you), or by setting selected environment variables of the form "OSHMEM_value". πŸ”§

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

okay that's the whole page!! go forth and link your Open SHMEM programs, bestie, you're gonna do amazing. πŸ’–βœ¨πŸ¦‹

this has been Open MPI 4.1.6, dated Sep 30, 2023, signing off. mwah. πŸ’‹πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from
  • ubuntu noble: openmpi-bin 4.1.6-7ubuntu2
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms