Skip to content
Snippets Groups Projects
Commit ad09caa9 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

algo: Add flag to indicate if parallel STL algorithms are available to BuildInfo.h.

parent 490d24f1
No related branches found
No related tags found
1 merge request!1203algo: Enable parallel sorting when libTBB is available.
......@@ -94,7 +94,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
if (TBB_FOUND)
message(STATUS "Found TBB")
add_compile_definitions(HAVE_TBB)
target_compile_definitions(Algo PUBLIC -DHAVE_TBB)
target_link_libraries(Algo PUBLIC TBB::tbb)
else()
message(STATUS "TBB not found")
......
......@@ -6,6 +6,10 @@
#include <string>
#if defined(HAVE_TBB) && defined(__cpp_lib_parallel_algorithm)
#define HAVE_PARALLEL_ALGORITHM
#endif
namespace cbm::algo::BuildInfo
{
......@@ -20,6 +24,13 @@ namespace cbm::algo::BuildInfo
false;
#endif
inline constexpr bool WITH_PARALLEL_ALGORITHM =
#ifdef HAVE_PARALLEL_ALGORITHM
true;
#else
false;
#endif
} // namespace cbm::algo::BuildInfo
#endif // CBM_ALGO_BUILD_INFO_H
......@@ -16,6 +16,9 @@
**/
#include <algorithm>
#include "BuildInfo.h"
#ifdef __cpp_lib_execution
#define WITH_EXECUTION
#include <execution>
......@@ -28,11 +31,11 @@ namespace cbm::algo
{
#ifdef WITH_EXECUTION
inline constexpr auto ExecPolicy =
#if defined(__cpp_lib_parallel_algorithm) && defined(HAVE_TBB)
#ifdef HAVE_PARALLEL_ALGORITHM
std::execution::par_unseq;
#else
std::execution::seq;
#endif // __cpp_lib_parallel_algorithm && WITH_TBB
#endif // HAVE_PARALLEL_ALGORITHM
#endif // WITH_EXECUTION
} // namespace detail
......
......@@ -59,7 +59,7 @@ namespace cbm::algo
}
} //# component
// --- Sorting of output digis. Is required by both digi trigger and event builder.
// --- Sorting of output digis. Is required by both digi trigger and event builder.
ParallelSort(digiTs.fData.fSts.fDigis.begin(), digiTs.fData.fSts.fDigis.end(),
[](CbmStsDigi digi1, CbmStsDigi digi2) { return digi1.GetTime() < digi2.GetTime(); });
ParallelSort(digiTs.fData.fMuch.fDigis.begin(), digiTs.fData.fMuch.fDigis.end(),
......
......@@ -34,7 +34,7 @@ int main(int argc, char** argv)
xpu::preload<GPUReco>();
L_(info) << "CBMRECO buildType=" << BuildInfo::BUILD_TYPE << " gpuDebug=" << BuildInfo::GPU_DEBUG
<< " commit=" << BuildInfo::GIT_HASH;
<< " parallelSTL=" << BuildInfo::WITH_PARALLEL_ALGORITHM << " commit=" << BuildInfo::GIT_HASH;
std::stringstream ss;
for (int i = 0; i < argc; i++) {
ss << argv[i] << " ";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment