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

LST followups: better work divisions, concrete kernel dimension, some cleanup and fixes #47084

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed include issues
  • Loading branch information
ariostas committed Jan 17, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1416747465fb87d83c89d01449580403d415cb44
46 changes: 46 additions & 0 deletions RecoTracker/LSTCore/interface/Circle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef RecoTracker_LSTCore_interface_Circle_h
#define RecoTracker_LSTCore_interface_Circle_h

#include <tuple>

#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

namespace lst {

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE std::tuple<float, float, float> computeRadiusFromThreeAnchorHits(
TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3) {
float radius = 0.f;

//first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3)

float denomInv = 1.0f / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3));

float xy1sqr = x1 * x1 + y1 * y1;

float xy2sqr = x2 * x2 + y2 * y2;

float xy3sqr = x3 * x3 + y3 * y3;

float regressionCenterX = 0.5f * ((y3 - y2) * xy1sqr + (y1 - y3) * xy2sqr + (y2 - y1) * xy3sqr) * denomInv;

float regressionCenterY = 0.5f * ((x2 - x3) * xy1sqr + (x3 - x1) * xy2sqr + (x1 - x2) * xy3sqr) * denomInv;

float c = ((x2 * y3 - x3 * y2) * xy1sqr + (x3 * y1 - x1 * y3) * xy2sqr + (x1 * y2 - x2 * y1) * xy3sqr) * denomInv;

if (((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) ||
(regressionCenterX * regressionCenterX + regressionCenterY * regressionCenterY - c < 0)) {
#ifdef WARNINGS
printf("three collinear points or FATAL! r^2 < 0!\n");
#endif
radius = -1.f;
} else
radius =
alpaka::math::sqrt(acc, regressionCenterX * regressionCenterX + regressionCenterY * regressionCenterY - c);

return std::make_tuple(radius, regressionCenterX, regressionCenterY);
}

} //namespace lst

#endif
2 changes: 2 additions & 0 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@

#include "LSTEvent.h"

#include "Hit.h"
#include "Kernels.h"
#include "MiniDoublet.h"
#include "PixelQuintuplet.h"
#include "PixelTriplet.h"
4 changes: 1 addition & 3 deletions RecoTracker/LSTCore/src/alpaka/LSTEvent.h
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
#include "RecoTracker/LSTCore/interface/ModulesHostCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/alpaka/LST.h"
#include "RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h"
@@ -26,9 +27,6 @@
#include "RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h"

#include "Hit.h"
#include "Kernels.h"

#include "HeterogeneousCore/AlpakaInterface/interface/host.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
3 changes: 1 addition & 2 deletions RecoTracker/LSTCore/src/alpaka/MiniDoublet.h
Original file line number Diff line number Diff line change
@@ -5,14 +5,13 @@
#include "FWCore/Utilities/interface/isFinite.h"

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"

#include "Hit.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addMDToMemory(TAcc const& acc,
3 changes: 2 additions & 1 deletion RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
#define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
@@ -10,7 +11,7 @@
#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"

#include "Hit.h"
#include "Quintuplet.h"
#include "PixelTriplet.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
5 changes: 2 additions & 3 deletions RecoTracker/LSTCore/src/alpaka/Quintuplet.h
Original file line number Diff line number Diff line change
@@ -13,10 +13,9 @@
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"
#include "RecoTracker/LSTCore/interface/Circle.h"

#include "NeuralNetwork.h"
#include "Hit.h"
#include "Triplet.h" // FIXME: need to refactor common functions to a common place

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(TripletsConst triplets,
@@ -1502,7 +1501,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

float g, f;
outerRadius = triplets.radius()[outerTripletIndex];
bridgeRadius = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4, g, f);
std::tie(bridgeRadius, g, f) = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4);
innerRadius = triplets.radius()[innerTripletIndex];

bool inference = lst::t5dnn::runInference(acc,
5 changes: 2 additions & 3 deletions RecoTracker/LSTCore/src/alpaka/Segment.h
Original file line number Diff line number Diff line change
@@ -9,12 +9,11 @@
#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"
#include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"

#include "MiniDoublet.h"
#include "Hit.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isTighterTiltedModules_seg(ModulesConst modules, unsigned int moduleIndex) {
3 changes: 1 addition & 2 deletions RecoTracker/LSTCore/src/alpaka/TrackCandidate.h
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

#include "RecoTracker/LSTCore/interface/alpaka/Common.h"
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h"
#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h"
@@ -13,8 +14,6 @@
#include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"

#include "Hit.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
ALPAKA_FN_ACC ALPAKA_FN_INLINE void addpLSTrackCandidateToMemory(TrackCandidates& cands,
unsigned int trackletIndex,
41 changes: 3 additions & 38 deletions RecoTracker/LSTCore/src/alpaka/Triplet.h
Original file line number Diff line number Diff line change
@@ -8,10 +8,7 @@
#include "RecoTracker/LSTCore/interface/ModulesSoA.h"
#include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h"
#include "RecoTracker/LSTCore/interface/TripletsSoA.h"

#include "Segment.h"
#include "MiniDoublet.h"
#include "Hit.h"
#include "RecoTracker/LSTCore/interface/Circle.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

@@ -628,39 +625,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
return false; // failsafe
}

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHits(
TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) {
float radius = 0.f;

//(g,f) -> center
//first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3)

float denomInv = 1.0f / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3));

float xy1sqr = x1 * x1 + y1 * y1;

float xy2sqr = x2 * x2 + y2 * y2;

float xy3sqr = x3 * x3 + y3 * y3;

g = 0.5f * ((y3 - y2) * xy1sqr + (y1 - y3) * xy2sqr + (y2 - y1) * xy3sqr) * denomInv;

f = 0.5f * ((x2 - x3) * xy1sqr + (x3 - x1) * xy2sqr + (x1 - x2) * xy3sqr) * denomInv;

float c = ((x2 * y3 - x3 * y2) * xy1sqr + (x3 * y1 - x1 * y3) * xy2sqr + (x1 * y2 - x2 * y1) * xy3sqr) * denomInv;

if (((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3) == 0) || (g * g + f * f - c < 0)) {
#ifdef WARNINGS
printf("three collinear points or FATAL! r^2 < 0!\n");
#endif
radius = -1.f;
} else
radius = alpaka::math::sqrt(acc, g * g + f * f - c);

return radius;
}

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletConstraintsAndAlgo(TAcc const& acc,
ModulesConst modules,
@@ -694,7 +658,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
float y2 = mds.anchorY()[secondMDIndex];
float y3 = mds.anchorY()[thirdMDIndex];

circleRadius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, circleCenterX, circleCenterY);
std::tie(circleRadius, circleCenterX, circleCenterY) =
computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3);

if (not passRZConstraint(acc,
modules,
21 changes: 9 additions & 12 deletions RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// to use computeRadiusFromThreeAnchorHits
#include "LSTEvent.h"
#include "Triplet.h"
#include "Circle.h"

#include "write_lst_ntuple.h"

@@ -672,17 +671,15 @@ void fillT5DNNBranches(LSTEvent* event, unsigned int iT3) {
ana.tx->pushbackToBranch<int>("t5_t3_" + idx + "_moduleType", modules.moduleType()[module]);
}

float g, f;
float radius;
auto const& devHost = cms::alpakatools::host();
float radius = computeRadiusFromThreeAnchorHits(devHost,
hitObjects[0].x(),
hitObjects[0].y(),
hitObjects[1].x(),
hitObjects[1].y(),
hitObjects[2].x(),
hitObjects[2].y(),
g,
f);
std::tie(radius, std::ignore, std::ignore) = computeRadiusFromThreeAnchorHits(devHost,
hitObjects[0].x(),
hitObjects[0].y(),
hitObjects[1].x(),
hitObjects[1].y(),
hitObjects[2].x(),
hitObjects[2].y());
ana.tx->pushbackToBranch<float>("t5_t3_pt", k2Rinv1GeVf * 2 * radius);

// Angles