Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#define gpuStream_t cudaStream_t
#define gpuStreamCreate( pStream ) checkGpu( cudaStreamCreate( pStream ) )
#define gpuStreamDestroy( stream ) checkGpu( cudaStreamDestroy( stream ) )
#define gpuMallocAsync( ptr, size, stream ) checkGpu( cudaMallocAsync( ptr, size, stream ) )
#define gpuFreeAsync( ptr, stream ) checkGpu( cudaFreeAsync( ptr, stream ) )
#define gpuStreamSynchronize( stream ) checkGpu( cudaStreamSynchronize( stream ) )

#define gpuBlasStatus_t cublasStatus_t
#define GPUBLAS_STATUS_SUCCESS CUBLAS_STATUS_SUCCESS
Expand Down Expand Up @@ -113,6 +116,9 @@
#define gpuStream_t hipStream_t
#define gpuStreamCreate( pStream ) checkGpu( hipStreamCreate( pStream ) )
#define gpuStreamDestroy( stream ) checkGpu( hipStreamDestroy( stream ) )
#define gpuMallocAsync( ptr, size, stream ) checkGpu( hipMallocAsync( ptr, size, stream ) )
#define gpuFreeAsync( ptr, stream ) checkGpu( hipFreeAsync( ptr, stream ) )
#define gpuStreamSynchronize( stream ) checkGpu( hipStreamSynchronize( stream ) )

#define gpuBlasStatus_t hipblasStatus_t
#define GPUBLAS_STATUS_SUCCESS HIPBLAS_STATUS_SUCCESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace mg5amcCpu
, NumberOfEvents( nevt )
, m_couplings( nevt )
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
, m_numerators( nevt )
, m_numerators( nevt * CPPProcess::ndiagrams )
, m_denominators( nevt )
#endif
{
Expand Down Expand Up @@ -220,7 +220,7 @@ namespace mg5amcCpu
computeDependentCouplings( m_gs.data(), m_couplings.data(), m_gs.size() );
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
const unsigned int* pChannelIds = ( useChannelIds ? m_channelIds.data() : nullptr );
sigmaKin( m_momenta.data(), m_couplings.data(), m_rndhel.data(), m_rndcol.data(), pChannelIds, m_matrixElements.data(), m_selhel.data(), m_selcol.data(), m_numerators.data(), m_denominators.data(), nevt() );
sigmaKin( m_momenta.data(), m_couplings.data(), m_rndhel.data(), m_rndcol.data(), pChannelIds, nullptr, m_matrixElements.data(), m_selhel.data(), m_selcol.data(), m_numerators.data(), m_denominators.data(), nullptr, true, nevt() );
#else
assert( useChannelIds == false );
sigmaKin( m_momenta.data(), m_couplings.data(), m_rndhel.data(), m_matrixElements.data(), m_selhel.data(), nevt() );
Expand Down Expand Up @@ -356,7 +356,7 @@ namespace mg5amcGpu
m_pHelJamps.reset( new DeviceBufferSimple( CPPProcess::ncolor * mgOnGpu::nx2 * this->nevt() ) );
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
// Create the "one-helicity" numerator and denominator buffers that will be used for helicity filtering
m_pHelNumerators.reset( new DeviceBufferSimple( this->nevt() ) );
m_pHelNumerators.reset( new DeviceBufferSimple( this->nevt() * CPPProcess::ndiagrams ) );
m_pHelDenominators.reset( new DeviceBufferSimple( this->nevt() ) );
#endif
// Decide at runtime whether to use BLAS for color sums
Expand Down Expand Up @@ -476,7 +476,7 @@ namespace mg5amcGpu
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
// ... Create the "many-helicity" super-buffers of nGoodHel numerator and denominator buffers (dynamically allocated)
// ... (calling reset here deletes the previously created "one-helicity" buffers used for helicity filtering)
m_pHelNumerators.reset( new DeviceBufferSimple( nGoodHel * nevt ) );
m_pHelNumerators.reset( new DeviceBufferSimple( nGoodHel * CPPProcess::ndiagrams * nevt ) );
m_pHelDenominators.reset( new DeviceBufferSimple( nGoodHel * nevt ) );
#endif
#ifndef MGONGPU_HAS_NO_BLAS
Expand Down Expand Up @@ -507,7 +507,7 @@ namespace mg5amcGpu
#endif
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
const unsigned int* pChannelIds = ( useChannelIds ? m_channelIds.data() : nullptr );
sigmaKin( m_momenta.data(), m_couplings.data(), m_rndhel.data(), m_rndcol.data(), pChannelIds, m_matrixElements.data(), m_selhel.data(), m_selcol.data(), m_colJamp2s.data(), m_pHelNumerators->data(), m_pHelDenominators->data(), m_pHelMEs->data(), m_pHelJamps->data(), ghelAllBlasTmp, pBlasHandle, m_helStreams, m_gpublocks, m_gputhreads );
sigmaKin( m_momenta.data(), m_couplings.data(), m_rndhel.data(), m_rndcol.data(), pChannelIds, nullptr, m_matrixElements.data(), m_selhel.data(), m_selcol.data(), m_colJamp2s.data(), m_pHelNumerators->data(), m_pHelDenominators->data(), nullptr, true, m_pHelMEs->data(), m_pHelJamps->data(), ghelAllBlasTmp, pBlasHandle, m_helStreams, m_gpublocks, m_gputhreads );
#else
assert( useChannelIds == false );
sigmaKin( m_momenta.data(), m_couplings.data(), m_rndhel.data(), m_matrixElements.data(), m_selhel.data(), m_pHelMEs->data(), m_pHelJamps->data(), ghelAllBlasTmp, pBlasHandle, m_helStreams, m_gpublocks, m_gputhreads );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ namespace mg5amcCpu
#endif
}

// Locate a field (output) in a memory buffer (input) from a kernel event-indexing mechanism (internal)
// [Signature (SCALAR OR VECTOR) ===> fptype_sv* kernelAccess( fptype* buffer ) <===]
static __host__ __device__ inline fptype_sv*
kernelAccessP( fptype* buffer )
{
return reinterpret_cast<fptype_sv*>( buffer );
}

// Locate a field (output) in a memory buffer (input) from a kernel event-indexing mechanism (internal) and the given field indexes (input)
// [Signature (const, SCALAR) ===> const fptype& kernelAccessConst( const fptype* buffer ) <===]
static constexpr auto kernelAccessConst_s =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "CPPProcess.h"
#include "GpuRuntime.h"
#include "Parameters_%(model_name)s.h"
#include "processConfig.h"

#include <sstream>

Expand Down Expand Up @@ -295,7 +296,8 @@ namespace mg5amcCpu
typedef BufferBase<fptype> BufferNumerators;

// The size (number of elements) per event in a memory buffer for numerators
constexpr size_t sizePerEventNumerators = 1;
// (should be equal to the number of diagrams in the process)
constexpr size_t sizePerEventNumerators = processConfig::ndiagrams;

#ifndef MGONGPUCPP_GPUIMPL
// A class encapsulating a C++ host buffer for numerators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,12 @@ processid_short=$(shell basename $(CURDIR) | awk -F_ '{print $$(NF-1)"_"$$NF}')
###$(info processid_short=$(processid_short))

MG5AMC_CXXLIB = mg5amc_$(processid_short)_cpp
cxx_objects_lib=$(BUILDDIR)/CPPProcess_cpp.o $(BUILDDIR)/color_sum_cpp.o $(BUILDDIR)/MatrixElementKernels_cpp.o $(BUILDDIR)/BridgeKernels_cpp.o $(BUILDDIR)/CrossSectionKernels_cpp.o
cxx_objects_lib=$(BUILDDIR)/CPPProcess_cpp.o $(BUILDDIR)/color_sum_cpp.o $(BUILDDIR)/MatrixElementKernels_cpp.o $(BUILDDIR)/BridgeKernels_cpp.o $(BUILDDIR)/CrossSectionKernels_cpp.o $(BUILDDIR)/umami_cpp.o
cxx_objects_exe=$(BUILDDIR)/CommonRandomNumberKernel_cpp.o $(BUILDDIR)/RamboSamplingKernels_cpp.o

ifneq ($(GPUCC),)
MG5AMC_GPULIB = mg5amc_$(processid_short)_$(GPUSUFFIX)
gpu_objects_lib=$(BUILDDIR)/CPPProcess_$(GPUSUFFIX).o $(BUILDDIR)/color_sum_$(GPUSUFFIX).o $(BUILDDIR)/MatrixElementKernels_$(GPUSUFFIX).o $(BUILDDIR)/BridgeKernels_$(GPUSUFFIX).o $(BUILDDIR)/CrossSectionKernels_$(GPUSUFFIX).o
gpu_objects_lib=$(BUILDDIR)/CPPProcess_$(GPUSUFFIX).o $(BUILDDIR)/color_sum_$(GPUSUFFIX).o $(BUILDDIR)/MatrixElementKernels_$(GPUSUFFIX).o $(BUILDDIR)/BridgeKernels_$(GPUSUFFIX).o $(BUILDDIR)/CrossSectionKernels_$(GPUSUFFIX).o $(BUILDDIR)/umami_$(GPUSUFFIX).o
gpu_objects_exe=$(BUILDDIR)/CommonRandomNumberKernel_$(GPUSUFFIX).o $(BUILDDIR)/RamboSamplingKernels_$(GPUSUFFIX).o
endif

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2025 CERN and UCLouvain.
// Licensed under the GNU Lesser General Public License (version 3 or later).
// Created by: S. Roiser (May 2025) for the MG5aMC CUDACPP plugin.
// Further modified by: ... for the MG5aMC CUDACPP plugin.


#ifndef MG5_CONFIG_%(processid_uppercase)s_H
#define MG5_CONFIG_%(processid_uppercase)s_H 1

namespace processConfig {

constexpr int ndiagrams = %(ndiagrams)d;

}

#endif // MG5_CONFIG_%(processid_uppercase)s_H
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "MemoryAccessMomenta.h"
#include "MemoryAccessWavefunctions.h"
#include "color_sum.h"
#include "processConfig.h"

#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
#include "MemoryAccessDenominators.h"
Expand Down
Loading
Loading