HW2: RC2 - Parallel Full Sort

This commit is contained in:
Christos Choutouridis 2025-01-03 16:15:13 +02:00
parent 1bd0cbb8d0
commit bc98ef4e9f
4 changed files with 15 additions and 33 deletions

View File

@ -45,18 +45,18 @@ DEP_DIR := $(BUILD_DIR)/.dep
# ========== Compiler settings ==========
# Compiler flags for debug and release
DEB_CFLAGS := -DDEBUG -g3 -Wall -Wextra -std=c11 #-fopenmp
REL_CFLAGS := -Wall -Wextra -O3 -std=c11 #-fopenmp
DEB_CXXFLAGS := -DDEBUG -g3 -Wall -Wextra -std=c++17 #-fopenmp
REL_CXXFLAGS := -Wall -Wextra -O3 -std=c++17 #-fopenmp
DEB_CFLAGS := -DDEBUG -g3 -Wall -Wextra -std=c11 -fopenmp
REL_CFLAGS := -Wall -Wextra -O3 -std=c11 -fopenmp
DEB_CXXFLAGS := -DDEBUG -g3 -Wall -Wextra -std=c++17 -fopenmp
REL_CXXFLAGS := -Wall -Wextra -O3 -std=c++17 -fopenmp
# Pre-defines
# PRE_DEFS := MYCAB=1729 SUPER_MODE
PRE_DEFS := #_GLIBCXX_PARALLEL
PRE_DEFS := _GLIBCXX_PARALLEL
# ============== Linker settings ==============
# Linker flags (example: -pthread -lm)
LDFLAGS := -pthread # -fopenmp
LDFLAGS := -pthread -fopenmp
# Map output file
MAP_FILE := output.map

View File

@ -10,7 +10,8 @@
# $> sbatch <this file>
#
# NOTE:
# First compile with
# First compile in aristotel with
# $> module load gcc/9.2.0 openmpi/4.0.3
# $> make -j hpc-build
#

View File

@ -12,7 +12,7 @@
#include <vector>
#include <algorithm>
//#include <parallel/algorithm>
#include <parallel/algorithm>
#include <cmath>
#include <cstdint>
#if !defined DEBUG
@ -162,10 +162,10 @@ template<typename RangeT>
void fullSort(RangeT& data, bool ascending) noexcept {
// Use introsort from stdlib++ here, unless ... __gnu_parallel
if (ascending) {
std::sort(data.begin(), data.end(), std::less<>());
__gnu_parallel::sort(data.begin(), data.end(), std::less<>());
}
else {
std::sort(data.begin(), data.end(), std::greater<>());
__gnu_parallel::sort(data.begin(), data.end(), std::greater<>());
}
}

View File

@ -357,32 +357,13 @@ private:
};
/*!
* Utility high level function to forward a function call to std::invoke and measure
* Utility high level function like to forward a function call and measure
* the excecution time
*
* @tparam Func The function type
* @tparam Args The argument
* @param func
* @param args
* @return
*/
#define timeCall(Tim, Func, ...) \
Tim.start(); \
Func(__VA_ARGS__); \
Tim.stop(); \
Tim.start(); \
Func(__VA_ARGS__); \
Tim.stop(); \
//template <typename Ret, typename Func, typename... Args>
//auto timeCall_r(Ret& ret, Func&& func, Args&&... args) {
// Timing timer;
//
// timer.start();
// ret = std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
// timer.stop();
//
// return timer.dt();
//}
#endif /* UTILS_HPP_ */