SHMEM_PUTMEM(3)

πŸ“¦
version 5.0.10 Β· 4 versions
, in ubuntu stonking

πŸ’– SHMEM_PUTMEM(3) β€” bestie edition πŸ’–

okay so this is the Open MPI family of put routines and honestly? they're iconic. this one page covers a whole squad of them:

shmem_character_put(3), shmem_complex_put(3), shmem_double_put(3), shmem_float_put(3), shmem_int_put(3), shmem_integer_put(3), shmem_logical_put(3), shmem_long_put(3), shmem_longdouble_put(3), shmem_longlong_put(3), shmem_put4(3), shmem_put8(3), shmem_put32(3), shmem_put64(3), shmem_put128(3), shmem_putmem(3), shmem_real_put(3), shmem_short_put(3)

and what do they all do? Transfers data to a specified processing element (PE) ✨ that's the whole vibe, that's the assignment. 🫢


✨ SYNOPSIS ✨

C or C++:

#include <mpp/shmem.h>

void shmem_double_put(double *target, const double *source,
  size_t len, int pe)

void shmem_float_put(float *target, const float *source,
  size_t len, int pe)

void shmem_int_put(int *target, const int *source, size_t len,
  int pe)

void shmem_long_put(long *target, const long *source,
  size_t len, int pe)

void shmem_longdouble_put(long double *target,
  const long double *source, size_t len, int pe)

void shmem_longlong_put(long long *target,
  const long long *source, size_t len, int pe)

void shmem_put32(void *target, const void *source, size_t len,
  int pe)

void shmem_put64(void *target, const void *source, size_t len,
  int pe)

void shmem_put128(void *target, const void *source, size_t len,
  int pe)

void shmem_putmem(void *target, const void *source, size_t len,
  int pe)

void shmem_short_put(short *target, const short *source,
  size_t len, int pe)

Fortran:

INCLUDE "mpp/shmem.fh"

INTEGER len, pe

CALL SHMEM_CHARACTER_PUT(target, source, len, pe)

CALL SHMEM_COMPLEX_PUT(target, source, len, pe)

CALL SHMEM_DOUBLE_PUT(target, source, len, pe)

CALL SHMEM_INTEGER_PUT(target, source, len, pe)

CALL SHMEM_LOGICAL_PUT(target, source, len, pe)

CALL SHMEM_PUT(target, source, len, pe)

CALL SHMEM_PUT4(target, source, len, pe)

CALL SHMEM_PUT8(target, source, len, pe)

CALL SHMEM_PUT32(target, source, len, pe)

CALL SHMEM_PUT64(target, source, len, pe)

CALL SHMEM_PUT128(target, source, len, pe)

CALL SHMEM_PUTMEM(target, source, len, pe)

CALL SHMEM_REAL_PUT(target, source, len, pe)

🌸 DESCRIPTION 🌸

okay so the lore: these routines transfer nelems elements of the data object at address source on the calling PE, over to the data object at address target on the remote PE pe. that's the whole runway walk πŸ’…

BUT. and this is the important part bestie β€” these routines start the remote transfer and may return before the data is delivered to the remote PE. it's giving "texted you but left you on read for a sec", not "hand-delivered with a bow". πŸŽ€

Also, the delivery of data into the data object on the destination PE from different put calls may occur in any order. Because of this, two successive put operations may deliver data out of order unless a call to shmem_fence(3) is introduced between the two calls. so if you're relying on order, no cap, you need that fence. πŸ™ˆ

the arguments, one by one πŸ¦‹

  • target β€” the data object to be updated on the remote PE. This data object must be remotely accessible. (yes this matters. it's not optional. it's the vibe check.)
  • source β€” the data object containing the data to be copied.
  • len β€” number of elements in the target and source arrays. len must be of type integer. If you're doing Fortran, it must be a constant, variable, or array element of default integer type.
  • pe β€” PE number of the remote PE. pe must be of type integer. If you're doing Fortran, it must be a constant, variable, or array element of default integer type.

typing constraints (the dress code) πŸ‘‘

The target and source data objects must conform to certain typing constraints, which are as follows:

  • shmem_putmem: Fortran: Any noncharacter type. C: Any data type. len is scaled in bytes. (yes, bytes. different unit. pay attention bestie.)
  • shmem_put4, shmem_put32: Any noncharacter type that has a storage size equal to 32 bits.
  • shmem_put8, shmem_put64: Any noncharacter type that has a storage size equal to 64 bits.
  • shmem_put128: Any noncharacter type that has a storage size equal to 128 bits.
  • shmem_short_put: Elements of type short.
  • shmem_int_put: Elements of type int.
  • shmem_long_put: Elements of type long.
  • shmem_longlong_put: Elements of type long long.
  • shmem_float_put: Elements of type float.
  • shmem_double_put: Elements of type double.
  • shmem_longdouble_put: Elements of type long double.
  • SHMEM_CHARACTER_PUT: Elements of type character. len is the number of characters to transfer. The actual character lengths of the source and target variables are ignored. (literally ignored. not even a little bit consulted. πŸ’€)
  • SHMEM_COMPLEX_PUT: Elements of type complex of default size.
  • SHMEM_DOUBLE_PUT: (Fortran) Elements of type double precision.
  • SHMEM_INTEGER_PUT: Elements of type integer.
  • SHMEM_LOGICAL_PUT: Elements of type logical.
  • SHMEM_REAL_PUT: Elements of type real. If you're using Fortran, data types must be of default size. For example, a real variable must be declared as REAL, REAL*4, or REAL(KIND=4).

⭐ EXAMPLES ⭐

The following shmem_put example is for C/C++ programs:

#include <stdio.h>
#include <mpp/shmem.h>

main()
{
  long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  static long target[10];
  shmem_init();

  if (shmem_my_pe() == 0) {
    /* put 10 words into target on PE 1 */
    shmem_long_put(target, source, 10, 1);
  }
  shmem_barrier_all();  /* sync sender and receiver */
  if (shmem_my_pe() == 1)
    shmem_udcflush();  /* not required on Altix systems */
  printf("target[0] on PE %d is %d\n", shmem_my_pe(), target[0]);
}

look at that. shmem_barrier_all() syncing sender and receiver like a good group chat moderator. and heads up, that shmem_udcflush() call is not required on Altix systems β€” it says so right there in the comment, iykyk. 😌


πŸ‘€ SEE ALSO πŸ‘€


fair warning bestie: remember the delivery-order thing. if you need your puts to land in a specific order, you need shmem_fence(3) in between. otherwise it's chaos and chaos is not the aesthetic here. πŸ’…

Copyright β€” 2003-2026, The Open MPI Community 🫢

and that's a wrap on the SHMEM_PUTMEM(3) page, dated Sep 10, 2026, from the Open MPI girlies to you. go put some data somewhere cute. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from