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

Dynamic Memory Limits for LST Objects #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions RecoTracker/LSTCore/interface/PixelSegmentsHostCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef RecoTracker_LSTCore_interface_PixelSegmentsHostCollection_h
#define RecoTracker_LSTCore_interface_PixelSegmentsHostCollection_h

#include "RecoTracker/LSTCore/interface/PixelSegmentsSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace lst {
using PixelSegmentsHostCollection = PortableHostCollection<PixelSegmentsSoA>;
} // namespace lst
#endif
40 changes: 40 additions & 0 deletions RecoTracker/LSTCore/interface/PixelSegmentsSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef RecoTracker_LSTCore_interface_PixelSegmentsSoA_h
#define RecoTracker_LSTCore_interface_PixelSegmentsSoA_h

#include "DataFormats/SoATemplate/interface/SoALayout.h"
#include "DataFormats/Portable/interface/PortableCollection.h"

#include "RecoTracker/LSTCore/interface/Common.h"

namespace lst {

GENERATE_SOA_LAYOUT(PixelSegmentsSoALayout,
SOA_COLUMN(unsigned int, seedIdx),
SOA_COLUMN(int, charge),
SOA_COLUMN(int, superbin),
SOA_COLUMN(uint4, pLSHitsIdxs),
SOA_COLUMN(PixelType, pixelType),
SOA_COLUMN(char, isQuad),
SOA_COLUMN(char, isDup),
SOA_COLUMN(bool, partOfPT5),
SOA_COLUMN(float, ptIn),
SOA_COLUMN(float, ptErr),
SOA_COLUMN(float, px),
SOA_COLUMN(float, py),
SOA_COLUMN(float, pz),
SOA_COLUMN(float, etaErr),
SOA_COLUMN(float, eta),
SOA_COLUMN(float, phi),
SOA_COLUMN(float, score),
SOA_COLUMN(float, circleCenterX),
SOA_COLUMN(float, circleCenterY),
SOA_COLUMN(float, circleRadius))

using PixelSegmentsSoA = PixelSegmentsSoALayout<>;

using PixelSegments = PixelSegmentsSoA::View;
using PixelSegmentsConst = PixelSegmentsSoA::ConstView;

} // namespace lst

#endif
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/SegmentsHostCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace lst {
using SegmentsHostCollection = PortableHostMultiCollection<SegmentsSoA, SegmentsOccupancySoA, SegmentsPixelSoA>;
using SegmentsHostCollection = PortableHostMultiCollection<SegmentsSoA, SegmentsOccupancySoA>;
} // namespace lst
#endif
25 changes: 0 additions & 25 deletions RecoTracker/LSTCore/interface/SegmentsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,13 @@ namespace lst {
SOA_COLUMN(unsigned int, nSegments), //number of segments per inner lower module
SOA_COLUMN(unsigned int, totOccupancySegments))

GENERATE_SOA_LAYOUT(SegmentsPixelSoALayout,
SOA_COLUMN(unsigned int, seedIdx),
SOA_COLUMN(int, charge),
SOA_COLUMN(int, superbin),
SOA_COLUMN(uint4, pLSHitsIdxs),
SOA_COLUMN(PixelType, pixelType),
SOA_COLUMN(char, isQuad),
SOA_COLUMN(char, isDup),
SOA_COLUMN(bool, partOfPT5),
SOA_COLUMN(float, ptIn),
SOA_COLUMN(float, ptErr),
SOA_COLUMN(float, px),
SOA_COLUMN(float, py),
SOA_COLUMN(float, pz),
SOA_COLUMN(float, etaErr),
SOA_COLUMN(float, eta),
SOA_COLUMN(float, phi),
SOA_COLUMN(float, score),
SOA_COLUMN(float, circleCenterX),
SOA_COLUMN(float, circleCenterY),
SOA_COLUMN(float, circleRadius))

using SegmentsSoA = SegmentsSoALayout<>;
using SegmentsOccupancySoA = SegmentsOccupancySoALayout<>;
using SegmentsPixelSoA = SegmentsPixelSoALayout<>;

using Segments = SegmentsSoA::View;
using SegmentsConst = SegmentsSoA::ConstView;
using SegmentsOccupancy = SegmentsOccupancySoA::View;
using SegmentsOccupancyConst = SegmentsOccupancySoA::ConstView;
using SegmentsPixel = SegmentsPixelSoA::View;
using SegmentsPixelConst = SegmentsPixelSoA::ConstView;

} // namespace lst

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef RecoTracker_LSTCore_interface_alpaka_PixelSegmentsDeviceCollection_h
#define RecoTracker_LSTCore_interface_alpaka_PixelSegmentsDeviceCollection_h

#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/PixelSegmentsSoA.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
using PixelSegmentsDeviceCollection = PortableCollection<PixelSegmentsSoA>;
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
using SegmentsDeviceCollection = PortableCollection3<SegmentsSoA, SegmentsOccupancySoA, SegmentsPixelSoA>;
using SegmentsDeviceCollection = PortableCollection2<SegmentsSoA, SegmentsOccupancySoA>;
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst

#endif
43 changes: 22 additions & 21 deletions RecoTracker/LSTCore/src/alpaka/Kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelSegmentsSoA.h"
#include "RecoTracker/LSTCore/interface/QuintupletsSoA.h"
#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"
Expand All @@ -30,10 +31,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
pixelQuintuplets.isDup()[pixelQuintupletIndex] = true;
}

ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(SegmentsPixel segmentsPixel,
ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(PixelSegments pixelSegments,
unsigned int pixelSegmentArrayIndex,
bool secondpass = false) {
segmentsPixel.isDup()[pixelSegmentArrayIndex] |= 1 + secondpass;
pixelSegments.isDup()[pixelSegmentArrayIndex] |= 1 + secondpass;
}

ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkHitsT5(unsigned int ix, unsigned int jx, QuintupletsConst quintuplets) {
Expand Down Expand Up @@ -321,7 +322,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_FN_ACC void operator()(Acc2D const& acc,
ModulesConst modules,
SegmentsOccupancyConst segmentsOccupancy,
SegmentsPixel segmentsPixel,
PixelSegments pixelSegments,
bool secondpass) const {
int pixelModuleIndex = modules.nLowerModules();
unsigned int nPixelSegments = segmentsOccupancy.nSegments()[pixelModuleIndex];
Expand All @@ -330,29 +331,29 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
nPixelSegments = n_max_pixel_segments_per_module;

for (unsigned int ix : cms::alpakatools::uniform_elements_y(acc, nPixelSegments)) {
if (secondpass && (!segmentsPixel.isQuad()[ix] || (segmentsPixel.isDup()[ix] & 1)))
if (secondpass && (!pixelSegments.isQuad()[ix] || (pixelSegments.isDup()[ix] & 1)))
continue;

unsigned int phits1[Params_pLS::kHits];
phits1[0] = segmentsPixel.pLSHitsIdxs()[ix].x;
phits1[1] = segmentsPixel.pLSHitsIdxs()[ix].y;
phits1[2] = segmentsPixel.pLSHitsIdxs()[ix].z;
phits1[3] = segmentsPixel.pLSHitsIdxs()[ix].w;
float eta_pix1 = segmentsPixel.eta()[ix];
float phi_pix1 = segmentsPixel.phi()[ix];
phits1[0] = pixelSegments.pLSHitsIdxs()[ix].x;
phits1[1] = pixelSegments.pLSHitsIdxs()[ix].y;
phits1[2] = pixelSegments.pLSHitsIdxs()[ix].z;
phits1[3] = pixelSegments.pLSHitsIdxs()[ix].w;
float eta_pix1 = pixelSegments.eta()[ix];
float phi_pix1 = pixelSegments.phi()[ix];

for (unsigned int jx : cms::alpakatools::uniform_elements_x(acc, ix + 1, nPixelSegments)) {
float eta_pix2 = segmentsPixel.eta()[jx];
float phi_pix2 = segmentsPixel.phi()[jx];
float eta_pix2 = pixelSegments.eta()[jx];
float phi_pix2 = pixelSegments.phi()[jx];

if (alpaka::math::abs(acc, eta_pix2 - eta_pix1) > 0.1f)
continue;

if (secondpass && (!segmentsPixel.isQuad()[jx] || (segmentsPixel.isDup()[jx] & 1)))
if (secondpass && (!pixelSegments.isQuad()[jx] || (pixelSegments.isDup()[jx] & 1)))
continue;

int8_t quad_diff = segmentsPixel.isQuad()[ix] - segmentsPixel.isQuad()[jx];
float score_diff = segmentsPixel.score()[ix] - segmentsPixel.score()[jx];
int8_t quad_diff = pixelSegments.isQuad()[ix] - pixelSegments.isQuad()[jx];
float score_diff = pixelSegments.score()[ix] - pixelSegments.score()[jx];
// Always keep quads over trips. If they are the same, we want the object with better score
int idxToRemove;
if (quad_diff > 0)
Expand All @@ -367,10 +368,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
idxToRemove = ix;

unsigned int phits2[Params_pLS::kHits];
phits2[0] = segmentsPixel.pLSHitsIdxs()[jx].x;
phits2[1] = segmentsPixel.pLSHitsIdxs()[jx].y;
phits2[2] = segmentsPixel.pLSHitsIdxs()[jx].z;
phits2[3] = segmentsPixel.pLSHitsIdxs()[jx].w;
phits2[0] = pixelSegments.pLSHitsIdxs()[jx].x;
phits2[1] = pixelSegments.pLSHitsIdxs()[jx].y;
phits2[2] = pixelSegments.pLSHitsIdxs()[jx].z;
phits2[3] = pixelSegments.pLSHitsIdxs()[jx].w;

int npMatched = 0;
for (int i = 0; i < Params_pLS::kHits; i++) {
Expand All @@ -390,15 +391,15 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
}
const int minNHitsForDup_pLS = 3;
if (npMatched >= minNHitsForDup_pLS) {
rmPixelSegmentFromMemory(segmentsPixel, idxToRemove, secondpass);
rmPixelSegmentFromMemory(pixelSegments, idxToRemove, secondpass);
}
if (secondpass) {
float dEta = alpaka::math::abs(acc, eta_pix1 - eta_pix2);
float dPhi = reco::deltaPhi(phi_pix1, phi_pix2);

float dR2 = dEta * dEta + dPhi * dPhi;
if ((npMatched >= 1) || (dR2 < 1e-5f)) {
rmPixelSegmentFromMemory(segmentsPixel, idxToRemove, secondpass);
rmPixelSegmentFromMemory(pixelSegments, idxToRemove, secondpass);
}
}
}
Expand Down
34 changes: 16 additions & 18 deletions RecoTracker/LSTCore/src/alpaka/LST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,19 @@ void LST::run(Queue& queue,
ptCut);

event.addHitToEvent(in_trkX_, in_trkY_, in_trkZ_, in_hitId_, in_hitIdxs_);
event.addPixelSegmentToEvent(in_hitIndices_vec0_,
in_hitIndices_vec1_,
in_hitIndices_vec2_,
in_hitIndices_vec3_,
in_deltaPhi_vec_,
in_ptIn_vec_,
in_ptErr_vec_,
in_px_vec_,
in_py_vec_,
in_pz_vec_,
in_eta_vec_,
in_etaErr_vec_,
in_phi_vec_,
in_charge_vec_,
in_seedIdx_vec_,
in_superbin_vec_,
in_pixelType_vec_,
in_isQuad_vec_);
event.addPixelSegmentToEventStart(in_ptIn_vec_,
in_ptErr_vec_,
in_px_vec_,
in_py_vec_,
in_pz_vec_,
in_eta_vec_,
in_etaErr_vec_,
in_phi_vec_,
in_charge_vec_,
in_seedIdx_vec_,
in_superbin_vec_,
in_pixelType_vec_,
in_isQuad_vec_);
event.createMiniDoublets();
if (verbose) {
alpaka::wait(queue); // event calls are asynchronous: wait before printing
Expand Down Expand Up @@ -388,6 +383,9 @@ void LST::run(Queue& queue,
printf("# of Quintuplets produced endcap layer 5: %d\n", event.getNumberOfQuintupletsByLayerEndcap(4));
}

event.addPixelSegmentToEventFinalize(
in_hitIndices_vec0_, in_hitIndices_vec1_, in_hitIndices_vec2_, in_hitIndices_vec3_, in_deltaPhi_vec_);

event.pixelLineSegmentCleaning(no_pls_dupclean);

event.createPixelQuintuplets();
Expand Down
Loading