gmpi_impl.hpp

Go to the documentation of this file.
00001 // $Id: gmpi_impl.hpp,v 1.3 2004/02/22 18:44:46 gottschling Exp $
00002 
00003 namespace GMPI {
00004 
00005   template <class Comm_ref_t>
00006   void Comm::Send (const Comm_ref_t& data, int dest, int tag) const {
00007     typedef typename Comm_ref_t::base_t   base_t;
00008     buffer_t<base_t>                      buffer;
00009     buffer << data.object_ref();
00010     // size_t bsize= buffer.size();
00011     // my_comm.Bsend (&bsize, 1, mpi_size_t, dest, tag); // at first send buffer size
00012     my_comm.Send (buffer.address(), buffer.size(), buffer.mpi_t, dest, tag);
00013   }
00014 
00015   template <class Comm_ref_t>
00016   void Comm::Recv (Comm_ref_t& data, int source, int tag, MPI::Status& status) const {
00017     typedef typename Comm_ref_t::base_t   base_t;
00018     // size_t                                bsize;
00019     // my_comm.Recv (&bsize, 1, mpi_size_t, source, tag, status); // at first receive buffer size
00020     // MPI::Status                           status;
00021     my_comm.Probe (source, tag, status);
00022     buffer_t<base_t>                      buffer;
00023     size_t                                bsize= status.Get_count (buffer.mpi_t);
00024     buffer.reserve (bsize);
00025     // if wildcards are used make sure to get the second message from the same processor
00026     // source= status.Get_source (); tag= status.Get_tag (); 
00027     my_comm.Recv (buffer.address(), bsize, buffer.mpi_t, source, tag, status);
00028   }
00029 
00030   template <class Comm_ref_t>
00031   void Intracomm::Bcast (Comm_ref_t& data, int root) const {
00032     typedef typename Comm_ref_t::base_t   base_t;
00033     buffer_t<base_t>                      buffer;
00034     size_t                                bsize;
00035     if (Get_rank () == root) {
00036       buffer << data.object_ref(); bsize= buffer.size(); }
00037     my_comm.Bcast (&bsize, 1, mpi_size_t, root);
00038     if (Get_rank () != root) 
00039       buffer.reserve (bsize);
00040     my_comm.Bcast (buffer.address(), bsize, buffer.mpi_t, root);
00041     if (Get_rank () != root) 
00042       buffer >> data.object_ref();
00043   }
00044 
00045 } // namespace GMPI

Generated on Wed Mar 11 10:33:11 2009 for angel by  doxygen 1.5.3