Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c211268
[klas5X] remove old code from pIparIp4Ipag
valassi Nov 30, 2021
0b2a6ac
[klas5X] bug fix in operator<< for vector types (replace std::cout by…
valassi Nov 30, 2021
50c387e
[klas5X] do not filter out WARNING in throughputX.sh
valassi Nov 30, 2021
98008b4
[klas5X] COMPLETE the port of the latest klas5 in epoch1/eemumu to kl…
valassi Nov 30, 2021
7a879bd
[klas5X] performance with the last commit - removed neppV from API
valassi Dec 1, 2021
a2f3388
[klas5X] try to improve performance in allMEs init to 0 - no change, …
valassi Dec 1, 2021
eb6e630
Revert "[klas5X] try to improve performance in allMEs init to 0 - no …
valassi Dec 1, 2021
a26e057
[klas5X] try to improve performance in allMEs "/= denominators" - ver…
valassi Dec 1, 2021
2ccae6e
Revert "[klas5X] try to improve performance in allMEs "/= denominator…
valassi Dec 1, 2021
c2f3d3c
[klas5X] backport to CODEGEN the latest klas5X changes from eemumu ma…
valassi Dec 1, 2021
e2dfcb1
[klas5X] regenerate eemumu.auto - now identical to eemumu manual
valassi Dec 1, 2021
25daaad
[klas5X] rerun all perf tests for eemumu, including float and inline …
valassi Dec 1, 2021
2392f5e
[klas5X] add copyLogs script
valassi Dec 1, 2021
41dd9b7
[klas5X] copy eemumu logs manu to auto (./copyLogs.sh -eemumu -m2a)
valassi Dec 1, 2021
32bf23b
[klas5X] regenerate ggtt auto and run all tests - all ok, essentially…
valassi Dec 1, 2021
b41e672
[klas5X] in eemumu manu use "mkdir -p" to avoid errors if dir exists …
valassi Dec 1, 2021
6275826
[klas5X] in CODEGEN use "mkdir -p" to avoid errors if dir exists and …
valassi Dec 1, 2021
52efa81
[klas5X] regenerate eemumu and ggtt auto with "mkdir -p" to allow par…
valassi Dec 1, 2021
573ace2
[klas5X] use parallel 'make -j' in throughputX script
valassi Dec 1, 2021
38fee9b
[klas5X] regenerate ggttgg auto and run all tests - all ok, essential…
valassi Dec 1, 2021
65f7b2d
[klas5X] rerun all ggttgg auto tests, all ok - essentially the same p…
valassi Dec 1, 2021
f16ca21
[klas5X] copy ggttgg auto code to manual
valassi Dec 1, 2021
0de4418
[klas5X] in ggttgg manu, split the avxall target into five separate t…
valassi Dec 1, 2021
e67db4d
[klas5X] in codegen, split avxall into five targets for parallel buil…
valassi Dec 1, 2021
5bdcd36
[klas5X] (ALMOST COMPLETE KLAS5X) simplify -avxall in throughputX scr…
valassi Dec 1, 2021
cb7aa60
[klas5X] port to epochX/klas5X the latest few changes in epoch1/klas5…
valassi Dec 1, 2021
a1e781a
[klas5X] enable make -j only if an explicit -makej is given in the te…
valassi Dec 1, 2021
b2abb48
[klas5X] rerun eemumu manual tests - a bit slower after adding one sa…
valassi Dec 1, 2021
34e1a95
[klas5X] backport latest eemumu manu changes t codegen, regenerate ee…
valassi Dec 1, 2021
f4d56a1
[klas5X] copy logs ./tput/copyLogs.sh -m2a -eemumu
valassi Dec 1, 2021
1e4e64e
[klas5X] regenerate ggtt and ggttgg auto, resync to ggttgg manual
valassi Dec 1, 2021
ceb7123
[klas5X] rerun ggtt auto tests - performance seems exactly the same w…
valassi Dec 1, 2021
9d335ef
[klas5X] rerun ggttgg auto tests - performance seems exactly the same…
valassi Dec 1, 2021
a4733d4
[klas5X] *** COMPLETE KLAS5X *** copy logs ./tput/copyLogs.sh -a2m -g…
valassi Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//--------------------------------------------------------------------------

#ifdef __CUDACC__
// Return by reference
// Decode momentum AOSOA: compute address of fptype for the given particle, 4-momentum component and event
// Return the fptype by reference (equivalent to returning its memory address)
__device__ inline
const fptype& pIparIp4Ievt( const fptype* momenta, // input: momenta as AOSOA[npagM][npar][4][neppM]
const int ipar,
Expand All @@ -10,46 +10,157 @@
{
using mgOnGpu::np4;
using mgOnGpu::npar;
const int neppM = mgOnGpu::neppM; // AOSOA layout: constant at compile-time
const int ipagM = ievt/neppM; // #eventpage in this iteration
const int ieppM = ievt%neppM; // #event in the current eventpage in this iteration
//printf( "%f\n", momenta[ipagM*npar*np4*neppM + ipar*np4*neppM + ip4*neppM + ieppM] );
constexpr int neppM = mgOnGpu::neppM; // AOSOA layout: constant at compile-time
const int ipagM = ievt/neppM; // #event "M-page"
const int ieppM = ievt%neppM; // #event in the current event M-page
//printf( "%2d %2d %8d %8.3f\n", ipar, ip4, ievt, momenta[ipagM*npar*np4*neppM + ipar*np4*neppM + ip4*neppM + ieppM] );
return momenta[ipagM*npar*np4*neppM + ipar*np4*neppM + ip4*neppM + ieppM]; // AOSOA[ipagM][ipar][ip4][ieppM]
//fptype (*momenta)[npar][np4][neppM] = (fptype (*)[npar][np4][neppM]) momenta; // cast to multiD array pointer (AOSOA)
//return momenta[ipagM][ipar][ip4][ieppM]; // this seems ~1-2% faster in eemumu C++?
}
#else
// Return by value: it seems a tiny bit faster than returning a reference (both for scalar and vector), not clear why

#ifndef __CUDACC__
// Return a SIMD vector of fptype's for neppV events (for the given particle, 4-momentum component and event "V-page")
// Return the vector by value: strictly speaking, this is only unavoidable for neppM<neppV
// For neppM>=neppV (both being powers of 2), the momentum neppM-AOSOA is reinterpreted in terms of neppV-vectors:
// it could also be returned by reference, but no performance degradation is observed when returning by value
inline
fptype_sv pIparIp4Ipag( const fptype_sv* momenta, // input: momenta as AOSOA[npagM][npar][4][neppM]
fptype_sv pIparIp4Ipag( const fptype* momenta, // input: momenta as AOSOA[npagM][npar][4][neppM]
const int ipar,
const int ip4,
const int ipagM )
const int ipagV )
{
/*
//#ifndef MGONGPU_CPPSIMD
// TEMPORARY during epochX step3! Eventually remove this section (start)
// TEMPORARY during epochX step3! THERE IS NO SIMD YET: HENCE ipagM=ievt
// NB: this is needed for neppM>1 while neppV==1 (no SIMD) in eemumu.auto
// NB: this remains valid for neppM==1 with neppV==1 in eemumu (scalar)
return pIparIp4Ievt( momenta, ipar, ip4, ipagM );
// TEMPORARY during epochX step3! Eventually remove this section (end)
//#else
*/
// NB: this assumes that neppV == neppM!
// NB: this is the same as "pIparIp4Ievt( momenta, ipar, ip4, ipagM )" for neppM==1 with neppV==1
using mgOnGpu::np4;
using mgOnGpu::npar;
//printf( "%f\n", momenta[ipagM*npar*np4 + ipar*np4 + ip4] );
return momenta[ipagM*npar*np4 + ipar*np4 + ip4]; // AOSOA[ipagM][ipar][ip4][ieppM]
const int ievt0 = ipagV*neppV; // virtual event V-page ipagV contains neppV events [ievt0...ievt0+neppV-1]
#ifdef MGONGPU_CPPSIMD
constexpr int neppM = mgOnGpu::neppM; // AOSOA layout: constant at compile-time
// Use c++17 "if constexpr": compile-time branching
if constexpr ( ( neppM >= neppV ) && ( neppM%neppV == 0 ) )
{
constexpr bool useReinterpretCastIfPossible = true; // DEFAULT
//constexpr bool useReinterpretCastIfPossible = false; // FOR PERFORMANCE TESTS
constexpr bool skipAlignmentCheck = true; // DEFAULT (MAY SEGFAULT, NEEDS A SANITY CHECK ELSEWHERE!)
//constexpr bool skipAlignmentCheck = false; // SLOWER BUT SAFER
if constexpr ( useReinterpretCastIfPossible && skipAlignmentCheck )
{
//static bool first=true; if( first ){ std::cout << "WARNING! skip alignment check" << std::endl; first=false; } // SLOWS DOWN...
// Fastest (4.92E6 in eemumu 512y)
// This requires alignment for momenta - segmentation fault otherwise!
return *reinterpret_cast<const fptype_sv*>( &( pIparIp4Ievt( momenta, ipar, ip4, ievt0 ) ) );
}
else if ( useReinterpretCastIfPossible && ( (size_t)(momenta) % mgOnGpu::cppAlign == 0 ) )
{
//static bool first=true; if( first ){ std::cout << "WARNING! alignment ok, use reinterpret cast" << std::endl; first=false; } // SLOWS DOWN...
// A bit (6%) slower (4.62E6 in eemumu 512y) because of the alignment check
// This explicitly checks alignment for momenta to avoid segmentation faults
return *reinterpret_cast<const fptype_sv*>( &( pIparIp4Ievt( momenta, ipar, ip4, ievt0 ) ) );
}
else
{
//static bool first=true; if( first ){ std::cout << "WARNING! AOSOA but no reinterpret cast" << std::endl; first=false; } // SLOWS DOWN...
// A bit (2%) slower (4.86E6 in eemumu 512y)
// This does not require alignment for momenta, but it requires AOSOA with neppM>=neppV and neppM%neppV==0
const fptype* out0 = &( pIparIp4Ievt( momenta, ipar, ip4, ievt0) );
#if MGONGPU_CPPSIMD == 2
return fptype_v{ *( out0 ),
*( out0+1 ) };
#elif MGONGPU_CPPSIMD == 4
return fptype_v{ *( out0 ),
*( out0+1 ),
*( out0+2 ),
*( out0+3 ) };
#elif MGONGPU_CPPSIMD == 8
return fptype_v{ *( out0 ),
*( out0+1 ),
*( out0+2 ),
*( out0+3 ),
*( out0+4 ),
*( out0+5 ),
*( out0+6 ),
*( out0+7 ) };
#elif MGONGPU_CPPSIMD == 16
return fptype_v{ *( out0 ),
*( out0+1 ),
*( out0+2 ),
*( out0+3 ),
*( out0+4 ),
*( out0+5 ),
*( out0+6 ),
*( out0+7 ),
*( out0+8 ),
*( out0+9 ),
*( out0+10 ),
*( out0+11 ),
*( out0+12 ),
*( out0+13 ),
*( out0+14 ),
*( out0+15 ) };
#else
#warning Internal error? This code should never be reached!
// A bit (2%) slower (4.86E6 in eemumu 512y)
// This does not require alignment for momenta, but it requires AOSOA with neppM>=neppV and neppM%neppV==0
fptype_v out;
for ( int ieppV=0; ieppV<neppV; ieppV++ ) out[ieppV] = *( out0 + ieppV );
return out;
#endif
}
}
else
{
// Much (20%) slower (4.07E6 in eemumu 512y)
// This does not even require AOSOA with neppM>=neppV and neppM%neppV==0 (e.g. can be used with AOS neppM==1)
#if MGONGPU_CPPSIMD == 2
return fptype_v{ pIparIp4Ievt( momenta, ipar, ip4, ievt0 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+1 ) };
#elif MGONGPU_CPPSIMD == 4
return fptype_v{ pIparIp4Ievt( momenta, ipar, ip4, ievt0 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+1 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+2 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+3 ) };
#elif MGONGPU_CPPSIMD == 8
return fptype_v{ pIparIp4Ievt( momenta, ipar, ip4, ievt0 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+1 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+2 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+3 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+4 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+5 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+6 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+7 ) };
#elif MGONGPU_CPPSIMD == 16
return fptype_v{ pIparIp4Ievt( momenta, ipar, ip4, ievt0 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+1 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+2 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+3 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+4 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+5 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+6 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+7 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+8 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+9 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+10 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+11 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+12 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+13 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+14 ),
pIparIp4Ievt( momenta, ipar, ip4, ievt0+15 ) };
#else
#warning Internal error? This code should never be reached!
// Much much (40%) slower (3.02E6 in eemumu 512y)
fptype_v out;
for ( int ieppV=0; ieppV<neppV; ieppV++ ) out[ieppV] = pIparIp4Ievt( momenta, ipar, ip4, ievt0+ieppV );
return out;
#endif
}
#else
return pIparIp4Ievt( momenta, ipar, ip4, ievt0 );
#endif
}
#endif

//--------------------------------------------------------------------------

// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
__device__
void ixxxxx( const fptype_sv* momenta,
void ixxxxx( const fptype* momenta,
const fptype fmass, // input: fermion mass
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -185,7 +296,7 @@
// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == +PZ > 0)
__device__
void ipzxxx( const fptype_sv* momenta,
void ipzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -234,7 +345,7 @@
// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == -PZ > 0)
__device__
void imzxxx( const fptype_sv* momenta,
void imzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -283,7 +394,7 @@
// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PT > 0)
__device__
void ixzxxx( const fptype_sv* momenta,
void ixzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -344,7 +455,7 @@

// Compute the output wavefunction vc[6] from the input momenta[npar*4*nevt]
__device__
void vxxxxx( const fptype_sv* momenta,
void vxxxxx( const fptype* momenta,
const fptype vmass, // input: vector boson mass
const int nhel, // input: -1, 0 (only if vmass!=0) or +1 (helicity of vector boson)
const int nsv, // input: +1 (final) or -1 (initial)
Expand Down Expand Up @@ -480,7 +591,7 @@

// Compute the output wavefunction sc[3] from the input momenta[npar*4*nevt]
__device__
void sxxxxx( const fptype_sv* momenta,
void sxxxxx( const fptype* momenta,
const fptype, // WARNING: input "smass" unused (missing in Fortran) - scalar boson mass
const int, // WARNING: input "nhel" unused (missing in Fortran) - scalar has no helicity!
const int nss, // input: +1 (final) or -1 (initial)
Expand Down Expand Up @@ -521,7 +632,7 @@

// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
__device__
void oxxxxx( const fptype_sv* momenta,
void oxxxxx( const fptype* momenta,
const fptype fmass, // input: fermion mass
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -658,7 +769,7 @@
// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == +PZ > 0)
__device__
void opzxxx( const fptype_sv* momenta,
void opzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -707,7 +818,7 @@
// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == -PZ > 0)
__device__
void omzxxx( const fptype_sv* momenta,
void omzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down Expand Up @@ -759,7 +870,7 @@
// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PT > 0)
__device__
void oxzxxx( const fptype_sv* momenta,
void oxzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
__device__ INLINE
void ixxxxx( const fptype_sv* momenta,
void ixxxxx( const fptype* momenta,
const fptype fmass, // input: fermion mass
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -26,7 +26,7 @@
// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == +PZ > 0)
__device__ INLINE
void ipzxxx( const fptype_sv* momenta,
void ipzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -41,7 +41,7 @@
// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == -PZ > 0)
__device__ INLINE
void imzxxx( const fptype_sv* momenta,
void imzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -56,7 +56,7 @@
// Compute the output wavefunction fi[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PT > 0)
__device__ INLINE
void ixzxxx( const fptype_sv* momenta,
void ixzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -70,7 +70,7 @@

// Compute the output wavefunction vc[6] from the input momenta[npar*4*nevt]
__device__ INLINE
void vxxxxx( const fptype_sv* momenta,
void vxxxxx( const fptype* momenta,
const fptype vmass, // input: vector boson mass
const int nhel, // input: -1, 0 (only if vmass!=0) or +1 (helicity of vector boson)
const int nsv, // input: +1 (final) or -1 (initial)
Expand All @@ -84,7 +84,7 @@

// Compute the output wavefunction sc[3] from the input momenta[npar*4*nevt]
__device__ INLINE
void sxxxxx( const fptype_sv* momenta,
void sxxxxx( const fptype* momenta,
const fptype, // WARNING: input "smass" unused (missing in Fortran) - scalar boson mass
const int, // WARNING: input "nhel" unused (missing in Fortran) - scalar has no helicity!
const int nss, // input: +1 (final) or -1 (initial)
Expand All @@ -98,7 +98,7 @@

// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
__device__ INLINE
void oxxxxx( const fptype_sv* momenta,
void oxxxxx( const fptype* momenta,
const fptype fmass, // input: fermion mass
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -113,7 +113,7 @@
// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == +PZ > 0)
__device__ INLINE
void opzxxx( const fptype_sv* momenta,
void opzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -128,7 +128,7 @@
// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
// ASSUMPTIONS: (FMASS == 0) and (PX == PY == 0 and E == -PZ > 0)
__device__ INLINE
void omzxxx( const fptype_sv* momenta,
void omzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand All @@ -142,7 +142,7 @@

// Compute the output wavefunction fo[6] from the input momenta[npar*4*nevt]
__device__ INLINE
void oxzxxx( const fptype_sv* momenta,
void oxzxxx( const fptype* momenta,
//const fptype fmass, // ASSUME fermion mass==0
const int nhel, // input: -1 or +1 (helicity of fermion)
const int nsf, // input: +1 (particle) or -1 (antiparticle)
Expand Down
Loading