offsets.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // Authors: Alain Miniussi
  6. #ifndef BOOST_MPI_OFFSETS_HPP
  7. #define BOOST_MPI_OFFSETS_HPP
  8. #include <vector>
  9. #include <boost/mpi/config.hpp>
  10. #include <boost/mpi/communicator.hpp>
  11. namespace boost { namespace mpi {
  12. namespace detail {
  13. // Convert a sequence of sizes [S0..Sn] to a sequence displacement
  14. // [O0..On] where O[0] = 0 and O[k+1] = O[k]+S[k].
  15. void BOOST_MPI_DECL sizes2offsets(int const* sizes, int* offsets, int n);
  16. // Same as size2offset(sizes.data(), offsets.data(), sizes.size())
  17. void BOOST_MPI_DECL sizes2offsets(std::vector<int> const& sizes, std::vector<int>& offsets);
  18. // Given a sequence of sizes (typically the number of records dispatched
  19. // to each process in a scater) and a sequence of displacements (typically the
  20. // slot index at with those record starts), convert the later to a number
  21. // of skipped slots.
  22. void offsets2skipped(int const* sizes, int const* offsets, int* skipped, int n);
  23. // Reconstruct offsets from sizes assuming no padding.
  24. // Only takes place if on the root process and if
  25. // displs are not already provided.
  26. // If memory was allocated, returns a pointer to it
  27. // otherwise null.
  28. int* make_offsets(communicator const& comm, int const* sizes, int const* displs, int root = -1);
  29. // Reconstruct skip slots from sizes and offsets.
  30. // Only takes place if on the root process and if
  31. // displs are provided.
  32. // If memory was allocated, returns a pointer to it
  33. // otherwise null.
  34. int* make_skipped_slots(communicator const& comm, int const* sizes, int const* displs, int root = -1);
  35. }
  36. }}// end namespace boost::mpi
  37. #endif // BOOST_MPI_OFFSETS_HPP