boost::mpi::cartesian_communicator — 具有笛卡尔拓扑的 MPI 通信器。
// In header: <boost/mpi/cartesian_communicator.hpp> class cartesian_communicator : public boost::mpi::communicator { public: // public member functions cartesian_communicator(const MPI_Comm &, comm_create_kind); cartesian_communicator(const communicator &, const cartesian_topology &, bool = false); cartesian_communicator(const cartesian_communicator &, const std::vector< int > &); int ndims() const; int rank(const std::vector< int > &) const; std::pair< int, int > shifted_ranks(int, int) const; std::vector< int > coordinates(int) const; void topology(cartesian_topology &, std::vector< int > &) const; cartesian_topology topology() const; int rank() const; };
cartesian_communicator
是一个拓扑表示为网格的通信器。笛卡尔通信器具有与(内部)通信器相同的功能,还可以查询进程之间的关系以及网格的属性。
cartesian_communicator
公共成员函数cartesian_communicator(const MPI_Comm & comm, comm_create_kind kind);
基于具有笛卡尔拓扑的 MPI 通信器 comm
构建一个新的 Boost.MPI 笛卡尔通信器。
comm
可以是任何有效的 MPI 通信器。如果 comm
是 MPI_COMM_NULL,则会创建一个空的通信器(不能用于通信),并且 kind
参数将被忽略。否则,kind
参数决定了 Boost.MPI 通信器将如何与 comm
相关联:
如果 kind
是 comm_duplicate
,则复制 comm
来创建一个新的通信器。当 Boost.MPI 通信器(及其所有副本)被销毁时,这个新的通信器也将被释放。此选项仅在底层 MPI 实现支持 MPI 2.0 时才允许;MPI 1.x 中不支持复制通信器。
如果 kind
为 comm_take_ownership
,则获取 comm
的所有权。当所有 Boost.MPI 通信器超出作用域时,它将被自动释放。
如果 kind
是 comm_attach
,此 Boost.MPI 通信器将引用现有的 MPI 通信器 comm
,但在 Boost.MPI 通信器超出范围时不会释放 comm
。仅当通信器由用户管理时,才应使用此选项。
cartesian_communicator(const communicator & comm, const cartesian_topology & dims, bool reorder = false);
创建一个新的通信器,其拓扑由给定的笛卡尔图描述。笛卡尔图中的顶点索引将被假定为通信器内进程的秩。笛卡尔图中可能比通信器中的进程数少;在这种情况下,结果通信器将是 NULL 通信器。
参数 |
|
cartesian_communicator(const cartesian_communicator & comm, const std::vector< int > & keep);
创建一个新的笛卡尔通信器,其拓扑是现有笛卡尔通信器的子集。
参数 |
|
int ndims() const;
检索底层拓扑的维度数。
int rank(const std::vector< int > & coords) const;
返回给定坐标处进程的秩。
参数 |
|
std::pair< int, int > shifted_ranks(int dim, int disp) const;
通过位移返回源和目标进程的秩。
参数 |
|
std::vector< int > coordinates(int rk) const;
提供具有给定秩的进程的坐标。
参数 |
|
||
返回 |
坐标。 |
void topology(cartesian_topology & dims, std::vector< int > & coords) const;
检索此进程在网格中的拓扑和坐标。
cartesian_topology topology() const;
检索网格的拓扑。
int rank() const;确定执行进程在通信器中的秩。
此例程等同于 MPI_Comm_rank
。
返回 |
进程在通信器中的秩,其值将在 [0, size()) 范围内。 |