#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 int cntDt = 3; struct SpecialData { char letter_; unsigned int id_; double value_; SpecialData(char letter='\0', unsigned int id=0, double value=0.0) : letter_(letter) , id_(id) , value_(value) {} }; MPI::Datatype types[] = {MPI::CHAR, MPI::UNSIGNED, MPI::DOUBLE}; int lenBlock[] = {1,1,1}; SpecialData specialData; MPI::Aint tmpDisp[] = { MPI::Get_address(&specialData.letter_), MPI::Get_address(&specialData.id_), MPI::Get_address(&specialData.value_)}; MPI::Aint displacement[cntDt] = {}; for(unsigned int i=1; irank() == master) //master { specialData.letter_ = 'a'; specialData.id_ = mpi->rank(); specialData.value_ = 13.0; cout << *mpi->instance() << " send: " << specialData.letter_ << " "; cout << specialData.id_ << " " << specialData.value_ << endl; const int tag = 0; Transceiver<> transceiver; for (int dest=1; destsize(); ++dest) { transceiver.send(&specialData, 1, buff_datatype, dest, tag); } } else { const int from = master; const int tag = 0; MPI::Status status; Transceiver<> transceiver; transceiver.recv(&specialData, 1, buff_datatype, from, tag, status); cout << *mpi->instance() << " send: " << specialData.letter_ << " "; cout << specialData.id_ << " " << specialData.value_ << endl; } buff_datatype.Free(); return 0; }