Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-22 23:29:59

0001 #ifndef RecoTracker_LSTCore_interface_Common_h
0002 #define RecoTracker_LSTCore_interface_Common_h
0003 
0004 #include "DataFormats/Common/interface/StdArray.h"
0005 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0006 
0007 #if defined(FP16_Base)
0008 #if defined ALPAKA_ACC_GPU_CUDA_ENABLED
0009 #include <cuda_fp16.h>
0010 #elif defined ALPAKA_ACC_GPU_HIP_ENABLED
0011 #include <hip/hip_fp16.h>
0012 #endif
0013 #endif
0014 
0015 namespace lst {
0016 
0017   // Named constants for pixelTypes
0018   enum PixelType : int8_t { kInvalid = -1, kHighPt = 0, kLowPtPosCurv = 1, kLowPtNegCurv = 2 };
0019 
0020   // Named types for LST objects
0021   enum LSTObjType { T5 = 4, pT3 = 5, pT5 = 7, pLS = 8 };
0022 
0023   constexpr unsigned int max_blocks = 80;
0024   constexpr unsigned int max_connected_modules = 40;
0025 
0026   constexpr unsigned int n_max_pixel_segments_per_module = 500000;
0027 
0028   constexpr unsigned int n_max_pixel_md_per_modules = 2 * n_max_pixel_segments_per_module;
0029 
0030   constexpr unsigned int n_max_pixel_triplets = 5000;
0031   constexpr unsigned int n_max_pixel_quintuplets = 15000;
0032 
0033   constexpr unsigned int n_max_pixel_track_candidates = 300000;
0034   constexpr unsigned int n_max_nonpixel_track_candidates = 10000;
0035 
0036   constexpr unsigned int size_superbins = 45000;
0037 
0038 // Half precision wrapper functions.
0039 #if defined(FP16_Base)
0040 #define __F2H __float2half
0041 #define __H2F __half2float
0042   typedef __half FPX;
0043 #else
0044 #define __F2H
0045 #define __H2F
0046   typedef float FPX;
0047 #endif
0048 
0049 // Needed for files that are compiled by g++ to not throw an error.
0050 // uint4 is defined only for CUDA, so we will have to revisit this soon when running on other backends.
0051 #if !defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && !defined(ALPAKA_ACC_GPU_HIP_ENABLED)
0052   struct uint4 {
0053     unsigned int x;
0054     unsigned int y;
0055     unsigned int z;
0056     unsigned int w;
0057   };
0058 #endif
0059 
0060   // Defining the constant host device variables right up here
0061   // Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future.
0062   struct Params_Modules {
0063     using ArrayU16xMaxConnected = edm::StdArray<uint16_t, max_connected_modules>;
0064   };
0065   struct Params_pLS {
0066     static constexpr int kLayers = 2, kHits = 4;
0067   };
0068   struct Params_LS {
0069     static constexpr int kLayers = 2, kHits = 4;
0070     using ArrayUxLayers = edm::StdArray<unsigned int, kLayers>;
0071   };
0072   struct Params_T3 {
0073     static constexpr int kLayers = 3, kHits = 6;
0074     using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
0075     using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
0076     using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
0077   };
0078   struct Params_pT3 {
0079     static constexpr int kLayers = 5, kHits = 10;
0080     using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
0081     using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
0082     using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
0083   };
0084   struct Params_T5 {
0085     static constexpr int kLayers = 5, kHits = 10;
0086     using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
0087     using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
0088     using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
0089   };
0090   struct Params_pT5 {
0091     static constexpr int kLayers = 7, kHits = 14;
0092     using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
0093     using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
0094     using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
0095   };
0096 
0097   using ArrayIx2 = edm::StdArray<int, 2>;
0098   using ArrayUx2 = edm::StdArray<unsigned int, 2>;
0099 
0100 }  //namespace lst
0101 
0102 #endif