mpi-communicator-duplication
Table of Contents
MPI Communicator duplication
Communicator duplication prevents libraries from intercepting application messages. MPI_Comm_dup creates a new communicator with its own tag namespace.
MPI_Comm lib_comm; MPI_Comm_dup(MPI_COMM_WORLD, &lib_comm); library_init(lib_comm); // all internal library traffic uses lib_comm // ... MPI_Comm_free(&lib_comm);
Passing MPI_COMM_WORLD directly into a third-party library is unsafe: the library's internal messages can be matched by wildcards in the application and vice versa, producing message mismatches that are difficult to diagnose. The convention is for any reusable MPI code to accept a communicator argument and duplicate it internally rather than operating on the passed communicator directly.
mpi-communicator-duplication.md · Last modified: by 127.0.0.1
