Boost C++ 库
...目前世界上最受推崇、设计最精巧的 C++ 库项目之一。
— Herb Sutter 和 Andrei Alexandrescu, C++ Coding Standards
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()) 范围内。 |