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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/launch_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,27 @@ def compile(self, *args, **opts):
cudacpp_supported_backends = [ 'fortran', 'cuda', 'hip', 'cpp', 'cppnone', 'cppsse4', 'cppavx2', 'cpp512y', 'cpp512z', 'cppauto' ]
if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
cudacpp_backend = self.run_card['cudacpp_backend'].lower() # the default value is defined in launch_plugin.py
logger.info("Building madevent in madevent_interface.py with '%s' matrix elements"%cudacpp_backend)
if cudacpp_backend in ['cpp', 'cppauto']:
backend_log = pjoin(opts["cwd"], ".resolved-backend")
# try to remove old file if present
breakpoint()
try:
os.remove(backend_log)
except FileNotFoundError:
pass
misc.compile(["-f", "cudacpp.mk", f"BACKEND=cppauto", f"BACKEND_LOG={backend_log}", "detect-backend"], **opts)
try:
with open(backend_log, "r") as f:
resolved_backend = f.read().strip()
logger.info(f"Backend '{cudacpp_backend}' resolved as '{resolved_backend}'")
cudacpp_backend = resolved_backend
except FileNotFoundError:
raise RuntimeError("Could not resolve cudacpp_backend=cppauto|cpp; ensure Makefile detection runs properly.")
logger.info(f"Building madevent in madevent_interface.py with '{cudacpp_backend}' matrix elements")
if cudacpp_backend in cudacpp_supported_backends :
args[0][0] = 'madevent_' + cudacpp_backend + '_link'
else:
raise Exception( "Invalid cudacpp_backend='%s': supported backends are %s"%supported_backends )
raise Exception(f"Invalid cudacpp_backend='{cudacpp_backend}': supported backends are [ '" + "', '".join(cudacpp_supported_backends) + "' ]")
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)
else:
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ endif
#=== Redefine BACKEND if the current value is 'cppauto'

# Set the default BACKEND choice corresponding to 'cppauto' (the 'best' C++ vectorization available: eventually use native instead?)
BACKEND_ORIG := $(BACKEND)
ifeq ($(BACKEND),cppauto)
ifeq ($(UNAME_P),ppc64le)
override BACKEND = cppsse4
Expand All @@ -80,6 +81,11 @@ else
$(info BACKEND='$(BACKEND)')
endif

# Create file with the resolved backend in case user chooses 'cppauto'
BACKEND_LOG ?= .resolved-backend
ifneq ($(BACKEND_ORIG),$(BACKEND))
$(file >$(BACKEND_LOG),$(BACKEND))
endif
#-------------------------------------------------------------------------------

#=== Configure the C++ compiler
Expand Down Expand Up @@ -1235,4 +1241,9 @@ endif
cuda-memcheck: all.$(TAG)
$(RUNTIME) $(CUDA_HOME)/bin/cuda-memcheck --check-api-memory-access yes --check-deprecated-instr yes --check-device-heap yes --demangle full --language c --leak-check full --racecheck-report all --report-api-errors all --show-backtrace yes --tool memcheck --track-unused-memory yes $(BUILDDIR)/check_$(GPUSUFFIX).exe -p 2 32 2

# Detect backend (to be used in case of 'cppauto' to give info to the user)
.PHONY: detect-backend
detect-backend:
@echo "Resolved backend has already been written to $(BACKEND_LOG) at parse time."

#-------------------------------------------------------------------------------