Skip to content

Commit

Permalink
[gtest/june24] regenerate all processes, with fixes for constexpr_mat…
Browse files Browse the repository at this point in the history
…h.h madgraph5#905 and test_misc.cc/valgrind.h madgraph5#906

Add valgrind.h for all processes

for d in $(git ls-tree --name-only HEAD */SubProcesses); do git add $d/valgrind.h $d/*/valgrind.h; done
  • Loading branch information
valassi committed Jul 12, 2024
1 parent 8c3e32e commit 1b69f9d
Show file tree
Hide file tree
Showing 148 changed files with 155,185 additions and 1,012 deletions.
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.0053675174713134766 
DEBUG: model prefixing takes 0.005549430847167969 
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 @@ -177,7 +177,7 @@ INFO: Generating Helas calls for process: e+ e- > mu+ mu- WEIGHTED<=4 @1
INFO: Processing color information for process: e+ e- > mu+ mu- @1
INFO: Creating files in directory P1_epem_mupmum
DEBUG: kwargs[prefix] = 0 [model_handling.py at line 1151] 
DEBUG: process_exporter_cpp =  <PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_OneProcessExporter object at 0x7f6d5db19760> [export_v4.py at line 6261] 
DEBUG: process_exporter_cpp =  <PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_OneProcessExporter object at 0x7f95bd7c0790> [export_v4.py at line 6261] 
INFO: Creating files in directory .
FileWriter <class 'PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_CPPWriter'> for ././CPPProcess.h
FileWriter <class 'PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_CPPWriter'> for ././CPPProcess.cc
Expand All @@ -203,14 +203,14 @@ ALOHA: aloha starts to compute helicity amplitudes
ALOHA: aloha creates FFV1 routines
ALOHA: aloha creates FFV2 routines
ALOHA: aloha creates FFV4 routines
ALOHA: aloha creates 3 routines in 0.198 s
ALOHA: aloha creates 3 routines in 0.200 s
DEBUG: Entering PLUGIN_ProcessExporter.convert_model (create the model) [output.py at line 205] 
ALOHA: aloha starts to compute helicity amplitudes
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.262 s
ALOHA: aloha creates 7 routines in 0.255 s
<class 'aloha.create_aloha.AbstractRoutine'> FFV1
<class 'aloha.create_aloha.AbstractRoutine'> FFV1
<class 'aloha.create_aloha.AbstractRoutine'> FFV2
Expand Down Expand Up @@ -255,9 +255,9 @@ Type "launch" to generate events from this process, or see
Run "open index.html" to see more information about this process.
quit

real 0m2.114s
user 0m1.793s
sys 0m0.254s
real 0m2.174s
user 0m1.833s
sys 0m0.256s
Code generation completed in 2 seconds
************************************************************
* *
Expand Down
18 changes: 17 additions & 1 deletion epochX/cudacpp/ee_mumu.mad/SubProcesses/cudacpp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,21 @@ endif

# Target (and build options): debug
MAKEDEBUG=
debug: OPTFLAGS = -g -O0
debug: OPTFLAGS = -g -O0
debug: CUDA_OPTFLAGS = -G
debug: MAKEDEBUG := debug
debug: all.$(TAG)

# Target (and build options): address sanitizer #207
###CXXLIBFLAGSASAN =
###GPULIBFLAGSASAN =
###asan: OPTFLAGS = -g -O0 -fsanitize=address -fno-omit-frame-pointer
###asan: CUDA_OPTFLAGS = -G $(XCOMPILERFLAG) -fsanitize=address $(XCOMPILERFLAG) -fno-omit-frame-pointer
###asan: CXXLIBFLAGSASAN = -fsanitize=address
###asan: GPULIBFLAGSASAN = -Xlinker -fsanitize=address -Xlinker -shared
###asan: MAKEDEBUG := debug
###asan: all.$(TAG)

# Target: tag-specific build lockfiles
override oldtagsb=`if [ -d $(BUILDDIR) ]; then find $(BUILDDIR) -maxdepth 1 -name '.build.*' ! -name '.build.$(TAG)' -exec echo $(shell pwd)/{} \; ; fi`
$(BUILDDIR)/.build.$(TAG):
Expand Down Expand Up @@ -772,11 +782,13 @@ endif
#-------------------------------------------------------------------------------

# Target (and build rules): C++ and CUDA/HIP standalone executables
###$(cxx_checkmain): LIBFLAGS += $(CXXLIBFLAGSASAN)
$(cxx_checkmain): LIBFLAGS += $(CXXLIBFLAGSRPATH) # avoid the need for LD_LIBRARY_PATH
$(cxx_checkmain): $(BUILDDIR)/check_sa_cpp.o $(LIBDIR)/lib$(MG5AMC_CXXLIB).so $(cxx_objects_exe) $(BUILDDIR)/CurandRandomNumberKernel_cpp.o $(BUILDDIR)/HiprandRandomNumberKernel_cpp.o
$(CXX) -o $@ $(BUILDDIR)/check_sa_cpp.o $(OMPFLAGS) -ldl -pthread $(LIBFLAGS) -L$(LIBDIR) -l$(MG5AMC_CXXLIB) $(cxx_objects_exe) $(BUILDDIR)/CurandRandomNumberKernel_cpp.o $(BUILDDIR)/HiprandRandomNumberKernel_cpp.o $(RNDLIBFLAGS)

ifneq ($(GPUCC),)
###$(gpu_checkmain): LIBFLAGS += $(GPULIBFLAGSASAN)
ifneq ($(shell $(CXX) --version | grep ^Intel),)
$(gpu_checkmain): LIBFLAGS += -lintlc # compile with icpx and link with GPUCC (undefined reference to `_intel_fast_memcpy')
$(gpu_checkmain): LIBFLAGS += -lsvml # compile with icpx and link with GPUCC (undefined reference to `__svml_cos4_l9')
Expand Down Expand Up @@ -806,6 +818,7 @@ $(BUILDDIR)/%_fortran.o : %.f *.inc
# Target (and build rules): Fortran standalone executables
###$(BUILDDIR)/fcheck_sa_fortran.o : $(INCDIR)/fbridge.inc

###$(cxx_fcheckmain): LIBFLAGS += $(CXXLIBFLAGSASAN)
ifeq ($(UNAME_S),Darwin)
$(cxx_fcheckmain): LIBFLAGS += -L$(shell dirname $(shell $(FC) --print-file-name libgfortran.dylib)) # add path to libgfortran on Mac #375
endif
Expand All @@ -818,6 +831,7 @@ else
endif

ifneq ($(GPUCC),)
###$(gpu_fcheckmain): LIBFLAGS += $(GPULIBFLAGSASAN)
ifneq ($(shell $(CXX) --version | grep ^Intel),)
$(gpu_fcheckmain): LIBFLAGS += -lintlc # compile with icpx and link with GPUCC (undefined reference to `_intel_fast_memcpy')
$(gpu_fcheckmain): LIBFLAGS += -lsvml # compile with icpx and link with GPUCC (undefined reference to `__svml_cos4_l9')
Expand Down Expand Up @@ -920,10 +934,12 @@ endif
###endif

ifeq ($(GPUCC),) # link only runTest_cpp.o
###$(cxx_testmain): LIBFLAGS += $(CXXLIBFLAGSASAN)
$(cxx_testmain): LIBFLAGS += $(CXXLIBFLAGSRPATH) # avoid the need for LD_LIBRARY_PATH
$(cxx_testmain): $(LIBDIR)/lib$(MG5AMC_COMMONLIB).so $(cxx_objects_lib) $(cxx_objects_exe) $(GTESTLIBS)
$(CXX) -o $@ $(cxx_objects_lib) $(cxx_objects_exe) -ldl -pthread $(LIBFLAGS)
else # link only runTest_$(GPUSUFFIX).o (new: in the past, this was linking both runTest_cpp.o and runTest_$(GPUSUFFIX).o)
###$(gpu_testmain): LIBFLAGS += $(GPULIBFLAGSASAN)
$(gpu_testmain): LIBFLAGS += $(GPULIBFLAGSRPATH) # avoid the need for LD_LIBRARY_PATH
$(gpu_testmain): $(LIBDIR)/lib$(MG5AMC_COMMONLIB).so $(gpu_objects_lib) $(gpu_objects_exe) $(GTESTLIBS)
ifneq ($(findstring hipcc,$(GPUCC)),) # link fortran/c++/hip using $FC when hipcc is used #802
Expand Down
69 changes: 63 additions & 6 deletions epochX/cudacpp/ee_mumu.mad/SubProcesses/testmisc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "constexpr_math.h"
#include "epoch_process_id.h"
#include "valgrind.h"

#include <gtest/gtest.h>

Expand Down Expand Up @@ -334,9 +335,10 @@ TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testmisc )
};

// Test constexpr sin, cos, tan - specific, problematic, points
auto testSinCosTanX = []( const long double xx, const double tolerance, const bool debug = false, const long long istep = -999999999 )
auto testSinCosTanX = []( const long double xx, const double tolerance0, const bool debug = false, const long long istep = -999999999 )
{
const double x = (double)xx;
const double tolerance = tolerance0 * ( !RUNNING_ON_VALGRIND ? 1 : 1100 ); // higher tolerance when running through valgrind #906
if( debug )
{
//std::cout << std::setprecision(40) << "testSinCosTanX: xx= " << xx << std::endl;
Expand All @@ -353,8 +355,35 @@ TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testmisc )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
EXPECT_NEAR( std::cos( x ), constexpr_cos( x ), std::abs( std::cos( x ) * tolerance ) )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
EXPECT_NEAR( std::tan( x ), constexpr_tan( x ), std::abs( std::tan( x ) * tolerance ) )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
if( !RUNNING_ON_VALGRIND )
{
EXPECT_NEAR( std::tan( x ), constexpr_tan( x ), std::abs( std::tan( x ) * tolerance ) )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
}
else
{
// Higher tolerance when running through valgrind #906
const long double ctanx = constexpr_tan( x );
const long double taninf = 4E14; // declare tan(x) as "infinity if above this threshold
if( ctanx > -taninf && ctanx < taninf )
EXPECT_NEAR( std::tan( x ), ctanx, std::abs( std::tan( x ) * tolerance ) )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
else
{
// Allow tan(x)=-inf if ctan(x)=+inf and viceversa
EXPECT_GT( std::abs( std::tan( x ) ), taninf )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
/*
// Require tan(x)=+inf if ctan(x)=+inf and similarly for -inf (this fails around 3*pi/2)
if( ctanx > 0 )
EXPECT_GT( std::tan( x ), taninf )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
else
EXPECT_LT( std::tan( x ), -taninf )
<< "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ", istep=" << istep;
*/
}
}
std::cout << std::setprecision( 6 ); // default
};
testSinCosTanX( constexpr_pi, 1E-3, true ); // from math.h
Expand Down Expand Up @@ -425,13 +454,41 @@ TEST( XTESTID( MG_EPOCH_PROCESS_ID ), testmisc )
for( int istep = 0; istep < nstep + 1; istep++ )
{
double x = x0 + istep * ( x1 - x0 ) / nstep; // test this for double (else std::cos and std::sin use long double)
const double tolerance = toleranceForX( x );
const double tolerance0 = toleranceForX( x );
const double tolerance = tolerance0 * ( !RUNNING_ON_VALGRIND ? 1 : 1100 ); // higher tolerance when running through valgrind #906
EXPECT_NEAR( std::sin( x ), constexpr_sin( x ), std::max( std::abs( std::sin( x ) * tolerance ), 3E-15 ) )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
EXPECT_NEAR( std::cos( x ), constexpr_cos( x ), std::max( std::abs( std::cos( x ) * tolerance ), 3E-15 ) )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
EXPECT_NEAR( std::tan( x ), constexpr_tan( x ), std::max( std::abs( std::tan( x ) * tolerance ), 3E-15 ) )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
if( !RUNNING_ON_VALGRIND )
{
EXPECT_NEAR( std::tan( x ), constexpr_tan( x ), std::max( std::abs( std::tan( x ) * tolerance ), 3E-15 ) )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
}
else
{
// Higher tolerance when running through valgrind #906
const long double ctanx = constexpr_tan( x );
const long double taninf = 4E14; // declare tan(x) as "infinity if above this threshold
if( ctanx > -taninf && ctanx < taninf )
EXPECT_NEAR( std::tan( x ), constexpr_tan( x ), std::max( std::abs( std::tan( x ) * tolerance ), 3E-15 ) )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
else
{
// Allow tan(x)=-inf if ctan(x)=+inf and viceversa
EXPECT_GT( std::abs( std::tan( x ) ), taninf )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
/*
// Require tan(x)=+inf if ctan(x)=+inf and similarly for -inf (this fails around 3*pi/2)
if( ctanx > 0 )
EXPECT_GT( std::tan( x ), taninf )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
else
EXPECT_LT( std::tan( x ), -taninf )
<< std::setprecision( 40 ) << "x=" << x << ", x(0to2Pi)=" << mapIn0to2Pi( x ) << ",\n istep=" << istep << ", distance4=" << distance4( x );
*/
}
}
}
};
testSinCosTanN( 100, -4 * constexpr_pi, 6 * constexpr_pi ); // this was failing at 3*pi/2 (now fixed by absolute tolerance 3E-15)
Expand Down
Loading

0 comments on commit 1b69f9d

Please sign in to comment.