gpt4 book ai didi

c - MPI 中派生数据类型的范围

转载 作者:行者123 更新时间:2023-11-30 16:51:45 24 4
gpt4 key购买 nike

我正在尝试为 2D 子矩阵创建数据类型并使用 MPI 处理它。到目前为止我发现的是 this问题。它的回答完全涵盖了我的问题。我唯一无法理解的是如何计算子数组数据类型的范围。任何解释都会非常有帮助。

这是从该问题的答案中复制的代码和语句:

MPI_Datatype newtype;
int sizes[2] = {6,6}; /* size of global array */
int subsizes[2] = {3,3}; /* size of sub-region */
int starts[2] = {0,0}; /* let's say we're looking at region "0",
which begins at index [0,0] */

MPI_Type_create_subarray(2, sizes, subsizes, starts, MPI_ORDER_C, MPI_INT, &newtype);
MPI_Type_commit(&newtype);

We couldn't just use MPI_Scatter() (or even scatterv) with these types yet, because these types have an extent of 16 integers;

最佳答案

事实上,我认为它们的范围是 36 个整数而不是 16?无论如何,您是正确的,这个范围意味着在 Scatter 或 Scatterv 操作中子数组类型并不容易。

您需要使用 MPI_Type_create_resized 将范围修复为更有用的内容,例如一个整数。

我在 C - MPI - Send/Receive Subarrays to Array 中回答了类似的问题- Jonathan Dursi 在 sending blocks of 2D array in C using MPI 中发布了更完整的解释。

关于c - MPI 中派生数据类型的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41611528/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com