Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' (including PR madgraph…
Browse files Browse the repository at this point in the history
…5#368 adding _cu.o and removing gXXX.cu links) into rocrand

Fix conflicts:
	epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/cudacpp.mk
	epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py

The conflicts were in the interplay of adding Hiprand and adding _cu.o (so for instance gHipRandRandomNumberKernel.o becomes HipRandRandomNumberKernel_cu.o)
  • Loading branch information
valassi committed Feb 5, 2024
2 parents 64bb526 + 9f8085e commit 3548fbd
Show file tree
Hide file tree
Showing 282 changed files with 19 additions and 310 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ $(BUILDDIR)/.build.$(TAG):
@if [ "$(oldtagsb)" != "" ]; then echo "Cannot build for tag=$(TAG) as old builds exist for other tags:"; echo " $(oldtagsb)"; echo "Please run 'make clean' first\nIf 'make clean' is not enough: run 'make clean USEBUILDDIR=1 AVX=$(AVX) FPTYPE=$(FPTYPE)' or 'make cleanall'"; exit 1; fi
@touch $(BUILDDIR)/.build.$(TAG)

# Generic target and build rules: objects from CUDA compilation
# Generic target and build rules: objects from CUDA or HIP compilation
# NB: CCBUILDRULEFLAGS includes "-x cu" for nvcc and "-x hip" for hipcc (#810)
ifneq ($(GPUCC),)
$(BUILDDIR)/%%.o : %%.cu *.h ../../src/*.h $(BUILDDIR)/.build.$(TAG)
Expand All @@ -620,7 +620,7 @@ $(BUILDDIR)/%%.o : %%.cc *.h ../../src/*.h $(BUILDDIR)/.build.$(TAG)
@if [ ! -d $(BUILDDIR) ]; then echo "mkdir -p $(BUILDDIR)"; mkdir -p $(BUILDDIR); fi
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC -c $< -o $@

# Apply special build flags only to CrossSectionKernel.cc and gCrossSectionKernel.cu (no fast math, see #117 and #516)
# Apply special build flags only to CrossSectionKernel[_cu].o (no fast math, see #117 and #516)
# Added edgecase for HIP compilation
ifeq ($(shell $(CXX) --version | grep ^nvc++),)
$(BUILDDIR)/CrossSectionKernels.o: CXXFLAGS := $(filter-out -ffast-math,$(CXXFLAGS))
Expand All @@ -632,17 +632,17 @@ else
endif
endif

# Apply special build flags only to check_sa.o and gcheck_sa.o (NVTX in timermap.h, #679)
# Apply special build flags only to check_sa[_cu].o (NVTX in timermap.h, #679)
$(BUILDDIR)/check_sa.o: CXXFLAGS += $(USE_NVTX) $(CUINC)
$(BUILDDIR)/gcheck_sa.o: CXXFLAGS += $(USE_NVTX) $(CUINC)
$(BUILDDIR)/check_sa_cu.o: CXXFLAGS += $(USE_NVTX) $(CUINC)

# Apply special build flags only to check_sa and (Cu|Roc)randRandomNumberKernel
# Apply special build flags only to check_sa[_cu].o and (Cu|Hip)randRandomNumberKernel[_cu].o
$(BUILDDIR)/check_sa.o: CXXFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/gcheck_sa.o: CUFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/check_sa_cu.o: CUFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/CurandRandomNumberKernel.o: CXXFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/gCurandRandomNumberKernel.o: CUFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/CurandRandomNumberKernel_cu.o: CUFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/HiprandRandomNumberKernel.o: CXXFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/gHiprandRandomNumberKernel.o: CUFLAGS += $(RNDCXXFLAGS)
$(BUILDDIR)/HiprandRandomNumberKernel_cu.o: CUFLAGS += $(RNDCXXFLAGS)
ifeq ($(HASCURAND),hasCurand) # curand headers, #679
$(BUILDDIR)/CurandRandomNumberKernel.o: CXXFLAGS += $(CUINC)
endif
Expand All @@ -666,10 +666,10 @@ endif
###endif
###endif

#### Apply special build flags only to CPPProcess.cc (-flto)
#### Apply special build flags only to CPPProcess.o (-flto)
###$(BUILDDIR)/CPPProcess.o: CXXFLAGS += -flto

#### Apply special build flags only to CPPProcess.cc (AVXFLAGS)
#### Apply special build flags only to CPPProcess.o (AVXFLAGS)
###$(BUILDDIR)/CPPProcess.o: CXXFLAGS += $(AVXFLAGS)

#-------------------------------------------------------------------------------
Expand All @@ -691,8 +691,8 @@ cxx_objects_exe=$(BUILDDIR)/CommonRandomNumberKernel.o $(BUILDDIR)/RamboSampling

ifneq ($(GPUCC),)
MG5AMC_CULIB = mg5amc_$(processid_short)_cuda
cu_objects_lib=$(BUILDDIR)/gCPPProcess.o $(BUILDDIR)/gMatrixElementKernels.o $(BUILDDIR)/gBridgeKernels.o $(BUILDDIR)/gCrossSectionKernels.o
cu_objects_exe=$(BUILDDIR)/gCommonRandomNumberKernel.o $(BUILDDIR)/gRamboSamplingKernels.o
cu_objects_lib=$(BUILDDIR)/CPPProcess_cu.o $(BUILDDIR)/MatrixElementKernels_cu.o $(BUILDDIR)/BridgeKernels_cu.o $(BUILDDIR)/CrossSectionKernels_cu.o
cu_objects_exe=$(BUILDDIR)/CommonRandomNumberKernel_cu.o $(BUILDDIR)/RamboSamplingKernels_cu.o
endif

# Target (and build rules): C++ and CUDA shared libraries
Expand Down
25 changes: 7 additions & 18 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,7 @@ class PLUGIN_OneProcessExporter(PLUGIN_export_cpp.OneProcessExporterGPU):
# AV - change defaults from export_cpp.OneProcessExporterGPU
# [NB process_class = "CPPProcess" is set in OneProcessExporterCPP.__init__]
# [NB process_class = "gCPPProcess" is set in OneProcessExporterGPU.__init__]
###cc_ext = 'cu' # create gCPPProcess.cu (and symlink it as CPPProcess.cc)
cc_ext = 'cc' # create CPPProcess.cc (and symlink it as gCPPProcess.cu)
cc_ext = 'cc' # create CPPProcess.cc (build it also as CPPProcess_cu.so, no longer symlink it as gCPPProcess.cu)

# AV - keep defaults from export_cpp.OneProcessExporterGPU
###process_dir = '.'
Expand Down Expand Up @@ -1079,7 +1078,7 @@ def get_process_class_definitions(self, write=True):
file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_class.inc (copyright)
return file

# AV - replace export_cpp.OneProcessExporterGPU method (fix gCPPProcess.cu)
# AV - replace export_cpp.OneProcessExporterGPU method (fix CPPProcess.cc)
def get_process_function_definitions(self, write=True):
"""The complete class definition for the process"""
replace_dict = super(PLUGIN_export_cpp.OneProcessExporterGPU,self).get_process_function_definitions(write=False) # defines replace_dict['initProc_lines']
Expand Down Expand Up @@ -1178,9 +1177,9 @@ def get_sigmaKin_lines(self, color_amplitudes, write=True):
else:
return replace_dict

# AV - modify export_cpp.OneProcessExporterGPU method (fix gCPPProcess.cu)
# AV - modify export_cpp.OneProcessExporterGPU method (fix CPPProcess.cc)
def get_all_sigmaKin_lines(self, color_amplitudes, class_name):
"""Get sigmaKin_process for all subprocesses for gCPPProcess.cu"""
"""Get sigmaKin_process for all subprocesses for CPPProcess.cc"""
ret_lines = []
if self.single_helicities:
###assert self.include_multi_channel # remove this assert: must handle both cases and produce two different code bases (#473)
Expand Down Expand Up @@ -1339,16 +1338,6 @@ def generate_process_files(self):
self.edit_testxxx() # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
self.edit_memorybuffers() # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
self.edit_memoryaccesscouplings() # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
# Add symbolic links in the P1 directory
files.ln(pjoin(self.path, 'check_sa.cc'), self.path, 'gcheck_sa.cu')
files.ln(pjoin(self.path, 'CPPProcess.cc'), self.path, 'gCPPProcess.cu')
files.ln(pjoin(self.path, 'CrossSectionKernels.cc'), self.path, 'gCrossSectionKernels.cu')
files.ln(pjoin(self.path, 'MatrixElementKernels.cc'), self.path, 'gMatrixElementKernels.cu')
files.ln(pjoin(self.path, 'RamboSamplingKernels.cc'), self.path, 'gRamboSamplingKernels.cu')
files.ln(pjoin(self.path, 'CommonRandomNumberKernel.cc'), self.path, 'gCommonRandomNumberKernel.cu')
files.ln(pjoin(self.path, 'CurandRandomNumberKernel.cc'), self.path, 'gCurandRandomNumberKernel.cu')
files.ln(pjoin(self.path, 'HiprandRandomNumberKernel.cc'), self.path, 'gHiprandRandomNumberKernel.cu')
files.ln(pjoin(self.path, 'BridgeKernels.cc'), self.path, 'gBridgeKernels.cu')
# NB: symlink of cudacpp.mk to makefile is overwritten by madevent makefile if this exists (#480)
# NB: this relies on the assumption that cudacpp code is generated before madevent code
files.ln(pjoin(self.path, 'cudacpp.mk'), self.path, 'makefile')
Expand Down Expand Up @@ -1477,7 +1466,7 @@ def edit_memoryaccesscouplings(self):
# AV - overload the export_cpp.OneProcessExporterGPU method (add debug printout and truncate last \n)
# [*NB export_cpp.UFOModelConverterGPU.write_process_h_file is not called!*]
def write_process_h_file(self, writer):
"""Generate final gCPPProcess.h"""
"""Generate final CPPProcess.h"""
###misc.sprint('Entering PLUGIN_OneProcessExporter.write_process_h_file')
out = super().write_process_h_file(writer)
writer.seek(-1, os.SEEK_CUR)
Expand Down Expand Up @@ -1561,7 +1550,7 @@ def get_color_matrix_lines(self, matrix_element):

# AV - replace the export_cpp.OneProcessExporterGPU method (improve formatting)
def get_initProc_lines(self, matrix_element, color_amplitudes):
"""Get initProc_lines for function definition for gCPPProcess::initProc"""
"""Get initProc_lines for function definition for CPPProcess::initProc"""
initProc_lines = []
initProc_lines.append('// Set external particle masses for this matrix element')
for part in matrix_element.get_external_wavefunctions():
Expand Down Expand Up @@ -1607,7 +1596,7 @@ class PLUGIN_GPUFOHelasCallWriter(helas_call_writers.GPUFOHelasCallWriter):
# - PLUGIN_GPUFOHelasCallWriter(GPUFOHelasCallWriter)
# This class

# AV - replace helas_call_writers.GPUFOHelasCallWriter method (improve formatting of gCPPProcess.cu)
# AV - replace helas_call_writers.GPUFOHelasCallWriter method (improve formatting of CPPProcess.cc)
# [GPUFOHelasCallWriter.format_coupling is called by GPUFOHelasCallWriter.get_external_line/generate_helas_call]
# [GPUFOHelasCallWriter.get_external_line is called by GPUFOHelasCallWriter.get_external]
# [GPUFOHelasCallWriter.get_external (adding #ifdef CUDA) is called by GPUFOHelasCallWriter.generate_helas_call]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3548fbd

Please sign in to comment.