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

Commit

Permalink
Merge pull request #377 from slava77/arch-decoupled-build-141X
Browse files Browse the repository at this point in the history
symbol decoupling for multi-arch alpaka builds
  • Loading branch information
ariostas authored Mar 29, 2024
2 parents f4a2fdd + ff4626b commit ad8ed39
Show file tree
Hide file tree
Showing 29 changed files with 1,123 additions and 1,006 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ scripts/moduleconnection*.txt
.make.log*
bin/doAnalysis
bin/sdl
bin/sdl_cuda
bin/sdl_cpu
code/rooutil/librooutil.so
code/rooutil/rooutil.so
.gitversion.txt
Expand Down
44 changes: 25 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@

# Simple makefile

EXES=bin/sdl

ROOUTIL=code/rooutil/
EXES := bin/sdl_cpu bin/sdl_cuda

SOURCES=$(wildcard code/core/*.cc)
OBJECTS=$(SOURCES:.cc=.o)
OBJECTS_CPU=$(SOURCES:.cc=_cpu.o)
OBJECTS_CUDA=$(SOURCES:.cc=_cuda.o)
HEADERS=$(SOURCES:.cc=.h)

CXX = g++
CXXFLAGS = -g -O2 -Wall -fPIC -Wshadow -Woverloaded-virtual -lineinfo -fopenmp -lgomp --default-stream per-thread
LDFLAGS = -g -O2 -Wall -fPIC -Wshadow -Woverloaded-virtual
SOFLAGS = -g -shared
CXXFLAGS = -g -O2 -Wall -fPIC -Wshadow -Woverloaded-virtual
LDFLAGS = -g -O2 -lsdl -L${TRACKLOOPERDIR}/SDL/cuda -L${TRACKLOOPERDIR}/SDL/cpu
LDFLAGS = -g -O2 $(SDLLIB) -L${TRACKLOOPERDIR}/SDL
ROOTLIBS = $(shell root-config --libs)
ROOTCFLAGS = $(foreach option, $(shell root-config --cflags), $(option))
ALPAKAINCLUDE = -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include -std=c++17 -DALPAKA_DEBUG=0
ALPAKASERIAL = -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
ALPAKA_CPU = -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
ALPAKA_CUDA = -DALPAKA_ACC_GPU_CUDA_ENABLED -DALPAKA_HOST_ONLY
CFLAGS = $(ROOTCFLAGS) -Wall -Wno-unused-function -g -O2 -fPIC -fno-var-tracking -ISDL -I$(shell pwd) -Icode -Icode/core -I${CUDA_HOME}/include -fopenmp
EXTRACFLAGS = $(shell rooutil-config) -g
EXTRAFLAGS = -fPIC -ITMultiDrawTreePlayer -Wunused-variable -lTMVA -lEG -lGenVector -lXMLIO -lMLP -lTreePlayer -L${CUDA_HOME}/lib64 -lcudart -fopenmp
Expand All @@ -30,40 +31,45 @@ CUTVALUEFLAG_FLAGS = -DCUT_VALUE_DEBUG
PRIMITIVEFLAG =
PRIMITIVEFLAG_FLAGS = -DPRIMITIVE_STUDY

all: $(ROOUTIL) efficiency $(EXES)
all: rooutil efficiency $(EXES)


cutvalue: CUTVALUEFLAG = ${CUTVALUEFLAG_FLAGS}
cutvalue: $(ROOUTIL) efficiency $(EXES)
cutvalue: rooutil efficiency $(EXES)

primitive: PRIMITIVEFLAG = ${PRIMITIVEFLAG_FLAGS}
primitive: $(ROOUTIL) efficiency $(EXES)
primitive: rooutil efficiency $(EXES)

cutvalue_primitive: CUTVALUEFLAG = ${CUTVALUEFLAG_FLAGS}
cutvalue_primitive: PRIMITIVEFLAG = ${PRIMITIVEFLAG_FLAGS}
cutvalue_primitive: $(ROOUTIL) efficiency $(EXES)

cutvalue_primitive: rooutil efficiency $(EXES)

bin/doAnalysis: bin/doAnalysis.o $(OBJECTS)
$(CXX) $(PTCUTFLAG) $(LDFLAGS) $^ $(ROOTLIBS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(EXTRAFLAGS) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKASERIAL) -o $@
$(CXX) $(PTCUTFLAG) $(LDFLAGS) $^ $(ROOTLIBS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(EXTRAFLAGS) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKA_CPU) -o $@

bin/sdl: bin/sdl.o $(OBJECTS)
$(CXX) $(PTCUTFLAG) $(LDFLAGS) $^ $(ROOTLIBS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(EXTRAFLAGS) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKASERIAL) -o $@
bin/sdl_cpu: SDLLIB=-lsdl_cpu
bin/sdl_cpu: bin/sdl_cpu.o $(OBJECTS_CPU)
$(CXX) $(PTCUTFLAG) $(LDFLAGS) $^ $(ROOTLIBS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(EXTRAFLAGS) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKA_CPU) -o $@
bin/sdl_cuda: SDLLIB=-lsdl_cuda
bin/sdl_cuda: bin/sdl_cuda.o $(OBJECTS_CUDA)
$(CXX) $(PTCUTFLAG) $(LDFLAGS) $^ $(ROOTLIBS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(EXTRAFLAGS) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKA_CUDA) -o $@

%.o: %.cc
$(CXX) $(PTCUTFLAG) $(CFLAGS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKASERIAL) $< -c -o $@
%_cpu.o: %.cc rooutil
$(CXX) $(PTCUTFLAG) $(CFLAGS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKA_CPU) $< -c -o $@
%_cuda.o: %.cc rooutil
$(CXX) $(PTCUTFLAG) $(CFLAGS) $(EXTRACFLAGS) $(CUTVALUEFLAG) $(PRIMITIVEFLAG) $(DOQUINTUPLET) $(ALPAKAINCLUDE) $(ALPAKA_CUDA) $< -c -o $@

$(ROOUTIL):
rooutil:
$(MAKE) -C code/rooutil/

efficiency:
efficiency: rooutil
$(MAKE) -C efficiency/

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

.PHONY: $(ROOUTIL) efficiency
.PHONY: rooutil efficiency
21 changes: 5 additions & 16 deletions SDL/EndcapGeometry.cc
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
#include "EndcapGeometry.h"

SDL::EndcapGeometry* SDL::endcapGeometry = new SDL::EndcapGeometry();

void SDL::freeEndcap() {
if (SDL::endcapGeometry != nullptr) {
delete SDL::endcapGeometry;
SDL::endcapGeometry = nullptr;
}
}

SDL::EndcapGeometry::EndcapGeometry(unsigned int sizef)
SDL::EndcapGeometry<SDL::Dev>::EndcapGeometry(unsigned int sizef)
: geoMapDetId_buf(allocBufWrapper<unsigned int>(devAcc, sizef)),
geoMapPhi_buf(allocBufWrapper<float>(devAcc, sizef)) {}

SDL::EndcapGeometry::EndcapGeometry(std::string filename, unsigned int sizef)
SDL::EndcapGeometry<SDL::Dev>::EndcapGeometry(std::string filename, unsigned int sizef)
: geoMapDetId_buf(allocBufWrapper<unsigned int>(devAcc, sizef)),
geoMapPhi_buf(allocBufWrapper<float>(devAcc, sizef)) {
load(filename);
}

SDL::EndcapGeometry::~EndcapGeometry() {}

void SDL::EndcapGeometry::load(std::string filename) {
void SDL::EndcapGeometry<SDL::Dev>::load(std::string filename) {
dxdy_slope_.clear();
centroid_phis_.clear();

Expand All @@ -44,7 +33,7 @@ void SDL::EndcapGeometry::load(std::string filename) {
fillGeoMapArraysExplicit();
}

void SDL::EndcapGeometry::fillGeoMapArraysExplicit() {
void SDL::EndcapGeometry<SDL::Dev>::fillGeoMapArraysExplicit() {
QueueAcc queue(devAcc);

int phi_size = centroid_phis_.size();
Expand Down Expand Up @@ -82,4 +71,4 @@ void SDL::EndcapGeometry::fillGeoMapArraysExplicit() {
alpaka::wait(queue);
}

float SDL::EndcapGeometry::getdxdy_slope(unsigned int detid) { return dxdy_slope_[detid]; }
float SDL::EndcapGeometry<SDL::Dev>::getdxdy_slope(unsigned int detid) { return dxdy_slope_[detid]; }
9 changes: 5 additions & 4 deletions SDL/EndcapGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#include "Constants.h"

namespace SDL {
class EndcapGeometry {
template <typename TDev>
class EndcapGeometry {};
template <>
class EndcapGeometry<SDL::Dev> {
private:
std::map<unsigned int, float> dxdy_slope_; // dx/dy slope
std::map<unsigned int, float> centroid_phis_; // centroid phi
Expand All @@ -25,16 +28,14 @@ namespace SDL {

EndcapGeometry(unsigned int sizef = endcap_size);
EndcapGeometry(std::string filename, unsigned int sizef = endcap_size);
~EndcapGeometry();
~EndcapGeometry() = default;

void load(std::string);

void fillGeoMapArraysExplicit();
void CreateGeoMapArraysExplicit();
float getdxdy_slope(unsigned int detid);
};
void freeEndcap();
extern EndcapGeometry* endcapGeometry;
} // namespace SDL

#endif
Loading

0 comments on commit ad8ed39

Please sign in to comment.