当前位置:  开发笔记 > 编程语言 > 正文

MPI_Cart_Shift.Corner邻居

如何解决《MPI_Cart_Shift.Corner邻居》经验,为你挑选了0个好方法。

在此输入图像描述

我需要使用多维数据集拓扑创建一个通信器,然后选择多维数据集的面,使用MPI_Cart_Shift在边缘处理的进程之间实现消息传递.例如,我处理等级0(R0)我的邻居是R2,R4,R6(立方体的下面).我可以找到R2和R4,但我无法理解如何找到R6.我的代码:

#include
#include

int main(int argc, char *argv[])
{
int rank, k;
int size; 
int ndims = 3; 
int source, dest;
int up,down,right,left,up3, down3;

int edges[6][4] = {{0,1,5,4},
                {4,5,7,6},
                {2,3,1,0},
                {6,7,3,2},
                {1,3,7,5},
                {0,2,6,7}};

int t, incep=0;
char processor_name[MPI_MAX_PROCESSOR_NAME];

MPI_Comm comm, comm3d;
int dims[3]={0,0,0}, coords[3]={0,0,0},
    periods[3]={1,1,1}, reorder = 0;


MPI_Status status;


int user_edge;

MPI_Init(&argc, &argv);

MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

MPI_Dims_create(size, ndims, dims);


  MPI_Cart_create(MPI_COMM_WORLD, ndims, dims, periods, reorder, &comm);


  MPI_Cart_coords(comm, rank, 3, coords);

 fflush(stdout);
     printf("Rank %d coordinates are %d %d %d\n", rank, coords[0], coords[1], coords[2]);
 MPI_Barrier(comm);

    int leftrank, rightrank;
    int downrank, uprank;

MPI_Comm_rank(comm, &rank);
    MPI_Cart_coords(comm, rank, 2, coords);
MPI_Cart_shift(comm, 0, -1, &downrank, &uprank); 
MPI_Sendrecv(buffer, 10, MPI_INT, downrank, 123, buffer2, 10, MPI_INT, uprank, 123, comm, &status);
MPI_Cart_shift(comm, 1, -1, &rightrank, &leftrank); 
    MPI_Sendrecv(buffer, 10, MPI_INT, leftrank, 123, buffer2, 10, MPI_INT, rightrank, 123, comm, &status);


printf("P:%d My neighbors are rightRank: %d downRank:%d leftRank:%d upRank:%d diagonal:%d diagonalX:%d\n", rank,rightrank,downrank,leftrank,uprank,diagonal,diagonalX);



MPI_Finalize();

return 0;

}

我会尝试添加像这样的MPI_Cart_shift(comm,2,1,&diagonal,&diagonalX); 但对于R0,它向我展示了R1,我理解......我怎样才能获得角落社区?

推荐阅读
夏晶阳--艺术
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有