July 2017
Intermediate to advanced
244 pages
6h 33m
English
In addition to these basic formats, one can also create new MPI data types. These use a number of MPI functions, including MPI_Type_create_struct:
int MPI_Type_create_struct(
int count,
int array_of_blocklengths[],
const MPI_Aint array_of_displacements[],
const MPI_Datatype array_of_types[],
MPI_Datatype *newtype)
With this function, one can create an MPI type that contains a struct, to be passed just like a basic MPI data type:
#include <cstdio> #include <cstdlib> #include <mpi.h> #include <cstddef> struct car { int shifts; int topSpeed; }; int main(int argc, char **argv) { const int tag = 13; int size, rank; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); if (size < 2) { fprintf(stderr,"Requires at least two ...Read now
Unlock full access