Skip to content

Commit 2f2da03

Browse files
committed
Bridge + __CADNA_ANALYSIS__ define
1 parent f2e7532 commit 2f2da03

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

madgraph/iolibs/template_files/madmatrix/Bridge.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
#include "MemoryAccessMomenta.h" // for MemoryAccessMomenta::neppM
1616
#include "MemoryBuffers.h" // for HostBufferMomenta, DeviceBufferMomenta etc
1717

18+
#ifdef __CADNA_ANALYSIS__
19+
#include <cadna.h>
20+
#include <iomanip>
21+
#endif
22+
1823
//#ifdef __HIPCC__
1924
//#include <experimental/filesystem> // see
2025
//https://rocm.docs.amd.com/en/docs-5.4.3/CHANGELOG.html#id79 #else #include
@@ -409,6 +414,34 @@ paramCard; #endif
409414
copyHostFromDevice( m_hstMEs, m_devMEs );
410415
#ifdef MGONGPUCPP_VERBOSE
411416
flagAbnormalMEs( m_hstMEs.data(), m_nevt );
417+
#ifdef __CADNA_ANALYSIS__
418+
for(unsigned int ievt = 0 ; ievt< m_nevt; ievt++)
419+
{
420+
// Display momenta
421+
std::cout << "Momenta:" << std::endl;
422+
for( int ipar = 0; ipar < CPPProcess::npar; ipar++ )
423+
{
424+
// NB: 'setw' affects only the next field (of any type)
425+
std::cout << std::scientific // fixed format: affects all floats (default precision: 6)
426+
<< std::setw( 4 ) << ipar + 1
427+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 0, ipar )
428+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 1, ipar )
429+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 2, ipar )
430+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 3, ipar )
431+
<< std::endl
432+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 0, ipar ).nb_significant_digit()
433+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 1, ipar ).nb_significant_digit()
434+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 2, ipar ).nb_significant_digit()
435+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 3, ipar ).nb_significant_digit()
436+
<< std::endl
437+
<< std::defaultfloat; // default format: affects all floats
438+
}
439+
std::cout << std::string( 79, '-' ) << std::endl;
440+
std::cout << " Matrix element = " << m_hstMEs.data()[ievt] << " GeV^" << std::endl;
441+
std::cout << " Matrix element number of sig dig = " << m_hstMEs.data()[ievt].nb_significant_digit() << std::endl;
442+
std::cout << std::string( 79, '-' ) << std::endl;
443+
}
444+
#endif
412445
#endif
413446
copyHostFromDevice( m_hstSelHel, m_devSelHel );
414447
copyHostFromDevice( m_hstSelCol, m_devSelCol );
@@ -471,6 +504,34 @@ paramCard; #endif
471504
m_pmek->computeMatrixElements( useChannelIds );
472505
#ifdef MGONGPUCPP_VERBOSE
473506
flagAbnormalMEs( m_hstMEs.data(), m_nevt );
507+
#ifdef __CADNA_ANALYSIS__
508+
for(unsigned int ievt = 0 ; ievt< m_nevt; ievt++)
509+
{
510+
// Display momenta
511+
std::cout << "Momenta:" << std::endl;
512+
for( int ipar = 0; ipar < CPPProcess::npar; ipar++ )
513+
{
514+
// NB: 'setw' affects only the next field (of any type)
515+
std::cout << std::scientific // fixed format: affects all floats (default precision: 6)
516+
<< std::setw( 4 ) << ipar + 1
517+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 0, ipar )
518+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 1, ipar )
519+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 2, ipar )
520+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 3, ipar )
521+
<< std::endl
522+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 0, ipar ).nb_significant_digit()
523+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 1, ipar ).nb_significant_digit()
524+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 2, ipar ).nb_significant_digit()
525+
<< std::setw( 14 ) << MemoryAccessMomenta::ieventAccessIp4IparConst( m_hstMomentaC.data(), ievt, 3, ipar ).nb_significant_digit()
526+
<< std::endl
527+
<< std::defaultfloat; // default format: affects all floats
528+
}
529+
std::cout << std::string( 79, '-' ) << std::endl;
530+
std::cout << " Matrix element = " << m_hstMEs.data()[ievt] << " GeV^" << std::endl;
531+
std::cout << " Matrix element number of sig dig = " << m_hstMEs.data()[ievt].nb_significant_digit() << std::endl;
532+
std::cout << std::string( 79, '-' ) << std::endl;
533+
}
534+
#endif
474535
#endif
475536
if constexpr( std::is_same_v<FORTRANFPTYPE, fptype> )
476537
{

madgraph/iolibs/template_files/madmatrix/mgOnGpuCxtypes.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ namespace mg5amcCpu
235235
return cxsmpl<FP>( a, 0 ) * b;
236236
}
237237

238+
#ifndef __CADNA_ANALYSIS__
238239
inline __host__ __device__ constexpr cxsmpl<float>
239240
operator*( const double& a, const cxsmpl<float>& b )
240241
{
@@ -246,6 +247,7 @@ namespace mg5amcCpu
246247
{
247248
return a * cxsmpl<float>( b, 0 );
248249
}
250+
#endif
249251

250252
template<typename FP>
251253
inline __host__ __device__ constexpr cxsmpl<FP>
@@ -291,6 +293,7 @@ namespace mg5amcCpu
291293
return a / cxsmpl<FP>( b, 0 );
292294
}
293295

296+
#ifdef __CADNA_ANALYSIS__
294297
//CADNA operator overload
295298
template <typename T>
296299
constexpr bool is_special_fp_v =
@@ -370,7 +373,7 @@ namespace mg5amcCpu
370373
}
371374
}
372375

373-
template < typename FP2,
376+
template < typename FP2,
374377
std::enable_if_t< is_special_fp_v<FP2>, int> = 0>
375378
inline constexpr auto
376379
operator*(const double& a, const cxsmpl<FP2>& b)
@@ -385,6 +388,7 @@ template < typename FP2,
385388
{
386389
return a*cxsmpl<FP2>(b,0.);
387390
}
391+
#endif
388392

389393
}
390394

0 commit comments

Comments
 (0)