这让我疯了 - 我不知道我做错了什么。我一遍又一遍地看着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)
即使只是一点点暗示也会很好...... 谢谢
答案 0 :(得分:3)
您有processCount
个进程,但是您正在尝试创建一个大小为processCount
x processCount
的通信器(总共产生processCount
^ 2个进程)。而且,正如documentation会告诉你的那样:
如果指定的网格大于组大小,则调用是错误的。
试试这个:
dim_size[0] = processCount;
dim_size[1] = 1;
答案 1 :(得分:-1)
int * dims和int * period是指针。你正在发送阵列。
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);