Skip to content
Snippets Groups Projects
Commit 158e28d6 authored by Administrator's avatar Administrator
Browse files

Fix compiler error on several systems

Depending on the compiler the STL library support or does not support the
usage of std::execution. Tets in the build system if the feature is available
and switch off the usage if not supported.

Remove default(none) from OpenMP parameters since it creates problems with
older OpenMP versions. In the current code according to Jan the statement
isn't needed.
parent 9656dea7
No related branches found
Tags dev_2023_27
1 merge request!828Add multithreading to CbmTaskUnpack and fix compiler errors on several systems
Pipeline #17579 passed
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# V. Friese, 2 June 2021 # V. Friese, 2 June 2021
# ----- Library name ---------------------------------- # ----- Library name ----------------------------------
Set(LIBRARY_NAME CbmRecoTasks) Set(LIBRARY_NAME CbmRecoTasks)
# --------------------------------------------------------- # ---------------------------------------------------------
...@@ -81,6 +80,25 @@ endif() ...@@ -81,6 +80,25 @@ endif()
set(LINKDEF ${LIBRARY_NAME}LinkDef.h) set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
# --------------------------------------------------------- # ---------------------------------------------------------
# Check if the compiler supports std::execution in the respective STL
# library
CHECK_CXX_SOURCE_COMPILES("
#include <numeric>
#include <vector>
#include <execution>
int main(int argc, char *argv[])
{
std::vector<double> v(10, 1);
auto result = std::reduce(std::execution::par, v.begin(), v.end());
return 0;
}" HAS_STD_EXECUTION)
if (HAS_STD_EXECUTION)
message("Execution is available in STL")
add_definitions(-DWITH_EXECUTION)
endif()
# ----- Let cmake do the job --------------------------- # ----- Let cmake do the job ---------------------------
include_directories( ${INCLUDE_DIRECTORIES}) include_directories( ${INCLUDE_DIRECTORIES})
......
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#ifdef WITH_EXECUTION
#include <execution> #include <execution>
#endif
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
...@@ -71,7 +73,7 @@ void CbmTaskUnpack::Exec(Option_t*) ...@@ -71,7 +73,7 @@ void CbmTaskUnpack::Exec(Option_t*)
uint64_t numCompUsed = 0; uint64_t numCompUsed = 0;
// --- Component loop // --- Component loop
#pragma omp parallel for schedule(dynamic) default(none) shared(timeslice) reduction(+: numMs, numBytes, numDigis, numCompUsed) #pragma omp parallel for schedule(dynamic) shared(timeslice) reduction(+ : numMs, numBytes, numDigis, numCompUsed)
for (uint64_t comp = 0; comp < timeslice->num_components(); comp++) { for (uint64_t comp = 0; comp < timeslice->num_components(); comp++) {
auto systemId = static_cast<fles::SubsystemIdentifier>(timeslice->descriptor(comp, 0).sys_id); auto systemId = static_cast<fles::SubsystemIdentifier>(timeslice->descriptor(comp, 0).sys_id);
...@@ -124,9 +126,13 @@ void CbmTaskUnpack::Exec(Option_t*) ...@@ -124,9 +126,13 @@ void CbmTaskUnpack::Exec(Option_t*)
} //# component } //# 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.
#ifdef WITH_EXECUTION
std::sort(std::execution::par_unseq, fTimeslice->fData.fSts.fDigis.begin(), fTimeslice->fData.fSts.fDigis.end(), std::sort(std::execution::par_unseq, fTimeslice->fData.fSts.fDigis.begin(), fTimeslice->fData.fSts.fDigis.end(),
[](CbmStsDigi digi1, CbmStsDigi digi2) { return digi1.GetTime() < digi2.GetTime(); }); [](CbmStsDigi digi1, CbmStsDigi digi2) { return digi1.GetTime() < digi2.GetTime(); });
#else
std::sort(fTimeslice->fData.fSts.fDigis.begin(), fTimeslice->fData.fSts.fDigis.end(),
[](CbmStsDigi digi1, CbmStsDigi digi2) { return digi1.GetTime() < digi2.GetTime(); });
#endif
// --- Timeslice log // --- Timeslice log
timer.Stop(); timer.Stop();
......
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