SHMEM_INIT(3)

πŸ’– NAME πŸ’–

shmem_init, start_pes β€” allocates a block of memory from the symmetric heap.

Okay bestie, this is the Open MPI SHMEM_INIT(3) page, and it's literally the first thing you touch in a SHMEM program, so pay attention 🫢


✨ SYNOPSIS ✨

C or C++:

void shmem_init(void)
void start_pes(int npes)

Fortran:

CALL SHMEM_INIT()
CALL START_PES(npes)

🌸 DESCRIPTION 🌸

So the whole vibe here is: start_pes should be the very first statement in a SHMEM parallel program. Like, opening-credits first. No cap.

The start_pes routine accepts this one argument:

  • npes β€” unused, girl. Set it to 0 and move on. πŸ™ˆ

This routine initializes the SHMEM API, so it must be called before you call literally any other SHMEM routine. It's the one responsible, inter alia, for setting up the symmetric heap on the calling PE and for the creation of the virtual PE numbers. Once this routine returns successfully, the calling PE can communicate with and transfer data to other PEs. Iconic behavior only ✨

🚫 Multiple calls to this function are not allowed. Not twice. Not "just to be sure." Don't.

For an overview of programming with SHMEM communication routines, example SHMEM programs, and instructions for compiling SHMEM programs, go read the intro_shmem(3) man page. It's giving required reading. πŸ’…


πŸ’€ EXAMPLES πŸ’€

This is a simple program that calls shmem_integer_put(3):

PROGRAM PUT
  INCLUDE "mpp/shmem.fh"

  INTEGER TARG, SRC, RECEIVER, BAR
  COMMON /T/ TARG
  PARAMETER (RECEIVER=1)

  CALL SHMEM_INIT()
  IF (MY_PE() .EQ. 0) THEN
    SRC = 33
    CALL SHMEM_INTEGER_PUT(TARG, SRC, 1, RECEIVER)
  ENDIF
  CALL SHMEM_BARRIER_ALL ! SYNCHRONIZES SENDER AND RECEIVER
  IF (MY_PE() .EQ. RECEIVER) THEN
    PRINT *,'PE ', MY_PE(),' TARG=',TARG,' (expect 33)'
  ENDIF
END

See how SHMEM_INIT() shows up first? That's not a coincidence, that's the assignment πŸŽ€


πŸ¦‹ NOTES πŸ¦‹

⚠️ If the start_pes call is not the first statement in a program, unexpected results may occur on some architectures. Highkey do not test this. 😭

See also: intro_shmem(3) shmem_barrier(3) shmem_barrier_all(3) shmem_put(3) my_pe(3) shmem_n_pes(3)


2003-2026, The Open MPI Community


That's the whole page, bestie β€” you're set. This was SHMEM_INIT(3) from the Open MPI squad, dated Sep 10, 2026, and honestly? She ate. Slay, and remember: init first, everything else after. Periodt πŸ’œπŸŒˆ

πŸ“¦ where this page comes from