我有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;
}
}发布于 2013-12-04 13:29:16
没有矩阵。这只是一个惯例,使争论的过程,左,右,上和下更容易理解。
如果您想要获取当前进程的坐标,那么您已经有了代码。只是排名而已,而不是我。
https://stackoverflow.com/questions/20376567
复制相似问题