user7671105 user7671105 - 5 months ago 22
C Question


How is

stored in the memory?

I wanna send a column using
and i think it's better to define new type using

but i don't know it's a good way or not, and how?

denote that i wrote a c program.

Answer Source

Taken from the OpenMPI documentation:

int MPI_Type_create_hvector(int count, int blocklength,
    MPI_Aint stride, MPI_Datatype oldtype, MPI_Datatype *newtype)

It's not very clear from your question what exactly you are trying to do. Note that when you create this datatype, you decide exactly how your vector is stored in memory.

So if you have a contiguous chunk of doubles that are accessed in a row-major 2D-esque manner (i.e. data[iCol+N_COLS*iRow]), then you can create a "column" datatype in the following manner.

MPI_Datatype mpiColumn;
int info = MPI_Type_create_hvector(N_ROWS, 1, sizeof(double)*N_COLS, MPI_DOUBLE, &mpiColumn);