Communication backends#

cuFFTMp uses a communication library to move data between GPUs. cuFFTMp has two communication backends:

Select the backend#

The comm_type and comm_handle arguments select the backend. Give these arguments to cufftMpMakePlan, cufftMpMakePlanDecomposition or cufftMpMakeReshape.

comm_type

comm_handle

Backend

Initialization

CUFFT_COMM_MPI

A pointer to an MPI_Comm

NVSHMEM

cuFFTMp initializes NVSHMEM on the processes of the MPI communicator.

CUFFT_COMM_NONE

NULL

NVSHMEM

cuFFTMp initializes NVSHMEM as NVSHMEM_BOOTSTRAP specifies.

CUFFT_COMM_NCCL

A pointer to an ncclComm_t

NCCL

The application creates the NCCL communicator before it creates the plan.

With CUFFT_COMM_NONE, the default value of NVSHMEM_BOOTSTRAP is PMI. With Open MPI mpirun and the default bootstrap settings, each process starts alone. Plan creation then returns CUFFT_SUCCESS, and each process makes a plan for the whole array. To prevent this problem, set NVSHMEM_BOOTSTRAP=MPI.

The two backends use the same cuFFTMp API, the same data distributions and the same plan types. The differences are in the requirements, the memory rules and the performance.

Compare the backends#

NVSHMEM

NCCL

Library that cuFFTMp loads at run time

libnvshmem_host.so.3, version 3.8.0 or later

libnccl.so.2, version 2.30.7 or later

Data buffers for cufftExec*, cufftXtExec and cufftMpExecReshapeAsync

NVSHMEM symmetric memory (nvshmem_malloc), with the same size on all processes

Any device memory, for example from cudaMalloc. For the size, refer to Memory with NCCL.

Work area that the application supplies

NVSHMEM symmetric memory

Any device memory. Call cufftSetAutoAllocation(plan, 0) before you make the plan. Refer to Memory with NCCL.

Synchronization before an execution on user buffers

The application must make sure that the remote buffers are ready, for example with nvshmemx_sync_all_on_stream.

Not necessary

Interconnect

Peer-to-peer in a node or in one NVLink domain, GPUDirect RDMA over InfiniBand between nodes

All interconnects that NCCL supports

Workspace for the standalone reshape

Can be zero

Not zero

Use the NVSHMEM backend if your application already uses NVSHMEM.

Use the NCCL backend if your application already uses NCCL, or if the data must be in device memory from cudaMalloc. The NCCL backend does not use NVSHMEM.

Rules for the two communication backends#

One backend at a time#

All the plans and reshape handles that exist at the same time in a process must use the same backend. With NCCL, they must also use the same NCCL communicator. If not, plan or reshape creation returns CUFFT_INVALID_VALUE.

After the application destroys all the plans and reshape handles, it can use a different backend or a different NCCL communicator.

With NVSHMEM, use the same comm_type and the same MPI communicator for all the plans and reshapes in a process.

Concurrent executions#

Do not execute two cuFFTMp plans or reshapes at the same time on different streams.

All the plans and reshapes in a process can use the same barrier to synchronize the GPUs. If two executions use this barrier at the same time, a process can wait forever. A process can also leave the barrier before the other processes arrive, which gives incorrect results.

To prevent this problem, do one of these steps:

  • Execute all the cuFFTMp plans and reshapes on the same stream.

  • Synchronize the streams between the executions, for example with CUDA events.

On all processes, execute the plans and reshapes in the same order.

Library load errors#

cuFFTMp loads the communication library one time in a process, when the application creates the first plan or reshape that uses it. If this load fails, plan or reshape creation returns CUFFT_INTERNAL_ERROR. The load fails if cuFFTMp cannot find the library, if the version is not compatible, or if a necessary function is missing.

After a load failure, all later plan and reshape creations with the same backend in the process also fail. To recover, correct the installation and start the process again.

Diagnostics#

For messages from the communication library, set its debug variable, for example NVSHMEM_DEBUG=INFO or NCCL_DEBUG=INFO.