#ifndef P2PCOMM_HPP_ #define P2PCOMM_HPP_ #include "MyMPI.hpp" #define DEBUG_EXTRA #ifdef DEBUG_EXTRA #include #endif namespace MF { class Send { public: void operator()(const void* data, int cnt, const MPI::Datatype &type, int dest, int tag) const { #ifdef DEBUG_EXTRA std::cout << *MyMPI::instance() << " sends with MPI::Send() to process " << dest; std::cout << " at address " << data << " count: " << cnt << " type: " << type << " tag: "<world().Send(data, cnt, type, dest, tag); } }; class BSend { public: void operator()(const void* data, int cnt, const MPI::Datatype& type, int dest, int tag ) const { #ifdef DEBUG_EXTRA std::cout << *MyMPI::instance() << " sends with MPI::Bsend() to process " << dest; std::cout << " at address " << data << " count: " << cnt << " type: " << type << " tag: "<world()); bufsize += MPI::BSEND_OVERHEAD; void* buf = new char[bufsize]; MPI::Attach_buffer(buf, bufsize); MyMPI::instance()->world().Bsend(data, cnt, type, dest, tag); MPI::Detach_buffer(buf); delete [] buf; } }; class RSend { public: void operator()(const void* data, int cnt, const MPI::Datatype &type, int dest, int tag) const { #ifdef DEBUG_EXTRA std::cout << *MyMPI::instance() << " sends with MPI::Rsend() to process " << dest; std::cout << " at address " << data << " count: " << cnt << " type: " << type << " tag: "<world().Rsend(data, cnt, type, dest, tag); } }; class SSend { public: void operator()(const void* data, int cnt, const MPI::Datatype &type, int dest, int tag) const { #ifdef DEBUG_EXTRA std::cout << *MyMPI::instance() << " sends with MPI::Ssend() to process " << dest; std::cout << " at address " << data << " count: " << cnt << " type: " << type << " tag: "<world().Ssend(data, cnt, type, dest, tag); } }; class Recv { public: void operator()(void* data, int cnt, const MPI::Datatype& type, int from, int tag, MPI::Status& status) const { #ifdef DEBUG_EXTRA std::cout << *MyMPI::instance() << " receives with MPI::Recv() from process " << from; std::cout << " at address " << data << " count: " << cnt << " type: " << type << " tag: "<world().Recv(data, cnt, type, from, tag, status); } }; template class Transceiver { public: void send(const void* data, int cnt, const MPI::Datatype& type, int dest, int tag) { T()(data, cnt, type, dest, tag); } void recv(void* data, int cnt, const MPI::Datatype& type, int from, int tag, MPI::Status& status) { R()(data, cnt, type, from, tag, status); } }; }//end namespace MF #undef DEBUG_EXTRA #endif