我有 16 个进程,每个进程都在随机化一个数字。
我为进程创建了笛卡尔拓扑,现在我知道每个等级(进程)的坐标是什么。
我想知道“矩阵”在哪里,如何获得笛卡尔拓扑中每个进程的值?
这是代码:
int dim[2],period[2],coord[2],reorder,myValue;
dim[0] = 4; dim[1] = 4;
period[0] = 1; period[1] = 0;
reorder = 1;
myValue = rand() % 100 + 1;
MPI_Cart_create(MPI_COMM_WORLD,2,dim,period,reorder,&comm);
if (rank == 0) // root
{
//prints the coordinates of each process , i = process rank
for (int i = 0 ; i < DIM*DIM; i++)
{
MPI_Cart_coords(comm,i,2,coord);
cout << coord[0] << coord[1] << i << endl;
}
}