Skip to content

Commit

Permalink
Further work on naming values and sqrt, loop, etc. simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
VourMa committed Jul 8, 2024
1 parent 4d7e54a commit c563eb0
Show file tree
Hide file tree
Showing 10 changed files with 464 additions and 527 deletions.
111 changes: 60 additions & 51 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,71 +104,80 @@ namespace SDL {
constexpr float PT_CUT = 0.8f;
#endif

const unsigned int MAX_BLOCKS = 80;
const unsigned int MAX_CONNECTED_MODULES = 40;
constexpr unsigned int MAX_BLOCKS = 80;
constexpr unsigned int MAX_CONNECTED_MODULES = 40;

const unsigned int N_MAX_PIXEL_SEGMENTS_PER_MODULE = 50000;
constexpr unsigned int N_MAX_PIXEL_SEGMENTS_PER_MODULE = 50000;

const unsigned int N_MAX_PIXEL_MD_PER_MODULES = 2 * N_MAX_PIXEL_SEGMENTS_PER_MODULE;
constexpr unsigned int N_MAX_PIXEL_MD_PER_MODULES = 2 * N_MAX_PIXEL_SEGMENTS_PER_MODULE;

const unsigned int N_MAX_PIXEL_TRIPLETS = 5000;
const unsigned int N_MAX_PIXEL_QUINTUPLETS = 15000;
constexpr unsigned int N_MAX_PIXEL_TRIPLETS = 5000;
constexpr unsigned int N_MAX_PIXEL_QUINTUPLETS = 15000;

const unsigned int N_MAX_PIXEL_TRACK_CANDIDATES = 30000;
const unsigned int N_MAX_NONPIXEL_TRACK_CANDIDATES = 1000;
constexpr unsigned int N_MAX_PIXEL_TRACK_CANDIDATES = 30000;
constexpr unsigned int N_MAX_NONPIXEL_TRACK_CANDIDATES = 1000;

const unsigned int size_superbins = 45000;
constexpr unsigned int size_superbins = 45000;

//defining the constant host device variables right up here
ALPAKA_STATIC_ACC_MEM_GLOBAL const int layers_pLS = 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int layers_LS = 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int layers_T3 = 3;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int layers_pT3 = 5;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int layers_T5 = 5;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int layers_pT5 = 7;

ALPAKA_STATIC_ACC_MEM_GLOBAL const int hits_pLS = 4;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int hits_LS = 4;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int hits_T3 = 6;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int hits_pT3 = 10;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int hits_T5 = 10;
ALPAKA_STATIC_ACC_MEM_GLOBAL const int hits_pT5 = 14;

ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniMulsPtScaleBarrel[6] = {0.0052, 0.0038, 0.0034, 0.0034, 0.0032, 0.0034};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniRminMeanBarrel[6] = {
namespace objLayers {
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kpLS =
2; // Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4). To be potentially handled better in the future.
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kLS = 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kT3 = 3;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kpT3 = 5;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kT5 = 5;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kpT5 = 7;
} // namespace objLayers

namespace objHits {
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kpLS =
4; // Currently pixel tracks treated as LSs with 4 hits. To be potentially handled better in the future.
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kLS = 4;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kT3 = 6;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kpT3 = 10;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kT5 = 10;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr int kpT5 = 14;
} // namespace objHits

ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMulsInGev2 =
0.015; // 15 MeV constant from the approximate Bethe-Bloch formula
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleBarrel[6] = {
0.0052, 0.0038, 0.0034, 0.0034, 0.0032, 0.0034};
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006};
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniRminMeanBarrel[6] = {
25.007152356, 37.2186993757, 52.3104270826, 68.6658656666, 85.9770373007, 108.301772384};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniRminMeanEndcap[5] = {
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniRminMeanEndcap[5] = {
130.992832231, 154.813883559, 185.352604327, 221.635123002, 265.022076742};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float k2Rinv1GeVf = (2.99792458e-3 * 3.8) / 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float kR1GeVf = 1. / (2.99792458e-3 * 3.8);
ALPAKA_STATIC_ACC_MEM_GLOBAL const float sinAlphaMax = 0.95;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float ptCut = PT_CUT;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float deltaZLum = 15.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float pixelPSZpitch = 0.15;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float stripPSZpitch = 2.4;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float strip2SZpitch = 5.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float width2S = 0.009;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float widthPS = 0.01;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float pt_betaMax = 7.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float magnetic_field = 3.8112;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float k2Rinv1GeVf = (2.99792458e-3 * 3.8) / 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kR1GeVf = 1. / (2.99792458e-3 * 3.8);
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float sinAlphaMax = 0.95;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float ptCut = PT_CUT;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float deltaZLum = 15.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float pixelPSZpitch = 0.15;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float stripPSZpitch = 2.4;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float strip2SZpitch = 5.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float width2S = 0.009;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float widthPS = 0.01;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float pt_betaMax = 7.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float magnetic_field = 3.8112;
// Since C++ can't represent infinity, SDL_INF = 123456789 was used to represent infinity in the data table
ALPAKA_STATIC_ACC_MEM_GLOBAL const float SDL_INF = 123456789.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float SDL_INF = 123456789.0;
} //namespace SDL

namespace T5DNN {
// Working points matching LST fake rate (43.9%) or signal acceptance (82.0%)
ALPAKA_STATIC_ACC_MEM_GLOBAL const float LSTWP1 = 0.3418833f; // 94.0% TPR, 43.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float LSTWP2 = 0.6177366f; // 82.0% TPR, 20.0% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float LSTWP1 = 0.3418833f; // 94.0% TPR, 43.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float LSTWP2 = 0.6177366f; // 82.0% TPR, 20.0% FPR
// Other working points
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP70 = 0.7776195f; // 70.0% TPR, 10.0% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP75 = 0.7181118f; // 75.0% TPR, 13.5% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP80 = 0.6492643f; // 80.0% TPR, 17.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP85 = 0.5655319f; // 85.0% TPR, 23.8% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP90 = 0.4592205f; // 90.0% TPR, 32.6% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP95 = 0.3073708f; // 95.0% TPR, 47.7% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP97p5 = 0.2001348f; // 97.5% TPR, 61.2% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP99 = 0.1120605f; // 99.0% TPR, 75.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP99p9 = 0.0218196f; // 99.9% TPR, 95.4% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP70 = 0.7776195f; // 70.0% TPR, 10.0% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP75 = 0.7181118f; // 75.0% TPR, 13.5% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP80 = 0.6492643f; // 80.0% TPR, 17.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP85 = 0.5655319f; // 85.0% TPR, 23.8% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP90 = 0.4592205f; // 90.0% TPR, 32.6% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP95 = 0.3073708f; // 95.0% TPR, 47.7% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP97p5 = 0.2001348f; // 97.5% TPR, 61.2% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP99 = 0.1120605f; // 99.0% TPR, 75.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP99p9 = 0.0218196f; // 99.9% TPR, 95.4% FPR
} // namespace T5DNN
#endif
21 changes: 13 additions & 8 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1623,8 +1623,9 @@ SDL::tripletsBuffer<alpaka::DevCpu>* SDL::Event<SDL::Acc>::getTriplets() {
alpaka::memcpy(queue, tripletsInCPU->rtLo_buf, tripletsBuffers->rtLo_buf, nMemHost);
alpaka::memcpy(queue, tripletsInCPU->rtHi_buf, tripletsBuffers->rtHi_buf, nMemHost);
#endif
alpaka::memcpy(queue, tripletsInCPU->hitIndices_buf, tripletsBuffers->hitIndices_buf, hits_T3 * nMemHost);
alpaka::memcpy(queue, tripletsInCPU->logicalLayers_buf, tripletsBuffers->logicalLayers_buf, layers_T3 * nMemHost);
alpaka::memcpy(queue, tripletsInCPU->hitIndices_buf, tripletsBuffers->hitIndices_buf, objHits::kT3 * nMemHost);
alpaka::memcpy(
queue, tripletsInCPU->logicalLayers_buf, tripletsBuffers->logicalLayers_buf, objLayers::kT3 * 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->circleRadius_buf, tripletsBuffers->circleRadius_buf, nMemHost);
Expand Down Expand Up @@ -1654,7 +1655,7 @@ SDL::quintupletsBuffer<alpaka::DevCpu>* SDL::Event<SDL::Acc>::getQuintuplets() {
alpaka::memcpy(queue,
quintupletsInCPU->lowerModuleIndices_buf,
quintupletsBuffers->lowerModuleIndices_buf,
layers_T5 * nMemHost);
objLayers::kT5 * nMemHost);
alpaka::memcpy(queue, quintupletsInCPU->innerRadius_buf, quintupletsBuffers->innerRadius_buf, nMemHost);
alpaka::memcpy(queue, quintupletsInCPU->bridgeRadius_buf, quintupletsBuffers->bridgeRadius_buf, nMemHost);
alpaka::memcpy(queue, quintupletsInCPU->outerRadius_buf, quintupletsBuffers->outerRadius_buf, nMemHost);
Expand Down Expand Up @@ -1759,14 +1760,16 @@ SDL::trackCandidatesBuffer<alpaka::DevCpu>* SDL::Event<SDL::Acc>::getTrackCandid
trackCandidatesInCPU->setData(*trackCandidatesInCPU);

*alpaka::getPtrNative(trackCandidatesInCPU->nTrackCandidates_buf) = nTrackCanHost;
alpaka::memcpy(
queue, trackCandidatesInCPU->hitIndices_buf, trackCandidatesBuffers->hitIndices_buf, hits_pT5 * nTrackCanHost);
alpaka::memcpy(queue,
trackCandidatesInCPU->hitIndices_buf,
trackCandidatesBuffers->hitIndices_buf,
objHits::kpT5 * nTrackCanHost);
alpaka::memcpy(
queue, trackCandidatesInCPU->pixelSeedIndex_buf, trackCandidatesBuffers->pixelSeedIndex_buf, nTrackCanHost);
alpaka::memcpy(queue,
trackCandidatesInCPU->logicalLayers_buf,
trackCandidatesBuffers->logicalLayers_buf,
layers_pT5 * nTrackCanHost);
objLayers::kpT5 * nTrackCanHost);
alpaka::memcpy(queue,
trackCandidatesInCPU->directObjectIndices_buf,
trackCandidatesBuffers->directObjectIndices_buf,
Expand Down Expand Up @@ -1795,8 +1798,10 @@ SDL::trackCandidatesBuffer<alpaka::DevCpu>* SDL::Event<SDL::Acc>::getTrackCandid
trackCandidatesInCPU->setData(*trackCandidatesInCPU);

*alpaka::getPtrNative(trackCandidatesInCPU->nTrackCandidates_buf) = nTrackCanHost;
alpaka::memcpy(
queue, trackCandidatesInCPU->hitIndices_buf, trackCandidatesBuffers->hitIndices_buf, hits_pT5 * nTrackCanHost);
alpaka::memcpy(queue,
trackCandidatesInCPU->hitIndices_buf,
trackCandidatesBuffers->hitIndices_buf,
objHits::kpT5 * nTrackCanHost);
alpaka::memcpy(
queue, trackCandidatesInCPU->pixelSeedIndex_buf, trackCandidatesBuffers->pixelSeedIndex_buf, nTrackCanHost);
alpaka::memcpy(queue,
Expand Down
Loading

0 comments on commit c563eb0

Please sign in to comment.