From 09b75cd52a7e755fb92cb0f9ddd058d893403d07 Mon Sep 17 00:00:00 2001 From: Andrea Valassi Date: Wed, 19 Jul 2023 11:52:44 +0200 Subject: [PATCH] [fpe] cherry-pick the last commit from the namespace branch and fix a conflict: "[namespace] in ggtt.sa, fix testmisc.cc and testxxx.cc to use different namespaces This CONCLUDES the cleanup of namespaces in ggtt.sa: everything builds and runs ok NB: in debug mode, now runTest succeeds! As intended, this fixes the segfault in #725" --- .../cudacpp/gg_tt.sa/SubProcesses/testmisc.cc | 48 +++++++++++++------ .../cudacpp/gg_tt.sa/SubProcesses/testxxx.cc | 9 +--- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/epochX/cudacpp/gg_tt.sa/SubProcesses/testmisc.cc b/epochX/cudacpp/gg_tt.sa/SubProcesses/testmisc.cc index 88c5cb0061..e141b629c4 100644 --- a/epochX/cudacpp/gg_tt.sa/SubProcesses/testmisc.cc +++ b/epochX/cudacpp/gg_tt.sa/SubProcesses/testmisc.cc @@ -25,32 +25,50 @@ #define XTESTID( s ) TESTID( s ) +// NB: namespaces mg5amcGpu and mg5amcCpu includes types which are defined in different ways for CPU and GPU builds (see #318 and #725) +#ifdef __CUDACC__ +namespace mg5amcGpu +#else +namespace mg5amcCpu +#endif +{ + #ifdef MGONGPU_CPPSIMD /* clang-format off */ #define EXPECT_TRUE_sv( cond ) { bool_v mask( cond ); EXPECT_TRUE( maskand( mask ) ); } #else #define EXPECT_TRUE_sv( cond ) { EXPECT_TRUE( cond ); } #endif /* clang-format on */ -inline const std::string -boolTF( const bool& b ) -{ - return ( b ? "T" : "F" ); -} + inline const std::string + boolTF( const bool& b ) + { + return ( b ? "T" : "F" ); + } #ifdef MGONGPU_CPPSIMD -inline const std::string -boolTF( const bool_v& v ) -{ - std::stringstream out; - out << "{ " << ( v[0] ? "T" : "F" ); - for( int i = 1; i < neppV; i++ ) out << ", " << ( v[i] ? "T" : "F" ); - out << " }"; - return out.str(); -} + inline const std::string + boolTF( const bool_v& v ) + { + std::stringstream out; + out << "{ " << ( v[0] ? "T" : "F" ); + for( int i = 1; i < neppV; i++ ) out << ", " << ( v[i] ? "T" : "F" ); + out << " }"; + return out.str(); + } #endif +} + TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testmisc ) -{ +{ +#ifdef __CUDACC__ + using namespace mg5amcGpu; +#else + using namespace mg5amcCpu; +#endif + + //-------------------------------------------------------------------------- + EXPECT_TRUE( true ); //-------------------------------------------------------------------------- diff --git a/epochX/cudacpp/gg_tt.sa/SubProcesses/testxxx.cc b/epochX/cudacpp/gg_tt.sa/SubProcesses/testxxx.cc index 9fb3052f4c..6bcac217bf 100644 --- a/epochX/cudacpp/gg_tt.sa/SubProcesses/testxxx.cc +++ b/epochX/cudacpp/gg_tt.sa/SubProcesses/testxxx.cc @@ -53,13 +53,9 @@ namespace mg5amcCpu TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testxxx ) { #ifdef __CUDACC__ - auto FPEhandler = mg5amcGpu::FPEhandler; - std::string& FPEhandlerMessage = mg5amcGpu::FPEhandlerMessage; - int& FPEhandlerIevt = mg5amcGpu::FPEhandlerIevt; + using namespace mg5amcGpu; #else - auto FPEhandler = mg5amcCpu::FPEhandler; - std::string& FPEhandlerMessage = mg5amcCpu::FPEhandlerMessage; - int& FPEhandlerIevt = mg5amcCpu::FPEhandlerIevt; + using namespace mg5amcCpu; #endif const bool enableFPE = !getenv( "CUDACPP_RUNTIME_DISABLEFPE" ); if ( enableFPE ) @@ -72,7 +68,6 @@ TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testxxx ) constexpr fptype toleranceXXXs = std::is_same::value ? 1.E-15 : 1.E-5; // Constant parameters constexpr int neppM = MemoryAccessMomenta::neppM; // AOSOA layout - using mgOnGpu::neppV; constexpr int np4 = CPPProcess::np4; const int nevt = 32; // 12 independent tests plus 20 duplicates (need a multiple of 16 for floats '512z') assert( nevt % neppM == 0 ); // nevt must be a multiple of neppM