• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //          Copyright Alain Miniussi 2014.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors: Alain Miniussi
7 
8 #ifndef BOOST_MPI_OFFSETS_HPP
9 #define BOOST_MPI_OFFSETS_HPP
10 
11 #include <vector>
12 #include <boost/mpi/config.hpp>
13 #include <boost/mpi/communicator.hpp>
14 
15 namespace boost { namespace mpi {
16 namespace detail {
17 
18 // Convert a sequence of sizes [S0..Sn] to a sequence displacement
19 // [O0..On] where O[0] = 0 and O[k+1] = O[k]+S[k].
20 void BOOST_MPI_DECL sizes2offsets(int const* sizes, int* offsets, int n);
21 
22 // Same as size2offset(sizes.data(), offsets.data(), sizes.size())
23 void BOOST_MPI_DECL sizes2offsets(std::vector<int> const& sizes, std::vector<int>& offsets);
24 
25 // Given a sequence of sizes (typically the number of records dispatched
26 // to each process in a scater) and a sequence of displacements (typically the
27 // slot index at with those record starts), convert the later to a number
28 // of skipped slots.
29 void offsets2skipped(int const* sizes, int const* offsets, int* skipped, int n);
30 
31 // Reconstruct offsets from sizes assuming no padding.
32 // Only takes place if on the root process and if
33 // displs are not already provided.
34 // If memory was allocated, returns a pointer to it
35 // otherwise null.
36 int* make_offsets(communicator const& comm, int const* sizes, int const* displs, int root = -1);
37 
38 // Reconstruct skip slots from sizes and offsets.
39 // Only takes place if on the root process and if
40 // displs are provided.
41 // If memory was allocated, returns a pointer to it
42 // otherwise null.
43 int* make_skipped_slots(communicator const& comm, int const* sizes, int const* displs, int root = -1);
44 
45 }
46 }}// end namespace boost::mpi
47 
48 #endif // BOOST_MPI_OFFSETS_HPP
49