/* Jonathan Hauenstein - University of Notre Dame Center for Applied Mathematics Minicourse on Parallel Computing April 24, May 1, May 8, 2008 Sample programs are designed for educational use */ #include "test.h" #include // creates the MPI datatype mpi_aStruct void create_aStruct(MPI_Datatype *mpi_aStruct) { MPI_Aint sAdd, add; aStruct A; // arrays for length, displacement and datatypes int blockLen[3] = {1,1,1}; // 1 element in each block MPI_Datatype types[3] = {MPI_INT, MPI_CHAR, MPI_DOUBLE}; MPI_Aint indices[3] = {0,0,0}; // calculate the starting address MPI_Address(&A.a, &sAdd); // calculate the second address and compute the displacement MPI_Address(&A.s, &add); indices[1] = add - sAdd; // calculate the third address and compute the displacement MPI_Address(&A.r, &add); indices[2] = add - sAdd; // build the mpi datatype MPI_Type_struct(3, blockLen, indices, types, mpi_aStruct); // commit the mpi datatype MPI_Type_commit(mpi_aStruct); return; }