Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into patchMadsh-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
valassi committed Aug 14, 2023
2 parents 30df485 + edf846e commit cafcf4f
Show file tree
Hide file tree
Showing 154 changed files with 7,943 additions and 5,932 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ namespace mg5amcCpu
fptype* allDenominators, // output: multichannel denominators[nevt], running_sum_over_helicities
#endif
bool* isGoodHel ) // output: isGoodHel[ncomb] - device array (CUDA implementation)
{ /* clang-format on */
fptype allMEsLast = 0;
{ /* clang-format on */
const int ievt = blockDim.x * blockIdx.x + threadIdx.x; // index of event (thread) in grid
allMEs[ievt] = 0;
for( int ihel = 0; ihel < ncomb; ihel++ )
{
// NEW IMPLEMENTATION OF GETGOODHEL (#630): RESET THE RUNNING SUM OVER HELICITIES TO 0 BEFORE ADDING A NEW HELICITY
allMEs[ievt] = 0;
// NB: calculate_wavefunctions ADDS |M|^2 for a given ihel to the running sum of |M|^2 over helicities for the given event(s)
constexpr fptype_sv* jamp2_sv = nullptr; // no need for color selection during helicity filtering
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
Expand All @@ -265,12 +265,11 @@ namespace mg5amcCpu
#else
calculate_wavefunctions( ihel, allmomenta, allcouplings, allMEs, jamp2_sv );
#endif
if( allMEs[ievt] != allMEsLast )
if( allMEs[ievt] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast = allMEs[ievt]; // running sum up to helicity ihel for event ievt
}
}
#else
Expand All @@ -289,19 +288,11 @@ namespace mg5amcCpu
//assert( (size_t)(allMEs) %% mgOnGpu::cppAlign == 0 ); // SANITY CHECK: require SIMD-friendly alignment [COMMENT OUT TO TEST MISALIGNED ACCESS]
// Allocate arrays at build time to contain at least 16 events (or at least neppV events if neppV>16, e.g. in future VPUs)
constexpr int maxtry0 = std::max( 16, neppV ); // 16, but at least neppV (otherwise the npagV loop does not even start)
fptype allMEsLast[maxtry0] = { 0 }; // allocated at build time: maxtry0 must be a constexpr
// Loop over only nevt events if nevt is < 16 (note that nevt is always >= neppV)
assert( nevt >= neppV );
const int maxtry = std::min( maxtry0, nevt ); // 16, but at most nevt (avoid invalid memory access if nevt<maxtry0)

// PART 0 - INITIALISATION (before calculate_wavefunctions)
// Reset the "matrix elements" - running sums of |M|^2 over helicities for the given event
for( int ievt = 0; ievt < maxtry; ++ievt )
{
allMEs[ievt] = 0; // all zeros
}

// PART 1 - HELICITY LOOP: CALCULATE WAVEFUNCTIONS
// HELICITY LOOP: CALCULATE WAVEFUNCTIONS
const int npagV = maxtry / neppV;
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
// Mixed fptypes #537: float for color algebra and double elsewhere
Expand All @@ -320,6 +311,16 @@ namespace mg5amcCpu
#endif
for( int ihel = 0; ihel < ncomb; ihel++ )
{
// NEW IMPLEMENTATION OF GETGOODHEL (#630): RESET THE RUNNING SUM OVER HELICITIES TO 0 BEFORE ADDING A NEW HELICITY
for( int ieppV = 0; ieppV < neppV; ++ieppV )
{
const int ievt = ievt00 + ieppV;
allMEs[ievt] = 0;
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
const int ievt2 = ievt00 + ieppV + neppV;
allMEs[ievt2] = 0;
#endif
}
constexpr fptype_sv* jamp2_sv = nullptr; // no need for color selection during helicity filtering
//std::cout << "sigmaKin_getGoodHel ihel=" << ihel << ( isGoodHel[ihel] ? " true" : " false" ) << std::endl;
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
Expand All @@ -331,22 +332,18 @@ namespace mg5amcCpu
for( int ieppV = 0; ieppV < neppV; ++ieppV )
{
const int ievt = ievt00 + ieppV;
const bool differs = ( allMEs[ievt] != allMEsLast[ievt] );
if( differs )
if( allMEs[ievt] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast[ievt] = allMEs[ievt]; // running sum up to helicity ihel
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
const int ievt2 = ievt00 + ieppV + neppV;
const bool differs2 = ( allMEs[ievt2] != allMEsLast[ievt2] );
if( differs2 )
if( allMEs[ievt2] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast[ievt2] = allMEs[ievt2]; // running sum up to helicity ihel
#endif
}
}
Expand Down
13 changes: 11 additions & 2 deletions epochX/cudacpp/CODEGEN/generateAndCompare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ function codeGenAndDiff()
gq_ttq)
cmd="define q = u c d s u~ c~ d~ s~; generate g q > t t~ q"
;;
gu_ttu)
cmd="generate g u > t t~ u"
;;
gg_uu)
cmd="generate g g > u u~"
;;
gq_ttllq)
cmd="define q = u c d s u~ c~ d~ s~; generate g q > t t~ l- l+ q"
;;
Expand Down Expand Up @@ -66,11 +72,14 @@ function codeGenAndDiff()
generate p p > t t~ z @0
add process p p > t t~ z j @1"
;;
uu_dd)
cmd="generate u u~ > d d~"
;;
uu_tt)
cmd="generate u u~ > t t~"
;;
uu_dd)
cmd="generate u u~ > d d~"
uu_ttg)
cmd="generate u u~ > t t~ g"
;;
bb_tt)
cmd="generate b b~ > t t~"
Expand Down
14 changes: 7 additions & 7 deletions epochX/cudacpp/ee_mumu.mad/CODEGEN_mad_ee_mumu_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ generate e+ e- > mu+ mu-
No model currently active, so we import the Standard Model
INFO: load particles
INFO: load vertices
DEBUG: model prefixing takes 0.00445103645324707 
DEBUG: model prefixing takes 0.004861593246459961 
INFO: Restrict model sm with file models/sm/restrict_default.dat .
DEBUG: Simplifying conditional expressions 
DEBUG: remove interactions: u s w+ at order: QED=1 
Expand Down Expand Up @@ -176,7 +176,7 @@ INFO: Creating files in directory P1_epem_mupmum
DEBUG: Entering PLUGIN_OneProcessExporter.__init__ [model_handling.py at line 1039] 
DEBUG: kwargs[prefix] = 0 [model_handling.py at line 1040] 
DEBUG: proc_id =  1 [model_handling.py at line 1045] 
DEBUG: process_exporter_cpp =  <PLUGIN.CUDACPP_SA_OUTPUT.model_handling.PLUGIN_OneProcessExporter object at 0x7f7976656ca0> [export_v4.py at line 6179] 
DEBUG: process_exporter_cpp =  <PLUGIN.CUDACPP_SA_OUTPUT.model_handling.PLUGIN_OneProcessExporter object at 0x7f7e993895e0> [export_v4.py at line 6179] 
INFO: Creating files in directory .
DEBUG: Entering PLUGIN_OneProcessExporter.generate_process_files [model_handling.py at line 1297] 
DEBUG: self.include_multi_channel is already defined: this is madevent+second_exporter mode [model_handling.py at line 1299] 
Expand Down Expand Up @@ -210,7 +210,7 @@ INFO: Created files CPPProcess.h and CPPProcess.cc in directory ./.
INFO: Generating Feynman diagrams for Process: e+ e- > mu+ mu- WEIGHTED<=4 @1
INFO: Finding symmetric diagrams for subprocess group epem_mupmum
Generated helas calls for 1 subprocesses (2 diagrams) in 0.004 s
Wrote files for 8 helas calls in 0.094 s
Wrote files for 8 helas calls in 0.092 s
ALOHA: aloha starts to compute helicity amplitudes
ALOHA: aloha creates FFV1 routines
ALOHA: aloha creates FFV2 routines
Expand All @@ -222,7 +222,7 @@ ALOHA: aloha creates FFV1 routines
ALOHA: aloha creates FFV2 routines
ALOHA: aloha creates FFV4 routines
ALOHA: aloha creates FFV2_4 routines
ALOHA: aloha creates 7 routines in 0.215 s
ALOHA: aloha creates 7 routines in 0.216 s
<class 'aloha.create_aloha.AbstractRoutine'> FFV1
<class 'aloha.create_aloha.AbstractRoutine'> FFV1
<class 'aloha.create_aloha.AbstractRoutine'> FFV2
Expand Down Expand Up @@ -254,6 +254,6 @@ Type "launch" to generate events from this process, or see
Run "open index.html" to see more information about this process.
quit

real 0m1.729s
user 0m1.513s
sys 0m0.202s
real 0m1.771s
user 0m1.516s
sys 0m0.203s
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,12 @@ namespace mg5amcCpu
fptype* allDenominators, // output: multichannel denominators[nevt], running_sum_over_helicities
#endif
bool* isGoodHel ) // output: isGoodHel[ncomb] - device array (CUDA implementation)
{ /* clang-format on */
fptype allMEsLast = 0;
{ /* clang-format on */
const int ievt = blockDim.x * blockIdx.x + threadIdx.x; // index of event (thread) in grid
allMEs[ievt] = 0;
for( int ihel = 0; ihel < ncomb; ihel++ )
{
// NEW IMPLEMENTATION OF GETGOODHEL (#630): RESET THE RUNNING SUM OVER HELICITIES TO 0 BEFORE ADDING A NEW HELICITY
allMEs[ievt] = 0;
// NB: calculate_wavefunctions ADDS |M|^2 for a given ihel to the running sum of |M|^2 over helicities for the given event(s)
constexpr fptype_sv* jamp2_sv = nullptr; // no need for color selection during helicity filtering
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
Expand All @@ -651,12 +651,11 @@ namespace mg5amcCpu
#else
calculate_wavefunctions( ihel, allmomenta, allcouplings, allMEs, jamp2_sv );
#endif
if( allMEs[ievt] != allMEsLast )
if( allMEs[ievt] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast = allMEs[ievt]; // running sum up to helicity ihel for event ievt
}
}
#else
Expand All @@ -675,19 +674,11 @@ namespace mg5amcCpu
//assert( (size_t)(allMEs) % mgOnGpu::cppAlign == 0 ); // SANITY CHECK: require SIMD-friendly alignment [COMMENT OUT TO TEST MISALIGNED ACCESS]
// Allocate arrays at build time to contain at least 16 events (or at least neppV events if neppV>16, e.g. in future VPUs)
constexpr int maxtry0 = std::max( 16, neppV ); // 16, but at least neppV (otherwise the npagV loop does not even start)
fptype allMEsLast[maxtry0] = { 0 }; // allocated at build time: maxtry0 must be a constexpr
// Loop over only nevt events if nevt is < 16 (note that nevt is always >= neppV)
assert( nevt >= neppV );
const int maxtry = std::min( maxtry0, nevt ); // 16, but at most nevt (avoid invalid memory access if nevt<maxtry0)

// PART 0 - INITIALISATION (before calculate_wavefunctions)
// Reset the "matrix elements" - running sums of |M|^2 over helicities for the given event
for( int ievt = 0; ievt < maxtry; ++ievt )
{
allMEs[ievt] = 0; // all zeros
}

// PART 1 - HELICITY LOOP: CALCULATE WAVEFUNCTIONS
// HELICITY LOOP: CALCULATE WAVEFUNCTIONS
const int npagV = maxtry / neppV;
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
// Mixed fptypes #537: float for color algebra and double elsewhere
Expand All @@ -706,6 +697,16 @@ namespace mg5amcCpu
#endif
for( int ihel = 0; ihel < ncomb; ihel++ )
{
// NEW IMPLEMENTATION OF GETGOODHEL (#630): RESET THE RUNNING SUM OVER HELICITIES TO 0 BEFORE ADDING A NEW HELICITY
for( int ieppV = 0; ieppV < neppV; ++ieppV )
{
const int ievt = ievt00 + ieppV;
allMEs[ievt] = 0;
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
const int ievt2 = ievt00 + ieppV + neppV;
allMEs[ievt2] = 0;
#endif
}
constexpr fptype_sv* jamp2_sv = nullptr; // no need for color selection during helicity filtering
//std::cout << "sigmaKin_getGoodHel ihel=" << ihel << ( isGoodHel[ihel] ? " true" : " false" ) << std::endl;
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
Expand All @@ -717,22 +718,18 @@ namespace mg5amcCpu
for( int ieppV = 0; ieppV < neppV; ++ieppV )
{
const int ievt = ievt00 + ieppV;
const bool differs = ( allMEs[ievt] != allMEsLast[ievt] );
if( differs )
if( allMEs[ievt] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast[ievt] = allMEs[ievt]; // running sum up to helicity ihel
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
const int ievt2 = ievt00 + ieppV + neppV;
const bool differs2 = ( allMEs[ievt2] != allMEsLast[ievt2] );
if( differs2 )
if( allMEs[ievt2] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast[ievt2] = allMEs[ievt2]; // running sum up to helicity ihel
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions epochX/cudacpp/ee_mumu.sa/CODEGEN_cudacpp_ee_mumu_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ generate e+ e- > mu+ mu-
No model currently active, so we import the Standard Model
INFO: load particles
INFO: load vertices
DEBUG: model prefixing takes 0.004779815673828125 
DEBUG: model prefixing takes 0.004894733428955078 
INFO: Restrict model sm with file models/sm/restrict_default.dat .
DEBUG: Simplifying conditional expressions 
DEBUG: remove interactions: u s w+ at order: QED=1 
Expand Down Expand Up @@ -225,6 +225,6 @@ INFO: /data/avalassi/GPU2023/MG5aMC/ghav-mg5amcnlo/CODEGEN_cudacpp_ee_mumu/src/.
DEBUG: Entering PLUGIN_ProcessExporter.finalize [output.py at line 203] 
quit

real 0m0.644s
user 0m0.577s
sys 0m0.049s
real 0m0.637s
user 0m0.575s
sys 0m0.055s
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,12 @@ namespace mg5amcCpu
fptype* allDenominators, // output: multichannel denominators[nevt], running_sum_over_helicities
#endif
bool* isGoodHel ) // output: isGoodHel[ncomb] - device array (CUDA implementation)
{ /* clang-format on */
fptype allMEsLast = 0;
{ /* clang-format on */
const int ievt = blockDim.x * blockIdx.x + threadIdx.x; // index of event (thread) in grid
allMEs[ievt] = 0;
for( int ihel = 0; ihel < ncomb; ihel++ )
{
// NEW IMPLEMENTATION OF GETGOODHEL (#630): RESET THE RUNNING SUM OVER HELICITIES TO 0 BEFORE ADDING A NEW HELICITY
allMEs[ievt] = 0;
// NB: calculate_wavefunctions ADDS |M|^2 for a given ihel to the running sum of |M|^2 over helicities for the given event(s)
constexpr fptype_sv* jamp2_sv = nullptr; // no need for color selection during helicity filtering
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
Expand All @@ -649,12 +649,11 @@ namespace mg5amcCpu
#else
calculate_wavefunctions( ihel, allmomenta, allcouplings, allMEs, jamp2_sv );
#endif
if( allMEs[ievt] != allMEsLast )
if( allMEs[ievt] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast = allMEs[ievt]; // running sum up to helicity ihel for event ievt
}
}
#else
Expand All @@ -673,19 +672,11 @@ namespace mg5amcCpu
//assert( (size_t)(allMEs) % mgOnGpu::cppAlign == 0 ); // SANITY CHECK: require SIMD-friendly alignment [COMMENT OUT TO TEST MISALIGNED ACCESS]
// Allocate arrays at build time to contain at least 16 events (or at least neppV events if neppV>16, e.g. in future VPUs)
constexpr int maxtry0 = std::max( 16, neppV ); // 16, but at least neppV (otherwise the npagV loop does not even start)
fptype allMEsLast[maxtry0] = { 0 }; // allocated at build time: maxtry0 must be a constexpr
// Loop over only nevt events if nevt is < 16 (note that nevt is always >= neppV)
assert( nevt >= neppV );
const int maxtry = std::min( maxtry0, nevt ); // 16, but at most nevt (avoid invalid memory access if nevt<maxtry0)

// PART 0 - INITIALISATION (before calculate_wavefunctions)
// Reset the "matrix elements" - running sums of |M|^2 over helicities for the given event
for( int ievt = 0; ievt < maxtry; ++ievt )
{
allMEs[ievt] = 0; // all zeros
}

// PART 1 - HELICITY LOOP: CALCULATE WAVEFUNCTIONS
// HELICITY LOOP: CALCULATE WAVEFUNCTIONS
const int npagV = maxtry / neppV;
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
// Mixed fptypes #537: float for color algebra and double elsewhere
Expand All @@ -704,6 +695,16 @@ namespace mg5amcCpu
#endif
for( int ihel = 0; ihel < ncomb; ihel++ )
{
// NEW IMPLEMENTATION OF GETGOODHEL (#630): RESET THE RUNNING SUM OVER HELICITIES TO 0 BEFORE ADDING A NEW HELICITY
for( int ieppV = 0; ieppV < neppV; ++ieppV )
{
const int ievt = ievt00 + ieppV;
allMEs[ievt] = 0;
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
const int ievt2 = ievt00 + ieppV + neppV;
allMEs[ievt2] = 0;
#endif
}
constexpr fptype_sv* jamp2_sv = nullptr; // no need for color selection during helicity filtering
//std::cout << "sigmaKin_getGoodHel ihel=" << ihel << ( isGoodHel[ihel] ? " true" : " false" ) << std::endl;
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
Expand All @@ -715,22 +716,18 @@ namespace mg5amcCpu
for( int ieppV = 0; ieppV < neppV; ++ieppV )
{
const int ievt = ievt00 + ieppV;
const bool differs = ( allMEs[ievt] != allMEsLast[ievt] );
if( differs )
if( allMEs[ievt] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast[ievt] = allMEs[ievt]; // running sum up to helicity ihel
#if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT
const int ievt2 = ievt00 + ieppV + neppV;
const bool differs2 = ( allMEs[ievt2] != allMEsLast[ievt2] );
if( differs2 )
if( allMEs[ievt2] != 0 ) // NEW IMPLEMENTATION OF GETGOODHEL (#630): COMPARE EACH HELICITY CONTRIBUTION TO 0
{
//if ( !isGoodHel[ihel] ) std::cout << "sigmaKin_getGoodHel ihel=" << ihel << " TRUE" << std::endl;
isGoodHel[ihel] = true;
}
allMEsLast[ievt2] = allMEs[ievt2]; // running sum up to helicity ihel
#endif
}
}
Expand Down
Loading

0 comments on commit cafcf4f

Please sign in to comment.