Skip to content

Commit

Permalink
More Makefile tweaks.
Browse files Browse the repository at this point in the history
- Ensure that Fortran parts of madevent are built only once before cpp
and cuda builds start.
- Add a cleanall target to clean all subprocesses.
  • Loading branch information
hageboeck committed Nov 23, 2023
1 parent d8bfd81 commit a07d601
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions epochX/cudacpp/pp_tt012j.mad/Source/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ $(LIBDIR)libmodel.$(libext): MODEL param_card.inc
$(MAKE) -C $< FFLAGS="$(MG_FCFLAGS) $(FCFLAGS)" FCFLAGS="$(MG_FCFLAGS) $(FCFLAGS)"
param_card.inc: ../Cards/param_card.dat
../bin/madevent treatcards param
touch $@ # madevent doesn't update the time stamp if there's nothing to do



Expand All @@ -86,6 +87,7 @@ rw_events.o: rw_events.f run_config.inc

run_card.inc: ../Cards/run_card.dat
../bin/madevent treatcards run
touch $@ # madevent doesn't update the time stamp if there's nothing to do

clean4pdf:
rm -f ../lib/libpdf.$(libext)
Expand Down
16 changes: 8 additions & 8 deletions epochX/cudacpp/pp_tt012j.mad/SubProcesses/cudacpp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
CUDACPP_SRC_MAKEFILE = cudacpp_src.mk

# Self-invocation with adapted flags:
cppnative:
cppnative: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=native AVXFLAGS="-march=native" cppbuild
cppnone:
cppnone: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=none AVXFLAGS= cppbuild
cppsse4:
cppsse4: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=sse4 AVXFLAGS=-march=nehalem cppbuild
cppavx2:
cppavx2: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=avx2 AVXFLAGS=-march=haswell cppbuild
cppavx512y:
cppavx512y: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=512y AVXFLAGS="-march=skylake-avx512 -mprefer-vector-width=256" cppbuild
cppavx512z:
cppavx512z: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=512z AVXFLAGS="-march=skylake-avx512 -DMGONGPU_PVW512" cppbuild
cuda:
cuda: ../../Source/.sentry $(PROCESS)
$(MAKE) AVX=cuda cudabuild

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -324,7 +324,7 @@ endif
# Use flock (Linux only, no Mac) to allow 'make -j' if googletest has not yet been downloaded https://stackoverflow.com/a/32666215
$(GTESTLIBS):
ifneq ($(shell which flock 2>/dev/null),)
flock $(CUDACPP_BUILDDIR)/.make_test.lock $(MAKE) -C $(TESTDIR)
flock $(TESTDIR)/.make_test.lock $(MAKE) -C $(TESTDIR)
else
if [ -d $(TESTDIR) ]; then $(MAKE) -C $(TESTDIR); fi
endif
Expand Down
18 changes: 12 additions & 6 deletions epochX/cudacpp/pp_tt012j.mad/SubProcesses/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ ifneq ("$(wildcard ../../Source/RUNNING)","")
LIBS += $(LIBDIR)librunning.$(libext)
endif

SourceDir: ../../Source/*.f ../../Cards/param_card.dat ../../Cards/run_card.dat
$(MAKE) -C ../../Source
../../Source/.sentry ../../Source/discretesampler.mod &: ../../Source/*.f ../../Cards/param_card.dat ../../Cards/run_card.dat
ifneq ($(shell which flock 2>/dev/null),)
flock ../../Source/.lock -c "$(MAKE) -C ../../Source; touch ../../Source/.sentry"
else
$(MAKE) -C ../../Source; touch ../../Source/.sentry
endif

$(LIBS): SourceDir
$(LIBS): ../../Source/.sentry

# Source files

Expand Down Expand Up @@ -125,7 +129,7 @@ ifneq ($(UNAME_S),Darwin)
LIBFLAGSRPATH := -Wl,-rpath,'$$ORIGIN:$$ORIGIN/../$(LIBDIR)/$(CUDACPP_BUILDDIR)'
endif

.PHONY: SourceDir madevent_fortran_link madevent_cuda_link madevent_cpp_link madevent_cppnone_link madevent_cppsse4_link madevent_cppavx2_link madevent_cpp512y_link madevent_cpp512z_link
.PHONY: madevent_fortran_link madevent_cuda_link madevent_cpp_link madevent_cppnone_link madevent_cppsse4_link madevent_cppavx2_link madevent_cpp512y_link madevent_cpp512z_link

madevent_fortran_link: $(PROG)_fortran
rm -f $(PROG)
Expand Down Expand Up @@ -198,7 +202,6 @@ initcluster.o: message.inc

# Extra dependencies on discretesampler.mod
../../Source/discretesampler.mod: ../../Source/DiscreteSampler.f
$(MAKE) -C ../../Source

auto_dsig.o: ../../Source/discretesampler.mod
driver.o: ../../Source/discretesampler.mod
Expand All @@ -223,13 +226,16 @@ clean:
$(RM) *.o gensym $(PROG) $(PROG)_*
$(RM) -rf build.*/*{.o,.so,.exe,.dylib,madevent_*}

cleanall:
for PROCESS in ../P[0-9]*; do $(MAKE) -C $${PROCESS} clean; done

# Clean one architecture-specific build
clean%:
$(RM) -r build.$*_*/*{.o,.so,.exe,.dylib,madevent_*}

# Clean common source directories (interferes with other P*)
cleansrc:
make -C ../../Source clean
$(RM) ../../Source/*.mod ../../Source/*/*.mod
$(RM) -f ../../Source/{*.mod,.sentry} ../../Source/*/*.mod
$(RM) -r $(LIBDIR)libbias.$(libext)
if [ -d ../../src ]; then $(MAKE) -C ../../src -f cudacpp_src.mk clean; fi

0 comments on commit a07d601

Please sign in to comment.