• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2005-2006 Alain Miniussi <alain.miniussi -at- oca.eu>.
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 // Message Passing Interface 1.1 -- Section 4. MPI Collectives
8 
9 /** @file inplace.hpp
10  *
11  *  This header provides helpers to indicate to MPI collective operation
12  *  that a buffer can be use both as an input and output.
13  */
14 #ifndef BOOST_MPI_INPLACE_HPP
15 #define BOOST_MPI_INPLACE_HPP
16 
17 #include <boost/mpi/communicator.hpp>
18 #include <vector>
19 
20 namespace boost { namespace mpi {
21 
22 /**
23  *  @brief Wrapper type to explicitly indicate that a input data
24  * can be overriden with an output value.
25  */
26 template <typename T>
27 struct inplace_t {
inplace_tboost::mpi::inplace_t28   inplace_t(T& inout) : buffer(inout) {}
29   T& buffer;
30 };
31 
32 template <typename T>
33 struct inplace_t<T*> {
inplace_tboost::mpi::inplace_t34   inplace_t(T* inout) : buffer(inout) {}
35   T* buffer;
36 };
37 
38 
39 /**
40  *  @brief Wrapp a input data to indicate that it can be overriden
41  *  with an ouput value.
42  *  @param inout the contributing input value, it will be overriden
43  *  with the output value where one is expected. If it is a pointer,
44  *  the number of elements will be provided separatly.
45  *  @returns The wrapped value or pointer.
46  */
47 template<typename T>
48 inplace_t<T>
inplace(T & inout)49 inplace(T& inout) {
50   return inplace_t<T>(inout);
51 }
52 /**
53  * \overload
54  */
55 template<typename T>
56 inplace_t<T*>
inplace(T * inout)57 inplace(T* inout) {
58   return inplace_t<T*>(inout);
59 }
60 } }  // end namespace boost::mpi
61 
62 #endif // BOOST_MPI_INPLACE_HPP
63 
64