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

Event by event random choice of one color #573

Merged
merged 59 commits into from
Dec 18, 2022
Merged

Conversation

valassi
Copy link
Member

@valassi valassi commented Dec 16, 2022

Hi @oliviermattelaer @roiser I made progress for the random choice of color #402

This is still in WIP because I need amongst other things

… variable in sigmaKin for up to 2*neppV events
…or (inline in sigmaKin, remove select_color)

NB does not build because it is missing the isLeadingColor function...
…random choice of color madgraph5#402 in CPPProcess.cc - random color always 1?
…random color now 1 or 2 but C++ different from Fortran
…C indices) - still Fortran differs from C++ (but CUDA is ok!)
Revert "[lhe] add debug printouts in fortran and c++ for the random color choice"
This reverts commit aa4d429b79a43b137ae49d385dc4f22c4c49d07d.
…nitialise jamp2_sv for every SIMD page) - OK NOW! Fortran same as C++
…ocessExporterCPP.get_icolamp_lines instead!

Revert "[lhe] WIP in CODEGEN WIP to generate coloramps.h"
This reverts commit 62f9526cd1110f99a07eb28e3a42322d48ab5782.
…NOT needed for vectorised color selection

Revert "[lhe] in gg_tt.mad add an int_v typedef for vectorised color selection madgraph5#402"
This reverts commit 71565e4.
…ntvFromAlignedArray

Revert "[lhe] in gg_tt.mad add intvFromAlignedArray"
This reverts commit f721c49.
…sons of Fortran/C++ colors in auto_dsig1.f)

./CODEGEN/generateAndCompare.sh gg_tt --mad --nopatch
git diff --no-ext-diff -R gg_tt.mad/Source/dsample.f gg_tt.mad/Source/genps.inc gg_tt.mad/Source/vector.inc gg_tt.mad/SubProcesses/makefile > CODEGEN/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/MG5aMC_patches/PROD/patch.P1
git checkout gg_tt.mad
@valassi
Copy link
Member Author

valassi commented Dec 17, 2022

Ok I fixed the bug, regenerated all processes, now rerunning tests.

I guess that the bug was not showing up in ggtt chanel 1 because there only two channels exist and both are selected by icolamp. The bug was there when icolamp was not selecting all colors in a given channel

…tggg ok, but ggttgg fails?

STARTED AT Sat Dec 17 10:27:33 CET 2022
ENDED   AT Sat Dec 17 16:10:09 CET 2022
@valassi
Copy link
Member Author

valassi commented Dec 17, 2022

This is becoming very tiring. Now ggttgg fails (while all others including ggttggg succeed)

   1  0.31474429E-11  0.31474429E-11          1.00000000000 59 59  19  21
   2  0.86377810E-14  0.86377810E-14          1.00000000000 19 19   2   1
   3  0.56731328E-11  0.56731328E-11          1.00000000000  1  1  17  21
   4  0.67945873E-10  0.67945873E-10          1.00000000000 59 59  19  23
   5  0.31218012E-11  0.31218012E-11          1.00000000000  7  7  13  15
   6  0.82126219E-11  0.82126219E-11          1.00000000000 58 58  13  13
   7  0.10159941E-12  0.10159941E-12          1.00000000000 62 62  18  24
   8  0.27237259E-12  0.27237259E-12          1.00000000000  5  5  13  13
   9  0.10386178E-10  0.10386178E-10          1.00000000000  5  5  21  23
  10  0.61444696E-13  0.61444696E-13          1.00000000000 19 19   2  13
  11  0.13942560E-09  0.13942560E-09          1.00000000000  5  5   8   1
  12  0.48235311E-12  0.48235311E-12          1.00000000000 59 59   2   1
  13  0.89336345E-12  0.89336345E-12          1.00000000000  1  1   2   1
  14  0.13518722E-11  0.13518722E-11          1.00000000000 57 57  17  21
  15  0.60930733E-11  0.60930733E-11          1.00000000000 45 45   2   1
  16  0.59471752E-11  0.59471752E-11          1.00000000000 64 64  19  24
  17  0.14062121E-11  0.14062121E-11          1.00000000000 56 56  18  24
  18  0.66332970E-09  0.66332970E-09          1.00000000000  5  5  13  13
  19  0.35684751E-11  0.35684751E-11          1.00000000000 60 60  13   7
  20  0.74231873E-13  0.74231873E-13          1.00000000000  5  5  19  19
  21  0.23690718E-10  0.23690718E-10          1.00000000000  6  6  13  13
  22  0.17309408E-11  0.17309408E-11          1.00000000000 50 50  18  24
  23  0.11440207E-10  0.11440207E-10          1.00000000000 47 47   8   1
  24  0.88555898E-12  0.88555898E-12          1.00000000000 25 25  21  23
  25  0.32026869E-13  0.32026869E-13          1.00000000000 25 25   8   7
  26  0.19444256E-11  0.19444256E-11          1.00000000000 20 20   2   1
  27  0.20234129E-11  0.20234129E-11          1.00000000000  7  7   2   1
  28  0.50887711E-11  0.50887711E-11          1.00000000000 23 23   2   1
  29  0.64663342E-12  0.64663342E-12          1.00000000000 59 59  15  15
  30  0.35253467E-10  0.35253467E-10          1.00000000000  5  5  13   7
  31  0.17154946E-12  0.17154946E-12          1.00000000000 56 56  15  15
  32  0.52386604E-11  0.52386604E-11          1.00000000000 58 58   8   1

@valassi
Copy link
Member Author

valassi commented Dec 17, 2022

Ok so the root cause here is that for the channel 1 that I am using, coloramps.inc and coloramps.h are not the same thing...

      LOGICAL ICOLAMP(24,105,1)
      DATA(ICOLAMP(I,1,1),I=1,24)/.TRUE.,.FALSE.,.FALSE.,.FALSE.
     $ ,.FALSE.,.FALSE.,.TRUE.,.FALSE.,.FALSE.,.FALSE.,.FALSE.,.FALSE.
     $ ,.TRUE.,.FALSE.,.TRUE.,.FALSE.,.FALSE.,.FALSE.,.TRUE.,.FALSE.
     $ ,.TRUE.,.FALSE.,.TRUE.,.TRUE./

  __device__ constexpr bool icolamp[105][24] = { // FIXME: assume process.nprocesses == 1 for the moment
    { true, true, false, false, false, false, true, true, false, false, false, false, true, false, true, false, true, true, true, false, true, false, true, true },

I suspected this by looking at the targetamps... for the same event, it is a different set of colors in fortran and cpp that are considered leading

icol, targetamp 0 0.0120353
icol, targetamp 1 0.0120353
icol, targetamp 2 0.0120353
icol, targetamp 3 0.0120353
icol, targetamp 4 0.0120353
icol, targetamp 5 0.0120353
icol, targetamp 6 0.282099
icol, targetamp 7 0.282099
icol, targetamp 8 0.282099
icol, targetamp 9 0.282099
icol, targetamp 10 0.282099
icol, targetamp 11 0.282099
icol, targetamp 12 0.531494
icol, targetamp 13 0.531494
icol, targetamp 14 0.533597
icol, targetamp 15 0.533597
icol, targetamp 16 0.533597
icol, targetamp 17 0.533597
icol, targetamp 18 0.543515
icol, targetamp 19 0.543515
icol, targetamp 20 0.73962
icol, targetamp 21 0.73962
icol, targetamp 22 0.986362
icol, targetamp 23 1
icolsel, rcol   21 0.556235

IEVT  51
ICOL, TARGETAMP   1 0.000
ICOL, TARGETAMP   2 0.066
ICOL, TARGETAMP   3 0.066
ICOL, TARGETAMP   4 0.066
ICOL, TARGETAMP   5 0.066
ICOL, TARGETAMP   6 0.066
ICOL, TARGETAMP   7 0.066
ICOL, TARGETAMP   8 0.156
ICOL, TARGETAMP   9 0.156
ICOL, TARGETAMP  10 0.156
ICOL, TARGETAMP  11 0.156
ICOL, TARGETAMP  12 0.156
ICOL, TARGETAMP  13 0.563
ICOL, TARGETAMP  14 0.563
ICOL, TARGETAMP  15 0.567
ICOL, TARGETAMP  16 0.567
ICOL, TARGETAMP  17 0.615
ICOL, TARGETAMP  18 0.664
ICOL, TARGETAMP  19 0.680
ICOL, TARGETAMP  20 0.680
ICOL, TARGETAMP  21 1.000
ICOL, TARGETAMP  22 1.000
ICOL, TARGETAMP  23 1.000
ICOL, TARGETAMP  24 1.000
ICOLSEL, RCOL    13 0.556

   2  0.87322402E-11  0.87322402E-11          1.00000000000  5  5  13  21

@valassi
Copy link
Member Author

valassi commented Dec 17, 2022

Hi @oliviermattelaer is this caused by mg5amcnlo/mg5amcnlo#5?

Now that I read it, I would imagine so...
"This branch include change to the amp2 numbering as we discussed before.

For completeness, the main goal was to be able to have the same index for the identification of the amp2 index as for the one related to the definition of the allowed color flow for the event."

I had completely forgotten that we discussed this in June and that I should include it...

@valassi valassi marked this pull request as draft December 17, 2022 18:27
@valassi
Copy link
Member Author

valassi commented Dec 17, 2022

Hi @oliviermattelaer @roiser I am moving this back to draft.

I need to first upgrade the upstream to https://github.com/mg5amcnlo/mg5amcnlo/pull/5/files

The problem is that that pull request does not work against vecMLM which is what we use now.

So we need to fix the conflicts first. I can give it a try, but I am not sure I would do it right

@valassi
Copy link
Member Author

valassi commented Dec 18, 2022

Well in the end I am also trying a simple hack. By using brute force sed/awk I transformed coloramps.inc into coloramps.h in such a way that they have the same definition of icolamp. Assuming that the one in Fortran is correct (is it?!) then also the one in cudacpp is correct.

I am running the tests now. If they succeed, I will merge and consider this part closed.

Of course the code generation must be done properly and the lovectdiag must be merged, but at least we might say we have randol color choice.

@valassi valassi marked this pull request as ready for review December 18, 2022 08:53
@valassi valassi changed the title WIP: Event by event random choice of one color Event by event random choice of one color Dec 18, 2022
… will not be backported)

 git format-patch c686761 -1
 patch -R -p6 -i 0001-lhe-in-ggttg.mad-revert-debug-printouts.patch
…mments in fortran (no need to regenerate sa)
…from coloramps.inc

No need to regenerate SA processes, they have no coloramps.h
…put alltees - finally all ok

This completes the random color choice madgraph5#402

This took around 8 hours from 1h to 9h
STARTED  AT Sun Dec 18 07:32:03 CET 2022
./tput/teeThroughputX.sh -flt -hrd -makej -eemumu -ggtt -ggttg -ggttgg -ggttggg -makeclean
ENDED(1) AT Sun Dec 18 08:39:14 CET 2022 [Status=0]
./tput/teeThroughputX.sh -flt -hrd -makej -eemumu -ggtt -ggttgg -inlonly -makeclean
ENDED(2) AT Sun Dec 18 09:00:20 CET 2022 [Status=0]
./tput/teeThroughputX.sh -makej -eemumu -ggtt -ggttg -ggttgg -ggttggg -flt -bridge -makeclean
ENDED(3) AT Sun Dec 18 09:09:51 CET 2022 [Status=0]
./tput/teeThroughputX.sh -eemumu -ggtt -ggttgg -flt -rmbhst
ENDED(4) AT Sun Dec 18 09:13:28 CET 2022 [Status=0]
./tput/teeThroughputX.sh -eemumu -ggtt -ggttgg -flt -curhst
ENDED(5) AT Sun Dec 18 09:17:01 CET 2022 [Status=0]
@valassi
Copy link
Member Author

valassi commented Dec 18, 2022

I consider this complete - within madgraph4gpu, that is, within the context of my custom patches.

Eventually we need to fix coloramps.h out of the box in upstream mg5amcnlo but this is another story.

The important point here is: when coloramps.h and coloramps.inc hav ethe same contents, then Fortran and cudacpp produce the same LHE files including random color choice.

I will self merge as soon as the CI tests succed.

This will close #402.

@valassi
Copy link
Member Author

valassi commented Dec 18, 2022

The CI is good. Self merging and closing #402.

I have made a list in #576 of the things we still need for an alpha release IMO.

@valassi valassi merged commit 2b1424f into madgraph5:master Dec 18, 2022
roiser pushed a commit to roiser/madgraph4gpu that referenced this pull request Feb 8, 2023
roiser pushed a commit to roiser/madgraph4gpu that referenced this pull request Feb 8, 2023
BUT THIS IS SLOWER! (Probably because I am using ieppV loops now...)

FPTYPE=m make -j -f cudacpp.mk
./check.exe -p 2048 256 1 | egrep '(EvtsPerSec\[MECalcOnly|^MeanMa)'
EvtsPerSec[MECalcOnly] (3a) = ( 6.139981e+05                 )  sec^-1
MeanMatrixElemValue         = ( 2.085623e+00 +- 4.835084e-03 )  GeV^0

For comparison, in this commit with double:
FPTYPE=d make -j -f cudacpp.mk
./check.exe -p 2048 256 1 | egrep '(EvtsPerSec\[MECalcOnly|^MeanMa)'
EvtsPerSec[MECalcOnly] (3a) = ( 6.268384e+05                 )  sec^-1
MeanMatrixElemValue         = ( 2.085623e+00 +- 4.835084e-03 )  GeV^0

For comparison, in hack2 with double:
FPTYPE=d make -j -f cudacpp.mk
./check.exe -p 2048 256 1 | egrep '(EvtsPerSec\[MECalcOnly|^MeanMa)'
EvtsPerSec[MECalcOnly] (3a) = ( 6.265465e+05                 )  sec^-1
MeanMatrixElemValue         = ( 2.085623e+00 +- 4.835084e-03 )  GeV^0
roiser pushed a commit to roiser/madgraph4gpu that referenced this pull request Feb 8, 2023
… CUDA, just the color matrix for C++) madgraph5#573

FPTYPE=m make -j -f cudacpp.mk

./gcheck.exe -p 64 256 1 | egrep '(EvtsPerSec\[MECalcOnly|^MeanMa)'
EvtsPerSec[MECalcOnly] (3a) = ( 3.992718e+05                 )  sec^-1 [VARIES 3.78-3.99]
MeanMatrixElemValue         = ( 4.063123e+00 +- 2.368970e+00 )  GeV^-4

./check.exe -p 64 256 1 | egrep '(EvtsPerSec\[MECalcOnly|^MeanMa)'
EvtsPerSec[MECalcOnly] (3a) = ( 8.003095e+03                 )  sec^-1 [VARIES 8.00-8.00]
MeanMatrixElemValue         = ( 4.063123e+00 +- 2.368970e+00 )  GeV^-4

** NB: THE MEAN MATRIX ELEMENT VALUE HAS NOT MOVED AT ALL, SAME PRECISION! **
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.

Randomly pick one color for each event written to file (jamp2 handling)
1 participant