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 to0and 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)
π Copyright π
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
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms