Skip to content

Commit

Permalink
[patch] in CODEGEN PLUGIN_ProcessExporter.copy_template, copy the mod…
Browse files Browse the repository at this point in the history
…ified Fortran makefile if this is madevent + cudacpp madgraph5#656
  • Loading branch information
valassi committed Jun 2, 2023
1 parent d63c375 commit 3bc3d34
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ class PLUGIN_ProcessExporter(PLUGIN_export_cpp.ProcessExporterGPU):
template_Sub_make = pjoin(PLUGINDIR, 'madgraph', 'iolibs', 'template_files','gpu','cudacpp.mk')
template_tst_make = pjoin(PLUGINDIR, 'madgraph', 'iolibs', 'template_files','gpu','cudacpp_test.mk')

# AV - add the path to the modified Fortran templates
templatelo_Sub = pjoin(PLUGINDIR, 'Template', 'LO', 'SubProcesses')

# AV - use a custom UFOModelConverter (model/aloha exporter)
###create_model_class = PLUGIN_export_cpp.UFOModelConverterGPU
create_model_class = model_handling.PLUGIN_UFOModelConverter
Expand All @@ -151,15 +154,15 @@ def __init__(self, *args, **kwargs):
misc.sprint('Entering PLUGIN_ProcessExporter.__init__ (initialise the exporter)')
return super().__init__(*args, **kwargs)

# AV - overload the default version: create CMake directory, do not create lib directory; patch the fortran templates
# AV - overload the default version: create CMake directory, do not create lib directory; copy the patched fortran templates
def copy_template(self, model):
misc.sprint('Entering PLUGIN_ProcessExporter.copy_template (initialise the directory)')
if os.path.exists(self.dir_path):
misc.sprint('Top-level directory %s already exists: this is madevent + cudacpp' % self.dir_path)
self.standalone_cudacpp = True
self.standalone_cudacpp = False
else:
misc.sprint('Top-level directory %s does not exist yet: this is standalone_cudacpp' % self.dir_path)
self.standalone_cudacpp = False
self.standalone_cudacpp = True
try: os.mkdir(self.dir_path)
except os.error as error: logger.warning(error.strerror + ' ' + self.dir_path)
with misc.chdir(self.dir_path):
Expand All @@ -185,6 +188,11 @@ def copy_template(self, model):
if self.template_tst_make:
makefile_test = self.read_template_file(self.template_tst_make) % {'model': self.get_model_name(model.get('name'))}
open(os.path.join('test', 'cudacpp_test.mk'), 'w').write(makefile_test)
# For madevent + cudacpp: copy the modified Fortran templates (replacing patchMad.sh #656)
if not self.standalone_cudacpp:
misc.sprint('In PLUGIN_ProcessExporter.copy_template: copy the modified Fortran templates')
txt = self.read_template_file(self.templatelo_Sub+'/makefile')
open(os.path.join('SubProcesses', 'makefile'), 'w').write(txt)

# AV - add debug printouts (in addition to the default one from OM's tutorial)
# (NB: this is only called in standalone_cudacpp, not in madevent + cudacpp)
Expand Down

0 comments on commit 3bc3d34

Please sign in to comment.