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

WIP: refactor makefiles (additions to Stephan's and Joorgen's PRs) #797

Closed
wants to merge 130 commits into from

Conversation

valassi
Copy link
Member

@valassi valassi commented Dec 9, 2023

This is a WIP PR about refactoring makefiles.

It contains a few additions to Stephan's PR #753 (itself including Joorgen's PR #775 IIUC).

I find it easier to have it as a separate PR so that I can trigger the CI.

Specifically, the first issue I wanted to fix is that 96f9ba7 fails the CI in PR #753.

Later todo:

  • fix sa generation as discussed
  • review the make targets as discussed
  • make sure my test scripts function correctly

…ff so that it can be digested by both clang13 and clang16

Using Stephan's previous commits, codegen (for ggtt.mad) was failing clang-format checks on itscrd90.
Now codegen succeeds completely on itscrd90, but fails on itscrd80 because patchMad.sh fails.
…patch.P1 and patch.common from scratch

(This is an old commit from 9 Dec but the description is still valid on 14 Dec)

./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/make_opts 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/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

NB1: In the instructions above, I changed the order of files in the patches (I moved make_opts to the beginning), to minimise differences in patch.common with respect to Stephan's.
NB2: In another branch mch (PR madgraph5#796) I had decided to remove make_opts from patch.common: this is clearly no longer possible now

Before this commit, i.e. using Stephan's patch.P1 and patch.common, this was happening:
- code generation succeeds on itscrd90, fails on itscrd80 (patchMad.sh fails on the latter)
- executing './CODEGEN/generateAndCompare.sh gg_tt  --mad --nopatch' shows that the only difference between itscrd80 and itscrd90 is f2py (f2py3.9 on the former, f2py on the latter)

After this commit, however:
- code generation fails on itscrd90 (patchMad.sh fails, probably due to f2py issues)
…2py patching from generateAndCompare.sh to patchMad.sh

(This is an old commit from 9 Dec but the description is still valid on 14 Dec)

Before this commit, codegen was now failing on itscrd90 as it was previously failing on itscrd80 (patchMd.sh fails due to f2py)

After this commit, codegen is succeeding again on itscrd90, and now also on itscrd80 (fixing the issue in PR madgraph5#753)
@valassi valassi force-pushed the refactorMakefile branch 2 times, most recently from 5473f65 to fbcf4a4 Compare December 14, 2023 07:40
@valassi
Copy link
Member Author

valassi commented Dec 14, 2023

I have temporarely forced push again the code I had 2 days ago
fbcf4a4

But now I will incorporate Stephan's latest changes (force pushed) to PR #753

Note: at this stage, the new CI fails because 'make avxall' does not exist

@valassi
Copy link
Member Author

valassi commented Dec 14, 2023

@hageboeck I have now moved to your latest 629d5aa and am adding my previous patches on top one by one.

I will go on until this CI is fixed, at least.

As previously observed, at this stage codegen succeeds on itscrd80 and itscrd90 but not in the CI. I will again add my sorting magic to make everything reproducible and allow all codegen to succeed.

Stephan then I will ask you to cherry pick or merge these changes (and stop force pushing please at that point)

….sh in the CI (it works instead in itscrd90/80): reorder make_opts_variables before patching - however codegen now fails on itscrd90

(This is an old commit from 9 Dec but the description is still valid on 14 Dec)
… keep the special handling of make_opts also in --nopatch mode (and will regenerate patch.common)

(This is an old commit from 9 Dec but the description is still valid on 14 Dec)
(This is an old commit from 9 Dec but the description is still valid on 14 Dec - patch.common is regenerated on 14 Dec anyway)

./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/make_opts 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/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

Now code generation succeeds again on itscrd90 and also on itscrd80 - and is expected to succeed also in the CI
@valassi
Copy link
Member Author

valassi commented Dec 14, 2023

The CI codegen was indeed failing, I have now again addded the commits necessary to fix that.

Now codegen succeeds in the CI (for mad) but the build fails because 'make avxall' does not exist. I will also change that.

First however I will also make other minor changes to disable ccache for fortran.

…for fortran as it is not supported

(This is an old commit from 12 Dec but the description is still valid on 14 Dec)
(This is an old commit from 12 Dec but the description is still valid on 14 Dec - patch.common is regenerated on 14 Dec anyway)

./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/make_opts 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/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

I need to regenerate all .mad files (.sa generation still needs to be fixed)
…---sa flags

(This is an old commit from 9 Dec but the description is still valid on 14 Dec)
./CODEGEN/allGenerateAndCompare.sh --mad
…ild.* directory (without bash nullglob, this expands to literal build.* otherwise)
…r.mod in Source/makefile

Without this fix, the following situation could take place:

1. When make is interrupted by ctrl-c, DiscreteSampler.o exists but discretesampler.mod does not exist

make[1]: Entering directory '/data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/gg_tt.mad/Source'
AVX=none
RNDGEN=hasCurand
gfortran -I. -fPIC -w -ffixed-line-length-132 -O3 -ffast-math -fbounds-check -c StringCast.f -o StringCast.o
gfortran -I. -fPIC -w -ffixed-line-length-132 -O3 -ffast-math -fbounds-check -c DiscreteSampler.f -o DiscreteSampler.o
gfortran -I. -fPIC -w -ffixed-line-length-132 -O3 -ffast-math -fbounds-check -c dsample.f -o dsample.o
^Cmake: *** [../../Source/.timestamp_guard] Deleting file '../../Source/discretesampler.mod'
make: *** [makefile:65: ../../Source/.timestamp_guard] Interrupt

2. When make (or make -j) is then attempted, discretesampler.mod does not exist and cannot be recreated

make[1]: Entering directory '/data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/gg_tt.mad/Source'
AVX=none
RNDGEN=hasCurand
gfortran -I. -fPIC -w -ffixed-line-length-132 -O3 -ffast-math -fbounds-check -c dsample.f -o dsample.o
dsample.f:1090:10:

 1090 |       use DiscreteSampler
      |          1
Fatal Error: Cannot open module file ‘discretesampler.mod’ for reading at (1): No such file or directory
compilation terminated.
This reverts commit 06ec67a.
valassi added a commit to valassi/madgraph4gpu that referenced this pull request Dec 15, 2023
…ster's version instead of Jorgen's for those 5 lines)

NB1: currently, Jorgen's version differs from upstream/master only in three CODEGEN files
git diff --name-only upstream/master
epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.common
epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/cudacpp.mk
epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/cudacpp_src.mk

NB2: code generation for ggtt.mad currently fails on itscrd90 (patchMad..sh fails for makefile - same as seen in PR madgraph5#797?)
valassi added a commit to valassi/madgraph4gpu that referenced this pull request Dec 17, 2023
…ral fixes to ensure make_opts is reproducible

This is the combination of three successive patches I had first used in PR madgraph5#797
- keep the special handling of make_opts also in --nopatch mode
- reorder make_opts_variables before patching
- move back f2py patching from generateAndCompare.sh to patchMad.sh
@valassi
Copy link
Member Author

valassi commented May 22, 2024

I am closing this one after merging #798 and #841. May reopen if needed depending on #753.

@valassi valassi closed this May 22, 2024
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.

3 participants