how to create MPI custom type properly

I have structure(single element of complex matrix):

typedef struct  s_complex_number {
    int real;
    int img;
}               ComplexNumber;

This is how i described Complex matrix as custom MPI datatype

#define SIZE_COL 10
MPI_Datatype  matrix;
MPI_Datatype  types[2] = {MPI_INT, MPI_INT};
MPI_Datatype  row;
MPI_Datatype  complexNumber;
MPI_Aint      disp[2];
ComplexNumber ***recvData;
ComplexNumber ***sendData;
ComplexNumber example;

int blockLength[] = {1, 1};

disp[0] = (uintptr_t)&example.real - (uintptr_t)&example;
disp[1] = (uintptr_t)&example.img - (uintptr_t)&example;

/***********************Initialize custom types************************/
MPI_Type_create_struct(2, blockLength, disp, types, &complexNumber);

MPI_Type_vector(1, SIZE_COL, 1, complexNumber, &row);

MPI_Type_vector(1, SIZE_COL, 1, row, &matrix);

Each time i am trying to send data, geting segmentation fault.

How to describe ComplexNumber** type in MPI properly?

Read more here:

Content Attribution

This content was originally published by romandkv at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: