11Shared Memory
22=============
33
4- .. error :: TODO This section needs to be converted from FAQ Q&A style
5- to regular documentation style.
64
7- What is the sm BTL?
8- -------------------
5+ The sm BTL
6+ ----------
97
108The ``sm `` BTL is a low-latency, high-bandwidth mechanism for
119transferring data between two processes via shared memory. This BTL
@@ -26,8 +24,8 @@ can only be used between processes executing on the same node.
2624
2725/////////////////////////////////////////////////////////////////////////
2826
29- How do I specify use of sm for MPI messages?
30- --------------------------------------------
27+ Specifying the Use of sm for MPI Messages
28+ -----------------------------------------
3129
3230Typically, it is unnecessary to do so; OMPI will use the best BTL available
3331for each communication.
@@ -44,8 +42,8 @@ communications. For example:
4442
4543 /////////////////////////////////////////////////////////////////////////
4644
47- How can I tune these parameters to improve performance?
48- -------------------------------------------------------
45+ Tuning Parameters to Improve Performance
46+ ----------------------------------------
4947
5048Mostly, the default values of the MCA parameters have already
5149been chosen to give good performance. To improve performance further
@@ -71,21 +69,107 @@ performance for memory.
7169 to resource congestion, but you can increase this parameter to
7270 pre-reserve space for more fragments.
7371
72+ * ``btl_sm_backing_directory ``: Directory to place backing files for
73+ shared memory communication. This directory should be on a local
74+ filesystem such as /tmp or /dev/shm (default: (linux) /dev/shm,
75+ (others) session directory)
76+
7477/////////////////////////////////////////////////////////////////////////
7578
76- Where is the shared memory mapped on the filesystem?
79+ Shared Memory Mechanisms
80+ ------------------------
81+
82+ The ``sm `` BTL supports two modes of shared memory communication:
83+
84+ #. **Two-copy: ** Otherwise known as "copy-in / copy-out", this mode is
85+ where the sender copies data into shared memory and the receiver
86+ copies the data out.
87+
88+ This mechanism is always available.
89+
90+ #. **Single copy: ** In this mode, the sender or receiver makes a
91+ single copy of the message data from the source buffer in one
92+ process to the destination buffer in another process. Open MPI
93+ supports three flavors of shared memory single-copy transfers:
94+
95+ * `Linux KNEM <https://knem.gitlabpages.inria.fr/ >`_. This is a
96+ standalone Linux kernel module, made specifically for HPC and MPI
97+ libraries to enable high-performance single-copy message
98+ transfers.
99+
100+ Open MPI must be able to find the KNEM header files in order to
101+ build support for KNEM.
102+
103+ * `Linux XPMEM <https://github.com/hjelmn/xpmem >`_. Similar to
104+ KNEM, this is a standalone Linux kernel module, made specifically
105+ for HPC and MPI libraries to enable high-performance single-copy
106+ message transfers. It is derived from the Cray XPMEM system.
107+
108+ Open MPI must be able to find the XPMEM header files in order to
109+ build support for XPMEM.
110+
111+ * Linux Cross-Memory Attach (CMA). This mechanism is built-in to
112+ modern versions of the Linux kernel. Although more performance
113+ than the two-copy shared memory transfer mechanism, CMA is the
114+ lowest performance of the single-copy mechanisms. However, CMA
115+ is likely the most widely available because it is enabled by
116+ default in several modern Linux distributions.
117+
118+ Open MPI must be built on a Linux system with a recent enough
119+ Glibc and kernel version in order to build support for Linux CMA.
120+
121+ Which mechanism is used at run time depends both on how Open MPI was
122+ built and how your system is configured. You can check to see which
123+ single-copy mechanisms Open MPI was built with via two mechanisms:
124+
125+ #. At the end of running ``configure ``, Open MPI emits a list of
126+ transports for which it found relevant header files and libraries
127+ such that it will be able to build support for them. You might see
128+ lines like this, for example:
129+
130+ .. code-block :: text
131+
132+ Shared memory/copy in+copy out: yes
133+ Shared memory/Linux CMA: yes
134+ Shared memory/Linux KNEM: no
135+ Shared memory/XPMEM: no
136+
137+ The above output indicates that Open MPI will be built with 2-copy
138+ (as mentioned above, 2-copy is *always * available) and with Linux
139+ CMA support. KNEM and XPMEM support will *not * be built.
140+
141+ #. After Open MPI is installed, the ``ompi_info `` command can show
142+ which ``smsc `` (shared memory single copy) components are
143+ available:
144+
145+ .. code-block :: text
146+
147+ shell$ ompi_info | grep smsc
148+ MCA smsc: cma (MCA v2.1.0, API v1.0.0, Component v5.1.0)
149+
150+ This Open MPI installation only supports the Linux CMA single-copy
151+ mechanism.
152+
153+ .. note :: As implied by the SMSC component names, none of them are
154+ supported on macOS. macOS users will use the two-copy mechanism.
155+
156+ /////////////////////////////////////////////////////////////////////////
77157
78- .. error :: TODO Is this correct?
158+ Shared Memory Mapping on the Filesystem
159+ ---------------------------------------
79160
80- The file will be in the OMPI session directory, which is typically
81- something like `` /tmp/openmpi-sessions-USERNAME@HOSTNAME/* ``.
82- The file itself will have the name
83- ``shared_mem_pool.HOSTNAME ``. For example, the full path could be
84- ``/tmp/openmpi-sessions-johndoe@node0_0/1543/1/shared_mem_pool.node0 ``.
161+ The default location of the file is in the `` /dev/shm directory``. If `` /dev/shm ``
162+ does not exist on the system, the default location will be the OMPI session
163+ directory. The path is typically something like:
164+ ``/dev/shm/sm_segment.nodename.user_id.job_id.my_node_rank ``.
165+ For example, the full path could be: ``/dev/shm/sm_segment.x.1000.23c70000.0 ``.
85166
86- .. error :: TODO The filename above will certainly be wrong.
167+ You can use the MCA parameter ``btl_sm_backing_directory `` to place the session
168+ directory in a non-default location.
87169
88- To place the session directory in a non-default location, use the MCA parameter
89- ``orte_tmpdir_base ``.
170+ .. note :: The session directory is defined in PMIx. You can
171+ use ``--pmixmca orte_tmpdir_base "/path/to/somewhere" `` to place the session
172+ directory in a non-default location.
90173
91- .. error :: TODO The MCA param name above is definitely wrong.
174+ .. note :: Even when using single-copy methods like CMA, a shared memory file is still
175+ created for managing connection metadata.
0 commit comments