这让我抓狂——我不知道我做错了什么。我一遍又一遍地查看 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;
我是一名优秀的程序员,十分优秀!