From 0acd6fc1712de6402e693af6870da7484a5cef73 Mon Sep 17 00:00:00 2001 From: YonsiG Date: Fri, 7 Jul 2023 09:02:15 -0700 Subject: [PATCH] change the atan2 function into a wrapped SDL::phi function --- SDL/Quintuplet.cu | 24 ++++++++++++------------ SDL/Segment.cu | 2 +- SDL/Triplet.cu | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/SDL/Quintuplet.cu b/SDL/Quintuplet.cu index 65d91dcb..a460e1d3 100644 --- a/SDL/Quintuplet.cu +++ b/SDL/Quintuplet.cu @@ -1786,7 +1786,7 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBBB(struct SDL::modules& modulesIn float alpha_OutUp,alpha_OutUp_highEdge,alpha_OutUp_lowEdge; - alpha_OutUp = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); + alpha_OutUp = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); alpha_OutUp_highEdge = alpha_OutUp; alpha_OutUp_lowEdge = alpha_OutUp; @@ -1799,27 +1799,27 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBBB(struct SDL::modules& modulesIn float tl_axis_lowEdge_x = tl_axis_x; float tl_axis_lowEdge_y = tl_axis_y; - betaIn = alpha_InLo - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]); + betaIn = alpha_InLo - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = -alpha_OutUp + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]); + betaOut = -alpha_OutUp + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; if(isEC_lastLayer) { - alpha_OutUp_highEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); - alpha_OutUp_lowEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); + alpha_OutUp_highEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); + alpha_OutUp_lowEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); tl_axis_highEdge_x = mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; tl_axis_highEdge_y = mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; tl_axis_lowEdge_x = mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; tl_axis_lowEdge_y = mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(atan2f(tl_axis_highEdge_y,tl_axis_highEdge_x)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); - betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(atan2f(tl_axis_lowEdge_y,tl_axis_lowEdge_x)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); + betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_highEdge_x, tl_axis_highEdge_y)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); + betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_lowEdge_x, tl_axis_lowEdge_y)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); } //beta computation @@ -1997,7 +1997,7 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBEE(struct SDL::modules& modulesIn float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); float sdOut_alpha = sdIn_alpha; //weird - float sdOut_alphaOut = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); + float sdOut_alphaOut = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); float sdOut_alphaOut_min = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex])); float sdOut_alphaOut_max = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex])); @@ -2006,11 +2006,11 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBEE(struct SDL::modules& modulesIn float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex]; - betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]); + betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]); + betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; @@ -2226,13 +2226,13 @@ __device__ bool SDL::runQuintupletDefaultAlgoEEEE(struct SDL::modules& modulesIn float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex]; - betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]); + betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]); float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]); + betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut; diff --git a/SDL/Segment.cu b/SDL/Segment.cu index 3e65d2c6..0ec6b51d 100644 --- a/SDL/Segment.cu +++ b/SDL/Segment.cu @@ -548,7 +548,7 @@ __device__ bool SDL::runSegmentDefaultAlgoBarrel(struct modules& modulesInGPU, s pass = pass and (fabsf(dPhi) <= sdCut); if(not pass) return pass; - dPhiChange = SDL::phi_mpi_pi(atan2f(yOut-yIn, xOut-xIn)-mdsInGPU.anchorPhi[innerMDIndex]); + dPhiChange = SDL::phi_mpi_pi(SDL::phi(xOut-xIn, yOut-yIn)-mdsInGPU.anchorPhi[innerMDIndex]); pass = pass and (fabsf(dPhiChange) <= sdCut); if(not pass) return pass; diff --git a/SDL/Triplet.cu b/SDL/Triplet.cu index 285e5fa9..f75ad6bd 100644 --- a/SDL/Triplet.cu +++ b/SDL/Triplet.cu @@ -797,7 +797,7 @@ __device__ bool SDL::runTripletDefaultAlgoBBBB(struct SDL::modules& modulesInGPU float alpha_OutUp,alpha_OutUp_highEdge,alpha_OutUp_lowEdge; - alpha_OutUp = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); + alpha_OutUp = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); alpha_OutUp_highEdge = alpha_OutUp; alpha_OutUp_lowEdge = alpha_OutUp; @@ -810,19 +810,19 @@ __device__ bool SDL::runTripletDefaultAlgoBBBB(struct SDL::modules& modulesInGPU float tl_axis_lowEdge_x = tl_axis_x; float tl_axis_lowEdge_y = tl_axis_y; - betaIn = alpha_InLo - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]); + betaIn = alpha_InLo - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = -alpha_OutUp + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]); + betaOut = -alpha_OutUp + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; if(isEC_lastLayer) { - alpha_OutUp_highEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); - alpha_OutUp_lowEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); + alpha_OutUp_highEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); + alpha_OutUp_lowEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); tl_axis_highEdge_x = mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; tl_axis_highEdge_y = mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; @@ -830,8 +830,8 @@ __device__ bool SDL::runTripletDefaultAlgoBBBB(struct SDL::modules& modulesInGPU tl_axis_lowEdge_y = mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(atan2f(tl_axis_highEdge_y,tl_axis_highEdge_x)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); - betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(atan2f(tl_axis_lowEdge_y,tl_axis_lowEdge_x)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); + betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_highEdge_x, tl_axis_highEdge_y)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]); + betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_lowEdge_x, tl_axis_lowEdge_y)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]); } //beta computation @@ -1010,7 +1010,7 @@ __device__ bool SDL::runTripletDefaultAlgoBBEE(struct SDL::modules& modulesInGPU float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); float sdOut_alpha = sdIn_alpha; //weird - float sdOut_alphaOut = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); + float sdOut_alphaOut = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]); float sdOut_alphaOut_min = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex])); float sdOut_alphaOut_max = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex])); @@ -1019,11 +1019,11 @@ __device__ bool SDL::runTripletDefaultAlgoBBEE(struct SDL::modules& modulesInGPU float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex]; - betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]); + betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]); + betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; float betaOutRHmax = betaOut; @@ -1240,14 +1240,14 @@ __device__ bool SDL::runTripletDefaultAlgoEEEE(struct SDL::modules& modulesInGPU float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex]; - betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]); + betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]); float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]); + betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut;