Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14_0_X] Allow Runtime Number of Hits for Alpaka Pixel Reconstruction #44774

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Geometry/CommonTopologies/interface/SimplePixelTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ namespace pixelTopology {
using tindex_type = uint32_t; // for tuples
using cindex_type = uint32_t; // for cells

static constexpr uint32_t maxNumberOfHits = 256 * 1024;
static constexpr uint32_t maxCellNeighbors = 64;
static constexpr uint32_t maxCellTracks = 302;
static constexpr uint32_t maxHitsOnTrack = 15;
Expand Down Expand Up @@ -417,7 +416,6 @@ namespace pixelTopology {
using tindex_type = uint16_t; // for tuples
using cindex_type = uint32_t; // for cells

static constexpr uint32_t maxNumberOfHits = 48 * 1024;
static constexpr uint32_t maxCellNeighbors = 36;
static constexpr uint32_t maxCellTracks = 48;
static constexpr uint32_t maxHitsOnTrack = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
alpaka::syncBlockThreads(acc);
}
#ifdef GPU_DEBUG
ALPAKA_ASSERT_ACC(0 == clus_view[0].moduleStart());
auto c0 = std::min(maxHitsInModule, clus_view[1].clusModuleStart());
ALPAKA_ASSERT_ACC(c0 == clus_view[1].moduleStart());
ALPAKA_ASSERT_ACC(0 == clus_view[1].moduleStart());
auto c0 = std::min(maxHitsInModule, clus_view[2].clusModuleStart());
ALPAKA_ASSERT_ACC(c0 == clus_view[2].moduleStart());
ALPAKA_ASSERT_ACC(clus_view[1024].moduleStart() >= clus_view[1023].moduleStart());
ALPAKA_ASSERT_ACC(clus_view[1025].moduleStart() >= clus_view[1024].moduleStart());
ALPAKA_ASSERT_ACC(clus_view[numberOfModules].moduleStart() >= clus_view[1025].moduleStart());
Expand All @@ -504,13 +504,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
if (i == bpix2 || i == fpix1)
printf("moduleStart %d %d\n", i, clus_view[i].moduleStart());
}

#endif
// avoid overflow
constexpr auto MAX_HITS = TrackerTraits::maxNumberOfHits;
for (uint32_t i : cms::alpakatools::independent_group_elements(acc, numberOfModules + 1)) {
if (clus_view[i].clusModuleStart() > MAX_HITS)
clus_view[i].clusModuleStart() = MAX_HITS;
}

} // end of FillHitsModuleStart kernel operator()
}; // end of FillHitsModuleStart struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
hrv_d.contentSize = nHits;
hrv_d.contentStorage = hits_d.view().phiBinnerStorage();

// fillManyFromVector<Acc1D>(h_d.data(), nParts, v_d.data(), offsets_d.data(), offsets[10], 256, queue);
/* cms::alpakatools::fillManyFromVector<Acc1D>(&(hits_d.view().phiBinner()),
nLayers,
hits_d.view().iphi(),
hits_d.view().hitsLayerStart().data(),
nHits,
(uint32_t)256,
queue);
*/
cms::alpakatools::fillManyFromVector<Acc1D>(&(hits_d.view().phiBinner()),
hrv_d,
nLayers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

// workspace
device_hitToTuple_{cms::alpakatools::make_device_buffer<HitToTuple>(queue)},
device_hitToTupleStorage_{
cms::alpakatools::make_device_buffer<typename HitToTuple::Counter[]>(queue, nhits + 1)},
device_tupleMultiplicity_{cms::alpakatools::make_device_buffer<TupleMultiplicity>(queue)},

// NB: In legacy, device_theCells_ and device_isOuterHitOfCell_ were allocated inside buildDoublets
Expand Down Expand Up @@ -66,6 +68,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
device_hitToTuple_apc_{reinterpret_cast<cms::alpakatools::AtomicPairCounter *>(device_storage_.data() + 1)},
device_nCells_{cms::alpakatools::make_device_view(alpaka::getDev(queue),
*reinterpret_cast<uint32_t *>(device_storage_.data() + 2))} {
#ifdef GPU_DEBUG
std::cout << "Allocation for tuple building. N hits " << nhits << std::endl;
#endif

alpaka::memset(queue, counters_, 0);
alpaka::memset(queue, device_nCells_, 0);
alpaka::memset(queue, cellStorage_, 0);
Expand All @@ -74,14 +80,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
alpaka::memcpy(queue, device_cellCuts_, cellCuts_h);

[[maybe_unused]] TupleMultiplicity *tupleMultiplicityDeviceData = device_tupleMultiplicity_.data();
[[maybe_unused]] HitToTuple *hitToTupleDeviceData = device_hitToTuple_.data();
using TM = cms::alpakatools::OneToManyAssocRandomAccess<typename TrackerTraits::tindex_type,
TrackerTraits::maxHitsOnTrack + 1,
TrackerTraits::maxNumberOfTuples>;
TM *tm = device_tupleMultiplicity_.data();
TM::template launchZero<Acc1D>(tm, queue);
TupleMultiplicity::template launchZero<Acc1D>(tupleMultiplicityDeviceData, queue);
HitToTuple::template launchZero<Acc1D>(hitToTupleDeviceData, queue);

device_hitToTupleView_.assoc = device_hitToTuple_.data();
device_hitToTupleView_.offStorage = device_hitToTupleStorage_.data();
device_hitToTupleView_.offSize = nhits + 1;

HitToTuple::template launchZero<Acc1D>(device_hitToTupleView_, queue);
#ifdef GPU_DEBUG
std::cout << "Allocations for CAHitNtupletGeneratorKernels: done!" << std::endl;
#endif
}

template <typename TrackerTraits>
Expand Down Expand Up @@ -401,7 +414,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
tracks_view,
this->device_hitToTuple_.data()); //CHECK

HitToTuple::template launchFinalize<Acc1D>(this->device_hitToTuple_.data(), queue);
HitToTuple::template launchFinalize<Acc1D>(this->device_hitToTupleView_, queue);
alpaka::exec<Acc1D>(
queue, workDiv1D, Kernel_fillHitInTracks<TrackerTraits>{}, tracks_view, this->device_hitToTuple_.data());
#ifdef GPU_DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

// workspace
cms::alpakatools::device_buffer<Device, HitToTuple> device_hitToTuple_;
cms::alpakatools::device_buffer<Device, uint32_t[]> device_hitToTupleStorage_;
typename HitToTuple::View device_hitToTupleView_;
cms::alpakatools::device_buffer<Device, TupleMultiplicity> device_tupleMultiplicity_;
cms::alpakatools::device_buffer<Device, CACell[]> device_theCells_;
cms::alpakatools::device_buffer<Device, OuterHitOfCellContainer[]> device_isOuterHitOfCell_;
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/PixelSeeding/plugins/alpaka/CAStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace caStructures {
template <typename TrackerTraits>
using HitToTupleT =
cms::alpakatools::OneToManyAssocRandomAccess<typename TrackerTraits::tindex_type,
TrackerTraits::maxNumberOfHits,
-1,
TrackerTraits::maxHitsForContainers>; // 3.5 should be enough

template <typename TrackerTraits>
Expand Down