Shared memory on a processor or node (SHM)

At the time of writing the MPI standard does not offer the possibility to address a common memory segment for a group of tasks on shared memory systems. Nevertheless shared memory can be used with the help of the Unix System V inter-process communication functions shmget, shmat [7], which allocate a memory segment and attach it to the memory space of each calling task.

The main steps to this algorithm are as follows:

  1. find the tasks belonging to the same processor or node (multiple processors that share memory) with ''mpi_get_processor_name'' procedure,
  2. allocate the memory needed to store the BC and attach it to the tasks memory space with shmget and shmat,
  3. pass the reference of the shared memory segment to the FORTRAN program via a Cray pointer.

The implementation uses a set of functions written in C which group the tasks that can use shared memory and create the shared memory segment for them. The subroutines that make available the shared memory to a FORTRAN pointer using Cray pointers are provided in a FORTRAN module [6].

There are two non-portable components in this implementation according to the CASINO coding standard (FORTRAN95+MPI), although widely available on currently used parallel computers: the shared memory subroutines, which are not portable on a all operating systems, and the Cray pointers, which are not FORTRAN 95 compliant.

In order to conform with CASINO portability requirements or for use in cases that do not need shared memory an alternative FORTRAN module is provided that implements the initial algorithm, that is, each task has a full copy of the BC. The user can switch between the two modules with the help of a makefile variable (CASINO does not use code preprocessing).