#include "MyMPI.hpp" #include "P2PComm.hpp" #include using std::cout; using std::endl; using namespace MF; int main(int argc, char* argv[]) { const MyMPI* mpi = MyMPI::instance(); const int master = 0; const unsigned int cntAlpha = 26 + 1; const unsigned int cntBlock = 3; const int lenBlock[cntBlock] = {3, 3, 3}; const int displ[cntBlock] = {0, 6, 12}; const MPI::Datatype type[cntBlock] = {MPI::CHAR, MPI::CHAR, MPI::CHAR}; MPI::Datatype Alphabet = MPI::Datatype::Create_struct(cntBlock, &lenBlock[0], &displ[0], &type[0]); Alphabet.Commit(); if (mpi->rank() == master) //master { char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int tag = 0; Transceiver<> transceiver; for (int dest=1; destsize(); ++dest) { transceiver.send(&alphabet, 1, Alphabet, dest, tag); } } else { const int from = master; const int tag = 0; MPI::Status status; Transceiver<> transceiver; char toRecv[cntAlpha]; transceiver.recv(&toRecv, 1, Alphabet, from, tag, status); toRecv[26] = '\0';//explicit termination cout << *mpi->instance() << " received: " << toRecv << endl; } Alphabet.Free(); return 0; }