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