Skip to content

Commit

Permalink
Migrate assert() to ALPAKA_ASSERT_ACC()
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Apr 22, 2024
1 parent 5f962ba commit 198c126
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#define CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h

#include <cstdint>

#include <alpaka/alpaka.hpp>

#include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLTLayout.h"

struct SiPixelGainUtilities {
Expand All @@ -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];
Expand All @@ -38,4 +40,4 @@ struct SiPixelGainUtilities {
};
};

#endif //CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h
#endif // CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testClusterSoA {
template <typename TAcc, typename = std::enable_if_t<isAccelerator<TAcc>>>
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);
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions DataFormats/SiPixelDigiSoA/test/alpaka/DigiErrors_test.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA {
template <typename TAcc, typename = std::enable_if_t<isAccelerator<TAcc>>>
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);
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions DataFormats/SiPixelDigiSoA/test/alpaka/Digis_test.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA {
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
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);
}
}
};
Expand Down
14 changes: 7 additions & 7 deletions DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
uint32_t const* __restrict__ hitsModuleStart,
pixelCPEforDevice::ParamsOnDeviceT<TrackerTraits> 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]];
Expand Down
9 changes: 4 additions & 5 deletions RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/PixelSeeding/plugins/alpaka/CACell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename TAcc>
Expand Down Expand Up @@ -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....
Expand All @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand All @@ -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;
}
};
Expand Down

0 comments on commit 198c126

Please sign in to comment.