Skip to content

Commit

Permalink
[jthip] backport to CODEGEN from ggttgg.mad
Browse files Browse the repository at this point in the history
  • Loading branch information
valassi authored and Jooorgen committed Aug 24, 2023
1 parent d1f5c5b commit 1b5c0fd
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace mg5amcCpu
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable" // e.g. <<warning: unused variable ‘mdl_G__exp__2’ [-Wunused-variable]>>
#pragma GCC diagnostic ignored "-Wunused-parameter" // e.g. <<warning: unused parameter ‘G’ [-Wunused-parameter]>>
#ifdef __CUDACC__
#ifdef MGONGPUCPP_GPUIMPL
#pragma nv_diagnostic push
#pragma nv_diag_suppress 177 // e.g. <<warning #177-D: variable "mdl_G__exp__2" was declared but never referenced>>
#endif
Expand All @@ -194,9 +194,9 @@ namespace mg5amcCpu
%(dcoupsetdcoup)s
}
%(eftspecial2)s
return out;
}
#ifdef __CUDACC__
return out;
}
#ifdef MGONGPUCPP_GPUIMPL
#pragma GCC diagnostic pop
#pragma nv_diagnostic pop
#endif
Expand All @@ -212,6 +212,12 @@ namespace mg5amcCpu

//==========================================================================

#ifdef MGONGPUCPP_GPUIMPL
namespace mg5amcGpu
#else
namespace mg5amcCpu
#endif
{
#pragma GCC diagnostic push
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" // e.g. <<warning: variable ‘couplings_sv’ set but not used [-Wunused-but-set-variable]>>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "BridgeKernels.h"
#include "CPPProcess.h"
#include "CrossSectionKernels.h"
#include "GpuRuntime.h"
#include "MatrixElementKernels.h"
#include "MemoryAccessMatrixElements.h"
#include "MemoryAccessMomenta.h"
Expand Down Expand Up @@ -102,12 +103,12 @@ main( int argc, char** argv )
CurandHost = 1,
CurandDevice = 2
};
#ifdef MGONGPUCPP_GPUIMPL
RandomNumberMode rndgen = RandomNumberMode::CurandDevice; // default on GPU
#ifdef __CUDACC__
RandomNumberMode rndgen = RandomNumberMode::CurandDevice; // default on CUDA GPU
#elif not defined MGONGPU_HAS_NO_CURAND
RandomNumberMode rndgen = RandomNumberMode::CurandHost; // default on CPU if build has curand
#else
RandomNumberMode rndgen = RandomNumberMode::CommonRandom; // default on CPU if build has no curand
RandomNumberMode rndgen = RandomNumberMode::CommonRandom; // default on CPU if build has no curand and on HIP GPU
#endif
// Rambo sampling mode (NB RamboHost implies CommonRandom or CurandHost!)
enum class RamboSamplingMode
Expand Down Expand Up @@ -145,10 +146,10 @@ main( int argc, char** argv )
}
else if( arg == "--curdev" )
{
#ifdef MGONGPUCPP_GPUIMPL
#ifdef __CUDACC__
rndgen = RandomNumberMode::CurandDevice;
#else
throw std::runtime_error( "CurandDevice is not supported on CPUs" );
throw std::runtime_error( "CurandDevice is not supported on CPUs or on HIP GPUs" );
#endif
}
else if( arg == "--curhst" )
Expand Down Expand Up @@ -265,12 +266,12 @@ main( int argc, char** argv )

#ifdef MGONGPUCPP_GPUIMPL

// --- 00. Initialise cuda
// Instantiate a CudaRuntime at the beginnining of the application's main to
// invoke cudaSetDevice(0) in the constructor and book a cudaDeviceReset() call in the destructor
const std::string cdinKey = "00 CudaInit";
// --- 00. Initialise GPU
// Instantiate a GpuRuntime at the beginnining of the application's main.
// For CUDA this invokes cudaSetDevice(0) in the constructor and books a cudaDeviceReset() call in the destructor.
const std::string cdinKey = "00 GpuInit";
timermap.start( cdinKey );
CudaRuntime cudaRuntime( debug );
GpuRuntime GpuRuntime( debug );
#endif

// --- 0a. Initialise physics process
Expand Down Expand Up @@ -394,7 +395,7 @@ main( int argc, char** argv )
const bool onDevice = false;
prnk.reset( new CurandRandomNumberKernel( hstRndmom, onDevice ) );
}
#ifdef MGONGPUCPP_GPUIMPL
#ifdef __CUDACC__
else
{
const bool onDevice = true;
Expand All @@ -403,7 +404,7 @@ main( int argc, char** argv )
#else
else
{
throw std::logic_error( "CurandDevice is not supported on CPUs" ); // INTERNAL ERROR (no path to this statement)
throw std::logic_error( "CurandDevice is not supported on CPUs or HIP GPUs" ); // INTERNAL ERROR (no path to this statement)
}
#endif
#else
Expand Down Expand Up @@ -729,17 +730,21 @@ main( int argc, char** argv )
rndgentxt = "CURAND HOST";
else if( rndgen == RandomNumberMode::CurandDevice )
rndgentxt = "CURAND DEVICE";
#ifdef MGONGPUCPP_GPUIMPL
#ifdef __CUDACC__
rndgentxt += " (CUDA code)";
#elif defined __HIPCC__
rndgentxt += " (HIP code)";
#else
rndgentxt += " (C++ code)";
#endif

// Workflow description summary
std::string wrkflwtxt;
// -- CUDA or C++?
#ifdef MGONGPUCPP_GPUIMPL
// -- CUDA or HIP or C++?
#ifdef __CUDACC__
wrkflwtxt += "CUD:";
#elif defined __HIPCC__
wrkflwtxt += "HIP:";
#else
wrkflwtxt += "CPP:";
#endif
Expand All @@ -754,7 +759,7 @@ main( int argc, char** argv )
wrkflwtxt += "???+"; // no path to this statement
#endif
// -- CUCOMPLEX or THRUST or STD complex numbers?
#ifdef MGONGPUCPP_GPUIMPL
#ifdef __CUDACC__
#if defined MGONGPU_CUCXTYPE_CUCOMPLEX
wrkflwtxt += "CUX:";
#elif defined MGONGPU_CUCXTYPE_THRUST
Expand All @@ -764,6 +769,12 @@ main( int argc, char** argv )
#else
wrkflwtxt += "???:"; // no path to this statement
#endif
#elif defined __HIPCC__
#if defined MGONGPU_CUCXTYPE_CXSMPL
wrkflwtxt += "CXS:";
#else
wrkflwtxt += "???:"; // no path to this statement
#endif
#else
#if defined MGONGPU_CPPCXTYPE_STDCOMPLEX
wrkflwtxt += "STX:";
Expand Down Expand Up @@ -864,8 +875,10 @@ main( int argc, char** argv )
#endif
// Dump all configuration parameters and all results
std::cout << std::string( SEP79, '*' ) << std::endl
#ifdef MGONGPUCPP_GPUIMPL
#ifdef __CUDACC__
<< "Process = " << XSTRINGIFY( MG_EPOCH_PROCESS_ID ) << "_CUDA"
#elif defined __HIPCC__
<< "Process = " << XSTRINGIFY( MG_EPOCH_PROCESS_ID ) << "_HIP"
#else
<< "Process = " << XSTRINGIFY( MG_EPOCH_PROCESS_ID ) << "_CPP"
#endif
Expand All @@ -892,14 +905,14 @@ main( int argc, char** argv )
#elif defined MGONGPU_FPTYPE_FLOAT
<< "FP precision = FLOAT (NaN/abnormal=" << nabn << ", zero=" << nzero << ")" << std::endl
#endif
#ifdef MGONGPUCPP_GPUIMPL
#if defined MGONGPU_CUCXTYPE_CUCOMPLEX
<< "Complex type = CUCOMPLEX" << std::endl
#elif defined MGONGPU_CUCXTYPE_THRUST
<< "Complex type = THRUST::COMPLEX" << std::endl
#endif
#else
#elif defined MGONGPU_CUCXTYPE_CXSMPL
<< "Complex type = STD::COMPLEX" << std::endl
#else
<< "Complex type = ???" << std::endl // no path to this statement...
#endif
<< "RanNumb memory layout = AOSOA[" << neppR << "]"
<< ( neppR == 1 ? " == AOS" : "" )
Expand Down Expand Up @@ -1033,14 +1046,14 @@ main( int argc, char** argv )
<< "\"FLOAT (NaN/abnormal=" << nabn << ")\"," << std::endl
#endif
<< "\"Complex type\": "
#ifdef MGONGPUCPP_GPUIMPL
#if defined MGONGPU_CUCXTYPE_CUCOMPLEX
<< "\"CUCOMPLEX\"," << std::endl
#elif defined MGONGPU_CUCXTYPE_THRUST
<< "\"THRUST::COMPLEX\"," << std::endl
#endif
#else
#elif defined MGONGPU_CUCXTYPE_CXSMPL
<< "\"STD::COMPLEX\"," << std::endl
#else
<< "\"???\"," << std::endl // no path to this statement...
#endif
<< "\"RanNumb memory layout\": "
<< "\"AOSOA[" << neppR << "]\""
Expand Down
Loading

0 comments on commit 1b5c0fd

Please # to comment.