ArticleslgStudy

computer science

SHMEM

SHMEM is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand SHMEM rather than just read about it. In short: SHMEM (from Cray Research's “shared memory” library) is a family of parallel programming libraries, providing one-sided, RDMA, parallel-processing interfaces for low-latency distributed-memory supercomputers. The SHMEM acronym was subsequently reverse engineered to mean "Symmetric Hierarchical MEMory”.

Key takeaways

  • SHMEM belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect SHMEM to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of SHMEM from memory before moving on to harder problems.

Reference excerpt

SHMEM (from Cray Research's “shared memory” library) is a family of parallel programming libraries, providing one-sided, RDMA, parallel-processing interfaces for low-latency distributed-memory supercomputers. The SHMEM acronym was subsequently reverse engineered to mean "Symmetric Hierarchical MEMory”. Later it was expanded to distributed memory parallel computer clusters, and is used as parallel programming interface or as low-level interface to build partitioned global address space (PGAS) systems and languages. “Libsma”, the first SHMEM library, was created by Richard Smith at Cray Research in 1993 as a set of thin interfaces to access the CRAY T3D's inter-processor-communication hardware. SHMEM has been implemented by Cray Research, SGI, Cray Inc., Quadrics, HP, GSHMEM, IBM, QLogic, Mellanox, Universities of Houston and Florida, Stony Brook University, and Texas-Tech University; there is also open-source OpenSHMEM. SHMEM laid the foundations for low-latency (sub-microsecond) one-sided communication. After its use on the CRAY T3E, its popularity waned as few machines could deliver the near-microsecond latencies necessary to maintain efficiency for its hallmark individual-word communication. With the advent of popular sub-microsecond interconnects, SHMEM has been used to address the necessity of hyper-efficient, portable, parallel-communication methods for exascale computing. Programs written using SHMEM can be started on several computers, connected together with some high-performance network, supported by used SHMEM library. Every computer runs a copy of a program (SPMD); each copy is called PE (processing element). PEs can ask the SHMEM library to do remote memory-access operations, like reading ("shmem_get" operation) or writing ("shmem_put" operation) data. Peer-to-peer operations are one-sided, which means that no active cooperation from remote thread is needed to complete the action (but it can poll its local memory for changes using "shmem_wait"). Operations can be done on short types like bytes or words, or on longer datatypes like arrays, sometimes evenly strided or indexed (only some elements of array are sent). For short datatypes, SHMEM can do atomic operations (CAS, fetch and add, atomic increment, etc.) even in remote memory. Also there are two different synchronization methods: task control sync (barriers and locks) and functions to enforce memory fencing and ordering. SHMEM has several collective operations, which should be started by all PEs, like reductions, broadcast, collect. Every PE has some of its memory declared as "symmetric" segments (or shared memory area), and other memory is private. Only "shared" memory can be accessed in one-sided operation from remote PEs. Programmers can use static-memory constructs or shmem_malloc/shmem_free routines to create objects with symmetric addresses that span the PEs.

Typical SHMEM functions init() — start all processing elements (PE) _my_pe() — ask SHMEM to return the PE identifier of current thread shmem_barrier_all() — wait until all PEs run up to barrier; then enable them to go further shmem_put(target, source, length, pe) — write data of length "length" to the remote address "target" on PE with id "pe" from local address "source" shmem_get(target, source, length, pe) — read data of length "length" from the remote address "source" on PE with id "pe" and save to read values into local address "target"

List of SHMEM implementations Cray Research: Original SHMEM for Cray T3D, Cray T3E, and Cray Research PVP supercomputers SGI: SGI-SHMEM for systems with NUMAlink and Altix build with InfiniBand network adapters Cray Inc.: MP-SHMEM for Unicos MP (X1E supercomputer) Cray Inc.: LC-SHMEM for Unicos LC (Cray XT3, XT4, XT5) Quadrics: Q-SHMEM for Linux clusters with QsNet interconnect Cyclops-64 SHMEM HP SHMEM IBM SHMEM GPSHMEM NVSHMEM is based on the OpenSHMEM API and supports GPUs, including both host- and device-initiated communication.

OpenSHMEM implementations OpenSHMEM is a standard effort by SGI and Open Source Software Solutions, Inc.

University of Houston: Reference OpenSHMEM Mellanox ScalableSHMEM Portals-SHMEM (on top of Portals interface) University of Florida: Gator SHMEM Open MPI includes an implementation of OpenSHMEM Adapteva Epiphany Coprocessor Sandia OpenSHMEM (SOS) supports multiple networking APIs OpenSHMEM over MPI (OSHMPI) version 1 is based on MPI one-sided communication and supports the OpenSHMEM 1.2 specification OpenSHMEM over MPI (OSHMPI) version 2 is based on MPI one-sided communication and supports the OpenSHMEM 1.4 specification MVAPICH2-X includes an OpenSHMEM implementation shmem4py provides Python support for the OpenSHMEM 1.5 specification functionality, as a wrapper around a C implementation.

Disadvantages In first years SHMEM was accessible only on some Cray Research machines (later additionally on SGI) equipped with special networks, limiting library widespread and being vendor lock-in (for example, Cray Research recommended to partially rewrite MPI programs to combine both MPI and shmem calls, which make the program non-portable to other clear-MPI environment). SHMEM was not defined as standard, so there were created several incompatible variants of SHMEM libraries by other vendors. Libraries had different include file names, different management function names for starting PEs or getting current PE id, and some functions were changed or not supported. Variants of SHMEM libraries can run on top of any MPI library, even when a cluster has only non-RDMA optimized Ethernet, however the performance will be typically worse than other enhanced networking protocols. Memory in shared region should be allocated using special functions (shmalloc/shfree), not with the system malloc. Many disadvantages of SHMEM have been overcome with the use of OpenSHMEM on popular sub-microsecond interconnects, driven by exascale development.

See also Message Passing Interface (especially one-sided operations of MPI-2) Active Messages Unified Parallel C (one of PGAS languages, can be implemented on top of SHMEM)

References

Further reading Shared Memory Access (SHMEM) Routines // Cray Research, 1995

External links Using SHMEM on the CRAY T3E man intro_shmem (SGI TPL) - Introduction to the SHMEM programming model OpenSHMEM: an effort to create a specification for a standardized API for parallel programming in the Partitioned Global Address Space.

Worked examples

Example 1 — a first encounter with SHMEM

Start with the simplest possible case. Write down what SHMEM claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to SHMEM before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about SHMEM ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of SHMEM

In research
SHMEM appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses SHMEM in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
SHMEM is common in secondary-school and first-year university syllabi. It links to neighbouring topics Application programming interfaces, Parallel computing, so understanding it makes those chapters shorter.
In everyday life
Look for SHMEM outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “SHMEM” →

How to study SHMEM in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what SHMEM means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain SHMEM out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is SHMEM in simple terms?

SHMEM (from Cray Research's “shared memory” library) is a family of parallel programming libraries, providing one-sided, RDMA, parallel-processing interfaces for low-latency distributed-memory supercomputers. The SHMEM acronym was subsequently reverse engineered to mean "Symmetric Hierarchical MEMo…

Why does SHMEM matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study SHMEM?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on SHMEM.

Tags

  • Application programming interfaces
  • Parallel computing

Keep exploring