Files
rocm-systems/README.md
T

195 lines
7.8 KiB
Markdown
Raw Normal View History

2024-11-25 14:12:15 -06:00
# ROCm OpenSHMEM (rocSHMEM)
2024-07-01 09:57:08 -05:00
2024-11-25 14:12:15 -06:00
The ROCm OpenSHMEM (rocSHMEM) runtime is part of an AMD Research
2024-07-01 09:57:08 -05:00
initiative to provide a unified runtime for heterogeneous systems.
2024-11-25 14:12:15 -06:00
rocSHMEM supports both host-centric (a traditional host-driven
2024-07-01 09:57:08 -05:00
OpenSHMEM runtime) and GPU-centric networking (provided a GPU kernel
the ability to perform network operations) through an
OpenSHMEM-like interface. This intra-kernel networking simplifies application
code complexity and enables more fine-grained communication/computation
overlap than traditional host-driven networking.
2024-11-25 14:12:15 -06:00
rocSHMEM's primary target is heterogeneous computing; hence, for both
CPU-centric and GPU-centric communications, rocSHMEM uses a single
2024-07-01 09:57:08 -05:00
symmetric heap (SHEAP) that is allocated on GPU memories.
2024-11-25 14:12:15 -06:00
rocSHMEM's GPU-centric communication has two different backend designs.
2024-07-01 09:57:08 -05:00
The backends primarily differ in their implementations of
intra-kernel networking.
The first design will be referred to as the the GPU InfiniBand (GPU-IB)
backend. This backend implements a lightweight InfiniBand verbs interface
on the GPU. The GPU itself is responsible with building commands and ringing
the doorbell on the NIC to send network commands. GPU-IB is the default and
preferred backend design that offers the best performance.
The second design will be referred to as the Reverse Offload (RO) backend. With
2024-11-25 14:12:15 -06:00
the RO backend, the GPU runtime forwards rocSHMEM networking operations to the
2024-07-01 09:57:08 -05:00
host-side runtime, which calls into a traditional MPI or OpenSHMEM
implementation. This forwarding of requests is transparent to the
programmer, who only sees the GPU-side interface.
Both designs of the GPU-centric interface coexist seamlessly with the
2024-11-25 14:12:15 -06:00
CPU-centric interface of the unified runtime. rocSHMEM ensures that CPU-centric
2024-07-01 09:57:08 -05:00
updates to the SHEAP are consistent and visible to a GPU kernel that is executing
in parallel to host-initiated communication.
## Limitations
2024-11-25 14:12:15 -06:00
rocSHMEM is an experimental prototype from AMD Research and not an official
2024-07-01 09:57:08 -05:00
ROCm product. The software is provided as-is with no guarantees of support
from AMD or AMD Research.
2024-11-25 14:12:15 -06:00
rocSHMEM base requirements:
2024-07-01 09:57:08 -05:00
* ROCm version 4.3.1 onwards
* May work with other versions, but not tested
* AMD GFX9 GPUs (e.g.: MI25, Vega 56, Vega 64, MI50, MI60, MI100, Radeon VII)
* AMD MI200 GPUs: To enable the support on MI200, please configure the library
2024-07-15 10:18:20 -05:00
with USE_COHERENT_HEAP
2024-07-01 09:57:08 -05:00
* ROCm-aware MPI as described in
[Building the Dependencies](#building-the-dependencies)
* InfiniBand adaptor compatable with ROCm RDMA technology
* UCX 1.6 or greater with ROCm support
2024-11-25 14:12:15 -06:00
rocSHMEM optional requirements
2024-07-01 09:57:08 -05:00
* For Documentation:
* Doxygen
2024-11-25 14:12:15 -06:00
rocSHMEM only supports HIP applications. There are no plans to port to
2024-07-01 09:57:08 -05:00
OpenCL.
## Building and Installation
2024-11-25 14:12:15 -06:00
rocSHMEM uses the CMake build system. The CMakeLists file contains
2024-07-01 09:57:08 -05:00
additional details about library options.
To create an out-of-source build:
mkdir build
cd build
Next, choose one configuration from the build_configs subdirectory. These
scripts pass configuration options to CMake to setup canonical builds which
are regularly tested:
../scripts/build_configs/dc_single
../scripts/build_configs/dc_multi
../scripts/build_configs/rc_single
../scripts/build_configs/rc_multi
../scripts/build_configs/rc_multi_wf_coal
../scripts/build_configs/ro_net_basic
By default, the library is installed in `~/rocshmem`. You may provide a
custom install path by supplying it as an argument. For example:
../scripts/build_configs/rc_single /path/to/install
2024-11-25 14:12:15 -06:00
## Compiling/linking and Running with rocSHMEM
2024-07-01 09:57:08 -05:00
2024-11-25 14:12:15 -06:00
rocSHMEM is built as a host and device side library that can be statically
2024-07-01 09:57:08 -05:00
linked to your application during compilation using hipcc.
2024-11-25 14:12:15 -06:00
During the compilation of your application, include the rocSHMEM header files
and the rocSHMEM library when using hipcc:
2024-07-01 09:57:08 -05:00
-I/path/to/rocshmem/install/include
-L/path/to/rocshmem/install/lib -lrocshmem
2024-11-25 14:12:15 -06:00
NOTE: rocSHMEM depends on MPI for its host code. So, you will need to link
2024-07-01 09:57:08 -05:00
to an MPI library. Since you must use the hipcc compiler, the arguments for
MPI linkage must be added manually as opposed to using mpicc. Similary,
2024-11-25 14:12:15 -06:00
rocSHMEM depends on Verbs for its device code. So, you will need to link
2024-07-01 09:57:08 -05:00
to a Verbs library.
When using hipcc directly (as opposed to through a build system), we
recommend performing the compilation and linking steps separately.
Here are the steps to build a standalone program, say
2024-11-25 14:12:15 -06:00
rocshmem_hello.cpp.
2024-07-01 09:57:08 -05:00
```
# Compile
2024-11-25 14:12:15 -06:00
/opt/rocm/bin/hipcc ./rocshmem_hello.cpp -I/path/to/rocshmem/install/include -fgpu-rdc -o ./rocshmem_hello.o -c
2024-07-01 09:57:08 -05:00
# Link
2024-11-25 14:12:15 -06:00
/opt/rocm/bin/hipcc ./rocshmem_hello.o /path/to/rocshmem/install/lib/librocshmem.a -lmpi -lmlx5 -libverbs -lhsa-runtime64 -fgpu-rdc -o rocshmem_hello
2024-07-01 09:57:08 -05:00
```
If your project uses cmake, please refer to the CMakeLists.txt files
in the clients directory for examples. You may also find the
[Using CMake with AMD ROCm](https://rocmdocs.amd.com/en/latest/conceptual/cmake-packages.html)
page useful.
## Runtime Parameters
2024-11-25 14:12:15 -06:00
ROCSHMEM_HEAP_SIZE (default : 1 GB)
2024-07-01 09:57:08 -05:00
Defines the size of the OpenSHMEM symmetric heap
Note the heap is on the GPU memory.
2024-11-25 14:12:15 -06:00
ROCSHMEM_SQ_SIZE (default 1024)
2024-07-01 09:57:08 -05:00
Defines the size of the SQ as number of network
packet (WQE). Each WQE is 64B. This only for
GPU-IB conduit
2024-11-25 14:12:15 -06:00
ROCSHMEM_USE_CQ_GPU_MEM (default : 1)
2024-07-01 09:57:08 -05:00
Set the placement of CQ on GPU memory (1)
or CPU memory (0)
2024-11-25 14:12:15 -06:00
ROCSHMEM_USE_SQ_GPU_MEM (default : 1)
2024-07-01 09:57:08 -05:00
Set the placement of SQ on GPU memory (1)
or CPU memory (0)
RO_NET_CPU_QUEUE (default: not set)
Force producer/consumer queues between CPU and GPU to
be in CPU memory. RO backend only.
2024-11-25 14:12:15 -06:00
rocSHMEM also requires the following environment variable be set for ROCm:
2024-07-01 09:57:08 -05:00
export HSA_FORCE_FINE_GRAIN_PCIE=1
## Documentation
2024-11-25 14:12:15 -06:00
To generate doxygen documentation for rocSHMEM's API, run the following
2024-07-01 09:57:08 -05:00
from the library's build directory:
make docs
The doxygen output will be in the `docs` folder of the build directory.
## Examples
2024-11-25 14:12:15 -06:00
rocSHMEM is similar to OpenSHMEM and should be familiar to programmers who
2024-07-01 09:57:08 -05:00
have experience with OpenSHMEM or other PGAS network programming APIs in the
2024-11-25 14:12:15 -06:00
context of CPUs. The best way to learn how to use rocSHMEM is to read the
2024-07-01 09:57:08 -05:00
autogenerated doxygen documentation for functions described in
2024-11-25 14:12:15 -06:00
`rocshmem/rocshmem.hpp`, or to look at the provided sample applications in the
`tests/` folder. rocSHMEM is shipped with a basic test suite for the
supported rocSHMEM API. The examples test Puts, Gets, nonblocking Puts,
2024-07-01 09:57:08 -05:00
nonblocking Gets, Quiets, Atomics, Tests, Wai-untils, Broadcasts, and
Reductions.
To run the examples, you may use the driver scripts provided in respective
folders of device- or host-initiated communication examples. Simply
executing `./driver.sh` will show the help message on how to use the script.
Here are some example uses of the driver script:
./scripts/functional_tests/driver.sh ./build/rocshmem_example_driver single_thread ./build (for device-initiated communication)
./scripts/sos_tests/driver.sh ./build short (for host-initiated communication)
## Building the Dependencies
2024-11-25 14:12:15 -06:00
rocSHMEM requires an MPI runtime on the host that supports ROCm-Aware MPI.
2024-07-01 09:57:08 -05:00
Currently all ROCm-Aware MPI runtimes require the usage of ROCm-Aware UCX.
To build and configure ROCm-Aware UCX, you need to:
1. Download the latest UCX
2. Configure and build UCX with ROCm support: --with-rocm=/opt/rocm
Then, you need to build your MPI (OpenMPI or MPICH CH4) with UCX support.
For more information on OpenMPI-UCX support, please visit:
https://github.com/openucx/ucx/wiki/OpenMPI-and-OpenSHMEM-installation-with-UCX
For more information on MPICH-UCX support, please visit:
https://www.mpich.org/about/news/