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