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

Commit fe2bae3

Browse files
authored
Merge pull request #273 from tresreid/addObjects
factorize addXXXObectsToEventExplicit into GPU and optional CPU functions
2 parents 58d7293 + 069c78b commit fe2bae3

File tree

14 files changed

+106
-264
lines changed

14 files changed

+106
-264
lines changed

SDL/Event.cu

Lines changed: 22 additions & 254 deletions
Large diffs are not rendered by default.

SDL/Event.cuh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace SDL
2929
{
3030
private:
3131
cudaStream_t stream;
32+
bool addObjects;
3233
std::array<unsigned int, 6> n_hits_by_layer_barrel_;
3334
std::array<unsigned int, 5> n_hits_by_layer_endcap_;
3435
std::array<unsigned int, 6> n_minidoublets_by_layer_barrel_;
@@ -72,21 +73,17 @@ namespace SDL
7273
int* superbinCPU;
7374
int8_t* pixelTypeCPU;
7475
public:
75-
Event(cudaStream_t estream);
76+
Event(cudaStream_t estream,bool verbose);
7677
~Event();
7778
void resetEvent();
7879

7980
void addHitToEvent(std::vector<float> x, std::vector<float> y, std::vector<float> z, std::vector<unsigned int> detId, std::vector<unsigned int> idxInNtuple); //call the appropriate hit function, then increment the counter here
8081
void addPixelSegmentToEvent(std::vector<unsigned int> hitIndices0,std::vector<unsigned int> hitIndices1,std::vector<unsigned int> hitIndices2,std::vector<unsigned int> hitIndices3, std::vector<float> dPhiChange, std::vector<float> ptIn, std::vector<float> ptErr, std::vector<float> px, std::vector<float> py, std::vector<float> pz, std::vector<float> eta, std::vector<float> etaErr, std::vector<float> phi, std::vector<int> charge, std::vector<unsigned int> seedIdx, std::vector<int> superbin, std::vector<int8_t> pixelType, std::vector<short> isQuad);
8182

8283
/*functions that map the objects to the appropriate modules*/
83-
void addMiniDoubletsToEvent();
84-
void addSegmentsToEvent();
85-
void addTripletsToEvent();
8684
void addMiniDoubletsToEventExplicit();
8785
void addSegmentsToEventExplicit();
8886
void addTripletsToEventExplicit();
89-
void addQuintupletsToEvent();
9087
void addQuintupletsToEventExplicit();
9188
void resetObjectsInModule();
9289

SDL/LST.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void SDL::LST::eventSetup() {
1010
SDL::initModules(path);
1111
}
1212

13-
void SDL::LST::run(cudaStream_t stream,
13+
void SDL::LST::run(cudaStream_t stream,bool verbose,
1414
const std::vector<float> see_px,
1515
const std::vector<float> see_py,
1616
const std::vector<float> see_pz,
@@ -31,7 +31,7 @@ void SDL::LST::run(cudaStream_t stream,
3131
const std::vector<float> ph2_x,
3232
const std::vector<float> ph2_y,
3333
const std::vector<float> ph2_z) {
34-
auto event = SDL::Event(stream);
34+
auto event = SDL::Event(stream,verbose);
3535
prepareInput(see_px, see_py, see_pz, see_dxy, see_dz, see_ptErr, see_etaErr, see_stateTrajGlbX, see_stateTrajGlbY, see_stateTrajGlbZ, see_stateTrajGlbPx, see_stateTrajGlbPy, see_stateTrajGlbPz, see_q, see_algo, see_hitIdx, ph2_detId, ph2_x, ph2_y, ph2_z);
3636

3737
event.addHitToEvent(in_trkX_, in_trkY_, in_trkZ_, in_hitId_, in_hitIdxs_); // TODO : Need to fix the hitIdxs

SDL/LST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace SDL {
1717
LST();
1818

1919
void eventSetup();
20-
void run(cudaStream_t stream,
20+
void run(cudaStream_t stream,bool verbose,
2121
const std::vector<float> see_px,
2222
const std::vector<float> see_py,
2323
const std::vector<float> see_pz,

SDL/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CXXFLAGS = -g --compiler-options -Wall --compiler-options -Wshadow
2222
ROOTCFLAGS = --compiler-options -pthread --compiler-options -std=c++17 -m64 -I/cvmfs/cms.cern.ch/slc7_amd64_gcc900/cms/cmssw/CMSSW_11_2_0_pre5/external/slc7_amd64_gcc900/bin/../../../../../../../slc7_amd64_gcc900/lcg/root/6.20.06-ghbfee3/include
2323
LD = nvcc
2424
SOFLAGS = -g -shared --compiler-options -fPIC --cudart shared -arch=compute_70 -code=sm_72
25-
PRINTFLAG = -DAddObjects -DT4FromT3 #-DWarnings
25+
PRINTFLAG = -DT4FromT3 #-DWarnings
2626
DUPLICATES = -DDUP_pLS -DDUP_T5 -DDUP_pT5 -DDUP_pT3 -DCrossclean_T5 -DCrossclean_pT3 -DFP16_Base -DFP16_dPhi
2727
MEMFLAG =
2828
CACHEFLAG =

SDL/MiniDoublet.cu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,3 +950,21 @@ if(success)
950950
}
951951
}
952952
}
953+
__global__ void SDL::addMiniDoubletRangesToEventExplicit(struct modules& modulesInGPU, struct miniDoublets& mdsInGPU, struct objectRanges& rangesInGPU,struct hits& hitsInGPU)
954+
{
955+
int gid = blockIdx.x * blockDim.x + threadIdx.x;
956+
int np = gridDim.x * blockDim.x;
957+
for(uint16_t i = gid; i < *modulesInGPU.nLowerModules; i+= np)
958+
{
959+
if(mdsInGPU.nMDs[i] == 0 or hitsInGPU.hitRanges[i * 2] == -1)
960+
{
961+
rangesInGPU.mdRanges[i * 2] = -1;
962+
rangesInGPU.mdRanges[i * 2 + 1] = -1;
963+
}
964+
else
965+
{
966+
rangesInGPU.mdRanges[i * 2] = rangesInGPU.miniDoubletModuleIndices[i] ;
967+
rangesInGPU.mdRanges[i * 2 + 1] = rangesInGPU.miniDoubletModuleIndices[i] + mdsInGPU.nMDs[i] - 1;
968+
}
969+
}
970+
}

SDL/MiniDoublet.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ namespace SDL
9494

9595
void createMDArrayRanges(struct modules& modulesInGPU, struct objectRanges& rangesInGPU, uint16_t& nLowerModules, unsigned int& nTotalMDs, cudaStream_t stream, const unsigned int& maxPixelMDs);
9696

97+
__global__ void addMiniDoubletRangesToEventExplicit(struct modules& modulesInGPU, struct miniDoublets& mdsInGPU, struct objectRanges& rangesInGPU, struct hits& hitsInGPU);
9798

9899
//#ifdef CUT_VALUE_DEBUG
99100
// CUDA_HOSTDEV void addMDToMemory(struct miniDoublets& mdsInGPU, struct hits& hitsInGPU, struct modules& modulesInGPU, unsigned int lowerHitIdx, unsigned int upperHitIdx, uint16_t& lowerModuleIdx, float dz, float drt, float dPhi, float dPhiChange, float shiftedX, float shiftedY, float shiftedZ, float noShiftedDz, float noShiftedDphi, float noShiftedDPhiChange, float dzCut, float drtCut, float miniCut, unsigned int idx);

SDL/Quintuplet.cu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,3 +2068,21 @@ __device__ void SDL::runDeltaBetaIterationsT5(float& betaIn, float& betaOut, flo
20682068

20692069
}
20702070
}
2071+
__global__ void SDL::addQuintupletRangesToEventExplicit(struct modules& modulesInGPU, struct quintuplets& quintupletsInGPU, struct objectRanges& rangesInGPU)
2072+
{
2073+
int gid = blockIdx.x * blockDim.x + threadIdx.x;
2074+
int np = gridDim.x * blockDim.x;
2075+
for(uint16_t i = gid; i < *modulesInGPU.nLowerModules; i+= np)
2076+
{
2077+
if(quintupletsInGPU.nQuintuplets[i] == 0 or rangesInGPU.quintupletModuleIndices[i] == -1)
2078+
{
2079+
rangesInGPU.quintupletRanges[i * 2] = -1;
2080+
rangesInGPU.quintupletRanges[i * 2 + 1] = -1;
2081+
}
2082+
else
2083+
{
2084+
rangesInGPU.quintupletRanges[i * 2] = rangesInGPU.quintupletModuleIndices[i];
2085+
rangesInGPU.quintupletRanges[i * 2 + 1] = rangesInGPU.quintupletModuleIndices[i] + quintupletsInGPU.nQuintuplets[i] - 1;
2086+
}
2087+
}
2088+
}

SDL/Quintuplet.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace SDL
6161
void createQuintupletsInExplicitMemory(struct SDL::quintuplets& quintupletsInGPU, const unsigned int& maxQuintuplets, const uint16_t& nLowerModules, const uint16_t& nEligibleModules,cudaStream_t stream);
6262

6363
__global__ void createEligibleModulesListForQuintupletsGPU(struct modules& modulesInGPU, struct triplets& tripletsInGPU, unsigned int* nTotalQuintuplets, struct objectRanges& rangesInGPU);
64+
__global__ void addQuintupletRangesToEventExplicit(struct modules& modulesInGPU, struct quintuplets& quintupletsInGPU, struct objectRanges& rangesInGPU);
6465

6566
// CUDA_DEV void rmQuintupletToMemory(struct SDL::quintuplets& quintupletsInGPU, unsigned int quintupletIndex);
6667

SDL/Segment.cu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,3 +869,21 @@ __global__ void SDL::createSegmentsInGPUv2(struct SDL::modules& modulesInGPU, st
869869
}
870870
}
871871
}
872+
__global__ void SDL::addSegmentRangesToEventExplicit(struct modules& modulesInGPU, struct segments& segmentsInGPU, struct objectRanges& rangesInGPU)
873+
{
874+
int gid = blockIdx.x * blockDim.x + threadIdx.x;
875+
int np = gridDim.x * blockDim.x;
876+
for(uint16_t i = gid; i < *modulesInGPU.nLowerModules; i+= np)
877+
{
878+
if(segmentsInGPU.nSegments[i] == 0)
879+
{
880+
rangesInGPU.segmentRanges[i * 2] = -1;
881+
rangesInGPU.segmentRanges[i * 2 + 1] = -1;
882+
}
883+
else
884+
{
885+
rangesInGPU.segmentRanges[i * 2] = rangesInGPU.segmentModuleIndices[i];
886+
rangesInGPU.segmentRanges[i * 2 + 1] = rangesInGPU.segmentModuleIndices[i] + segmentsInGPU.nSegments[i] - 1;
887+
}
888+
}
889+
}

0 commit comments

Comments
 (0)