Skip to content
Snippets Groups Projects
Commit 4da2402d authored by Dominik Smith's avatar Dominik Smith
Browse files

Fixed error in module-partitioning of trd::Hitfind output on multiple threads.

parent bdf5f245
No related branches found
No related tags found
1 merge request!1792Fixed error in module-partitioning of trd::Hitfind output on multiple threads.
Pipeline #29156 passed
......@@ -186,12 +186,14 @@ namespace cbm::algo::trd
monitor.timeClusterize = xpu::pop_timer();
// Hit finding
PODVector<Hit> hitsFlat; // hit storage
std::vector<size_t> modSizes(fModList.size()); // nHits per modules
std::vector<uint> modAddresses(fModList.size()); // address of modules
PODVector<Hit> hitsFlat; // hit storage
PODVector<size_t> modSizes; // nHits per modules
PODVector<uint> modAddresses; // address of modules
// Prefix array for parallelization
std::vector<size_t> hitsPrefix;
std::vector<size_t> sizePrefix;
std::vector<size_t> addrPrefix;
xpu::push_timer("FindHits");
CBM_PARALLEL()
......@@ -199,9 +201,16 @@ namespace cbm::algo::trd
const int ithread = openmp::GetThreadNum();
const int nthreads = openmp::GetNumThreads();
CBM_OMP(single) { hitsPrefix.resize(nthreads + 1); }
CBM_OMP(single)
{
hitsPrefix.resize(nthreads + 1);
sizePrefix.resize(nthreads + 1);
addrPrefix.resize(nthreads + 1);
}
std::vector<Hit> local_hits;
std::vector<size_t> local_sizes;
std::vector<uint> local_addresses;
CBM_OMP(for schedule(dynamic) nowait)
for (size_t mod = 0; mod < fModList.size(); mod++) {
......@@ -228,27 +237,35 @@ namespace cbm::algo::trd
//sort(clusters.begin(), clusters.end(), [](const auto& a, const auto& b) { return a.GetStartTime() < b.GetStartTime(); });
mod_hits = (*fHitFind[address])(&clusters);
}
// Append clusters to output
local_hits.insert(local_hits.end(), std::make_move_iterator(mod_hits.begin()),
std::make_move_iterator(mod_hits.end()));
// store partition size
modSizes[mod] = mod_hits.size();
local_sizes.push_back(mod_hits.size());
// store hw address of partition
modAddresses[mod] = address;
local_addresses.push_back(address);
// Append clusters to output
local_hits.insert(local_hits.end(), std::make_move_iterator(mod_hits.begin()),
std::make_move_iterator(mod_hits.end()));
}
hitsPrefix[ithread + 1] = local_hits.size();
sizePrefix[ithread + 1] = local_sizes.size();
addrPrefix[ithread + 1] = local_addresses.size();
CBM_OMP(barrier)
CBM_OMP(single)
{
for (int i = 1; i < (nthreads + 1); i++) {
hitsPrefix[i] += hitsPrefix[i - 1];
sizePrefix[i] += sizePrefix[i - 1];
addrPrefix[i] += addrPrefix[i - 1];
}
hitsFlat.resize(hitsPrefix[nthreads]);
modSizes.resize(sizePrefix[nthreads]);
modAddresses.resize(addrPrefix[nthreads]);
}
std::move(local_hits.begin(), local_hits.end(), hitsFlat.begin() + hitsPrefix[ithread]);
std::move(local_sizes.begin(), local_sizes.end(), modSizes.begin() + sizePrefix[ithread]);
std::move(local_addresses.begin(), local_addresses.end(), modAddresses.begin() + addrPrefix[ithread]);
}
// Monitoring
monitor.timeHitfind = xpu::pop_timer();
......
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