Skip to content

Remove patches and patchMad.sh, fix googletest incompatibilities#1052

Merged
Qubitol merged 16 commits intomadgraph5:masterfrom
Qubitol:nopatch
Oct 17, 2025
Merged

Remove patches and patchMad.sh, fix googletest incompatibilities#1052
Qubitol merged 16 commits intomadgraph5:masterfrom
Qubitol:nopatch

Conversation

@Qubitol
Copy link
Collaborator

@Qubitol Qubitol commented Oct 14, 2025

PR to remove patches and patchMad.sh.
The code additions have been done using the code generation placeholders present within MadGraph itself.

Additionally, fix issues due to googletest incompatibilities, in the CI, see previous PRs #1040, #1045, #1048, #1051, and commits 5c73921, af17e41.

@Qubitol Qubitol marked this pull request as ready for review October 14, 2025 10:08
@Qubitol Qubitol requested a review from a team as a code owner October 14, 2025 10:08
Copy link
Member

@valassi valassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Daniele, thanks and well done, nice MR! It was about time we remove patchMad.

As discussed, I send you here a few (minor) comments/questions.

  1. I saw that make bldall no longer works and one must do make -f makefile -f cudacpp_overlay.mk bldall. First point, it would be nice if possible to avoid passing the two extra -f. Second point, this spits out many warnings. I was wondering, would it not be possible to use the same trick you used elsewhere, "%(CUDACPP_MAKEFILE_EXTRA)" inside the makefile template and define/modify some things inside the makefile itself? For instance, to instruct the makefile itself to add the overlay, and in the relevant places to make changes that avoid the warnings? Not a problem if you think that's not useful/needed, but I wanted to suggest it.

  2. I got confused at some point because you have a MR open on mg5amc mg5amcnlo/mg5amcnlo#191, and I was wondering how your MR can work without it. Then I realised that actually this MR uses a similar change I had already done in view of removing patchMad, mg5amcnlo/mg5amcnlo@c1509dc. So my question is, can mg5amcnlo/mg5amcnlo#191 be closed or do you still need that too (why)?

I also sent a couple of other minor points directly in the code.

Thanks again, cheers Andrea

@valassi
Copy link
Member

valassi commented Oct 15, 2025

PS Specifically about the warnings, these are things like

make -f makefile -f cudacpp_overlay.mk bldall
cudacpp_overlay.mk:134: warning: overriding recipe for target '../../lib/libmodel.a'
makefile:65: warning: ignoring old recipe for target '../../lib/libmodel.a'
cudacpp_overlay.mk:135: warning: overriding recipe for target '../../lib/libgeneric.a'
makefile:68: warning: ignoring old recipe for target '../../lib/libgeneric.a'
cudacpp_overlay.mk:136: warning: overriding recipe for target '../../lib/libpdf.a'
makefile:71: warning: ignoring old recipe for target '../../lib/libpdf.a'
cudacpp_overlay.mk:137: warning: overriding recipe for target '../../lib/libgammaUPC.a'
makefile:74: warning: ignoring old recipe for target '../../lib/libgammaUPC.a'
cudacpp_overlay.mk:175: warning: overriding recipe for target 'madevent_forhel'
makefile:59: warning: ignoring old recipe for target 'madevent_forhel'
cudacpp_overlay.mk:178: warning: overriding recipe for target 'gensym'
makefile:62: warning: ignoring old recipe for target 'gensym'
cudacpp_overlay.mk:182: warning: overriding recipe for target 'matrix1.o'
makefile:78: warning: ignoring old recipe for target 'matrix1.o'
cudacpp_overlay.mk:280: warning: overriding recipe for target 'clean'
makefile:101: warning: ignoring old recipe for target 'clean'

@Qubitol
Copy link
Collaborator Author

Qubitol commented Oct 15, 2025

Thanks for the comments! Here are my thoughts.

I saw that make bldall no longer works and one must do make -f makefile -f cudacpp_overlay.mk bldall. First point, it would be nice if possible to avoid passing the two extra -f.

I thought about that, and there are 2 solutions:

  1. rename makefile to makefile_orig.mk or something similar (this should be done from the CUDACPP point of view, since makefile is copied from MadGraph side, then add a wrapper makefile like the following:
    SHELL := /bin/bash
    include makefile_orig.mk
    include cudacpp_overlay.mk
  2. with a quick search, I found out that a makefile GNUmakefile has precedence over makefile (see the relevant part on the GNU make manual). So in principle we can create GNUmakefile as:
    SHELL := /bin/bash
    include makefile
    include cudacpp_overlay.mk

I don't have a strong opinion on either 3 of the solutions (leave it as it is, use approach 1 or use approach 2), I guess we should involve @roiser and @oliviermattelaer for a final decision.
Notice that with approach 2, we explicitly require GNU make, with respect to other make flavours. Is this a concern? Probably not, since we are already using e.g. include directives in other makefiles, and those are not supported by BSD make for example, so de-facto we are already enforcing GNU make.

Second point, this spits out many warnings. I was wondering, would it not be possible to use the same trick you used elsewhere, "%(CUDACPP_MAKEFILE_EXTRA)" inside the makefile template and define/modify some things inside the makefile itself? For instance, to instruct the makefile itself to add the overlay, and in the relevant places to make changes that avoid the warnings? Not a problem if you think that's not useful/needed, but I wanted to suggest it.

That's a good point, but this requires to modify the MadGraph code generator to write makefile from a template, and now the makefile is copied as it is, it is not written by the code generator.
In principle, we could modify makefile from the MadGraph side to add an if statement that checks the presence of cudacpp_overlay.mk and includes it if found. But I'm not sure this is the right approach: I feel we should control these things from the CUDACPP side entirely.

I got confused at some point because you have a MR open on mg5amc mg5amcnlo/mg5amcnlo#191, and I was wondering how your MR can work without it. Then I realised that actually this MR uses a similar change I had already done in view of removing patchMad, mg5amcnlo/mg5amcnlo@c1509dc. So my question is, can mg5amcnlo/mg5amcnlo#191 be closed or do you still need that too (why)?

Yes, indeed that PR can be closed, no changes in MadGraph are necessary for this PR.

@Qubitol
Copy link
Collaborator Author

Qubitol commented Oct 15, 2025

PS Specifically about the warnings, these are things like

make -f makefile -f cudacpp_overlay.mk bldall
cudacpp_overlay.mk:134: warning: overriding recipe for target '../../lib/libmodel.a'
makefile:65: warning: ignoring old recipe for target '../../lib/libmodel.a'
cudacpp_overlay.mk:135: warning: overriding recipe for target '../../lib/libgeneric.a'
makefile:68: warning: ignoring old recipe for target '../../lib/libgeneric.a'
cudacpp_overlay.mk:136: warning: overriding recipe for target '../../lib/libpdf.a'
makefile:71: warning: ignoring old recipe for target '../../lib/libpdf.a'
cudacpp_overlay.mk:137: warning: overriding recipe for target '../../lib/libgammaUPC.a'
makefile:74: warning: ignoring old recipe for target '../../lib/libgammaUPC.a'
cudacpp_overlay.mk:175: warning: overriding recipe for target 'madevent_forhel'
makefile:59: warning: ignoring old recipe for target 'madevent_forhel'
cudacpp_overlay.mk:178: warning: overriding recipe for target 'gensym'
makefile:62: warning: ignoring old recipe for target 'gensym'
cudacpp_overlay.mk:182: warning: overriding recipe for target 'matrix1.o'
makefile:78: warning: ignoring old recipe for target 'matrix1.o'
cudacpp_overlay.mk:280: warning: overriding recipe for target 'clean'
makefile:101: warning: ignoring old recipe for target 'clean'

Yeah, they are annoying, but there is no easy and robust way to remove them, unless we silence stderr. And I don't thing we should silence stderr. We can filter stderr, but I don't think it is worthy just to get rid of those lines. There may be other tricks, but I can't recall any.
Think of it as a proof that the overlay has actually been applied correctly.

@valassi
Copy link
Member

valassi commented Oct 15, 2025

Thanks for the comments! Here are my thoughts.

I saw that make bldall no longer works and one must do make -f makefile -f cudacpp_overlay.mk bldall. First point, it would be nice if possible to avoid passing the two extra -f.

I thought about that, and there are 2 solutions:

1. rename `makefile` to `makefile_orig.mk` or something similar (this should be done from the CUDACPP point of view, since `makefile` is copied from MadGraph side, then add a wrapper `makefile` like the following:
   ```makefile
   SHELL := /bin/bash
   include makefile_orig.mk
   include cudacpp_overlay.mk
   ```

Thanks to you Daniele!
I like this option 1. I prefer it to the two other options (doing nothing i.e. forcing the use of two -f with makefiles; or using GNUMakefile, which would be very confusing imo).

Second point, this spits out many warnings. I was wondering, would it not be possible to use the same trick you used elsewhere, "%(CUDACPP_MAKEFILE_EXTRA)" inside the makefile template and define/modify some things inside the makefile itself? For instance, to instruct the makefile itself to add the overlay, and in the relevant places to make changes that avoid the warnings? Not a problem if you think that's not useful/needed, but I wanted to suggest it.

That's a good point, but this requires to modify the MadGraph code generator to write makefile from a template, and now the makefile is copied as it is, it is not written by the code generator. In principle, we could modify makefile from the MadGraph side to add an if statement that checks the presence of cudacpp_overlay.mk and includes it if found. But I'm not sure this is the right approach: I feel we should control these things from the CUDACPP side entirely.

I think the technicality is not too complex here. Whether makefile is copied or used as a template can be decidded in cudacpp, but if you do not inject the placeholders in the template in mg5amc this will not work. So in case it requires changes in mg5amc. I think this can be done (and in that case you do not even need option 1 above, you can just modify the makefile).

But another option is, just go ahead with the MR and keep the warnings. Then a future MR can always be done at another time to remove those warnings. This may speed things up.

I got confused at some point because you have a MR open on mg5amc mg5amcnlo/mg5amcnlo#191, and I was wondering how your MR can work without it. Then I realised that actually this MR uses a similar change I had already done in view of removing patchMad, mg5amcnlo/mg5amcnlo@c1509dc. So my question is, can mg5amcnlo/mg5amcnlo#191 be closed or do you still need that too (why)?

Yes, indeed that PR can be closed, no changes in MadGraph are necessary for this PR.

Ok thanks for confirming!

@valassi
Copy link
Member

valassi commented Oct 15, 2025

PS Specifically about the warnings, these are things like

make -f makefile -f cudacpp_overlay.mk bldall
cudacpp_overlay.mk:134: warning: overriding recipe for target '../../lib/libmodel.a'
makefile:65: warning: ignoring old recipe for target '../../lib/libmodel.a'
cudacpp_overlay.mk:135: warning: overriding recipe for target '../../lib/libgeneric.a'
makefile:68: warning: ignoring old recipe for target '../../lib/libgeneric.a'
cudacpp_overlay.mk:136: warning: overriding recipe for target '../../lib/libpdf.a'
makefile:71: warning: ignoring old recipe for target '../../lib/libpdf.a'
cudacpp_overlay.mk:137: warning: overriding recipe for target '../../lib/libgammaUPC.a'
makefile:74: warning: ignoring old recipe for target '../../lib/libgammaUPC.a'
cudacpp_overlay.mk:175: warning: overriding recipe for target 'madevent_forhel'
makefile:59: warning: ignoring old recipe for target 'madevent_forhel'
cudacpp_overlay.mk:178: warning: overriding recipe for target 'gensym'
makefile:62: warning: ignoring old recipe for target 'gensym'
cudacpp_overlay.mk:182: warning: overriding recipe for target 'matrix1.o'
makefile:78: warning: ignoring old recipe for target 'matrix1.o'
cudacpp_overlay.mk:280: warning: overriding recipe for target 'clean'
makefile:101: warning: ignoring old recipe for target 'clean'

Yeah, they are annoying, but there is no easy and robust way to remove them, unless we silence stderr. And I don't thing we should silence stderr. We can filter stderr, but I don't think it is worthy just to get rid of those lines. There may be other tricks, but I can't recall any. Think of it as a proof that the overlay has actually been applied correctly.

No I agree, I would not silence stderr. As I said previously, you can also just merge the MR as is, and then these warnings can be removed at a later stage.

Summary, all good for me, thanks for the changes you made!

Makefile wrapper used in case of madevent to join together both makefile_orig
and cudacpp_overlay.mk. This is to avoid doing make -f makefile -f cudacpp.mk,
keeping the possibility to just do `make`:
- makefile (after code generation by MadGraph) is renamed to makefile_original.mk
- makefile_wrapper.mk (copied from cudacpp) is symlinked as makefile
The logic is: in each SubProcesses/P* directory we have
- makefile -> ../makefile (this is the original makefile)
- cudacpp_overlay.mk -> ../cudacpp_overlay.mk
While in the SubProcesses directory we had to:
- makefile (this is the original makefile)
- cudacpp_overlay.mk
- makefile_wrapper.mk
So, in each SubProcesses/P* we had to (done in model_handling.py) symlink from
SubProcesses/P*/makefile_original.mk to SubProcesses/makefile_original.mk
(it will be broken initially).
While in SubProcesses we had to (done in output.py):
- copy makefile to makefile_original.mk (this fixes the previous symlink)
- remove makefile
- symlink from makefile_wrapper.mk to makefile
So that now the situation in each SubProcesses/P* is:
- makefile -> ../makefile (this is the makefile_wrapper.mk)
- cudacpp_overlay.mk -> ../cudacpp_overlay.mk
- makefile_original.mk -> ../makefile_original.mk (this is the original makefile)
@Qubitol
Copy link
Collaborator Author

Qubitol commented Oct 15, 2025

Thanks for the comments, regarding adding an additional makefile, I pushed now a commit that makes possible to do just make, removing any need of specifying the various makefiles.
Details on the implementation (it was bit of symlinkception) are in the commit notes.

@Qubitol Qubitol merged commit fad814f into madgraph5:master Oct 17, 2025
167 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.

2 participants