gpt4 book ai didi

c - MPI_Cart_create 给出 MPI_ERR_ARG

转载 作者:太空宇宙 更新时间:2023-11-04 02:53:21 25 4
gpt4 key购买 nike

这让我抓狂——我不知道我做错了什么。我一遍又一遍地查看 API。我知道 MPI_Cart_create 的签名:

int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims, int *periods, 
int reorder, MPI_Comm *comm_cart)

这是我的代码:

MPI_Init (&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &processCount);
MPI_Comm cart_com, old_com;
int ndims = 2;
int reorder = 0;
int dim_size[2], periods[2];
dim_size[0] = processCount;
dim_size[1] = processCount;
periods[0] = 1;
periods[1] = 1;
old_com = MPI_COMM_WORLD;
MPI_Cart_create(MPI_COMM_WORLD, ndims, dim_size, periods, reorder, &cart_com);

我得到错误:

[ubuntu:7975] *** An error occurred in MPI_Cart_create
[ubuntu:7975] *** on communicator MPI_COMM_WORLD
[ubuntu:7975] *** MPI_ERR_ARG: invalid argument of some other kind
[ubuntu:7975] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)

即使只是一点点提示也会很好......谢谢

最佳答案

你有 processCount进程,但您正在尝试创建一个通信器 processCount x processCount大小(总共产生 processCount ^2 个进程)。而且,作为 documentation会告诉你:

The call is erroneous if it specifies a grid that is larger than the group size.

试试这个:

dim_size[0] = processCount; 
dim_size[1] = 1;

关于c - MPI_Cart_create 给出 MPI_ERR_ARG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19849572/

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