Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #393 from SegmentLinking/T3_removeRedundant_new
Browse files Browse the repository at this point in the history
T3 remove redundant new
  • Loading branch information
slava77 authored May 7, 2024
2 parents 113d561 + cf39c3a commit 9f96dee
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 1,395 deletions.
5 changes: 0 additions & 5 deletions SDL/Event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1668,18 +1668,13 @@ SDL::tripletsBuffer<alpaka::DevCpu>* SDL::Event<SDL::Acc>::getTriplets() {
alpaka::memcpy(queue, tripletsInCPU->zHiPointed_buf, tripletsBuffers->zHiPointed_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->sdlCut_buf, tripletsBuffers->sdlCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->betaInCut_buf, tripletsBuffers->betaInCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->betaOutCut_buf, tripletsBuffers->betaOutCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->deltaBetaCut_buf, tripletsBuffers->deltaBetaCut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->rtLo_buf, tripletsBuffers->rtLo_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->rtHi_buf, tripletsBuffers->rtHi_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->kZ_buf, tripletsBuffers->kZ_buf, nMemHost);
#endif
alpaka::memcpy(queue, tripletsInCPU->hitIndices_buf, tripletsBuffers->hitIndices_buf, 6 * nMemHost);
alpaka::memcpy(queue, tripletsInCPU->logicalLayers_buf, tripletsBuffers->logicalLayers_buf, 3 * nMemHost);
alpaka::memcpy(queue, tripletsInCPU->segmentIndices_buf, tripletsBuffers->segmentIndices_buf, 2 * nMemHost);
alpaka::memcpy(queue, tripletsInCPU->betaIn_buf, tripletsBuffers->betaIn_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->betaOut_buf, tripletsBuffers->betaOut_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->pt_beta_buf, tripletsBuffers->pt_beta_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->nTriplets_buf, tripletsBuffers->nTriplets_buf);
alpaka::memcpy(queue, tripletsInCPU->totOccupancyTriplets_buf, tripletsBuffers->totOccupancyTriplets_buf);
alpaka::wait(queue);
Expand Down
38 changes: 3 additions & 35 deletions SDL/PixelTriplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,40 +202,6 @@ namespace SDL {
pixelTripletsInGPU.rzChiSquared[pixelTripletIndex] = rzChiSquared;
};

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeRadiusFromThreeAnchorHitspT3(
TAcc const& acc, const float* xs, const float* ys, float& g, float& f) {
float radius = 0;

//writing manual code for computing radius, which obviously sucks
//TODO:Use fancy inbuilt libraries like cuBLAS or cuSOLVE for this!
//(g,f) -> center
//first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3)

float denomInv = 1.f / ((ys[0] - ys[2]) * (xs[1] - xs[2]) - (xs[0] - xs[2]) * (ys[1] - ys[2]));

float xy1sqr = xs[0] * xs[0] + ys[0] * ys[0];
float xy2sqr = xs[1] * xs[1] + ys[1] * ys[1];
float xy3sqr = xs[2] * xs[2] + ys[2] * ys[2];

g = 0.5f * ((ys[2] - ys[1]) * xy1sqr + (ys[0] - ys[2]) * xy2sqr + (ys[1] - ys[0]) * xy3sqr) * denomInv;
f = 0.5f * ((xs[1] - xs[2]) * xy1sqr + (xs[2] - xs[0]) * xy2sqr + (xs[0] - xs[1]) * xy3sqr) * denomInv;

float c = ((xs[1] * ys[2] - xs[2] * ys[1]) * xy1sqr + (xs[2] * ys[0] - xs[0] * ys[2]) * xy2sqr +
(xs[0] * ys[1] - xs[1] * ys[0]) * xy3sqr) *
denomInv;

if (((ys[0] - ys[2]) * (xs[1] - xs[2]) - (xs[0] - xs[2]) * (ys[1] - ys[2]) == 0) || (g * g + f * f - c < 0)) {
#ifdef Warnings
printf("three collinear points or FATAL! r^2 < 0!\n");
#endif
radius = -1;
} else
radius = alpaka::math::sqrt(acc, g * g + f * f - c);

return radius;
};

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTrackletDefaultAlgopT3(TAcc const& acc,
struct SDL::modules& modulesInGPU,
Expand Down Expand Up @@ -982,7 +948,9 @@ namespace SDL {
float ys[3] = {mdsInGPU.anchorY[firstMDIndex], mdsInGPU.anchorY[secondMDIndex], mdsInGPU.anchorY[thirdMDIndex]};

float g, f;
tripletRadius = computeRadiusFromThreeAnchorHitspT3(acc, xs, ys, g, f);
tripletRadius = tripletsInGPU.circleRadius[tripletIndex];
g = tripletsInGPU.circleCenterX[tripletIndex];
f = tripletsInGPU.circleCenterY[tripletIndex];

pass = pass and passRadiusCriterion(acc,
modulesInGPU,
Expand Down
41 changes: 4 additions & 37 deletions SDL/Quintuplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,41 +749,6 @@ namespace SDL {
return (innerOuterOuterMiniDoubletIndex == outerInnerInnerMiniDoubletIndex);
};

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;

//writing manual code for computing radius, which obviously sucks
//TODO:Use fancy inbuilt libraries like cuBLAS or cuSOLVE for this!
//(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 void computeErrorInRadius(TAcc const& acc,
float* x1Vec,
Expand Down Expand Up @@ -2738,9 +2703,11 @@ namespace SDL {
computeErrorInRadius(acc, x3Vec, y3Vec, x1Vec, y1Vec, x2Vec, y2Vec, outerRadiusMin2S, outerRadiusMax2S);

float g, f;
outerRadius = computeRadiusFromThreeAnchorHits(acc, x3, y3, x4, y4, x5, y5, g, f);
outerRadius = tripletsInGPU.circleRadius[outerTripletIndex];
bridgeRadius = computeRadiusFromThreeAnchorHits(acc, x2, y2, x3, y3, x4, y4, g, f);
innerRadius = computeRadiusFromThreeAnchorHits(acc, x1, y1, x2, y2, x3, y3, g, f);
innerRadius = tripletsInGPU.circleRadius[innerTripletIndex];
g = tripletsInGPU.circleCenterX[innerTripletIndex];
f = tripletsInGPU.circleCenterY[innerTripletIndex];

#ifdef USE_RZCHI2
float inner_pt = 2 * k2Rinv1GeVf * innerRadius;
Expand Down
Loading

0 comments on commit 9f96dee

Please sign in to comment.