1

这让我发疯——我不知道我做错了什么。我一遍又一遍地查看 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)

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

4

2 回答 2

4

您有processCount进程,但您正在尝试创建一个大小为processCountx的通信器processCount(总共产生processCount^2 个进程)。而且,正如文档将告诉您的那样:

如果调用指定的网格大于组大小,则调用是错误的。

尝试这个:

dim_size[0] = processCount; 
dim_size[1] = 1;
于 2013-11-08T18:01:01.843 回答
-1

int *dims 和 int *periods 是指针。您正在发送数组。

MPI_Cart_create(MPI_COMM_WORLD, ndims, dim_size, periods, reorder, &cart_com);

尝试发送指针。

MPI_Cart_create(MPI_COMM_WORLD, ndims, &dim_size, &periods, reorder, &cart_com);
于 2013-11-08T05:26:48.300 回答