/*! * \file * \brief Distributed bitonic implementation header * * \author * Christos Choutouridis AEM:8997 * */ #ifndef DISTBITONIC_H_ #define DISTBITONIC_H_ #if !defined DEBUG #define NDEBUG #endif #include #include #if !defined TESTING #include #endif /*! * Enumerator for the different versions of the sorting method */ enum class SortMode { Bubbletonic, //!< The v0.5 of the algorithm where we use a bubble-sort like approach Bitonic //!< The v1.0 of the algorithm where we use the bitonic data-exchange approach }; using Data_t = std::vector; using AllData_t = std::vector; struct mpi_t { size_t world_size{}; size_t world_rank{}; std::string processor_name {}; }; extern mpi_t mpi; /* * ============================== Sort utilities ============================== */ /*! * The primary function template of ascending(). It is DISABLED since , it is explicitly specialized * for each of the \c SortMode */ template bool ascending(size_t, [[maybe_unused]] size_t) noexcept = delete; template <> bool ascending(size_t node, [[maybe_unused]] size_t depth) noexcept; template <> bool ascending(size_t node, size_t depth) noexcept; /*! * The primary function template of partner(). It is DISABLED since , it is explicitly specialized * for each of the \c SortMode */ template size_t partner(size_t, size_t) noexcept = delete; template <> size_t partner(size_t node, size_t step) noexcept; template <> size_t partner(size_t node, size_t step) noexcept; /*! * The primary function template of keepsmall(). It is DISABLED since , it is explicitly specialized * for each of the \c SortMode */ template bool keepsmall(size_t, size_t, [[maybe_unused]] size_t) noexcept = delete; template<> bool keepsmall(size_t node, size_t partner, [[maybe_unused]] size_t depth) noexcept; template<> bool keepsmall(size_t node, size_t partner, size_t depth) noexcept; bool isActive(size_t node, size_t nodes) noexcept; /* * ============================== Data utilities ============================== */ void exchange(size_t node, size_t partner); void minmax(AllData_t& data, size_t node, size_t partner, bool keepsmall); /* * ============================== Sort algorithms ============================== */ void bubbletonic_network(AllData_t& data, size_t nodes); void distbubbletonic(size_t P, AllData_t& data); void bitonic_network(AllData_t& data, size_t nodes, size_t depth); void distbitonic(size_t P, AllData_t& data); #endif //DISTBITONIC_H_