내 mpi programm에서 테두리 교환을 수행하고 싶습니다. 그 같이 구조가 : 셀 직교 토폴로지 mpi에서 테두리 교환
cell** local_petri_A;
local_petri_A = calloc(p_local_petri_x_dim,sizeof(*local_petri_A));
for(int i = 0; i < p_local_petri_x_dim ; i ++){
local_petri_A[i] = calloc(p_local_petri_y_dim,sizeof(**local_petri_A));
}
입니다
:typedef struct {
int color;
int strength;
} cell;
나는이 그림에 같은 교환 방식을 가지고 싶습니다을 Cartesian 토폴로지에서 먼저 mpi 유형을 정의하여 교환을 수행하십시오. void create_types() {
////////////////////////////////
////////////////////////////////
// cell type
const int nitems=2;
int blocklengths[2] = {1,1};
MPI_Datatype types[2] = {MPI_INT, MPI_INT};
MPI_Aint offsets[2];
offsets[0] = offsetof(cell, color);
offsets[1] = offsetof(cell, strength);
MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_cell_t);
MPI_Type_commit(&mpi_cell_t);
////////////////////////////////
///////////////////////////////
MPI_Type_vector (x_inside , 1 , 1 , mpi_cell_t , & border_row_t);
MPI_Type_commit (& border_row_t);
/*we put the stride to x_dim to get only one column*/
MPI_Type_vector (y_inside , 1 , p_local_petri_x_dim , MPI_DOUBLE , & border_col_t);
MPI_Type_commit (& border_col_t);
}
다음 마지막으로 남쪽과 북쪽에서 교환 수행하려고 :
/*send to the north receive from the south */
MPI_Sendrecv (& local_petri_A[0][1] , 1 , border_row_t , p_north , TAG_EXCHANGE ,& local_petri_A [0][ p_local_petri_y_dim -1] , 1 , border_row_t , p_south , TAG_EXCHANGE ,cart_comm , MPI_STATUS_IGNORE);
/*send to the south receive from the north */
MPI_Sendrecv (& local_petri_A[0][ p_local_petri_y_dim -2] , 1 , border_row_t , p_south , TAG_EXCHANGE ,& local_petri_A [0][0] , 1 , border_row_t , p_north , TAG_EXCHANGE ,cart_comm , MPI_STATUS_IGNORE);
NB :이 섹션 x_inside에서와 유령 부분없이 (배열의 "내부"차원 y_inside 있습니다) 및 p_local_petri_dim은 전체 배열의 차원입니다. 내가 잘못한 일이
있습니까 :
그런 다음이 오류가?도움을 주셔서 감사합니다.
그래도 열은 작동하지 않지만 행은 어떻게됩니까? 여기에서 나는 단지 어떤 행을 보내려고 노력한다. 그리고 나는 여전히 할당 된 행과 함께 오류가있다. memig에 contiguos가 있는가? –
mpi 형식으로 올바르게 만들 수있는 방법이 있습니까? –
행은 확실히 연속적입니다. 귀하의 질문을 [Minimal, Complete, Verifiable example] (https://stackoverflow.com/help/mcve)로 편집하십시오. –