Skip to content
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
2 changes: 1 addition & 1 deletion HeterogeneousCore/AlpakaMath/interface/deltaPhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace cms::alpakatools {

template <alpaka::concepts::Acc TAcc, typename T>
ALPAKA_FN_HOST_ACC inline T deltaPhi(TAcc const& acc, T x1, T y1, T x2, T y2) {
return reducePhiRange(acc, alpaka::math::atan2(acc, -y2, -x2) - alpaka::math::atan2(acc, -y1, -x1));
return alpaka::math::atan2(acc, x1 * y2 - x2 * y1, x1 * x2 + y1 * y2);
}

template <alpaka::concepts::Acc TAcc, typename T>
Expand Down
39 changes: 23 additions & 16 deletions RecoTracker/LSTCore/src/alpaka/Kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
if (quintuplets.isDup()[ix] & 1)
continue;

bool isPT5_ix = quintuplets.partOfPT5()[ix];
const bool isPT5_ix = quintuplets.partOfPT5()[ix];
const float eta1 = __H2F(quintuplets.eta()[ix]);
const float phi1 = __H2F(quintuplets.phi()[ix]);
const float score_rphisum1 = __H2F(quintuplets.score_rphisum()[ix]);

for (unsigned int jx1 = 0; jx1 < nQuintuplets_lowmod2; jx1++) {
unsigned int jx = quintupletModuleIndices_lowmod2 + jx1;
Expand All @@ -257,31 +260,24 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
if (quintuplets.isDup()[jx] & 1)
continue;

bool isPT5_jx = quintuplets.partOfPT5()[jx];
const bool isPT5_jx = quintuplets.partOfPT5()[jx];

if (isPT5_ix && isPT5_jx)
continue;

float eta1 = __H2F(quintuplets.eta()[ix]);
float phi1 = __H2F(quintuplets.phi()[ix]);
float score_rphisum1 = __H2F(quintuplets.score_rphisum()[ix]);

float eta2 = __H2F(quintuplets.eta()[jx]);
float phi2 = __H2F(quintuplets.phi()[jx]);
float score_rphisum2 = __H2F(quintuplets.score_rphisum()[jx]);

float dEta = alpaka::math::abs(acc, eta1 - eta2);
float dPhi = cms::alpakatools::deltaPhi(acc, phi1, phi2);

const float eta2 = __H2F(quintuplets.eta()[jx]);
const float dEta = alpaka::math::abs(acc, eta1 - eta2);
if (dEta > 0.1f)
continue;

const float phi2 = __H2F(quintuplets.phi()[jx]);
const float dPhi = cms::alpakatools::deltaPhi(acc, phi1, phi2);
if (alpaka::math::abs(acc, dPhi) > 0.1f)
continue;

float dR2 = dEta * dEta + dPhi * dPhi;
int nMatched = checkHitsT5(ix, jx, quintuplets);
const int minNHitsForDup_T5 = 5;
const float dR2 = dEta * dEta + dPhi * dPhi;
const int nMatched = checkHitsT5(ix, jx, quintuplets);
constexpr int minNHitsForDup_T5 = 5;

float d2 = 0.f;
CMS_UNROLL_LOOP
Expand All @@ -291,6 +287,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
}

if (((dR2 < 0.001f || nMatched >= minNHitsForDup_T5) && d2 < 1.0f) || (dR2 < 0.02f && d2 < 0.1f)) {
const float score_rphisum2 = __H2F(quintuplets.score_rphisum()[jx]);
if (isPT5_jx || score_rphisum1 > score_rphisum2) {
rmQuintupletFromMemory(quintuplets, ix, true);
} else if (isPT5_ix || score_rphisum1 < score_rphisum2) {
Expand Down Expand Up @@ -458,11 +455,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_FN_ACC void operator()(Acc2D const& acc, PixelQuintuplets pixelQuintuplets) const {
unsigned int nPixelQuintuplets = pixelQuintuplets.nPixelQuintuplets();
for (unsigned int ix : cms::alpakatools::uniform_elements_y(acc, nPixelQuintuplets)) {
float eta1 = __H2F(pixelQuintuplets.eta()[ix]);
float phi1 = __H2F(pixelQuintuplets.phi()[ix]);
float score1 = __H2F(pixelQuintuplets.score()[ix]);
for (unsigned int jx : cms::alpakatools::uniform_elements_x(acc, nPixelQuintuplets)) {
if (ix == jx)
continue;

float eta2 = __H2F(pixelQuintuplets.eta()[jx]);
if (alpaka::math::abs(acc, eta1 - eta2) > 0.2f)
continue;

float phi2 = __H2F(pixelQuintuplets.phi()[jx]);
if (alpaka::math::abs(acc, cms::alpakatools::deltaPhi(acc, phi1, phi2)) > 0.2f)
continue;

int nMatched = checkHitspT5(ix, jx, pixelQuintuplets);
float score2 = __H2F(pixelQuintuplets.score()[jx]);
const int minNHitsForDup_pT5 = 7;
Expand Down
728 changes: 369 additions & 359 deletions RecoTracker/LSTCore/src/alpaka/MiniDoublet.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

template <alpaka::concepts::Acc TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE float sigmoid_activation(TAcc const& acc, const float x) {
return alpaka::math::exp(acc, x) / (alpaka::math::exp(acc, x) + 1.f);
const float e = alpaka::math::exp(acc, x);
return e / (e + 1.f);
}

template <int IN_FEATURES, int OUT_FEATURES>
Expand Down
41 changes: 16 additions & 25 deletions RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,15 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
float pixelRadiusTemp, tripletRadius, rPhiChiSquaredTemp, rzChiSquaredTemp, rPhiChiSquaredInwardsTemp, centerXTemp,
centerYTemp, pixelRadiusErrorTemp;

PixelSeedData pixelData =
loadPixelSeedData(pixelSeeds, pixelSegments, mds, segments, pixelSegmentIndex, pixelSegmentArrayIndex);

if (not runPixelTripletDefaultAlgo<dnn::pt3dnn::pT5WP>(acc,
modules,
ranges,
mds,
segments,
pixelSeeds,
pixelSegments,
pixelData,
triplets,
pixelSegmentIndex,
t5InnerT3Index,
pixelRadiusTemp,
tripletRadius,
Expand All @@ -520,9 +520,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
unsigned int secondSegmentIndex = triplets.segmentIndices()[t5InnerT3Index][1];
unsigned int thirdSegmentIndex = triplets.segmentIndices()[t5OuterT3Index][0];
unsigned int fourthSegmentIndex = triplets.segmentIndices()[t5OuterT3Index][1];

unsigned int pixelInnerMDIndex = segments.mdIndices()[pixelSegmentIndex][0];
unsigned int pixelOuterMDIndex = segments.mdIndices()[pixelSegmentIndex][1];
unsigned int firstMDIndex = segments.mdIndices()[firstSegmentIndex][0];
unsigned int secondMDIndex = segments.mdIndices()[secondSegmentIndex][0];
unsigned int thirdMDIndex = segments.mdIndices()[secondSegmentIndex][1];
Expand All @@ -538,10 +535,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
uint16_t lowerModuleIndices[Params_T5::kLayers] = {
lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, lowerModuleIndex4, lowerModuleIndex5};

float rtPix[Params_pLS::kLayers] = {mds.anchorRt()[pixelInnerMDIndex], mds.anchorRt()[pixelOuterMDIndex]};
float xPix[Params_pLS::kLayers] = {mds.anchorX()[pixelInnerMDIndex], mds.anchorX()[pixelOuterMDIndex]};
float yPix[Params_pLS::kLayers] = {mds.anchorY()[pixelInnerMDIndex], mds.anchorY()[pixelOuterMDIndex]};
float zPix[Params_pLS::kLayers] = {mds.anchorZ()[pixelInnerMDIndex], mds.anchorZ()[pixelOuterMDIndex]};
float rtPix[Params_pLS::kLayers] = {pixelData.rt_InLo, pixelData.rt_InUp};
float xPix[Params_pLS::kLayers] = {pixelData.x_InLo, pixelData.x_InUp};
float yPix[Params_pLS::kLayers] = {pixelData.y_InLo, pixelData.y_InUp};
float zPix[Params_pLS::kLayers] = {pixelData.z_InLo, pixelData.z_InUp};
float zs[Params_T5::kLayers] = {mds.anchorZ()[firstMDIndex],
mds.anchorZ()[secondMDIndex],
mds.anchorZ()[thirdMDIndex],
Expand All @@ -553,16 +550,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
mds.anchorRt()[fourthMDIndex],
mds.anchorRt()[fifthMDIndex]};

float pixelSegmentPt = pixelSeeds.ptIn()[pixelSegmentArrayIndex];
float pixelSegmentPx = pixelSeeds.px()[pixelSegmentArrayIndex];
float pixelSegmentPy = pixelSeeds.py()[pixelSegmentArrayIndex];
float pixelSegmentPz = pixelSeeds.pz()[pixelSegmentArrayIndex];
int pixelSegmentCharge = pixelSeeds.charge()[pixelSegmentArrayIndex];

rzChiSquared = 0;

//get the appropriate centers
pixelRadius = pixelSegments.circleRadius()[pixelSegmentArrayIndex];
pixelRadius = pixelData.circleRadius;

rzChiSquared = computePT5RZChiSquared(acc,
modules,
Expand All @@ -573,11 +564,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
zPix,
rts,
zs,
pixelSegmentPt,
pixelSegmentPx,
pixelSegmentPy,
pixelSegmentPz,
pixelSegmentCharge);
pixelData.ptIn,
pixelData.px,
pixelData.py,
pixelData.pz,
pixelData.charge);

if (pixelRadius < 5.0f * kR1GeVf) { //only apply r-z chi2 cuts for <5GeV tracks
if (not passPT5RZChiSquaredCuts(modules,
Expand All @@ -603,8 +594,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
mds.anchorY()[fifthMDIndex]};

//get the appropriate centers
centerX = pixelSegments.circleCenterX()[pixelSegmentArrayIndex];
centerY = pixelSegments.circleCenterY()[pixelSegmentArrayIndex];
centerX = pixelData.circleCenterX;
centerY = pixelData.circleCenterY;

float T5CenterX = quintuplets.regressionCenterX()[quintupletIndex];
float T5CenterY = quintuplets.regressionCenterY()[quintupletIndex];
Expand Down
Loading