AUTH's THMMY "Parallel and distributed systems" course assignments.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

distbitonic.hpp 2.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*!
  2. * \file
  3. * \brief Distributed bitonic implementation header
  4. *
  5. * \author
  6. * Christos Choutouridis AEM:8997
  7. * <cchoutou@ece.auth.gr>
  8. */
  9. #ifndef DISTBITONIC_H_
  10. #define DISTBITONIC_H_
  11. #if !defined DEBUG
  12. #define NDEBUG
  13. #endif
  14. #include <cassert>
  15. #include <vector>
  16. #if !defined TESTING
  17. #include <mpi.h>
  18. #endif
  19. /*!
  20. * Enumerator for the different versions of the sorting method
  21. */
  22. enum class SortMode {
  23. Bubbletonic, //!< The v0.5 of the algorithm where we use a bubble-sort like approach
  24. Bitonic //!< The v1.0 of the algorithm where we use the bitonic data-exchange approach
  25. };
  26. using Data_t = std::vector<uint8_t>;
  27. using AllData_t = std::vector<Data_t>;
  28. struct mpi_t {
  29. size_t world_size{};
  30. size_t world_rank{};
  31. std::string processor_name {};
  32. };
  33. extern mpi_t mpi;
  34. /*
  35. * ============================== Sort utilities ==============================
  36. */
  37. /*!
  38. * The primary function template of ascending(). It is DISABLED since , it is explicitly specialized
  39. * for each of the \c SortMode
  40. */
  41. template <SortMode Mode> bool ascending(size_t, [[maybe_unused]] size_t) noexcept = delete;
  42. template <> bool ascending<SortMode::Bubbletonic>(size_t node, [[maybe_unused]] size_t depth) noexcept;
  43. template <> bool ascending<SortMode::Bitonic>(size_t node, size_t depth) noexcept;
  44. /*!
  45. * The primary function template of partner(). It is DISABLED since , it is explicitly specialized
  46. * for each of the \c SortMode
  47. */
  48. template <SortMode Mode> size_t partner(size_t, size_t) noexcept = delete;
  49. template <> size_t partner<SortMode::Bubbletonic>(size_t node, size_t step) noexcept;
  50. template <> size_t partner<SortMode::Bitonic>(size_t node, size_t step) noexcept;
  51. /*!
  52. * The primary function template of keepsmall(). It is DISABLED since , it is explicitly specialized
  53. * for each of the \c SortMode
  54. */
  55. template<SortMode Mode> bool keepsmall(size_t, size_t, [[maybe_unused]] size_t) noexcept = delete;
  56. template<> bool keepsmall<SortMode::Bubbletonic>(size_t node, size_t partner, [[maybe_unused]] size_t depth) noexcept;
  57. template<> bool keepsmall<SortMode::Bitonic>(size_t node, size_t partner, size_t depth) noexcept;
  58. bool isActive(size_t node, size_t nodes) noexcept;
  59. /*
  60. * ============================== Data utilities ==============================
  61. */
  62. void exchange(size_t node, size_t partner);
  63. void minmax(AllData_t& data, size_t node, size_t partner, bool keepsmall);
  64. /*
  65. * ============================== Sort algorithms ==============================
  66. */
  67. void bubbletonic_network(AllData_t& data, size_t nodes);
  68. void distbubbletonic(size_t P, AllData_t& data);
  69. void bitonic_network(AllData_t& data, size_t nodes, size_t depth);
  70. void distbitonic(size_t P, AllData_t& data);
  71. #endif //DISTBITONIC_H_