Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call the patchMad.sh script from within the plugin's finalize #747

Merged
merged 48 commits into from
Aug 15, 2023

Conversation

roiser
Copy link
Member

@roiser roiser commented Aug 11, 2023

first version of calling the patch script
patch script and patch files moved into the plugin directory

@roiser roiser changed the title Patch madsh upstream WIP: Patch madsh upstream Aug 11, 2023
oliviermattelaer and others added 6 commits August 11, 2023 11:51
…he the patches dir also contains files not necessary for the patching via upstream madgraph)
…ry (NB the the patches dir also contains files not necessary for the patching via upstream madgraph)"

This reverts commit d4a2532.
…e the patches dir also contains files not necessary for the patching via upstream madgraph)
…CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD to CODEGEN/MG5aMC_patches/PROD

These two files are ONLY needed by the madgraph4gpu generateAndCompare.sh script, they do not need to be exposed in upstream madgraph
…things changed or are missing? - will revert

*NB* The log clearly shows that there was a problem running patchMad.sh:
DEBUG:  'Entering PLUGIN_ProcessExporter.finalize', self.in_madevent_mode =  Entering PLUGIN_ProcessExporter.finalize True [output.py at line 204]
Usage: /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/patchMad.sh <process.[madonly|mad]> <vecsize> <patch_dir> [--nopatch|--upstream]
…d.sh)

Revert "[patchMadsh] try to regenerate ggtt.mad, it does not look good, many things changed or are missing? - will revert"
This reverts commit b34e3ec.
…ts new location inside the plugin, as it seems not to have worked in finalize
….sh from generateAndCompare (the one inside finalize still fails)
…ain (try instead to fix it inside finalize)

Revert "[patchMadsh] in CODEGEN/generateAndCompare.sh, run patchMad.sh from its new location inside the plugin, as it seems not to have worked in finalize"
This reverts commit 37c4fa9.
…leanup from that of plugins - and omit plugin cleanup at the end
@valassi
Copy link
Member

valassi commented Aug 14, 2023

I am doing further integration tests and patches, to make sure that calling this from generateAndCompare.sh also still works.

@roiser I am confused however because, unless I did something different from you, the patchMad.sh scripts is not called from finalize (or better, it is called but it does nothing because it fails and prints an error)

[avalassi@itscrd80 gcc11.2/cvmfs] /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo> more pippo 
set stdout_level DEBUG
set zerowidth_tchannel F
generate g g > t t~
output madevent CODEGEN_mad_gg_tt --hel_recycling=False --vector_size=32 --me_exporter=standalone_cudacpp

[avalassi@itscrd80 gcc11.2/cvmfs] /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo> ./bin/mg5_aMC pippo
...
INFO: Use Fortran compiler gfortran 
INFO: Use c++ compiler g++ 
INFO: Generate web pages 
DEBUG:  'Entering PLUGIN_ProcessExporter.finalize', self.in_madevent_mode =  Entering PLUGIN_ProcessExporter.finalize True [output.py at line 204] 
Usage: /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/patchMad.sh <process.[madonly|mad]> <vecsize> <patch_dir> [--nopatch|--upstream]
Output to directory /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt done.
Type "launch" to generate events from this process, or see
/data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt/README
Run "open index.html" to see more information about this process.
quit

In particular, Usage: /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/patchMad.sh <process.[madonly|mad]> <vecsize> <patch_dir> [--nopatch|--upstream] is an error printout. It means that the script failed.

I will add an error check if possible. And also try to fix this

…hMad.sh failed

This correctly stops code generation

DEBUG:  'Entering PLUGIN_ProcessExporter.finalize', self.in_madevent_mode =  Entering PLUGIN_ProcessExporter.finalize True [output.py at line 204]
Usage: /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/patchMad.sh <process.[madonly|mad]> <vecsize> <patch_dir> [--nopatch|--upstream]
Command "import /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt.mg" interrupted in sub-command:
"output madevent CODEGEN_mad_gg_tt --hel_recycling=False --vector_size=16384 --me_exporter=standalone_cudacpp" with error:
Exception : ERROR! the O/S call to patchMad.sh failed
Please report this bug on https://bugs.launchpad.net/mg5amcnlo
More information is found in 'MG5_debug'.
Please attach this file to your report.
…directory is called <proc>.mad or <proc>.madonly to allow the script to be called inside finalize
…till (silent) errors, and some differences with respect to the desired result

> cp: cannot stat '/data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/.clang-format': No such file or directory
> DEBUG: cd /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt; patch -p4 -i /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.common
> patching file Source/genps.inc
> patching file Source/makefile
> patching file Source/vector.inc
> patching file SubProcesses/makefile
> patching file Source/make_opts
> patching file bin/internal/banner.py
> Hunk #1 succeeded at 4187 (offset 23 lines).
> patching file bin/internal/gen_ximprove.py
> patching file bin/internal/madevent_interface.py
> cp: cannot stat '/data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/timer.h': No such file or directory
> DEBUG: cd /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt/SubProcesses/P1_gg_ttx; patch -p6 -i /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.P1
> patching file auto_dsig1.f
> patching file driver.f
> patching file matrix1.f
…iate exit on errors

The script now correctly fails

INFO:
cp: cannot stat '/data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/.clang-format': No such file or directory
Command "import /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt.mg" interrupted in sub-command:
"output madevent CODEGEN_mad_gg_tt --hel_recycling=False --vector_size=16384 --me_exporter=standalone_cudacpp" with error:
Exception : ERROR! the O/S call to patchMad.sh failed
Please report this bug on https://bugs.launchpad.net/mg5amcnlo
More information is found in 'MG5_debug'.
Please attach this file to your report.
quit
…mat (this is in the plugin since a long time anyway...)

The script now fails a bit later

cp: cannot stat '/data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/timer.h': No such file or directory
Command "import /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_mad_gg_tt.mg" interrupted in sub-command:
"output madevent CODEGEN_mad_gg_tt --hel_recycling=False --vector_size=16384 --me_exporter=standalone_cudacpp" with error:
Exception : ERROR! the O/S call to patchMad.sh failed
Please report this bug on https://bugs.launchpad.net/mg5amcnlo
More information is found in 'MG5_debug'.
Please attach this file to your report.
…mpts at regenerating

git checkout upstream/master gg_tt.mad
…hich is already copied via the plugin)

Generation now seems to succeed
…ster, with a few differences

Details
- banner.py has additional text (I guess this is intended in the upstream change of gpucpp)
- param_card.inc now has some values sorted in a different way, but everything is there
- run_card.inc now has changed SDE_STRAT=1 to SDE_STRAT=2
…ctor.inc (will eventually use runcards instead)
…via the hidden env variable CUDACPP_CODEGEN_PATCHLEVEL
… new MG5AMC patches as-is (in case, this should go to the plugin...)
…e first time in the new patch location (NB also remove vector.inc which no longer needs patches)

./CODEGEN/generateAndCompare.sh gg_tt --mad --nopatch
sed -i 's/DEFAULT_F2PY_COMPILER=f2py3.*/DEFAULT_F2PY_COMPILER=f2py3/' gg_tt.mad/Source/make_opts
git diff --no-ext-diff -R gg_tt.mad/Source/makefile gg_tt.mad/Source/dsample.f gg_tt.mad/Source/genps.inc gg_tt.mad/SubProcesses/makefile > CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.common
git diff --no-ext-diff -R gg_tt.mad/Source/make_opts gg_tt.mad/bin/internal/banner.py gg_tt.mad/bin/internal/gen_ximprove.py gg_tt.mad/bin/internal/madevent_interface.py >> CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.common
git diff --no-ext-diff -R gg_tt.mad/SubProcesses/P1_gg_ttx/auto_dsig1.f gg_tt.mad/SubProcesses/P1_gg_ttx/driver.f gg_tt.mad/SubProcesses/P1_gg_ttx/matrix1.f > CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.P1
git checkout gg_tt.mad
@valassi
Copy link
Member

valassi commented Aug 14, 2023

I have also fixed all other pending issues
To do still

  • allow the patchMad to be used with any vecsize as input (now it assumes it was generated with 16384, so the hardcoded 32 in output.py will fail there)
  • resurrect a "no-patch" mode in generateAndCompare: this is needed to create new patch.P1 and patch.common if needed
  • final checks that the same code is generated in mg5amc and in my generateAndCompare script (modulo irrelevant details)
  • regenerate all processes
  • added comments about self.in_madevent_mode (but did not use the flag everywhere, it did not seem appropriate/necessary)
  • I also moved to the very latest gpucpp from Olivier

Now rerunning tests, should be able to merge soon

@valassi valassi changed the title WIP: Patch madsh upstream Call the patchMad.sh script from within the plugin's finalize Aug 14, 2023
@valassi valassi mentioned this pull request Aug 14, 2023
@valassi
Copy link
Member

valassi commented Aug 14, 2023

I will wait for the tests running tonight to succeed, and will merge tomorrow.

This will close issue #656. Note that the strategy for integrating patchMad.sh patches upstream has changed:

…madevent+cudacpp mode (also move to self.in_madevent_mode in one place only)
… which does not work where I tried to use it)
Also checked that these are identical to those created in-situ in MG5AMC, except for a few minor points
- some .gitignore and CODEGEN logs are only in madgraph4gpu
- the VECSIZE_MEMMAX depends on whatever was used upstream...
- the Cards/me5_configuration.txt may have some differences
- SubProcesses/proc_characteristics has different values of bias_modules (I noted in the genAndComp script that this is irrelevant)
- the order of parameters in Cards/ident_card.dat is different (oliviermattelaer/mg5amc_test#2)
…anges - changes only in .mad python (mainly for combine events)
(Note: will rerun tput due to nsight config errors from AFS expired, #750)

STARTED AT Mon Aug 14 22:01:13 CEST 2023
ENDED   AT Tue Aug 15 02:20:34 CEST 2023

24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_eemumu_mad/log_eemumu_mad_d_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_eemumu_mad/log_eemumu_mad_f_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_eemumu_mad/log_eemumu_mad_m_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttggg_mad/log_ggttggg_mad_d_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttggg_mad/log_ggttggg_mad_f_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttggg_mad/log_ggttggg_mad_m_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttgg_mad/log_ggttgg_mad_d_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttgg_mad/log_ggttgg_mad_f_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttgg_mad/log_ggttgg_mad_m_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttg_mad/log_ggttg_mad_d_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttg_mad/log_ggttg_mad_f_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggttg_mad/log_ggttg_mad_m_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggtt_mad/log_ggtt_mad_d_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggtt_mad/log_ggtt_mad_f_inl0_hrd0.txt
24 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_ggtt_mad/log_ggtt_mad_m_inl0_hrd0.txt
0 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_gqttq_mad/log_gqttq_mad_d_inl0_hrd0.txt
0 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_gqttq_mad/log_gqttq_mad_f_inl0_hrd0.txt
0 /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/tmad/logs_gqttq_mad/log_gqttq_mad_m_inl0_hrd0.txt
STARTED  AT Tue Aug 15 07:47:04 CEST 2023
./tput/teeThroughputX.sh -mix -hrd -makej -eemumu -ggtt -ggttg -ggttgg -gqttq -ggttggg -makeclean
ENDED(1) AT Tue Aug 15 08:14:00 CEST 2023 [Status=0]
./tput/teeThroughputX.sh -flt -hrd -makej -eemumu -ggtt -ggttgg -inlonly -makeclean
ENDED(2) AT Tue Aug 15 08:23:38 CEST 2023 [Status=0]
./tput/teeThroughputX.sh -makej -eemumu -ggtt -ggttg -gqttq -ggttgg -ggttggg -flt -bridge -makeclean
ENDED(3) AT Tue Aug 15 08:33:37 CEST 2023 [Status=0]
./tput/teeThroughputX.sh -eemumu -ggtt -ggttgg -flt -rmbhst
ENDED(4) AT Tue Aug 15 08:36:51 CEST 2023 [Status=0]
./tput/teeThroughputX.sh -eemumu -ggtt -ggttgg -flt -curhst
ENDED(5) AT Tue Aug 15 08:40:02 CEST 2023 [Status=0]
@valassi
Copy link
Member

valassi commented Aug 15, 2023

The CI tests passsed - I am self merging

@valassi valassi merged commit 27069e0 into master Aug 15, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port post-generation patches (patchMad.sh) upstream to mg5amcnlo or to the plugin
3 participants