Skip to content

Commit

Permalink
Removal of sdl/SDL from all standalone code
Browse files Browse the repository at this point in the history
  • Loading branch information
VourMa committed Jul 30, 2024
1 parent 961d01e commit d378a59
Show file tree
Hide file tree
Showing 21 changed files with 447 additions and 496 deletions.
8 changes: 4 additions & 4 deletions RecoTracker/LSTCore/standalone/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ scripts/moduleconnection*.txt
*.root
.make.log*
bin/doAnalysis
bin/sdl
bin/sdl_cuda
bin/sdl_cpu
bin/sdl_rocm
bin/lst
bin/lst_cuda
bin/lst_cpu
bin/lst_rocm
code/rooutil/librooutil.so
code/rooutil/rooutil.so
.gitversion.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ LSTOBJECTS_ROCM=$(patsubst ../../src/alpaka/%.dev.cc, %_rocm.o, $(LSTSOURCES))

# Default to CPU and CUDA backends
ifeq ($(BACKEND),)
LIB_CPU=libsdl_cpu.so
LIB_CUDA=libsdl_cuda.so
LIB_CPU=liblst_cpu.so
LIB_CUDA=liblst_cuda.so
endif

ifneq ($(findstring cpu,$(BACKEND)),)
LIB_CPU=libsdl_cpu.so
LIB_CPU=liblst_cpu.so
endif
ifneq ($(findstring cuda,$(BACKEND)),)
LIB_CUDA=libsdl_cuda.so
LIB_CUDA=liblst_cuda.so
endif
ifneq ($(findstring rocm,$(BACKEND)),)
LIB_ROCM=libsdl_rocm.so
LIB_ROCM=liblst_rocm.so
endif
ifneq ($(findstring all,$(BACKEND)),)
LIB_CPU=libsdl_cpu.so
LIB_CUDA=libsdl_cuda.so
LIB_ROCM=libsdl_rocm.so
LIB_CPU=liblst_cpu.so
LIB_CUDA=liblst_cuda.so
LIB_ROCM=liblst_rocm.so
endif

LIBS=$(LIB_CPU) $(LIB_CUDA) $(LIB_ROCM)
Expand Down
24 changes: 12 additions & 12 deletions RecoTracker/LSTCore/standalone/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simple makefile

EXES := bin/sdl_cpu bin/sdl_cuda
EXES := bin/lst_cpu bin/lst_cuda

SOURCES=$(wildcard code/core/*.cc)
OBJECTS_CPU=$(SOURCES:.cc=_cpu.o)
Expand All @@ -10,11 +10,11 @@ OBJECTS=$(OBJECTS_CPU) $(OBJECTS_CUDA) $(OBJECTS_ROCM)

CXX = g++
CXXFLAGS = -g -O2 -Wall -fPIC -Wshadow -Woverloaded-virtual -Wno-unused-function -fno-var-tracking -std=c++17
INCLUDEFLAGS= -ISDL -I$(shell pwd) -Icode -Icode/core -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include $(shell rooutil-config --include) -I$(shell root-config --incdir) -I${TRACKLOOPERDIR}/../../../ -I${CMSSW_BASE}/src -I../interface/ -I../interface/alpaka/ -I../src/ -I../src/alpaka/
INCLUDEFLAGS= -ILST -I$(shell pwd) -Icode -Icode/core -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include $(shell rooutil-config --include) -I$(shell root-config --incdir) -I${TRACKLOOPERDIR}/../../../ -I${CMSSW_BASE}/src -I../interface/ -I../interface/alpaka/ -I../src/ -I../src/alpaka/
ifdef CMSSW_RELEASE_BASE
INCLUDEFLAGS:= ${INCLUDEFLAGS} -I${CMSSW_RELEASE_BASE}/src
endif
LDFLAGS = -g -O2 $(SDLLIB) -L${TRACKLOOPERDIR}/SDL $(shell rooutil-config --libs) $(shell root-config --libs)
LDFLAGS = -g -O2 $(LSTLIB) -L${TRACKLOOPERDIR}/LST $(shell rooutil-config --libs) $(shell root-config --libs)
LDFLAGS_CUDA= -L${CUDA_HOME}/lib64 -lcudart
LDFLAGS_ROCM= -L${ROCM_ROOT}/lib -lamdhip64
ALPAKAFLAGS = -DALPAKA_DEBUG=0
Expand Down Expand Up @@ -45,14 +45,14 @@ cutvalue_primitive: PRIMITIVEFLAG = ${PRIMITIVEFLAG_FLAGS}
cutvalue_primitive: rooutil efficiency $(EXES)


bin/sdl_cpu: SDLLIB=-lsdl_cpu
bin/sdl_cpu: bin/sdl_cpu.o $(OBJECTS_CPU)
bin/lst_cpu: LSTLIB=-llst_cpu
bin/lst_cpu: bin/lst_cpu.o $(OBJECTS_CPU)
$(CXX) $(LDFLAGS) $(EXTRAFLAGS) $(INCLUDEFLAGS) $(ALPAKAFLAGS) $^ $(ROOTLIBS) $(PTCUTFLAG) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(DOQUINTUPLET) $(ALPAKA_CPU) -o $@
bin/sdl_cuda: SDLLIB=-lsdl_cuda
bin/sdl_cuda: bin/sdl_cuda.o $(OBJECTS_CUDA)
bin/lst_cuda: LSTLIB=-llst_cuda
bin/lst_cuda: bin/lst_cuda.o $(OBJECTS_CUDA)
$(CXX) $(LDFLAGS) $(EXTRAFLAGS) $(INCLUDEFLAGS) $(ALPAKAFLAGS) $^ $(ROOTLIBS) $(PTCUTFLAG) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(DOQUINTUPLET) $(ALPAKA_CUDA) $(LDFLAGS_CUDA) -o $@
bin/sdl_rocm: SDLLIB=-lsdl_rocm
bin/sdl_rocm: bin/sdl_rocm.o $(OBJECTS_ROCM)
bin/lst_rocm: LSTLIB=-llst_rocm
bin/lst_rocm: bin/lst_rocm.o $(OBJECTS_ROCM)
$(CXX) $(LDFLAGS) $(EXTRAFLAGS) $(INCLUDEFLAGS) $(ALPAKAFLAGS) $^ $(ROOTLIBS) $(PTCUTFLAG) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(DOQUINTUPLET) $(ALPAKA_ROCM) $(LDFLAGS_ROCM) -o $@

%_cpu.o: %.cc rooutil
Expand All @@ -69,10 +69,10 @@ efficiency: rooutil
$(MAKE) -C efficiency/

clean:
rm -f $(OBJECTS) bin/*.o $(EXES) bin/sdl
rm -f $(OBJECTS) bin/*.o $(EXES) bin/lst
rm -f code/rooutil/*.so code/rooutil/*.o
rm -f bin/sdl.o
rm -f SDL/*.o
rm -f bin/lst.o
rm -f LST/*.o
cd efficiency/ && make clean

.PHONY: rooutil efficiency
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "sdl.h"
#include "lst.h"

#include <typeinfo>

Expand Down Expand Up @@ -37,7 +37,7 @@ int main(int argc, char **argv) {
// cxxopts is just a tool to parse argc, and argv easily

// Grand option setting
cxxopts::Options options("\n $ sdl",
cxxopts::Options options("\n $ lst",
"\n **********************\n * *\n * "
"Looper *\n * *\n **********************\n");

Expand Down Expand Up @@ -291,13 +291,13 @@ int main(int argc, char **argv) {
writeMetaData();

// Run the code
run_sdl();
run_lst();

return 0;
}

//___________________________________________________________________________________________________________________________________________________________________________________________
void run_sdl() {
void run_lst() {
Device devAcc = alpaka::getDevByIdx(ALPAKA_ACCELERATOR_NAMESPACE::Platform{}, 0u);
std::vector<Queue> queues;
for (int s = 0; s < ana.streams; s++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef sdl_h
#define sdl_h
#ifndef lst_h
#define lst_h

#include <vector>
#include <map>
Expand All @@ -20,11 +20,11 @@
// Efficiency study modules
#include "AnalysisConfig.h"
#include "trkCore.h"
#include "write_sdl_ntuple.h"
#include "write_lst_ntuple.h"

#include "TSystem.h"

// Main code
void run_sdl();
void run_lst();

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ usage()
echo " -h Help (Display this message)"
echo " -c cache (Make library with cache enabled)"
echo " -s show log (Full compilation script to stdout)"
echo " -m make clean binaries (Make clean binaries before remake. e.g. when header files changed in SDL/*.h)"
echo " -m make clean binaries (Make clean binaries before remake. e.g. when header files changed in LST/*.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 " -N neural networks (Toggle LST neural networks)"
Expand Down Expand Up @@ -123,8 +123,8 @@ if $MAKECACHE; then MAKETARGET=${MAKETARGET}_cache; fi

# If make clean binaries are called then first make clean before making
if $MAKECLEANBINARIES; then
echo "First make cleaning all of TrackLooper objects and libsdl*.so" | tee -a ${LOG}
cd SDL;make clean >>${LOG} 2>&1;cd -;
echo "First make cleaning all of TrackLooper objects and liblst*.so" | tee -a ${LOG}
cd LST;make clean >>${LOG} 2>&1;cd -;
make clean >> ${LOG} 2>&1
fi
#if make cut value is called then cut value ntuple making is done
Expand Down Expand Up @@ -152,19 +152,19 @@ BACKENDOPT="BACKEND="
EXES=
if [ "${ALLBACKENDS}" == true ]; then
BACKENDOPT="BACKEND=all"
EXES="bin/sdl_cpu bin/sdl_cuda bin/sdl_rocm"
EXES="bin/lst_cpu bin/lst_cuda bin/lst_rocm"
else
if [ "${CPUBACKEND}" == true ]; then
BACKENDOPT=$BACKENDOPT"cpu,"
EXES="$EXES bin/sdl_cpu"
EXES="$EXES bin/lst_cpu"
fi
if [ "${CUDABACKEND}" == true ]; then
BACKENDOPT=$BACKENDOPT"cuda,"
EXES="$EXES bin/sdl_cuda"
EXES="$EXES bin/lst_cuda"
fi
if [ "${ROCMBACKEND}" == true ]; then
BACKENDOPT=$BACKENDOPT"rocm,"
EXES="$EXES bin/sdl_rocm"
EXES="$EXES bin/lst_rocm"
fi
fi

Expand All @@ -187,21 +187,21 @@ echo "--------------------------------------------------------------------------
echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1
echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1
if $SHOWLOG; then
(cd SDL && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) 2>&1 | tee -a ${LOG}
(cd LST && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) 2>&1 | tee -a ${LOG}
else
(cd SDL && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) >> ${LOG} 2>&1
(cd LST && 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
echo "ERROR: libsdl_cpu.so failed to compile!" | tee -a ${LOG}
if ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cpu"* ]]) && [ ! -f LST/liblst_cpu.so ]; then
echo "ERROR: liblst_cpu.so failed to compile!" | tee -a ${LOG}
echo "See ${LOG} file for more detail..." | tee -a ${LOG}
exit 1
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cuda"* ]]) && [ ! -f SDL/libsdl_cuda.so ]; then
echo "ERROR: libsdl_cuda.so failed to compile!" | tee -a ${LOG}
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cuda"* ]]) && [ ! -f LST/liblst_cuda.so ]; then
echo "ERROR: liblst_cuda.so failed to compile!" | tee -a ${LOG}
echo "See ${LOG} file for more detail..." | tee -a ${LOG}
exit 1
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"rocm"* ]]) && [ ! -f SDL/libsdl_rocm.so ]; then
echo "ERROR: libsdl_rocm.so failed to compile!" | tee -a ${LOG}
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"rocm"* ]]) && [ ! -f LST/liblst_rocm.so ]; then
echo "ERROR: liblst_rocm.so failed to compile!" | tee -a ${LOG}
echo "See ${LOG} file for more detail..." | tee -a ${LOG}
exit 1
fi
Expand Down Expand Up @@ -229,27 +229,27 @@ else
make EXES="${EXES}" ${TRACKLOOPERTARGET} ${PTCUTOPT} -j >> ${LOG} 2>&1
fi

if ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cpu"* ]]) && [ ! -f bin/sdl_cpu ]; then
echo "ERROR: bin/sdl_cpu failed to compile!" | tee -a ${LOG}
if ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cpu"* ]]) && [ ! -f bin/lst_cpu ]; then
echo "ERROR: bin/lst_cpu failed to compile!" | tee -a ${LOG}
echo "See ${LOG} file for more detail..." | tee -a ${LOG}
exit 1
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cuda"* ]]) && [ ! -f bin/sdl_cuda ]; then
echo "ERROR: bin/sdl_cuda failed to compile!" | tee -a ${LOG}
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cuda"* ]]) && [ ! -f bin/lst_cuda ]; then
echo "ERROR: bin/lst_cuda failed to compile!" | tee -a ${LOG}
echo "See ${LOG} file for more detail..." | tee -a ${LOG}
exit 1
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"rocm"* ]]) && [ ! -f bin/sdl_rocm ]; then
echo "ERROR: bin/sdl_rocm failed to compile!" | tee -a ${LOG}
elif ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"rocm"* ]]) && [ ! -f bin/lst_rocm ]; then
echo "ERROR: bin/lst_rocm failed to compile!" | tee -a ${LOG}
echo "See ${LOG} file for more detail..." | tee -a ${LOG}
exit 1
fi

# Make a symlink with priority CUDA > CPU > ROCM
if [ "${CUDABACKEND}" == true ]; then
ln -sfr bin/sdl_cuda bin/sdl
ln -sfr bin/lst_cuda bin/lst
elif [ "${CPUBACKEND}" == true ]; then
ln -sfr bin/sdl_cpu bin/sdl
ln -sfr bin/lst_cpu bin/lst
elif [ "${ROCMBACKEND}" == true ]; then
ln -sfr bin/sdl_rocm bin/sdl
ln -sfr bin/lst_rocm bin/lst
fi

echo "" >> ${LOG}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ usage()
echo " -t tag for this run (Tag for this run)"
echo " -d delete previous output (Delete the previous outputs and re-run)"
echo " -b backend (Select a backend: cuda or cpu; default cuda)"
echo " -a arguments (Add command line arguments to the sdl command)"
echo " -a arguments (Add command line arguments to the lst command)"
echo
exit
}
Expand Down Expand Up @@ -102,7 +102,7 @@ file_already_exists()
{
echo "ERROR - Output already exists!"
echo ""
echo " Out of caution, the sdl_run fails to run if the following .root output files already exists:"
echo " Out of caution, the lst_run fails to run if the following .root output files already exists:"
echo ""
if [ -f "$LSTNTUPLEOUTPUT" ]; then
echo " $LSTNTUPLEOUTPUT already exists."
Expand Down Expand Up @@ -132,31 +132,31 @@ mkdir -p ${LSTOUTPUTDIR}
rm -f ${LSTOUTPUTDIR}/${JOBTAG}__LSTRun.log
if [[ ${PRECOMPILED} != true ]]; then
echo "Compiling code..."
sdl_make_tracklooper ${FLAGS} >> ${LSTOUTPUTDIR}/${JOBTAG}__LSTRun.log
lst_make_tracklooper ${FLAGS} >> ${LSTOUTPUTDIR}/${JOBTAG}__LSTRun.log
fi

# If a backend is specified then make sure that corresponding library exists
# and make a symbolic link to the correct binary
if [ "${BACKEND}" == "cuda" ]; then
if [ ! -f ${TRACKLOOPERDIR}/SDL/libsdl_cuda.so ]; then
if [ ! -f ${TRACKLOOPERDIR}/LST/liblst_cuda.so ]; then
echo "Error: CUDA backend was not compiled."
exit 1
fi
ln -s -f ${TRACKLOOPERDIR}/bin/sdl_cuda ${TRACKLOOPERDIR}/bin/sdl
ln -s -f ${TRACKLOOPERDIR}/bin/lst_cuda ${TRACKLOOPERDIR}/bin/lst
elif [ "${BACKEND}" == "cpu" ]; then
if [ ! -f ${TRACKLOOPERDIR}/SDL/libsdl_cpu.so ]; then
if [ ! -f ${TRACKLOOPERDIR}/LST/liblst_cpu.so ]; then
echo "Error: CPU backend was not compiled."
exit 1
fi
ln -s -f ${TRACKLOOPERDIR}/bin/sdl_cpu ${TRACKLOOPERDIR}/bin/sdl
ln -s -f ${TRACKLOOPERDIR}/bin/lst_cpu ${TRACKLOOPERDIR}/bin/lst
elif [ "${BACKEND}" == "rocm" ]; then
if [ ! -f ${TRACKLOOPERDIR}/SDL/libsdl_rocm.so ]; then
if [ ! -f ${TRACKLOOPERDIR}/LST/liblst_rocm.so ]; then
echo "Error: ROCM backend was not compiled."
exit 1
fi
ln -s -f ${TRACKLOOPERDIR}/bin/sdl_rocm ${TRACKLOOPERDIR}/bin/sdl
ln -s -f ${TRACKLOOPERDIR}/bin/lst_rocm ${TRACKLOOPERDIR}/bin/lst
elif [ "${BACKEND}" == "default" ]; then
if [[ ! -e ${TRACKLOOPERDIR}/bin/sdl ]]; then
if [[ ! -e ${TRACKLOOPERDIR}/bin/lst ]]; then
echo "Error: default backend was not found. Please recompile."
exit 1
fi
Expand All @@ -166,7 +166,7 @@ else
fi

echo "Running LST code..."
sdl -i ${SAMPLE} -o ${LSTOUTPUTDIR}/${JOBTAG}__LSTNtuple.root -n ${NEVENTS} ${ARGUMENTS} >> ${LSTOUTPUTDIR}/${JOBTAG}__LSTRun.log 2>&1 || { echo 'ERROR: sdl command failed!' ; exit 1; }
lst -i ${SAMPLE} -o ${LSTOUTPUTDIR}/${JOBTAG}__LSTNtuple.root -n ${NEVENTS} ${ARGUMENTS} >> ${LSTOUTPUTDIR}/${JOBTAG}__LSTRun.log 2>&1 || { echo 'ERROR: lst command failed!' ; exit 1; }
echo "Creating performance histograms..."
createPerfNumDenHists -i ${LSTOUTPUTDIR}/${JOBTAG}__LSTNtuple.root -o ${LSTOUTPUTDIR}/${JOBTAG}__LSTNumDen.root >> ${LSTOUTPUTDIR}/${JOBTAG}__LSTRun.log 2>&1 || { echo 'ERROR: createPerfNumDenHists command failed!' ; exit 1; }
echo "Creating plots..."
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/standalone/code/core/AnalysisConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AnalysisConfig {
RooUtil::TTreeX* tx;

// Boolean to control whether to write ntuple or not
bool write_sdl_ntuple;
bool write_lst_ntuple;

// Module boundaries related info
std::map<int, std::array<float, 6>> moduleBoundaries;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "write_sdl_ntuple.h"
#include "write_lst_ntuple.h"

using namespace ALPAKA_ACCELERATOR_NAMESPACE;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef write_sdl_ntuple_h
#define write_sdl_ntuple_h
#ifndef write_lst_ntuple_h
#define write_lst_ntuple_h

#include <iostream>
#include <tuple>
Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/LSTCore/standalone/efficiency/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ EXTRAFLAGS = -fPIC -ITMultiDrawTreePlayer -Wunused-variable -lTMVA -lEG -lGenVe

all: rooutil $(EXE)

$(EXE): src/performance.o src/helper.o src/SDL.o
$(LD) $(CXXFLAGS) $(LDFLAGS) src/performance.o src/helper.o src/SDL.o $(ROOTLIBS) $(EXTRAFLAGS) -o $@
$(EXE): src/performance.o src/helper.o src/LSTEff.o
$(LD) $(CXXFLAGS) $(LDFLAGS) src/performance.o src/helper.o src/LSTEff.o $(ROOTLIBS) $(EXTRAFLAGS) -o $@

src/SDL.o: src/SDL.cc src/SDL.h
src/LSTEff.o: src/LSTEff.cc src/LSTEff.h
$(CC) $(CFLAGS) $(EXTRACFLAGS) $< -c -o $@

src/performance.o: src/performance.cc src/performance.h
Expand All @@ -39,6 +39,6 @@ rooutil:
$(MAKE) -C ../code/rooutil

clean:
rm -r src/performance.o src/helper.o src/SDL.o $(EXE)
rm -r src/performance.o src/helper.o src/LSTEff.o $(EXE)

.PHONY: all clean rooutil
Loading

0 comments on commit d378a59

Please sign in to comment.