Boost C++ 库

...目前世界上最受推崇、设计最精巧的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

Class cartesian_communicator - Boost C++ 函数库
PrevUpHomeNext

Class cartesian_communicator

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 公有成员函数

  1. 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 相关联:

    • 如果 kindcomm_duplicate,则复制 comm 来创建一个新的通讯器。这个新通讯器将在 Boost.MPI 通讯器(及其所有副本)被销毁时被释放。仅当底层 MPI 实现支持 MPI 2.0 时才允许此选项;MPI 1.x 中不支持复制外部通讯器。

    • 如果 kindcomm_take_ownership,则获取 comm 的所有权。当所有 Boost.MPI 通信器超出作用域时,它将被自动释放。

    • 如果 kindcomm_attach,则此 Boost.MPI 通讯器将引用现有的 MPI 通讯器 comm,但在 Boost.MPI 通讯器超出作用域时不会释放 comm。只有当通讯器由用户管理时才应使用此选项。

  2. cartesian_communicator(const communicator & comm, 
                           const cartesian_topology & dims, bool reorder = false);

    创建一个新的通讯器,其拓扑由给定的笛卡尔图描述。笛卡尔图中的顶点索引将被假定为通讯器中进程的秩。笛卡尔图中可能比通讯器中的进程数少;在这种情况下,结果通讯器将是一个 NULL 通讯器。

    参数

    comm

    新笛卡尔通讯器将基于的通讯器。

    dims

    新通讯器的笛卡尔维度。大小表示维度的数量。某些维度可以设置为零,在这种情况下,相应的维度值将留给系统。

    reorder

    是否允许 MPI 重新排序返回通讯器内的进程秩,以更好地优化通信。如果为 false,则返回进程中的每个进程的秩将与该进程在原始通讯器内的秩精确匹配。

  3. cartesian_communicator(const cartesian_communicator & comm, 
                           const std::vector< int > & keep);

    创建一个新的笛卡尔通讯器,其拓扑是现有笛卡尔通讯器的子集。

    参数

    comm

    原始通讯器。

    keep

    包含要从现有通讯器中保留的维度的数组。

  4. int ndims() const;

    检索底层拓扑的维度数量。

  5. int rank(const std::vector< int > & coords) const;

    返回给定坐标处的进程的秩。

    参数

    coords

    坐标。大小必须与通讯器的拓扑匹配。

  6. std::pair< int, int > shifted_ranks(int dim, int disp) const;

    通过移位返回源和目标进程的秩。

    参数

    dim

    发生移位的维度。0 <= dim <= ndim()。

    disp

    移位距离,可以是正数(向上)或负数(向下)。

  7. std::vector< int > coordinates(int rk) const;

    提供具有给定秩的进程的坐标。

    参数

    rk

    此通讯器中的秩。

    返回

    坐标。

  8. void topology(cartesian_topology & dims, std::vector< int > & coords) const;

    检索此进程在网格中的拓扑和坐标。

  9. cartesian_topology topology() const;

    检索网格的拓扑。

  10. int rank() const;
    确定执行进程在通讯器中的秩。

    此例程等同于 MPI_Comm_rank

    返回

    进程在通讯器中的秩,其值将在 [0, size()) 范围内。


PrevUpHomeNext