Skip to content

Commit d9fefe6

Browse files
committed
uncommented debug statements but set default debug flags to false and added some additional compile time debug flags
1 parent 63bbbfc commit d9fefe6

File tree

13 files changed

+53
-34
lines changed

13 files changed

+53
-34
lines changed

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2020-2024 CERN and UCLouvain.
22
# Licensed under the GNU Lesser General Public License (version 3 or later).
33
# Created by: O. Mattelaer (Sep 2021) for the MG5aMC CUDACPP plugin.
4-
# Further modified by: O. Mattelaer, A. Valassi (2021-2024) for the MG5aMC CUDACPP plugin.
4+
# Further modified by: O. Mattelaer, A. Valassi, Z. Wettersten (2021-2024) for the MG5aMC CUDACPP plugin.
55

66
# AV - Rename the plugin as CUDACPP_OUTPUT (even if the madgraph4gpu directory is still called CUDACPP_SA_OUTPUT)
77
# This can be used in mg5amcnlo in one of two ways:

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/Bridge.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2020-2024 CERN and UCLouvain.
22
// Licensed under the GNU Lesser General Public License (version 3 or later).
33
// Created by: S. Roiser (Nov 2021) for the MG5aMC CUDACPP plugin.
4-
// Further modified by: S. Roiser, J. Teig, A. Valassi (2021-2024) for the MG5aMC CUDACPP plugin.
4+
// Further modified by: S. Roiser, J. Teig, A. Valassi, Z. Wettersten (2021-2024) for the MG5aMC CUDACPP plugin.
55

66
#ifndef BRIDGE_H
77
#define BRIDGE_H 1
@@ -255,19 +255,22 @@ namespace mg5amcCpu
255255
throw std::logic_error( "Bridge constructor: FIXME! cannot choose gputhreads" ); // this should never happen!
256256
m_gpublocks = m_nevt / m_gputhreads;
257257
}
258-
//std::cout << "WARNING! Instantiate device Bridge (nevt=" << m_nevt << ", gpublocks=" << m_gpublocks << ", gputhreads=" << m_gputhreads
259-
// << ", gpublocks*gputhreads=" << m_gpublocks * m_gputhreads << ")" << std::endl;
258+
#ifdef MGONGPU_VERBOSE_BRIDGE
259+
std::cout << "WARNING! Instantiate device Bridge (nevt=" << m_nevt << ", gpublocks=" << m_gpublocks << ", gputhreads=" << m_gputhreads
260+
<< ", gpublocks*gputhreads=" << m_gpublocks * m_gputhreads << ")" << std::endl;
261+
#endif
260262
m_pmek.reset( new MatrixElementKernelDevice( m_devMomentaC, m_devGs, m_devRndHel, m_devRndCol, m_devChannelIds, m_devMEs, m_devSelHel, m_devSelCol, m_gpublocks, m_gputhreads ) );
261263
#else
262-
//std::cout << "WARNING! Instantiate host Bridge (nevt=" << m_nevt << ")" << std::endl;
264+
#ifdef MGONGPU_VERBOSE_BRIDGE
265+
std::cout << "WARNING! Instantiate host Bridge (nevt=" << m_nevt << ")" << std::endl;
266+
#endif
263267
m_pmek.reset( new MatrixElementKernelHost( m_hstMomentaC, m_hstGs, m_hstRndHel, m_hstRndCol, m_hstChannelIds, m_hstMEs, m_hstSelHel, m_hstSelCol, m_nevt ) );
264268
#endif // MGONGPUCPP_GPUIMPL
265269
// Create a process object, read param card and set parameters
266270
// FIXME: the process instance can happily go out of scope because it is only needed to read parameters?
267271
// FIXME: the CPPProcess should really be a singleton? what if fbridgecreate is called from several Fortran threads?
268272
CPPProcess process( /*verbose=*/false );
269-
std::string paramCard = "../../Cards/param_card.dat";
270-
std::string paramCardTrex = "../Cards/param_card.dat";
273+
std::string paramCard = "../Cards/param_card.dat"; // ZW: change default param_card.dat location to one dir down
271274
/*
272275
#ifdef __HIPCC__
273276
if( !std::experimental::filesystem::exists( paramCard ) ) paramCard = "../" + paramCard;
@@ -279,8 +282,12 @@ namespace mg5amcCpu
279282
//if( !( stat( paramCard.c_str(), &dummyBuffer ) == 0 ) ) paramCard = "../" + paramCard; //
280283
auto fileExists = []( std::string& fileName )
281284
{ struct stat buffer; return stat( fileName.c_str(), &buffer ) == 0; };
282-
if( fileExists( paramCardTrex ) ) paramCard = paramCardTrex; // ZW: override param_card.dat to be one dir down since trex runs from the SubProcesses dir directory
283-
if( !fileExists( paramCard ) ) paramCard = "../" + paramCard; // bypass std::filesystem #803
285+
size_t paramCardCheck = 2; // ZW: check for paramCard up to 2 directories up
286+
for( size_t k = 0 ; k < paramCardCheck ; ++k )
287+
{
288+
if( fileExists( paramCard ) ) break; // bypass std::filesystem #803
289+
paramCard = "../" + paramCard;
290+
}
284291
process.initProc( paramCard );
285292
}
286293

@@ -349,7 +356,9 @@ namespace mg5amcCpu
349356
if( goodHelOnly ) return;
350357
m_pmek->computeMatrixElements( useChannelIds );
351358
copyHostFromDevice( m_hstMEs, m_devMEs );
352-
//flagAbnormalMEs( m_hstMEs.data(), m_nevt );
359+
#ifdef MGONGPU_VERBOSE_BRIDGE
360+
flagAbnormalMEs( m_hstMEs.data(), m_nevt );
361+
#endif
353362
copyHostFromDevice( m_hstSelHel, m_devSelHel );
354363
copyHostFromDevice( m_hstSelCol, m_devSelCol );
355364
if constexpr( std::is_same_v<FORTRANFPTYPE, fptype> )
@@ -402,7 +411,9 @@ namespace mg5amcCpu
402411
}
403412
if( goodHelOnly ) return;
404413
m_pmek->computeMatrixElements( useChannelIds );
405-
//flagAbnormalMEs( m_hstMEs.data(), m_nevt );
414+
#ifdef MGONGPU_VERBOSE_BRIDGE
415+
flagAbnormalMEs( m_hstMEs.data(), m_nevt );
416+
#endif
406417
if constexpr( std::is_same_v<FORTRANFPTYPE, fptype> )
407418
{
408419
memcpy( mes, m_hstMEs.data(), m_hstMEs.bytes() );

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/GpuRuntime.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2020-2024 CERN and UCLouvain.
22
// Licensed under the GNU Lesser General Public License (version 3 or later).
33
// Created by: J. Teig (Jun 2023, based on earlier work by S. Roiser) for the MG5aMC CUDACPP plugin.
4-
// Further modified by: O. Mattelaer, S. Roiser, J. Teig, A. Valassi (2020-2024) for the MG5aMC CUDACPP plugin.
4+
// Further modified by: O. Mattelaer, S. Roiser, J. Teig, A. Valassi, Z. Wettersten (2020-2024) for the MG5aMC CUDACPP plugin.
55

66
#ifndef MG5AMC_GPURUNTIME_H
77
#define MG5AMC_GPURUNTIME_H 1
@@ -38,7 +38,7 @@ namespace mg5amcGpu
3838
// *** FIXME! This will all need to be designed differently when going to multi-GPU nodes! ***
3939
struct GpuRuntime final
4040
{
41-
GpuRuntime( const bool debug = false )
41+
GpuRuntime( const bool debug = false ) // ZW: default debug to false
4242
: m_debug( debug ) { setUp( m_debug ); }
4343
~GpuRuntime() { tearDown( m_debug ); }
4444
GpuRuntime( const GpuRuntime& ) = delete;
@@ -50,7 +50,7 @@ namespace mg5amcGpu
5050
// Set up CUDA application
5151
// ** NB: strictly speaking this is not needed when using the CUDA runtime API **
5252
// Calling cudaSetDevice on startup is useful to properly book-keep the time spent in CUDA initialization
53-
static void setUp( const bool debug = false )
53+
static void setUp( const bool debug = false ) // ZW: default debug to false
5454
{
5555
// ** NB: it is useful to call cudaSetDevice, or cudaFree, to properly book-keep the time spent in CUDA initialization
5656
// ** NB: otherwise, the first CUDA operation (eg a cudaMemcpyToSymbol in CPPProcess ctor) appears to take much longer!
@@ -71,7 +71,7 @@ namespace mg5amcGpu
7171
// ** NB: strictly speaking this is not needed when using the CUDA runtime API **
7272
// Calling cudaDeviceReset on shutdown is only needed for checking memory leaks in cuda-memcheck
7373
// See https://docs.nvidia.com/cuda/cuda-memcheck/index.html#leak-checking
74-
static void tearDown( const bool debug = false )
74+
static void tearDown( const bool debug = false ) // ZW: default debug to false
7575
{
7676
if( debug ) std::cout << "__GpuRuntime: calling GpuDeviceReset()" << std::endl;
7777
checkGpu( gpuDeviceReset() );

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/MatrixElementKernels.cc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2020-2024 CERN and UCLouvain.
22
// Licensed under the GNU Lesser General Public License (version 3 or later).
33
// Created by: A. Valassi (Jan 2022) for the MG5aMC CUDACPP plugin.
4-
// Further modified by: J. Teig, A. Valassi (2022-2024) for the MG5aMC CUDACPP plugin.
4+
// Further modified by: J. Teig, A. Valassi, Z. Wettersten (2022-2024) for the MG5aMC CUDACPP plugin.
55

66
#include "MatrixElementKernels.h"
77

@@ -60,7 +60,9 @@ namespace mg5amcCpu
6060
#ifdef MGONGPU_CHANNELID_DEBUG
6161
MatrixElementKernelBase::dumpNevtProcessedByChannel();
6262
#endif
63-
// MatrixElementKernelBase::dumpSignallingFPEs();
63+
#ifdef MGONGPU_VERBOSE_FPES
64+
MatrixElementKernelBase::dumpSignallingFPEs();
65+
#endif
6466
}
6567

6668
//--------------------------------------------------------------------------
@@ -130,7 +132,9 @@ namespace mg5amcCpu
130132
if( std::fetestexcept( FE_OVERFLOW ) ) fpes += " FE_OVERFLOW";
131133
if( std::fetestexcept( FE_UNDERFLOW ) ) fpes += " FE_UNDERFLOW";
132134
//if( std::fetestexcept( FE_INEXACT ) ) fpes += " FE_INEXACT"; // do not print this out: this would almost always signal!
133-
if( fpes != "" )
135+
if( fpes == "" )
136+
std::cout << "INFO: No Floating Point Exceptions have been reported" << std::endl;
137+
else
134138
std::cerr << "INFO: The following Floating Point Exceptions have been reported:" << fpes << std::endl;
135139
}
136140

@@ -272,14 +276,15 @@ namespace mg5amcCpu
272276
#endif
273277
if( verbose )
274278
{
275-
if( tag != "none" ){
276-
//std::cout << "INFO: The application does not require the host to support any AVX feature" << std::endl;
277-
if( ok && !known )
279+
if( tag == "none" )
280+
std::cout << "INFO: The application does not require the host to support any AVX feature" << std::endl;
281+
else if( ok && known )
282+
std::cout << "INFO: The application is built for " << tag << " and the host supports it" << std::endl;
283+
else if( ok )
278284
std::cout << "WARNING: The application is built for " << tag << " but it is unknown if the host supports it" << std::endl;
279-
else if ( !ok && known )
285+
else
280286
std::cout << "ERROR! The application is built for " << tag << " but the host does not support it" << std::endl;
281287
}
282-
}
283288
return ok;
284289
}
285290

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/MatrixElementKernels.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ namespace mg5amcCpu
134134

135135
// Does this host system support the SIMD used in the matrix element calculation?
136136
// [NB: this is private, SIMD vectorization in mg5amc C++ code is currently only used in the ME calculations below MatrixElementKernelHost!]
137-
static bool hostSupportsSIMD( const bool verbose = true );
137+
static bool hostSupportsSIMD( const bool verbose = false ); // ZW: set verbose to false by default
138138

139139
private:
140140

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/cudacpp_config.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2020-2024 CERN and UCLouvain.
22
# Licensed under the GNU Lesser General Public License (version 3 or later).
33
# Created by: A. Valassi (Mar 2024) for the MG5aMC CUDACPP plugin.
4-
# Further modified by: A. Valassi (2024) for the MG5aMC CUDACPP plugin.
4+
# Further modified by: A. Valassi, Z. Wettersten (2024) for the MG5aMC CUDACPP plugin.
55

66
#-------------------------------------------------------------------------------
77

@@ -13,7 +13,8 @@ ifeq ($(BACKEND),)
1313
override BACKEND = gpucpp
1414
endif
1515

16-
# Stop immediately if BACKEND=cuda but nvcc is missing
16+
# ZW: gpucpp backend checks if there is a GPU backend available before going to SIMD
17+
# prioritises CUDA over HIP
1718
ifeq ($(BACKEND),gpucpp)
1819
ifeq ($(shell which nvcc 2>/dev/null),)
1920
ifeq ($(shell which hipcc 2>/dev/null),)

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/cudacpp_rex_src.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2020-2024 CERN and UCLouvain.
22
# Licensed under the GNU Lesser General Public License (version 3 or later).
33
# Created by: S. Roiser (Feb 2020) for the MG5aMC CUDACPP plugin.
4-
# Further modified by: S. Hageboeck, O. Mattelaer, S. Roiser, J. Teig, A. Valassi (2020-2024) for the MG5aMC CUDACPP plugin.
4+
# Further modified by: S. Hageboeck, O. Mattelaer, S. Roiser, J. Teig, A. Valassi, Z. Wettersten (2020-2024) for the MG5aMC CUDACPP plugin.
55

66
#=== Determine the name of this makefile (https://ftp.gnu.org/old-gnu/Manuals/make-3.80/html_node/make_17.html)
77
#=== NB: assume that the same name (e.g. cudacpp.mk, Makefile...) is used in the Subprocess and src directories

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/cudacpp_runner.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ endif
552552
#-------------------------------------------------------------------------------
553553

554554
# Target (and build rules): C++ rwgt libraries
555+
# ZW: the -Bsymbolic flag ensures that function calls will be handled internally by the library, rather than going to global context
555556
cxx_rwgtfiles := $(BUILDDIR)/rwgt_runner_cpp.o $(LIBDIR)/lib$(MG5AMC_COMMONLIB).so $(BUILDDIR)/fbridge_cpp.o $(cxx_objects_lib) $(cxx_objects_exe) $(BUILDDIR)/CurandRandomNumberKernel_cpp.o $(BUILDDIR)/HiprandRandomNumberKernel_cpp.o
556557
$(cxx_rwgtlib): LIBFLAGS += $(CXXLIBFLAGSRPATH)
557558
$(cxx_rwgtlib): $(LIBDIR)/lib$(MG5AMC_COMMONLIB).so $(cxx_rwgtfiles) $(cxx_objects_lib)

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/fbridge.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2020-2024 CERN and UCLouvain.
22
// Licensed under the GNU Lesser General Public License (version 3 or later).
33
// Created by: S. Roiser (Oct 2021) for the MG5aMC CUDACPP plugin.
4-
// Further modified by: S. Roiser, J. Teig, A. Valassi, Z. Wettersten (2021-2024) for the MG5aMC CUDACPP plugin.
4+
// Further modified by: S. Roiser, J. Teig, A. Valassi (2021-2024) for the MG5aMC CUDACPP plugin.
55

66
#include "Bridge.h"
77
#include "CPPProcess.h"

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_cc.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ fpeEnable()
6262
//std::cout << "fpeEnable: FE_INVALID is" << ( ( fpes & FE_INVALID ) ? " " : " NOT " ) << "enabled" << std::endl;
6363
//std::cout << "fpeEnable: FE_OVERFLOW is" << ( ( fpes & FE_OVERFLOW ) ? " " : " NOT " ) << "enabled" << std::endl;
6464
//std::cout << "fpeEnable: FE_UNDERFLOW is" << ( ( fpes & FE_UNDERFLOW ) ? " " : " NOT " ) << "enabled" << std::endl;
65-
constexpr bool enableFPE = true; // this is hardcoded and no longer controlled by getenv( "CUDACPP_RUNTIME_ENABLEFPE" )
65+
constexpr bool enableFPE = false; // this is hardcoded and no longer controlled by getenv( "CUDACPP_RUNTIME_ENABLEFPE" )
66+
// ZW: hardcode enableFPE to false
6667
if( enableFPE )
6768
{
68-
//std::cout << "INFO: The following Floating Point Exceptions will cause SIGFPE program aborts: FE_DIVBYZERO, FE_INVALID, FE_OVERFLOW" << std::endl;
69+
std::cout << "INFO: The following Floating Point Exceptions will cause SIGFPE program aborts: FE_DIVBYZERO, FE_INVALID, FE_OVERFLOW" << std::endl;
6970
feenableexcept( FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW ); // new strategy #831 (do not enable FE_UNDERFLOW)
7071
//fpes = fegetexcept();
7172
//std::cout << "fpeEnable: analyse fegetexcept()=" << fpes << std::endl;

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_function_definitions.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ namespace mg5amcCpu
117117
#else
118118
memcpy( cHel, tHel, ncomb * npar * sizeof( short ) );
119119
#endif
120-
//fpeEnable(); // enable SIGFPE traps for Floating Point Exceptions
120+
fpeEnable(); // enable SIGFPE traps for Floating Point Exceptions
121121
}
122122

123123
//--------------------------------------------------------------------------

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2020-2024 CERN and UCLouvain.
22
# Licensed under the GNU Lesser General Public License (version 3 or later).
33
# Created by: O. Mattelaer (Sep 2021) for the MG5aMC CUDACPP plugin.
4-
# Further modified by: O. Mattelaer, J. Teig, A. Valassi (2021-2024) for the MG5aMC CUDACPP plugin.
4+
# Further modified by: O. Mattelaer, J. Teig, A. Valassi, Z. Wettersten (2021-2024) for the MG5aMC CUDACPP plugin.
55

66
import os
77
import sys

tools/REX/rwgt_runner.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// A class for reweighting matrix elements for
1212
%(process_lines)s
1313
//--------------------------------------------------------------------------
14-
#ifndef _LIBCOMP_
15-
#define _LIBCOMP_
14+
#ifndef _TREX_
15+
#define _TREX_
1616
#endif
1717
#include "rwgt_instance.h"
1818
#include "fbridge.h"

0 commit comments

Comments
 (0)