From 010dc9762a7079c9a50259285de3991c17a987f9 Mon Sep 17 00:00:00 2001 From: Dominik Smith <smith@th.physik.uni-frankfurt.de> Date: Tue, 14 Nov 2023 15:18:40 +0100 Subject: [PATCH] Applied PODVector in cbm::algo::tof::Hitfind. Modified compat/OpenMP.h. --- algo/base/compat/OpenMP.h | 2 ++ algo/detectors/tof/Hitfind.cxx | 16 +++++----------- algo/detectors/tof/Hitfind.h | 4 +++- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/algo/base/compat/OpenMP.h b/algo/base/compat/OpenMP.h index 84d57489de..b535e43b37 100644 --- a/algo/base/compat/OpenMP.h +++ b/algo/base/compat/OpenMP.h @@ -45,10 +45,12 @@ namespace cbm::algo::openmp #ifndef HAVE_OMP inline int GetMaxThreads() { return 1; } inline int GetThreadNum() { return 0; } + inline int GetNumThreads() { return 1; } inline void SetNumThreads(int) {} #else inline int GetMaxThreads() { return omp_get_max_threads(); } inline int GetThreadNum() { return omp_get_thread_num(); } + inline int GetNumThreads() { return omp_get_num_threads(); } inline void SetNumThreads(int n) { omp_set_num_threads(n); } #endif diff --git a/algo/detectors/tof/Hitfind.cxx b/algo/detectors/tof/Hitfind.cxx index 02f3e30989..be317d82f9 100644 --- a/algo/detectors/tof/Hitfind.cxx +++ b/algo/detectors/tof/Hitfind.cxx @@ -97,9 +97,9 @@ namespace cbm::algo::tof } monitor.fSortTime = xpu::pop_timer(); - std::vector<Hit> clustersFlat; // cluster storage - std::vector<size_t> chanSizes; // nClusters per channel - std::vector<u32> chanAddresses; // channel addresses + PODVector<Hit> clustersFlat; // cluster storage + PODVector<size_t> chanSizes; // nClusters per channel + PODVector<u32> chanAddresses; // channel addresses // Prefix arrays for parallelization std::vector<size_t> cluPrefix; @@ -111,14 +111,8 @@ namespace cbm::algo::tof xpu::t_add_bytes(digiIn.size_bytes()); #pragma omp parallel { - -#ifdef _OPENMP - int ithread = omp_get_thread_num(); - int nthreads = omp_get_num_threads(); -#else - int ithread = 0; - int nthreads = 1; -#endif + const int ithread = openmp::GetThreadNum(); + const int nthreads = openmp::GetNumThreads(); #pragma omp single { diff --git a/algo/detectors/tof/Hitfind.h b/algo/detectors/tof/Hitfind.h index 23d40eeda5..b9b11c8a2b 100644 --- a/algo/detectors/tof/Hitfind.h +++ b/algo/detectors/tof/Hitfind.h @@ -17,8 +17,10 @@ #include <xpu/host.h> +#include "PODVector.h" #include "PartitionedVector.h" + namespace cbm::algo::tof { @@ -52,7 +54,7 @@ namespace cbm::algo::tof class Hitfind { public: - typedef std::tuple<PartitionedVector<Hit>, HitfindMonitorData, std::vector<i32>> resultType; + typedef std::tuple<PartitionedVector<Hit>, HitfindMonitorData, PODVector<i32>> resultType; /** @brief Algorithm execution ** @param fles timeslice to hitfind -- GitLab