Skip to content

Commit

Permalink
Adjusted naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Oct 10, 2024
1 parent 8fba6cb commit 129a2d4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
66 changes: 35 additions & 31 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Event::resetEventSync() {
}
hitsInGPU_.reset();
hitsBuffers_.reset();
mdsDev_.reset();
miniDoubletsDC_.reset();
rangesInGPU_.reset();
rangesBuffers_.reset();
segmentsInGPU_.reset();
Expand All @@ -70,7 +70,7 @@ void Event::resetEventSync() {

hitsInCPU_.reset();
rangesInCPU_.reset();
mdsHost_.reset();
miniDoubletsHC_.reset();
segmentsInCPU_.reset();
tripletsInCPU_.reset();
quintupletsInCPU_.reset();
Expand Down Expand Up @@ -170,7 +170,7 @@ void Event::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
unsigned int mdSize = 2 * size;
uint16_t pixelModuleIndex = pixelMapping_.pixelModuleIndex;

if (!mdsDev_) {
if (!miniDoubletsDC_) {
// Create a view for the element nLowerModules_ inside rangesBuffers_->miniDoubletModuleOccupancy
auto dst_view_miniDoubletModuleOccupancy =
alpaka::createSubView(rangesBuffers_->miniDoubletModuleOccupancy_buf, (Idx)1u, (Idx)nLowerModules_);
Expand All @@ -194,11 +194,12 @@ void Event::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
unsigned int nTotalMDs = *nTotalMDs_buf_h.data();

std::array<int, 2> const mds_sizes{{static_cast<int>(nTotalMDs), static_cast<int>(nLowerModules_ + 1)}};
mdsDev_.emplace(mds_sizes, queue_);
miniDoubletsDC_.emplace(mds_sizes, queue_);

auto nMDs_view = alpaka::createView(devAcc_, mdsDev_->view<MiniDoubletsOccupancySoA>().nMDs(), nLowerModules_ + 1);
auto totOccupancyMDs_view =
alpaka::createView(devAcc_, mdsDev_->view<MiniDoubletsOccupancySoA>().totOccupancyMDs(), nLowerModules_ + 1);
auto nMDs_view =
alpaka::createView(devAcc_, miniDoubletsDC_->view<MiniDoubletsOccupancySoA>().nMDs(), nLowerModules_ + 1);
auto totOccupancyMDs_view = alpaka::createView(
devAcc_, miniDoubletsDC_->view<MiniDoubletsOccupancySoA>().totOccupancyMDs(), nLowerModules_ + 1);
alpaka::memset(queue_, nMDs_view, 0u);
alpaka::memset(queue_, totOccupancyMDs_view, 0u);
}
Expand All @@ -213,7 +214,7 @@ void Event::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
CreateSegmentArrayRanges{},
*modulesBuffers_.data(),
*rangesInGPU_,
mdsDev_->const_view<MiniDoubletsSoA>());
miniDoubletsDC_->const_view<MiniDoubletsSoA>());

auto nTotalSegments_view = alpaka::createView(cms::alpakatools::host(), &nTotalSegments_, (Idx)1u);

Expand Down Expand Up @@ -266,7 +267,7 @@ void Event::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
alpaka::createSubView(segmentsBuffers_->totOccupancySegments_buf, (Idx)1u, (Idx)pixelModuleIndex);
alpaka::memcpy(queue_, dst_view_totOccupancySegments, src_view_size);

MiniDoubletsOccupancy mdsOccupancy = mdsDev_->view<MiniDoubletsOccupancySoA>();
MiniDoubletsOccupancy mdsOccupancy = miniDoubletsDC_->view<MiniDoubletsOccupancySoA>();
auto nMDs_view = alpaka::createView(devAcc_, mdsOccupancy.nMDs(), (Idx)nLowerModules_ + 1);
auto dst_view_nMDs = alpaka::createSubView(nMDs_view, (Idx)1u, (Idx)pixelModuleIndex);
alpaka::memcpy(queue_, dst_view_nMDs, src_view_mdSize);
Expand All @@ -287,7 +288,7 @@ void Event::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
*modulesBuffers_.data(),
*rangesInGPU_,
*hitsInGPU_,
mdsDev_->view<MiniDoubletsSoA>(),
miniDoubletsDC_->view<MiniDoubletsSoA>(),
*segmentsInGPU_,
hitIndices0_dev.data(),
hitIndices1_dev.data(),
Expand Down Expand Up @@ -321,13 +322,14 @@ void Event::createMiniDoublets() {
*nTotalMDs_buf_h.data() += n_max_pixel_md_per_modules;
unsigned int nTotalMDs = *nTotalMDs_buf_h.data();

if (!mdsDev_) {
if (!miniDoubletsDC_) {
std::array<int, 2> const mds_sizes{{static_cast<int>(nTotalMDs), static_cast<int>(nLowerModules_ + 1)}};
mdsDev_.emplace(mds_sizes, queue_);
miniDoubletsDC_.emplace(mds_sizes, queue_);

auto nMDs_view = alpaka::createView(devAcc_, mdsDev_->view<MiniDoubletsOccupancySoA>().nMDs(), nLowerModules_ + 1);
auto totOccupancyMDs_view =
alpaka::createView(devAcc_, mdsDev_->view<MiniDoubletsOccupancySoA>().totOccupancyMDs(), nLowerModules_ + 1);
auto nMDs_view =
alpaka::createView(devAcc_, miniDoubletsDC_->view<MiniDoubletsOccupancySoA>().nMDs(), nLowerModules_ + 1);
auto totOccupancyMDs_view = alpaka::createView(
devAcc_, miniDoubletsDC_->view<MiniDoubletsOccupancySoA>().totOccupancyMDs(), nLowerModules_ + 1);
alpaka::memset(queue_, nMDs_view, 0u);
alpaka::memset(queue_, totOccupancyMDs_view, 0u);
}
Expand All @@ -342,8 +344,8 @@ void Event::createMiniDoublets() {
CreateMiniDoubletsInGPUv2{},
*modulesBuffers_.data(),
*hitsInGPU_,
mdsDev_->view<MiniDoubletsSoA>(),
mdsDev_->view<MiniDoubletsOccupancySoA>(),
miniDoubletsDC_->view<MiniDoubletsSoA>(),
miniDoubletsDC_->view<MiniDoubletsOccupancySoA>(),
*rangesInGPU_);

WorkDiv1D const addMiniDoubletRangesToEventExplicit_workDiv = createWorkDiv<Vec1D>({1}, {1024}, {1});
Expand All @@ -352,7 +354,7 @@ void Event::createMiniDoublets() {
addMiniDoubletRangesToEventExplicit_workDiv,
AddMiniDoubletRangesToEventExplicit{},
*modulesBuffers_.data(),
mdsDev_->view<MiniDoubletsOccupancySoA>(),
miniDoubletsDC_->view<MiniDoubletsOccupancySoA>(),
*rangesInGPU_,
*hitsInGPU_);

Expand All @@ -377,8 +379,8 @@ void Event::createSegmentsWithModuleMap() {
createSegmentsInGPUv2_workDiv,
CreateSegmentsInGPUv2{},
*modulesBuffers_.data(),
mdsDev_->const_view<MiniDoubletsSoA>(),
mdsDev_->const_view<MiniDoubletsOccupancySoA>(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
miniDoubletsDC_->const_view<MiniDoubletsOccupancySoA>(),
*segmentsInGPU_,
*rangesInGPU_);

Expand Down Expand Up @@ -464,7 +466,7 @@ void Event::createTriplets() {
createTripletsInGPUv2_workDiv,
CreateTripletsInGPUv2{},
*modulesBuffers_.data(),
mdsDev_->const_view<MiniDoubletsSoA>(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
*segmentsInGPU_,
*tripletsInGPU_,
*rangesInGPU_,
Expand Down Expand Up @@ -583,7 +585,7 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) {
*pixelTripletsInGPU_,
trackCandidatesDC_->view(),
*segmentsInGPU_,
mdsDev_->const_view<MiniDoubletsSoA>(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
*hitsInGPU_,
*quintupletsInGPU_);

Expand Down Expand Up @@ -718,7 +720,7 @@ void Event::createPixelTriplets() {
CreatePixelTripletsInGPUFromMapv2{},
*modulesBuffers_.data(),
*rangesInGPU_,
mdsDev_->const_view<MiniDoubletsSoA>(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
*segmentsInGPU_,
*tripletsInGPU_,
*pixelTripletsInGPU_,
Expand Down Expand Up @@ -783,7 +785,7 @@ void Event::createQuintuplets() {
createQuintupletsInGPUv2_workDiv,
CreateQuintupletsInGPUv2{},
*modulesBuffers_.data(),
mdsDev_->const_view<MiniDoubletsSoA>(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
*segmentsInGPU_,
*tripletsInGPU_,
*quintupletsInGPU_,
Expand Down Expand Up @@ -918,7 +920,7 @@ void Event::createPixelQuintuplets() {
createPixelQuintupletsInGPUFromMapv2_workDiv,
CreatePixelQuintupletsInGPUFromMapv2{},
*modulesBuffers_.data(),
mdsDev_->const_view<MiniDoubletsSoA>(),
miniDoubletsDC_->const_view<MiniDoubletsSoA>(),
*segmentsInGPU_,
*tripletsInGPU_,
*quintupletsInGPU_,
Expand Down Expand Up @@ -961,7 +963,8 @@ void Event::createPixelQuintuplets() {

void Event::addMiniDoubletsToEventExplicit() {
auto nMDsCPU_buf = allocBufWrapper<unsigned int>(cms::alpakatools::host(), nLowerModules_, queue_);
auto nMDs_view = alpaka::createView(devAcc_, mdsDev_->const_view<MiniDoubletsOccupancySoA>().nMDs(), nLowerModules_);
auto nMDs_view =
alpaka::createView(devAcc_, miniDoubletsDC_->const_view<MiniDoubletsOccupancySoA>().nMDs(), nLowerModules_);
alpaka::memcpy(queue_, nMDsCPU_buf, nMDs_view, nLowerModules_);

// FIXME: replace by ES host data
Expand Down Expand Up @@ -1348,16 +1351,17 @@ ObjectRangesBuffer<alpaka_common::DevHost>& Event::getRanges(bool sync) {
template <typename TSoA, typename TDev>
typename TSoA::ConstView Event::getMiniDoublets(bool sync) {
if constexpr (std::is_same_v<TDev, DevHost>) {
return mdsDev_->const_view<TSoA>();
return miniDoubletsDC_->const_view<TSoA>();
} else {
if (!mdsHost_) {
mdsHost_.emplace(
if (!miniDoubletsHC_) {
miniDoubletsHC_.emplace(
cms::alpakatools::CopyToHost<
PortableMultiCollection<TDev, MiniDoubletsSoA, MiniDoubletsOccupancySoA>>::copyAsync(queue_, *mdsDev_));
PortableMultiCollection<TDev, MiniDoubletsSoA, MiniDoubletsOccupancySoA>>::copyAsync(queue_,
*miniDoubletsDC_));
if (sync)
alpaka::wait(queue_); // host consumers expect filled data
}
return mdsHost_->const_view<TSoA>();
return miniDoubletsHC_->const_view<TSoA>();
}
}
template MiniDoubletsConst Event::getMiniDoublets<MiniDoubletsSoA>(bool);
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
std::optional<ObjectRangesBuffer<Device>> rangesBuffers_;
std::optional<Hits> hitsInGPU_;
std::optional<HitsBuffer<Device>> hitsBuffers_;
std::optional<MiniDoubletsDeviceCollection> mdsDev_;
std::optional<MiniDoubletsDeviceCollection> miniDoubletsDC_;
std::optional<Segments> segmentsInGPU_;
std::optional<SegmentsBuffer<Device>> segmentsBuffers_;
std::optional<Triplets> tripletsInGPU_;
Expand All @@ -63,7 +63,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
//CPU interface stuff
std::optional<ObjectRangesBuffer<DevHost>> rangesInCPU_;
std::optional<HitsBuffer<DevHost>> hitsInCPU_;
std::optional<MiniDoubletsHostCollection> mdsHost_;
std::optional<MiniDoubletsHostCollection> miniDoubletsHC_;
std::optional<SegmentsBuffer<DevHost>> segmentsInCPU_;
std::optional<TripletsBuffer<DevHost>> tripletsInCPU_;
std::optional<TrackCandidatesHostCollection> trackCandidatesHC_;
Expand Down

0 comments on commit 129a2d4

Please sign in to comment.