Trisha Shetty (Editor)

SHMEM

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

SHMEM (from Symmetric Hierarchical Memory access) is a family of parallel programming libraries, initially providing remote memory access for big shared-memory supercomputers using one-sided communications. 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. The first SHMEM library, libsma, was created by Cray in 1993. Later the SHMEM was also implemented by SGI, Quadrics, HP, GSHMEM, IBM, QLogic, Mellanox, Universities of Houston and Florida; there is also open-source OpenSHMEM.

Contents

Historically, SHMEM, the earliest one-sided library, made the one-sided parallel programming paradigm popular.

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 PEs has some of it memory declared as "symmetric" segment (or shared memory area) and other memory is private. Only "shared" memory can be accessed in one-sided operation from remote PEs. It is possible to create symmetric objects which has same address on every PE.

Typical SHMEM functions

  • start_pes(N) - start N 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

  • SGI: SGI-SHMEM for systems with NUMALink and Altix build with Infiniband network adapters
  • Cray's original SHMEM for T3D, T3E, PVP supercomputers
  • Cray: MP-SHMEM for Unicos MP (X1E supercomputer)
  • Cray: 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
  • ----- OpenSHMEM implementations (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
  • Disadvantages

    In first years SHMEM was accessible only on some Cray machines (later additionally on SGI) equipped with special networks, limiting library widespread and being vendor lock-in (for example, Cray recommends 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.

    Some SHMEM routines were designed according to Cray T3D architecture limitations, for example reductions and broadcasts could be started only on subsets of PEs with size being power of two.

    Now there are variants of SHMEM libraries, which 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.

    SHMEM is available only for C and Fortran (some versions also to C++).

    References

    SHMEM Wikipedia