PageRenderTime 35ms CodeModel.GetById 23ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/mpi/detail/communicator_sc.hpp

http://hadesmem.googlecode.com/
C++ Header | 96 lines | 72 code | 17 blank | 7 comment | 0 complexity | c5868bdf9531a4a22f60b6d8651bdbfb MD5 | raw file
 1// Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
 2
 3// Use, modification and distribution is subject to the Boost Software
 4// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 5// http://www.boost.org/LICENSE_1_0.txt)
 6
 7// Skeleton and content support for communicators
 8
 9// This header should be included only after both communicator.hpp and
10// skeleton_and_content.hpp have been included.
11#ifndef BOOST_MPI_COMMUNICATOR_SC_HPP
12#define BOOST_MPI_COMMUNICATOR_SC_HPP
13
14namespace boost { namespace mpi {
15
16template<typename T>
17void
18communicator::send(int dest, int tag, const skeleton_proxy<T>& proxy) const
19{
20  packed_skeleton_oarchive ar(*this);
21  ar << proxy.object;
22  send(dest, tag, ar);
23}
24
25template<typename T>
26status
27communicator::recv(int source, int tag, const skeleton_proxy<T>& proxy) const
28{
29  packed_skeleton_iarchive ar(*this);
30  status result = recv(source, tag, ar);
31  ar >> proxy.object;
32  return result;
33}
34
35template<typename T>
36status communicator::recv(int source, int tag, skeleton_proxy<T>& proxy) const
37{
38  packed_skeleton_iarchive ar(*this);
39  status result = recv(source, tag, ar);
40  ar >> proxy.object;
41  return result;
42}
43
44template<typename T>
45request
46communicator::isend(int dest, int tag, const skeleton_proxy<T>& proxy) const
47{
48  shared_ptr<packed_skeleton_oarchive> 
49    archive(new packed_skeleton_oarchive(*this));
50
51  *archive << proxy.object;
52  request result = isend(dest, tag, *archive);
53  result.m_data = archive;
54  return result;
55}
56
57namespace detail {
58  template<typename T>
59  struct serialized_irecv_data<const skeleton_proxy<T> >
60  {
61    serialized_irecv_data(const communicator& comm, int source, int tag, 
62                          skeleton_proxy<T> proxy)
63      : comm(comm), source(source), tag(tag), isa(comm), 
64        ia(isa.get_skeleton()), proxy(proxy) { }
65
66    void deserialize(status& stat) 
67    { 
68      isa >> proxy.object;
69      stat.m_count = 1;
70    }
71
72    communicator comm;
73    int source;
74    int tag;
75    std::size_t count;
76    packed_skeleton_iarchive isa;
77    packed_iarchive& ia;
78    skeleton_proxy<T> proxy;
79  };
80
81  template<typename T>
82  struct serialized_irecv_data<skeleton_proxy<T> >
83    : public serialized_irecv_data<const skeleton_proxy<T> >
84  {
85    typedef serialized_irecv_data<const skeleton_proxy<T> > inherited;
86
87    serialized_irecv_data(const communicator& comm, int source, int tag, 
88                          const skeleton_proxy<T>& proxy)
89      : inherited(comm, source, tag, proxy) { }
90  };
91}
92
93} } // end namespace boost::mpi
94
95#endif // BOOST_MPI_COMMUNICATOR_SC_HPP
96