mpi 中的 darray 和 subarray 有什么区别?

发布于 2024-11-02 03:50:33 字数 100 浏览 5 评论 0原文

我有一个用于并行编程类的并行 I/O 项目,并且我必须实现派生数据类型。我不太清楚darray和subarray之间的区别。 darray 是否可以从动态分配的数组派生?主要区别是什么?

I have a parallel I/O project for parallel programming class, and I have to implement derived datatypes. I didn't clearly understand the difference between darray and subarray. Can darray be derived from dynamically allocated arrays or not? And what is the main difference?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的軌跡 2024-11-09 03:50:33

子数组可让您描述较大多维数组的单个块/切片。如果每个 MPI 任务都有大型全局数组的单个切片/块(或者如果您在任务之间通信本地数组块),那么 MPI_Type_create_subarray 就是最佳选择;语法非常简单。对于求解常规网格上的偏微分方程之类的问题,这种分布非常常见 - 每个处理器都有自己的全局网格块,其中尽可能多的网格单元位于本地。在 MPI-IO 的情况下,每个 MPI 任务将创建一个与其全局数组的一部分相对应的子数组,并将其用作视图,将其部分域读入/写出到包含所有数据的文件。

MPI_Type_create_darray 允许比单块每个更复杂的分布式数组模式。对于分布式线性代数计算,逐行分布一些矩阵可能是有意义的 - 例如,如果有 5 个 mpi 任务,任务 0 获取第 0、5、10 行...,任务 1 获取第 1、6 行, 11,等等。其他矩阵可能按列分布;或者您可以将它们分布在行、列或两者的块中。这些数据分布与不幸的 HPF 中提供的数据分布相同,它允许您定义数据- 以这种方式逐个数组地并行布局数组。

我自己使用 MPI_Type_create_darray 的唯一方法,实际上也是我见过它使用的唯一方法,是创建一个大型矩阵的 MPI 文件视图,以将数据分布在 块循环 方式,以便可以读取文件,然后使用 scalapack 对分布式矩阵进行并行线性代数运算。

Subarray lets you describe a single block/slice of a larger multidimensional array. If every MPI task has a single slice/block of a large global array, (or if you are communicating chunks of local arrays between tasks) then MPI_Type_create_subarray is the way to go; the syntax is very straightforward. For solving things like PDEs on regular meshes, this distribution is very common - each processor has it's own chunk of the global grid, with as many of its grid cells local as possible. In the case of MPI-IO, each MPI task would create a subarray corresponding to it's piece of the global array, and use that as it's view to read in / write out its part of the domain to the file containing all of the data.

MPI_Type_create_darray allows more complex distributed array patterns than single-chunk-each. For distributed linear algebra computations, it might make sense to distribute some matrices row-by-row -- say, if there's 5 mpi tasks, task 0 gets row 0, 5, 10... and task 1 gets row 1, 6, 11, and so on. Other matrices might get distributed by columns; or you could distribute them in blocks of rows, columns, or both. These data distributions are the same as were available in the ill-fated HPF, which let you define data-parallel layouts of arrays in this way, on an array-by-array basis.

The only way I've ever used MPI_Type_create_darray myself, and indeed the only way I've ever seen it used, is to create an MPI file view of a large matrix to distribute the data in a block-cyclic fashion, so that one can read the file in and then use scalapack to do parallel linear algebra operations on the distributed matrix.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文