如何正确使用MPI_Scaterv()
how to use MPI_Scatterv() properly
我在并行程序中使用MPI_Scatterv
时遇到问题。以下是它的定义:
int MPI_Scatterv(const void *sendbuf, const int *sendcounts,
const int *displs, MPI_Datatype sendtype, void *recvbuf,
int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
按照我的理解,MPI_Scatterv
和MPI_Scatter
之间的区别在于,在MPI_Scatterv
中,段不必具有相同的长度,也不必是连续的(允许内存中存在间隙)。我不明白的是,如果recvbuf
可以是每个进程的不同大小的数组,那么recvcount
应该使用什么。假设我想向进程0发送sendbuf的5个元素,向进程1发送15个元素。recvcount
的值应该是多少?
每个进程都必须用正确的recvcount
调用MPI_Scatterv
。您可以传递一个变量,该变量的值取决于每个进程的级别。
例如:
int recvcount = (rank == 0) ? 5 : 15;
MPI_Scatterv( sendbuf, sendcounts, displs, sendtype,
recvbuf, recvcount, recvtype, 0, MPI_COMM_WORLD );
具有秩0
的进程调用具有5
的recvcount
的MPI_Scatterv
,而进程1
通过15
的计数。
相关文章:
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- MPI突然停止了对多个核心的操作
- 设置 Visual Studio for MPI: 找不到标识符错误
- 使用 make 编译 MPI,几个命名空间错误,例如"错误:未知类型名称'使用'?
- 如何使用 MPI 的远程内存访问 (RMA) 功能并行化数据聚合?
- 重载 MPI 中的运算符 ()
- MPI:检查是否有任何进程已终止
- 使用 pybind11 共享 MPI 通信器
- 使用 CMake,Microsoft MPI 和 Visual Studio 2017 找不到 mpi.h
- 在具有 MPI 的超立方体中广播
- 通过 mpi 发送 c++ 标准::矢量<bool>
- 使用 MPI 的 C++ 中的并行 for 循环
- 如何将 OpenMP 和 MPI 导入到大型 CLion CMake 项目中?
- 如何通过Boost.MPI发送2d Boost.MultiArray的子阵列?
- HDF5 构建了并行支持,但找不到特定于 mpi 的功能
- MPI 集合通信中的指针分配
- 仅特定内核计数上的 MPI 内存损坏
- 如何在 Mac OS 上安装 boost-mpi 及其对 clang 的依赖关系?
- 从Visual Studio 2017运行MPI应用程序,每个进程在不同的cmd窗口中
- 在 MPI 中共享数组的一部分