Skip to content

Commit

Permalink
[oct23av] in CODEGEN move tmadmode steps (SDE config, runcard/paramca…
Browse files Browse the repository at this point in the history
…rd generation, cleanup) from patchMad.sh to generateAndCompare.sh

This is meant to fix various code generation issues introduced in generateAndCompare.sh by PR madgraph5#764
  • Loading branch information
valassi committed Oct 27, 2023
1 parent a30fd57 commit 2fa4830
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
31 changes: 2 additions & 29 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/patchMad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,9 @@ if [ ! -e ${dir} ]; then echo "ERROR! Directory $dir does not exist"; exit 1; fi

# AV Recover special 'tmad' mode used by generateAndCompare.sh, after OM's changes that commented this out in patchMad.sh
tmadmode=0
if [ "${MG5AMC_TMADMODE}" != "" ]; then
if [ "${CUDACPP_CODEGEN_TMADMODE}" != "" ]; then
tmadmode=1
echo "DEBUG! Switching on tmad mode (MG5AMC_TMADMODE=${MG5AMC_TMADMODE})"
fi

# These two steps are part of "cd Source; make" but they actually are code-generating steps
if [ "${tmadmode}" != "0" ]; then
${dir}/bin/madevent treatcards run # AV BUG! THIS MAY SILENTLY FAIL (should check if output contains "Please report this bug")
###echo status=$?
${dir}/bin/madevent treatcards param # AV BUG! THIS MAY SILENTLY FAIL (should check if output contains "Please report this bug")
###echo status=$?
fi

# Cleanup
if [ "${tmadmode}" != "0" ]; then
\rm -f ${dir}/crossx.html
\rm -f ${dir}/index.html
\rm -f ${dir}/madevent.tar.gz
\rm -f ${dir}/Cards/delphes_trigger.dat
\rm -f ${dir}/Cards/plot_card.dat
\rm -f ${dir}/bin/internal/run_plot*
\rm -f ${dir}/HTML/*
\rm -rf ${dir}/bin/internal/__pycache__
\rm -rf ${dir}/bin/internal/ufomodel/py3_model.pkl
\rm -rf ${dir}/bin/internal/ufomodel/__pycache__
touch ${dir}/HTML/.keep # new file
echo "DEBUG! Switching on tmad mode (CUDACPP_CODEGEN_TMADMODE=${CUDACPP_CODEGEN_TMADMODE})"
fi

# Exit here for patchlevel 0 (--upstream)
Expand All @@ -84,10 +61,6 @@ fi
# (1) Process-independent patches
touch ${dir}/Events/.keep # this file should already be present (mg5amcnlo copies it from Template/LO/Events/.keep)
\cp -pr ${scrdir}/MG5aMC_patches/${dir_patches}/fbridge_common.inc ${dir}/SubProcesses # new file
if [ "${tmadmode}" != "0" ]; then
sed -i 's/2 = sde_strategy/1 = sde_strategy/' ${dir}/Cards/run_card.dat # use strategy SDE=1 in multichannel mode (see #419)
sed -i 's/SDE_STRAT = 2/SDE_STRAT = 1/' ${dir}/Source/run_card.inc # use strategy SDE=1 in multichannel mode (see #419)
fi
if [ "${patchlevel}" == "2" ]; then
cd ${dir}
if [ "${tmadmode}" != "0" ]; then
Expand Down
26 changes: 24 additions & 2 deletions epochX/cudacpp/CODEGEN/generateAndCompare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e # fail on error

# AV Recover special 'tmad' mode used by generateAndCompare.sh, after OM's changes that commented this out in patchMad.sh
export MG5AMC_TMADMODE=1
export CUDACPP_CODEGEN_TMADMODE=1

#--------------------------------------------------------------------------------------

Expand Down Expand Up @@ -204,9 +204,31 @@ function codeGenAndDiff()
cat ${outproc}_log.txt | egrep -v '(Crash Annotation)' > ${outproc}_log.txt.new # remove firefox 'glxtest: libEGL initialize failed' errors
\mv ${outproc}_log.txt.new ${outproc}_log.txt
fi
# Patches moved here from patchMad.sh after Olivier's PR #764 (THIS IS ONLY NEEDED IN THE MADGRAPH4GPU GIT REPO)
if [ "${OUTBCK}" == "mad" ]; then
# Force the use of strategy SDE=1 in multichannel mode (see #419)
sed -i 's/2 = sde_strategy/1 = sde_strategy/' ${outproc}/Cards/run_card.dat
# Generate run_card.inc and param_card.inc (include stdout and stderr in the code generation log which is later checked for errors)
# These two steps are part of "cd Source; make" but they actually are code-generating steps
${outproc}/bin/madevent treatcards run >> ${outproc}_log.txt 2>&1 # AV BUG! THIS MAY SILENTLY FAIL (check if output contains "Please report this bug")
${outproc}/bin/madevent treatcards param >> ${outproc}_log.txt 2>&1 # AV BUG! THIS MAY SILENTLY FAIL (check if output contains "Please report this bug")
# Cleanup
\rm -f ${outproc}/crossx.html
\rm -f ${outproc}/index.html
\rm -f ${outproc}/madevent.tar.gz
\rm -f ${outproc}/Cards/delphes_trigger.dat
\rm -f ${outproc}/Cards/plot_card.dat
\rm -f ${outproc}/bin/internal/run_plot*
\rm -f ${outproc}/HTML/*
\rm -rf ${outproc}/bin/internal/__pycache__
\rm -rf ${outproc}/bin/internal/ufomodel/py3_model.pkl
\rm -rf ${outproc}/bin/internal/ufomodel/__pycache__
touch ${outproc}/HTML/.keep # new file
fi
# Check the code generation log for errors
if [ -d ${outproc} ] && ! grep -q "Please report this bug" ${outproc}_log.txt; then
###cat ${outproc}_log.txt; exit 0 # FOR DEBUGGING
cat ${MG5AMC_HOME}/${outproc}_log.txt | egrep 'INFO: (Try|Creat|Organiz|Process)'
cat ${MG5AMC_HOME}/${outproc}_log.txt | { egrep 'INFO: (Try|Creat|Organiz|Process)' || true; }
else
echo "*** ERROR! Code generation failed"
cat ${MG5AMC_HOME}/${outproc}_log.txt
Expand Down

0 comments on commit 2fa4830

Please sign in to comment.