Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ MPI购物车创建和购物车协调_C++_Mpich - Fatal编程技术网

C++ MPI购物车创建和购物车协调

C++ MPI购物车创建和购物车协调,c++,mpich,C++,Mpich,我有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(M

我有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;
    }
}
int dim[2],period[2],coord[2],reorder,myValue;
dim[0]=4;dim[1]=4;
期间[0]=1;周期[1]=0;
重新排序=1;
myValue=rand()%100+1;
MPI_Cart_create(MPI_COMM_WORLD,2,dim,period,reorder,&COMM);
if(rank==0)//根
{
//打印每个进程的坐标,i=进程等级
对于(int i=0;icout没有矩阵。它只是一种惯例,使得关于左、右、上、下过程的争论更容易理解

如果你想得到当前进程的坐标,你已经有了代码。只需输入rank,而不是i