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