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

Make compilation flags for duplicate cleaning and triplet pLSs into runtime flags #408

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions SDL/Event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void SDL::Event<SDL::Acc>::createTriplets() {
}
}

void SDL::Event<SDL::Acc>::createTrackCandidates() {
void SDL::Event<SDL::Acc>::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) {
if (trackCandidatesInGPU == nullptr) {
trackCandidatesInGPU = new SDL::trackCandidates();
trackCandidatesBuffers = new SDL::trackCandidatesBuffer<Dev>(
Expand Down Expand Up @@ -709,18 +709,18 @@ void SDL::Event<SDL::Acc>::createTrackCandidates() {

alpaka::enqueue(queue, addT5asTrackCandidateInGPUTask);

#ifndef NOPLSDUPCLEAN
Vec const threadsPerBlockCheckHitspLS = createVec(1, 16, 16);
Vec const blocksPerGridCheckHitspLS = createVec(1, MAX_BLOCKS * 4, MAX_BLOCKS / 4);
WorkDiv const checkHitspLS_workDiv =
createWorkDiv(blocksPerGridCheckHitspLS, threadsPerBlockCheckHitspLS, elementsPerThread);
if (!no_pls_dupclean) {
Vec const threadsPerBlockCheckHitspLS = createVec(1, 16, 16);
Vec const blocksPerGridCheckHitspLS = createVec(1, MAX_BLOCKS * 4, MAX_BLOCKS / 4);
WorkDiv const checkHitspLS_workDiv =
createWorkDiv(blocksPerGridCheckHitspLS, threadsPerBlockCheckHitspLS, elementsPerThread);

SDL::checkHitspLS checkHitspLS_kernel;
auto const checkHitspLSTask(alpaka::createTaskKernel<Acc>(
checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_->data(), *segmentsInGPU, true));
SDL::checkHitspLS checkHitspLS_kernel;
auto const checkHitspLSTask(alpaka::createTaskKernel<Acc>(
checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_->data(), *segmentsInGPU, true));

alpaka::enqueue(queue, checkHitspLSTask);
#endif
alpaka::enqueue(queue, checkHitspLSTask);
}

Vec const threadsPerBlock_crossCleanpLS = createVec(1, 16, 32);
Vec const blocksPerGrid_crossCleanpLS = createVec(1, 4, 20);
Expand Down Expand Up @@ -751,7 +751,8 @@ void SDL::Event<SDL::Acc>::createTrackCandidates() {
addpLSasTrackCandidateInGPU_kernel,
nLowerModules_,
*trackCandidatesInGPU,
*segmentsInGPU));
*segmentsInGPU,
tc_pls_triplets));

alpaka::enqueue(queue, addpLSasTrackCandidateInGPUTask);

Expand Down Expand Up @@ -990,20 +991,20 @@ void SDL::Event<SDL::Acc>::createQuintuplets() {
}
}

void SDL::Event<SDL::Acc>::pixelLineSegmentCleaning() {
#ifndef NOPLSDUPCLEAN
Vec const threadsPerBlockCheckHitspLS = createVec(1, 16, 16);
Vec const blocksPerGridCheckHitspLS = createVec(1, MAX_BLOCKS * 4, MAX_BLOCKS / 4);
WorkDiv const checkHitspLS_workDiv =
createWorkDiv(blocksPerGridCheckHitspLS, threadsPerBlockCheckHitspLS, elementsPerThread);
void SDL::Event<SDL::Acc>::pixelLineSegmentCleaning(bool no_pls_dupclean) {
if (!no_pls_dupclean) {
Vec const threadsPerBlockCheckHitspLS = createVec(1, 16, 16);
Vec const blocksPerGridCheckHitspLS = createVec(1, MAX_BLOCKS * 4, MAX_BLOCKS / 4);
WorkDiv const checkHitspLS_workDiv =
createWorkDiv(blocksPerGridCheckHitspLS, threadsPerBlockCheckHitspLS, elementsPerThread);

SDL::checkHitspLS checkHitspLS_kernel;
auto const checkHitspLSTask(alpaka::createTaskKernel<Acc>(
checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_->data(), *segmentsInGPU, false));
SDL::checkHitspLS checkHitspLS_kernel;
auto const checkHitspLSTask(alpaka::createTaskKernel<Acc>(
checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_->data(), *segmentsInGPU, false));

alpaka::enqueue(queue, checkHitspLSTask);
alpaka::wait(queue);
#endif
alpaka::enqueue(queue, checkHitspLSTask);
alpaka::wait(queue);
}
}

void SDL::Event<SDL::Acc>::createPixelQuintuplets() {
Expand Down
4 changes: 2 additions & 2 deletions SDL/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ namespace SDL {
void createTriplets();
void createPixelTracklets();
void createPixelTrackletsWithMap();
void createTrackCandidates();
void createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets);
void createExtendedTracks();
void createQuintuplets();
void createPixelTriplets();
void createPixelQuintuplets();
void pixelLineSegmentCleaning();
void pixelLineSegmentCleaning(bool no_pls_dupclean);

unsigned int getNumberOfHits();
unsigned int getNumberOfHitsByLayer(unsigned int layer);
Expand Down
8 changes: 5 additions & 3 deletions SDL/LST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ void SDL::LST<SDL::Acc>::run(SDL::QueueAcc& queue,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z) {
const std::vector<float> ph2_z,
bool no_pls_dupclean,
bool tc_pls_triplets) {
auto event = SDL::Event<Acc>(verbose, queue, deviceESData);
prepareInput(see_px,
see_py,
Expand Down Expand Up @@ -135,7 +137,7 @@ void SDL::LST<SDL::Acc>::run(SDL::QueueAcc& queue,
printf("# of Quintuplets produced endcap layer 5: %d\n", event.getNumberOfQuintupletsByLayerEndcap(4));
}

event.pixelLineSegmentCleaning();
event.pixelLineSegmentCleaning(no_pls_dupclean);

event.createPixelQuintuplets();
if (verbose)
Expand All @@ -145,7 +147,7 @@ void SDL::LST<SDL::Acc>::run(SDL::QueueAcc& queue,
if (verbose)
printf("# of Pixel T3s produced: %d\n", event.getNumberOfPixelTriplets());

event.createTrackCandidates();
event.createTrackCandidates(no_pls_dupclean, tc_pls_triplets);
if (verbose) {
printf("# of TrackCandidates produced: %d\n", event.getNumberOfTrackCandidates());
printf(" # of Pixel TrackCandidates produced: %d\n", event.getNumberOfPixelTrackCandidates());
Expand Down
4 changes: 3 additions & 1 deletion SDL/LST.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ namespace SDL {
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z);
const std::vector<float> ph2_z,
bool no_pls_dupclean,
bool tc_pls_triplets);
std::vector<std::vector<unsigned int>> hits() { return out_tc_hitIdxs_; }
std::vector<unsigned int> len() { return out_tc_len_; }
std::vector<int> seedIdx() { return out_tc_seedIdx_; }
Expand Down
6 changes: 3 additions & 3 deletions SDL/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ CUTVALUEFLAG =
CUTVALUEFLAG_FLAGS = -DCUT_VALUE_DEBUG

%_cpu.o: %.cc
$(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(NOPLSDUPCLEANFLAG) $(TCPLSTRIPLETSFLAG) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@
$(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@

%_cuda.o: %.cc
$(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(NOPLSDUPCLEANFLAG) $(TCPLSTRIPLETSFLAG) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@
$(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@

%_rocm.o: %.cc
$(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(NOPLSDUPCLEANFLAG) $(TCPLSTRIPLETSFLAG) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@
$(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@

$(LIB_CPU): $(CCOBJECTS_CPU) $(LSTOBJECTS_CPU)
$(LD_CPU) $(SOFLAGS_CPU) $^ -o $@
Expand Down
9 changes: 3 additions & 6 deletions SDL/TrackCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,15 @@ namespace SDL {
ALPAKA_FN_ACC void operator()(TAcc const& acc,
uint16_t nLowerModules,
struct SDL::trackCandidates trackCandidatesInGPU,
struct SDL::segments segmentsInGPU) const {
struct SDL::segments segmentsInGPU,
bool tc_pls_triplets) const {
auto const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc);
auto const gridThreadExtent = alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc);

unsigned int nPixels = segmentsInGPU.nSegments[nLowerModules];
for (unsigned int pixelArrayIndex = globalThreadIdx[2]; pixelArrayIndex < nPixels;
pixelArrayIndex += gridThreadExtent[2]) {
#ifdef TC_PLS_TRIPLETS
if (segmentsInGPU.isDup[pixelArrayIndex])
#else
if ((!segmentsInGPU.isQuad[pixelArrayIndex]) || (segmentsInGPU.isDup[pixelArrayIndex]))
#endif
if ((tc_pls_triplets ? 0 : !segmentsInGPU.isQuad[pixelArrayIndex]) || (segmentsInGPU.isDup[pixelArrayIndex]))
continue;

unsigned int trackCandidateIdx =
Expand Down
21 changes: 17 additions & 4 deletions bin/sdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ int main(int argc, char** argv)
("N,nmatch" , "N match for MTV-like matching", cxxopts::value<int>()->default_value("9"))
("n,nevents" , "N events to loop over", cxxopts::value<int>()->default_value("-1"))
("x,event_index" , "specific event index to process", cxxopts::value<int>()->default_value("-1"))
("g,pdg_id" , "The simhit pdgId match option (default = 0)", cxxopts::value<int>()->default_value("0"))
("g,pdg_id" , "The simhit pdgId match option", cxxopts::value<int>()->default_value("0"))
("v,verbose" , "Verbose mode (0: no print, 1: only final timing, 2: object multiplitcity", cxxopts::value<int>()->default_value("0"))
("w,write_ntuple" , "Write Ntuple", cxxopts::value<int>()->default_value("1"))
("s,streams" , "Set number of streams (default=1)", cxxopts::value<int>()->default_value("1"))
("s,streams" , "Set number of streams", cxxopts::value<int>()->default_value("1"))
("d,debug" , "Run debug job. i.e. overrides output option to 'debug.root' and 'recreate's the file.")
("l,lower_level" , "write lower level objects ntuple results")
("G,gnn_ntuple" , "write gnn input variable ntuple")
("j,nsplit_jobs" , "Enable splitting jobs by N blocks (--job_index must be set)", cxxopts::value<int>())
("I,job_index" , "job_index of split jobs (--nsplit_jobs must be set. index starts from 0. i.e. 0, 1, 2, 3, etc...)", cxxopts::value<int>())
("3,tc_pls_triplets" , "Allow triplet pLSs in TC collection")
("2,no_pls_dupclean" , "Disable pLS duplicate cleaning (both steps)")
("h,help" , "Print help");

auto result = options.parse(argc, argv);
Expand Down Expand Up @@ -253,6 +255,15 @@ int main(int argc, char** argv)
ana.gnn_ntuple = false;
}

//_______________________________________________________________________________
// --tc_pls_triplets
ana.tc_pls_triplets = result["tc_pls_triplets"].as<bool>();

//_______________________________________________________________________________
// --no_pls_dupclean
ana.no_pls_dupclean = result["no_pls_dupclean"].as<bool>();


// Printing out the option settings overview
std::cout << "=========================================================" << std::endl;
std::cout << " Running for Acc = " << alpaka::getAccName<SDL::Acc>() << std::endl;
Expand All @@ -269,6 +280,8 @@ int main(int argc, char** argv)
std::cout << " ana.streams: " << ana.streams << std::endl;
std::cout << " ana.verbose: " << ana.verbose << std::endl;
std::cout << " ana.nmatch_threshold: " << ana.nmatch_threshold << std::endl;
std::cout << " ana.tc_pls_triplets: " << ana.tc_pls_triplets << std::endl;
std::cout << " ana.no_pls_dupclean: " << ana.no_pls_dupclean << std::endl;
std::cout << "=========================================================" << std::endl;

// Create the TChain that holds the TTree's of the baby ntuples
Expand Down Expand Up @@ -452,10 +465,10 @@ void run_sdl()
timing_LS = runSegment(events.at(omp_get_thread_num()));
timing_T3 = runT3(events.at(omp_get_thread_num()));
timing_T5 = runQuintuplet(events.at(omp_get_thread_num()));
timing_pLS = runPixelLineSegment(events.at(omp_get_thread_num()));
timing_pLS = runPixelLineSegment(events.at(omp_get_thread_num()),ana.no_pls_dupclean);
timing_pT5 = runPixelQuintuplet(events.at(omp_get_thread_num()));
timing_pT3 = runpT3(events.at(omp_get_thread_num()));
timing_TC = runTrackCandidate(events.at(omp_get_thread_num()));
timing_TC = runTrackCandidate(events.at(omp_get_thread_num()),ana.no_pls_dupclean,ana.tc_pls_triplets);

if (ana.verbose == 4)
{
Expand Down
4 changes: 0 additions & 4 deletions bin/sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
#include "rooutil.h"
#include "cxxopts.h"

#include "SDL/Event.h" // SDL::Event
#include "SDL/Module.h" // SDL::Module
#include "SDL/EndcapGeometry.h" // SDL::EndcapGeometr
#include "SDL/ModuleConnectionMap.h" // SDL::ModuleConnectionMap
#include "SDL/Event.h"
#include "SDL/LST.h"

Expand Down
22 changes: 2 additions & 20 deletions bin/sdl_make_tracklooper
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ usage()
echo " -m make clean binaries (Make clean binaries before remake. e.g. when header files changed in SDL/*.h)"
echo " -d cut value ntuple (With extra variables in a debug ntuple file)"
echo " -p primitive object ntuple (With extra variables related to primitive objects)"
echo " -3 TC pLS triplets (Allow triplet pLSs in TC collection)"
echo " -N neural networks (Toggle LST neural networks)"
echo " -C CPU serial backend (Compile for CPU)"
echo " -G GPU (CUDA) backend (Compile for CUDA)"
echo " -R ROCm backend (Compile for ROCm)"
echo " -A All backends (Compile for all backends, including ROCm)"
echo " -P PT Cut Value (In GeV, Default is 0.8, Works only for standalone version of code)"
echo " -w Warning mode (Print extra warning outputs)"
echo " -2 no pLS duplicate cleaning (Don't perform the pLS duplicate cleaning step)"
echo
exit
}
Expand All @@ -45,13 +43,11 @@ while getopts ":cxgsmdp3NCGRA2ehwP:" OPTION; do
m) MAKECLEANBINARIES=true;;
d) MAKECUTVALUES=true;;
p) PRIMITIVE=true;;
3) TCPLSTRIPLETS=true;;
N) DONTUSENN=true;;
G) CUDABACKEND=true;;
C) CPUBACKEND=true;;
R) ROCMBACKEND=true;;
A) ALLBACKENDS=true;;
2) NOPLSDUPCLEAN=true;;
w) PRINTWARNINGS=true;;
P) PTCUTVALUE=$OPTARG;;
h) usage;;
Expand All @@ -65,13 +61,11 @@ if [ -z ${SHOWLOG} ]; then SHOWLOG=false; fi
if [ -z ${MAKECLEANBINARIES} ]; then MAKECLEANBINARIES=false; fi
if [ -z ${MAKECUTVALUES} ]; then MAKECUTVALUES=false; fi
if [ -z ${PRIMITIVE} ]; then PRIMITIVE=false; fi
if [ -z ${TCPLSTRIPLETS} ]; then TCPLSTRIPLETS=false; fi
if [ -z ${DONTUSENN} ]; then DONTUSENN=false; fi
if [ -z ${CPUBACKEND} ]; then CPUBACKEND=false; fi
if [ -z ${CUDABACKEND} ]; then CUDABACKEND=false; fi
if [ -z ${ROCMBACKEND} ]; then ROCMBACKEND=false; fi
if [ -z ${ALLBACKENDS} ]; then ALLBACKENDS=false; fi
if [ -z ${NOPLSDUPCLEAN} ]; then NOPLSDUPCLEAN=false; fi
if [ -z ${PRINTWARNINGS} ]; then PRINTWARNINGS=false; fi
if [ -z ${PTCUTVALUE} ]; then PTCUTVALUE=0.8; fi

Expand Down Expand Up @@ -107,12 +101,10 @@ echo " SHOWLOG : ${SHOWLOG}" | tee -a ${LOG}
echo " MAKECLEANBINARIES : ${MAKECLEANBINARIES}" | tee -a ${LOG}
echo " MAKECUTVALUES : ${MAKECUTVALUES}" | tee -a ${LOG}
echo " PRIMITIVE : ${PRIMITIVE}" | tee -a ${LOG}
echo " TCPLSTRIPLETS : ${TCPLSTRIPLETS}" | tee -a ${LOG}
echo " DONTUSENN : ${DONTUSENN}" | tee -a ${LOG}
echo " CPUBACKEND : ${CPUBACKEND}" | tee -a ${LOG}
echo " CUDABACKEND : ${CUDABACKEND}" | tee -a ${LOG}
echo " ROCMBACKEND : ${ROCMBACKEND}" | tee -a ${LOG}
echo " NOPLSDUPCLEAN : ${NOPLSDUPCLEAN}" | tee -a ${LOG}
echo " PRINTWARNINGS : ${PRINTWARNINGS}" | tee -a ${LOG}
echo " PTCUTVALUE : ${PTCUTVALUE} GeV" | tee -a ${LOG}
echo "" | tee -a ${LOG}
Expand Down Expand Up @@ -149,11 +141,6 @@ if $PRIMITIVE; then
echo "debug : MAKETARGET=${MAKETARGET}"
fi

TCPLSTRIPLETSOPT=
if $TCPLSTRIPLETS; then
TCPLSTRIPLETSOPT="TCPLSTRIPLETSFLAG=-DTC_PLS_TRIPLETS"
fi

T5CUTOPT=
if $DONTUSENN; then
T5CUTOPT="T5RZCHI2FLAG=-DUSE_RZCHI2 T5RPHICHI2FLAG=-DUSE_RPHICHI2"
Expand Down Expand Up @@ -181,11 +168,6 @@ else
fi
fi

NOPLSDUPCLEANOPT=
if $NOPLSDUPCLEAN; then
NOPLSDUPCLEANOPT="NOPLSDUPCLEANFLAG=-DNOPLSDUPCLEAN"
fi

PRINTWARNINGSOPT=
if $PRINTWARNINGS; then
PRINTWARNINGSOPT="LSTWARNINGSFLAG=-DWarnings"
Expand All @@ -205,9 +187,9 @@ echo "--------------------------------------------------------------------------
echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1
echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1
if $SHOWLOG; then
(cd SDL && make clean && make ${TCPLSTRIPLETSOPT} ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${NOPLSDUPCLEANOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) 2>&1 | tee -a ${LOG}
(cd SDL && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) 2>&1 | tee -a ${LOG}
else
(cd SDL && make clean && make ${TCPLSTRIPLETSOPT} ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${NOPLSDUPCLEANOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) >> ${LOG} 2>&1
(cd SDL && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) >> ${LOG} 2>&1
fi

if ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cpu"* ]]) && [ ! -f SDL/libsdl_cpu.so ]; then
Expand Down
Loading