Skip to content
Snippets Groups Projects
Commit cdc6c061 authored by Felix Weiglhofer's avatar Felix Weiglhofer Committed by Dominik Smith
Browse files

algo::Unpack: Add timers.

parent d214378f
No related branches found
No related tags found
1 merge request!1219algo: Unpack TOF and STS in parallel.
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <chrono> #include <chrono>
#include <xpu/host.h>
#include "compat/Algorithm.h" #include "compat/Algorithm.h"
#include "log.hpp" #include "log.hpp"
...@@ -17,6 +19,8 @@ namespace cbm::algo ...@@ -17,6 +19,8 @@ namespace cbm::algo
// ----- Execution ------------------------------------------------------- // ----- Execution -------------------------------------------------------
Unpack::resultType Unpack::operator()(const fles::Timeslice* timeslice) Unpack::resultType Unpack::operator()(const fles::Timeslice* timeslice)
{ {
xpu::scoped_timer t0("Unpack");
// --- Output data // --- Output data
resultType result = {}; resultType result = {};
CbmDigiTimeslice& digiTs = result.first; CbmDigiTimeslice& digiTs = result.first;
...@@ -25,6 +29,7 @@ namespace cbm::algo ...@@ -25,6 +29,7 @@ namespace cbm::algo
ParallelInit(*timeslice); ParallelInit(*timeslice);
if (DetectorEnabled(fles::SubsystemIdentifier::STS)) { if (DetectorEnabled(fles::SubsystemIdentifier::STS)) {
xpu::scoped_timer t1("STS");
ParallelMsLoop(digiTs.fData.fSts.fDigis, monitor.fSts, *timeslice, 0x20); ParallelMsLoop(digiTs.fData.fSts.fDigis, monitor.fSts, *timeslice, 0x20);
} }
...@@ -36,6 +41,8 @@ namespace cbm::algo ...@@ -36,6 +41,8 @@ namespace cbm::algo
if (!DetectorEnabled(systemId)) continue; if (!DetectorEnabled(systemId)) continue;
xpu::scoped_timer t1(fles::to_string(systemId));
// Equipment ID of current component // Equipment ID of current component
const uint16_t equipmentId = timeslice->descriptor(comp, 0).eq_id; const uint16_t equipmentId = timeslice->descriptor(comp, 0).eq_id;
...@@ -68,6 +75,8 @@ namespace cbm::algo ...@@ -68,6 +75,8 @@ namespace cbm::algo
} //# 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.
xpu::scoped_timer t2("Sort");
Sort(digiTs.fData.fSts.fDigis.begin(), digiTs.fData.fSts.fDigis.end(), Sort(digiTs.fData.fSts.fDigis.begin(), digiTs.fData.fSts.fDigis.end(),
[](CbmStsDigi digi1, CbmStsDigi digi2) { return digi1.GetTime() < digi2.GetTime(); }); [](CbmStsDigi digi1, CbmStsDigi digi2) { return digi1.GetTime() < digi2.GetTime(); });
Sort(digiTs.fData.fMuch.fDigis.begin(), digiTs.fData.fMuch.fDigis.end(), Sort(digiTs.fData.fMuch.fDigis.begin(), digiTs.fData.fMuch.fDigis.end(),
...@@ -305,6 +314,8 @@ namespace cbm::algo ...@@ -305,6 +314,8 @@ namespace cbm::algo
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void Unpack::ParallelInit(const fles::Timeslice& timeslice) void Unpack::ParallelInit(const fles::Timeslice& timeslice)
{ {
xpu::scoped_timer t("ParallelInit");
fParallelStsSetup = {}; fParallelStsSetup = {};
size_t numMs = 0; size_t numMs = 0;
...@@ -341,19 +352,25 @@ namespace cbm::algo ...@@ -341,19 +352,25 @@ namespace cbm::algo
auto& msDigis = fParallelStsSetup.msDigis; auto& msDigis = fParallelStsSetup.msDigis;
size_t numMs = msDigis.size(); size_t numMs = msDigis.size();
xpu::push_timer("Unpack");
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for (size_t i = 0; i < numMs; i++) { for (size_t i = 0; i < numMs; i++) {
auto result = fAlgoSts.at(msEqIds[i])(msContent[i], msDesc[i], ts.start_time()); auto result = fAlgoSts.at(msEqIds[i])(msContent[i], msDesc[i], ts.start_time());
msDigis[i] = std::move(result.first); msDigis[i] = std::move(result.first);
monitor[i] = std::move(result.second); monitor[i] = std::move(result.second);
} }
xpu::pop_timer();
size_t nDigisTotal = 0; size_t nDigisTotal = 0;
for (const auto& digis : msDigis) { for (const auto& digis : msDigis) {
nDigisTotal += digis.size(); nDigisTotal += digis.size();
} }
xpu::push_timer("Resize");
digisOut.resize(nDigisTotal); digisOut.resize(nDigisTotal);
xpu::pop_timer();
xpu::push_timer("Merge");
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for (unsigned int i = 0; i < numMs; i++) { for (unsigned int i = 0; i < numMs; i++) {
unsigned int offset = 0; unsigned int offset = 0;
...@@ -361,6 +378,7 @@ namespace cbm::algo ...@@ -361,6 +378,7 @@ namespace cbm::algo
offset += msDigis[x].size(); offset += msDigis[x].size();
std::copy(msDigis[i].begin(), msDigis[i].end(), digisOut.begin() + offset); std::copy(msDigis[i].begin(), msDigis[i].end(), digisOut.begin() + offset);
} }
xpu::pop_timer();
monitorOut = std::move(monitor); monitorOut = std::move(monitor);
......
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