From 486bfef5727ea57f21525f901e87d1631f48bb38 Mon Sep 17 00:00:00 2001
From: AuroraPerego <aurora.perego@cern.ch>
Date: Thu, 17 Oct 2024 11:21:25 +0200
Subject: [PATCH] generalize warp size in pixel clustering

---
 .../SiPixelClusterizer/plugins/alpaka/PixelClustering.h  | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/PixelClustering.h b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/PixelClustering.h
index 385fc0b852ad3..3405a97656cf7 100644
--- a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/PixelClustering.h
+++ b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/PixelClustering.h
@@ -182,8 +182,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering {
                                                       TrackerTraits::maxPixInModule,
                                                       TrackerTraits::clusterBits,
                                                       uint16_t>;
+#if defined(__HIP_DEVICE_COMPILE__)
+        constexpr auto warpSize = __AMDGCN_WAVEFRONT_SIZE;
+#else
+        constexpr auto warpSize = 32;
+#endif
         auto& hist = alpaka::declareSharedVar<Hist, __COUNTER__>(acc);
-        auto& ws = alpaka::declareSharedVar<typename Hist::Counter[32], __COUNTER__>(acc);
+        auto& ws = alpaka::declareSharedVar<typename Hist::Counter[warpSize], __COUNTER__>(acc);
         for (uint32_t j : cms::alpakatools::independent_group_elements(acc, Hist::totbins())) {
           hist.off[j] = 0;
         }
@@ -254,7 +259,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering {
           }
         }
         alpaka::syncBlockThreads(acc);  // FIXME this can be removed
-        for (uint32_t i : cms::alpakatools::independent_group_elements(acc, 32u)) {
+        for (uint32_t i : cms::alpakatools::independent_group_elements(acc, warpSize)) {
           ws[i] = 0;  // used by prefix scan...
         }
         alpaka::syncBlockThreads(acc);