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.
 
 
 
 
 
 

74 lignes
2.5 KiB

  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. #include <cstdint>
  12. #include "utils.hpp"
  13. /*!
  14. * Enumerator for the different versions of the sorting method
  15. */
  16. enum class SortMode {
  17. Bubbletonic, //!< The v0.5 of the algorithm where we use a bubble-sort like approach
  18. Bitonic //!< The v1.0 of the algorithm where we use the bitonic data-exchange approach
  19. };
  20. using Data_t = std::vector<uint8_t>;
  21. using AllData_t = std::vector<Data_t>;
  22. /*
  23. * ============================== Sort utilities ==============================
  24. */
  25. /*!
  26. * The primary function template of ascending(). It is DISABLED since , it is explicitly specialized
  27. * for each of the \c SortMode
  28. */
  29. template <SortMode Mode> bool ascending(mpi_id_t, [[maybe_unused]] size_t) noexcept = delete;
  30. template <> bool ascending<SortMode::Bubbletonic>(mpi_id_t node, [[maybe_unused]] size_t depth) noexcept;
  31. template <> bool ascending<SortMode::Bitonic>(mpi_id_t node, size_t depth) noexcept;
  32. /*!
  33. * The primary function template of partner(). It is DISABLED since , it is explicitly specialized
  34. * for each of the \c SortMode
  35. */
  36. template <SortMode Mode> mpi_id_t partner(mpi_id_t, size_t) noexcept = delete;
  37. template <> mpi_id_t partner<SortMode::Bubbletonic>(mpi_id_t node, size_t step) noexcept;
  38. template <> mpi_id_t partner<SortMode::Bitonic>(mpi_id_t node, size_t step) noexcept;
  39. /*!
  40. * The primary function template of keepSmall(). It is DISABLED since , it is explicitly specialized
  41. * for each of the \c SortMode
  42. */
  43. template<SortMode Mode> bool keepSmall(mpi_id_t, mpi_id_t, [[maybe_unused]] size_t) noexcept = delete;
  44. template<> bool keepSmall<SortMode::Bubbletonic>(mpi_id_t node, mpi_id_t partner, [[maybe_unused]] size_t depth) noexcept;
  45. template<> bool keepSmall<SortMode::Bitonic>(mpi_id_t node, mpi_id_t partner, size_t depth) noexcept;
  46. bool isActive(mpi_id_t node, mpi_id_t nodes) noexcept;
  47. /*
  48. * ============================== Data utilities ==============================
  49. */
  50. void exchange(mpi_id_t node, mpi_id_t partner);
  51. void minmax(AllData_t& data, mpi_id_t node, mpi_id_t partner, bool keepsmall);
  52. /*
  53. * ============================== Sort algorithms ==============================
  54. */
  55. void bubbletonic_network(AllData_t& data, mpi_id_t nodes);
  56. void distBubbletonic(mpi_id_t P, AllData_t& data);
  57. void bitonic_network(AllData_t& data, mpi_id_t nodes, mpi_id_t depth);
  58. void distBitonic(mpi_id_t P, AllData_t& data);
  59. #endif //DISTBITONIC_H_