From 198c1267267cb5f0a8f4f9c582a23bba95fc6cc3 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 22 Apr 2024 12:08:17 +0200 Subject: [PATCH] Migrate assert() to ALPAKA_ASSERT_ACC() --- .../alpaka/SiPixelGainCalibrationForHLTUtilities.h | 10 ++++++---- .../test/alpaka/Clusters_test.dev.cc | 8 ++++---- .../test/alpaka/DigiErrors_test.dev.cc | 8 ++++---- .../SiPixelDigiSoA/test/alpaka/Digis_test.dev.cc | 8 ++++---- .../VertexSoA/test/alpaka/ZVertexSoA_test.dev.cc | 14 +++++++------- .../plugins/alpaka/PixelRecHitKernels.dev.cc | 2 +- .../SiPixelRecHits/plugins/alpaka/PixelRecHits.h | 9 ++++----- RecoTracker/PixelSeeding/plugins/alpaka/CACell.h | 8 ++++---- .../plugins/alpaka/CAHitNtupletGeneratorKernels.h | 7 ++++--- 9 files changed, 38 insertions(+), 36 deletions(-) diff --git a/CondFormats/SiPixelObjects/interface/alpaka/SiPixelGainCalibrationForHLTUtilities.h b/CondFormats/SiPixelObjects/interface/alpaka/SiPixelGainCalibrationForHLTUtilities.h index 1fbce15dbe231..3767ab655a2c5 100644 --- a/CondFormats/SiPixelObjects/interface/alpaka/SiPixelGainCalibrationForHLTUtilities.h +++ b/CondFormats/SiPixelObjects/interface/alpaka/SiPixelGainCalibrationForHLTUtilities.h @@ -2,7 +2,9 @@ #define CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h #include + #include + #include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLTLayout.h" struct SiPixelGainUtilities { @@ -22,9 +24,9 @@ struct SiPixelGainUtilities { unsigned int numberOfDataBlocksToSkip = row / view.numberOfRowsAveragedOver(); auto offset = start + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip; - assert(offset < end); - assert(offset < 3088384); - assert(0 == offset % 2); + ALPAKA_ASSERT_ACC(offset < end); + ALPAKA_ASSERT_ACC(offset < 3088384); + ALPAKA_ASSERT_ACC(0 == offset % 2); auto lp = view.v_pedestals(); auto s = lp[offset / 2]; @@ -38,4 +40,4 @@ struct SiPixelGainUtilities { }; }; -#endif //CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h \ No newline at end of file +#endif // CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h diff --git a/DataFormats/SiPixelClusterSoA/test/alpaka/Clusters_test.dev.cc b/DataFormats/SiPixelClusterSoA/test/alpaka/Clusters_test.dev.cc index f98e7611c6229..77bbc73ad9f2e 100644 --- a/DataFormats/SiPixelClusterSoA/test/alpaka/Clusters_test.dev.cc +++ b/DataFormats/SiPixelClusterSoA/test/alpaka/Clusters_test.dev.cc @@ -31,10 +31,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testClusterSoA { template >> ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelClustersSoAConstView clust_view) const { for (uint32_t j : cms::alpakatools::uniform_elements(acc, clust_view.metadata().size())) { - assert(clust_view[j].moduleStart() == j); - assert(clust_view[j].clusInModule() == j * 2); - assert(clust_view[j].moduleId() == j * 3); - assert(clust_view[j].clusModuleStart() == j * 4); + ALPAKA_ASSERT_ACC(clust_view[j].moduleStart() == j); + ALPAKA_ASSERT_ACC(clust_view[j].clusInModule() == j * 2); + ALPAKA_ASSERT_ACC(clust_view[j].moduleId() == j * 3); + ALPAKA_ASSERT_ACC(clust_view[j].clusModuleStart() == j * 4); } } }; diff --git a/DataFormats/SiPixelDigiSoA/test/alpaka/DigiErrors_test.dev.cc b/DataFormats/SiPixelDigiSoA/test/alpaka/DigiErrors_test.dev.cc index 3829f7d755f6a..bf9b42c2c489d 100644 --- a/DataFormats/SiPixelDigiSoA/test/alpaka/DigiErrors_test.dev.cc +++ b/DataFormats/SiPixelDigiSoA/test/alpaka/DigiErrors_test.dev.cc @@ -32,10 +32,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA { template >> ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigiErrorsSoAConstView digiErrors_view) const { for (uint32_t j : cms::alpakatools::uniform_elements(acc, digiErrors_view.metadata().size())) { - assert(digiErrors_view[j].pixelErrors().rawId == j); - assert(digiErrors_view[j].pixelErrors().word == j); - assert(digiErrors_view[j].pixelErrors().errorType == j % 256); - assert(digiErrors_view[j].pixelErrors().fedId == j % 256); + ALPAKA_ASSERT_ACC(digiErrors_view[j].pixelErrors().rawId == j); + ALPAKA_ASSERT_ACC(digiErrors_view[j].pixelErrors().word == j); + ALPAKA_ASSERT_ACC(digiErrors_view[j].pixelErrors().errorType == j % 256); + ALPAKA_ASSERT_ACC(digiErrors_view[j].pixelErrors().fedId == j % 256); } } }; diff --git a/DataFormats/SiPixelDigiSoA/test/alpaka/Digis_test.dev.cc b/DataFormats/SiPixelDigiSoA/test/alpaka/Digis_test.dev.cc index 721b17912c65b..648b26ae3ddb7 100644 --- a/DataFormats/SiPixelDigiSoA/test/alpaka/Digis_test.dev.cc +++ b/DataFormats/SiPixelDigiSoA/test/alpaka/Digis_test.dev.cc @@ -29,10 +29,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA { template >> ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAConstView digi_view) const { for (uint32_t j : cms::alpakatools::uniform_elements(acc, digi_view.metadata().size())) { - assert(digi_view[j].clus() == int(j)); - assert(digi_view[j].rawIdArr() == j * 2); - assert(digi_view[j].xx() == j * 3); - assert(digi_view[j].moduleId() == j * 4); + ALPAKA_ASSERT_ACC(digi_view[j].clus() == int(j)); + ALPAKA_ASSERT_ACC(digi_view[j].rawIdArr() == j * 2); + ALPAKA_ASSERT_ACC(digi_view[j].xx() == j * 3); + ALPAKA_ASSERT_ACC(digi_view[j].moduleId() == j * 4); } } }; diff --git a/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.dev.cc b/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.dev.cc index 75a1ebf6b9269..1af92d5050943 100644 --- a/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.dev.cc +++ b/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.dev.cc @@ -37,13 +37,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testZVertexSoAT { } for (int32_t j : cms::alpakatools::uniform_elements(acc, zvertex_view.nvFinal())) { - assert(zvertex_view[j].idv() == j); - assert(zvertex_view[j].zv() - (float)j < 0.0001); - assert(zvertex_view[j].wv() - (float)j < 0.0001); - assert(zvertex_view[j].chi2() - (float)j < 0.0001); - assert(zvertex_view[j].ptv2() - (float)j < 0.0001); - assert(zvertex_view[j].ndof() == j); - assert(zvertex_view[j].sortInd() == uint32_t(j)); + ALPAKA_ASSERT_ACC(zvertex_view[j].idv() == j); + ALPAKA_ASSERT_ACC(zvertex_view[j].zv() - (float)j < 0.0001); + ALPAKA_ASSERT_ACC(zvertex_view[j].wv() - (float)j < 0.0001); + ALPAKA_ASSERT_ACC(zvertex_view[j].chi2() - (float)j < 0.0001); + ALPAKA_ASSERT_ACC(zvertex_view[j].ptv2() - (float)j < 0.0001); + ALPAKA_ASSERT_ACC(zvertex_view[j].ndof() == j); + ALPAKA_ASSERT_ACC(zvertex_view[j].sortInd() == uint32_t(j)); } } }; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc index fe3a703a8e713..1dbd77bb4ed09 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc @@ -34,7 +34,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { uint32_t const* __restrict__ hitsModuleStart, pixelCPEforDevice::ParamsOnDeviceT const* __restrict__ cpeParams, uint32_t* __restrict__ hitsLayerStart) const { - assert(0 == hitsModuleStart[0]); + ALPAKA_ASSERT_ACC(0 == hitsModuleStart[0]); for (int32_t i : cms::alpakatools::uniform_elements(acc, TrackerTraits::numberOfLayers + 1)) { hitsLayerStart[i] = hitsModuleStart[cpeParams->layerGeometry().layerStart[i]]; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h index aacdeb79a2749..7fd6234d0ba3b 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h +++ b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h @@ -97,11 +97,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { int nClusInIter = alpaka::math::min(acc, maxHitsInIter, endClus - startClus); int lastClus = startClus + nClusInIter; - assert(nClusInIter <= nclus); - assert(nClusInIter > 0); - assert(lastClus <= nclus); - - assert(nclus > maxHitsInIter || (0 == startClus && nClusInIter == nclus && lastClus == nclus)); + ALPAKA_ASSERT_ACC(nClusInIter <= nclus); + ALPAKA_ASSERT_ACC(nClusInIter > 0); + ALPAKA_ASSERT_ACC(lastClus <= nclus); + ALPAKA_ASSERT_ACC(nclus > maxHitsInIter || (0 == startClus && nClusInIter == nclus && lastClus == nclus)); // init for (uint32_t ic : cms::alpakatools::independent_group_elements(acc, nClusInIter)) { diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h b/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h index d8af548109d29..44b7bea5075fb 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h @@ -67,8 +67,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { // link to default empty theOuterNeighbors = &cellNeighbors[0]; theTracks = &cellTracks[0]; - assert(outerNeighbors().empty()); - assert(tracks().empty()); + ALPAKA_ASSERT_ACC(outerNeighbors().empty()); + ALPAKA_ASSERT_ACC(tracks().empty()); } template @@ -334,7 +334,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { hits[nh++] = cells[c].theFishboneId; // Fishbone hit is always outer than inner hit } } - assert(nh < TrackerTraits::maxHitsOnTrack); + ALPAKA_ASSERT_ACC(nh < TrackerTraits::maxHitsOnTrack); hits[nh] = theOuterHitId; auto it = foundNtuplets.bulkFill(acc, apc, hits, nh + 1); if (it >= 0) { // if negative is overflow.... @@ -346,7 +346,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { } } tmpNtuplet.pop_back(); - assert(tmpNtuplet.size() < int(TrackerTraits::maxHitsOnTrack - 1)); + ALPAKA_ASSERT_ACC(tmpNtuplet.size() < int(TrackerTraits::maxHitsOnTrack - 1)); } } diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h index 796bb3f36c586..6999169a46d73 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h @@ -65,8 +65,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { /// Is this a pair with inner == 0? ALPAKA_FN_ACC ALPAKA_FN_INLINE bool startAt0(int16_t pid) const { - assert((pixelTopology::Phase1::layerPairs[pid * 2] == 0) == - (pid < 3 || pid == 13 || pid == 15 || pid == 16)); // to be 100% sure it's working, may be removed + ALPAKA_ASSERT_ACC( + (pixelTopology::Phase1::layerPairs[pid * 2] == 0) == + (pid < 3 || pid == 13 || pid == 15 || pid == 16)); // to be 100% sure it's working, may be removed return pixelTopology::Phase1::layerPairs[pid * 2] == 0; } }; @@ -81,7 +82,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { /// Is this a pair with inner == 0 ALPAKA_FN_ACC ALPAKA_FN_INLINE bool startAt0(int16_t pid) const { - assert((pixelTopology::Phase2::layerPairs[pid * 2] == 0) == ((pid < 3) | (pid >= 23 && pid < 28))); + ALPAKA_ASSERT_ACC((pixelTopology::Phase2::layerPairs[pid * 2] == 0) == ((pid < 3) | (pid >= 23 && pid < 28))); return pixelTopology::Phase2::layerPairs[pid * 2] == 0; } };