Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:58

0001 // Copyright (C) 2005-2006 Alain Miniussi <alain.miniussi -at- oca.eu>.
0002 
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // Message Passing Interface 1.1 -- Section 4. MPI Collectives
0008 
0009 /** @file inplace.hpp
0010  *
0011  *  This header provides helpers to indicate to MPI collective operation
0012  *  that a buffer can be use both as an input and output.
0013  */
0014 #ifndef BOOST_MPI_INPLACE_HPP
0015 #define BOOST_MPI_INPLACE_HPP
0016 
0017 #include <boost/mpi/communicator.hpp>
0018 #include <vector>
0019 
0020 namespace boost { namespace mpi {
0021 
0022 /**
0023  *  @brief Wrapper type to explicitly indicate that a input data 
0024  * can be overriden with an output value.
0025  */
0026 template <typename T>
0027 struct inplace_t {
0028   inplace_t(T& inout) : buffer(inout) {}
0029   T& buffer;
0030 };
0031 
0032 template <typename T>
0033 struct inplace_t<T*> {
0034   inplace_t(T* inout) : buffer(inout) {}
0035   T* buffer;
0036 };
0037 
0038 
0039 /**
0040  *  @brief Wrapp a input data to indicate that it can be overriden 
0041  *  with an ouput value.
0042  *  @param inout the contributing input value, it will be overriden 
0043  *  with the output value where one is expected. If it is a pointer, 
0044  *  the number of elements will be provided separatly.
0045  *  @returns The wrapped value or pointer.
0046  */
0047 template<typename T>
0048 inplace_t<T>
0049 inplace(T& inout) { 
0050   return inplace_t<T>(inout);
0051 }
0052 /**
0053  * \overload
0054  */
0055 template<typename T>
0056 inplace_t<T*>
0057 inplace(T* inout) { 
0058   return inplace_t<T*>(inout);
0059 }
0060 } }  // end namespace boost::mpi
0061 
0062 #endif // BOOST_MPI_INPLACE_HPP
0063