Skip to content
Snippets Groups Projects
Commit 30ebf65d 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 f3e0974a
No related branches found
No related tags found
No related merge requests found
Pipeline #17550 failed
......@@ -2,7 +2,6 @@
# V. Friese, 2 June 2021
# ----- Library name ----------------------------------
Set(LIBRARY_NAME CbmRecoTasks)
# ---------------------------------------------------------
......@@ -81,6 +80,25 @@ endif()
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 ---------------------------
include_directories( ${INCLUDE_DIRECTORIES})
......
......@@ -22,7 +22,9 @@
#include <algorithm>
#include <cassert>
#include <cstdint>
#ifdef WITH_EXECUTION
#include <execution>
#endif
#include <iomanip>
#include <iostream>
#include <memory>
......@@ -71,7 +73,7 @@ void CbmTaskUnpack::Exec(Option_t*)
uint64_t numCompUsed = 0;
// --- 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++) {
auto systemId = static_cast<fles::SubsystemIdentifier>(timeslice->descriptor(comp, 0).sys_id);
......@@ -124,9 +126,13 @@ void CbmTaskUnpack::Exec(Option_t*)
} //# component
// --- 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(),
[](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
timer.Stop();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment