Skip to content

Commit

Permalink
[namespace] in ggtt.sa, fix testmisc.cc and testxxx.cc to use differe…
Browse files Browse the repository at this point in the history
…nt 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 madgraph5#725
  • Loading branch information
valassi committed Jul 19, 2023
1 parent 1a89987 commit eee0468
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
48 changes: 33 additions & 15 deletions epochX/cudacpp/gg_tt.sa/SubProcesses/testmisc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

//--------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion epochX/cudacpp/gg_tt.sa/SubProcesses/testxxx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@

TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testxxx )
{
#ifdef __CUDACC__
using namespace mg5amcGpu;
#else
using namespace mg5amcCpu;
#endif
constexpr bool dumpEvents = false; // dump the expected output of the test?
constexpr bool testEvents = !dumpEvents; // run the test?
constexpr fptype toleranceXXXs = std::is_same<fptype, double>::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 = 16; // 12 independent tests plus 4 duplicates (need a multiple of 8 for floats or for '512z')
assert( nevt % neppM == 0 ); // nevt must be a multiple of neppM
Expand Down

0 comments on commit eee0468

Please sign in to comment.