@@ -45,18 +45,18 @@ DEP_DIR := $(BUILD_DIR)/.dep | |||||
# ========== Compiler settings ========== | # ========== Compiler settings ========== | ||||
# Compiler flags for debug and release | # 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-defines | ||||
# PRE_DEFS := MYCAB=1729 SUPER_MODE | # PRE_DEFS := MYCAB=1729 SUPER_MODE | ||||
PRE_DEFS := #_GLIBCXX_PARALLEL | |||||
PRE_DEFS := _GLIBCXX_PARALLEL | |||||
# ============== Linker settings ============== | # ============== Linker settings ============== | ||||
# Linker flags (example: -pthread -lm) | # Linker flags (example: -pthread -lm) | ||||
LDFLAGS := -pthread # -fopenmp | |||||
LDFLAGS := -pthread -fopenmp | |||||
# Map output file | # Map output file | ||||
MAP_FILE := output.map | MAP_FILE := output.map | ||||
@@ -10,7 +10,8 @@ | |||||
# $> sbatch <this file> | # $> sbatch <this file> | ||||
# | # | ||||
# NOTE: | # NOTE: | ||||
# First compile with | |||||
# First compile in aristotel with | |||||
# $> module load gcc/9.2.0 openmpi/4.0.3 | |||||
# $> make -j hpc-build | # $> make -j hpc-build | ||||
# | # | ||||
@@ -12,7 +12,7 @@ | |||||
#include <vector> | #include <vector> | ||||
#include <algorithm> | #include <algorithm> | ||||
//#include <parallel/algorithm> | |||||
#include <parallel/algorithm> | |||||
#include <cmath> | #include <cmath> | ||||
#include <cstdint> | #include <cstdint> | ||||
#if !defined DEBUG | #if !defined DEBUG | ||||
@@ -162,10 +162,10 @@ template<typename RangeT> | |||||
void fullSort(RangeT& data, bool ascending) noexcept { | void fullSort(RangeT& data, bool ascending) noexcept { | ||||
// Use introsort from stdlib++ here, unless ... __gnu_parallel | // Use introsort from stdlib++ here, unless ... __gnu_parallel | ||||
if (ascending) { | if (ascending) { | ||||
std::sort(data.begin(), data.end(), std::less<>()); | |||||
__gnu_parallel::sort(data.begin(), data.end(), std::less<>()); | |||||
} | } | ||||
else { | else { | ||||
std::sort(data.begin(), data.end(), std::greater<>()); | |||||
__gnu_parallel::sort(data.begin(), data.end(), std::greater<>()); | |||||
} | } | ||||
} | } | ||||
@@ -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 | * the excecution time | ||||
* | |||||
* @tparam Func The function type | |||||
* @tparam Args The argument | |||||
* @param func | |||||
* @param args | |||||
* @return | |||||
*/ | */ | ||||
#define timeCall(Tim, Func, ...) \ | #define timeCall(Tim, Func, ...) \ | ||||
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(); | |||||
//} | |||||
Tim.start(); \ | |||||
Func(__VA_ARGS__); \ | |||||
Tim.stop(); \ | |||||
#endif /* UTILS_HPP_ */ | #endif /* UTILS_HPP_ */ |