Skip to content

Commit a30fd57

Browse files
committed
[oct23av] in CODEGEN, improve formatting and add an optional CUDACPPRunCard, but this does not solve code generation
1 parent b940731 commit a30fd57

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/launch_plugin.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,15 @@
2323
import madgraph.various.banner as banner_mod
2424

2525
class CPPMEInterface(madevent_interface.MadEventCmdShell):
26-
2726
def compile(self, *args, **opts):
2827
""" """
29-
3028
import multiprocessing
3129
if not self.options['nb_core'] or self.options['nb_core'] == 'None':
3230
self.options['nb_core'] = multiprocessing.cpu_count()
33-
3431
if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
3532
import pathlib
3633
import os
3734
pjoin = os.path.join
38-
39-
40-
41-
4235
cudacpp_backend = self.run_card['cudacpp_backend'].upper() # the default value is defined in banner.py
4336
logger.info("Building madevent in madevent_interface.py with '%s' matrix elements"%cudacpp_backend)
4437
if cudacpp_backend == 'FORTRAN':
@@ -54,15 +47,12 @@ def compile(self, *args, **opts):
5447
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)
5548

5649
class CPPRunCard(banner_mod.RunCardLO):
57-
5850
def reset_simd(self, old_value, new_value, name):
5951
if not hasattr(self, 'path'):
6052
raise Exception
61-
6253
if name == "vector_size" and new_value <= int(old_value):
6354
# code can handle the new size -> do not recompile
6455
return
65-
6656
Sourcedir = pjoin(os.path.dirname(os.path.dirname(self.path)), 'Source')
6757
subprocess.call(['make', 'cleanavx'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
6858

@@ -72,33 +62,31 @@ def plugin_input(self, finput):
7262
def default_setup(self):
7363
super().default_setup()
7464
self.add_param('cudacpp_backend', 'CPP', include=False, hidden=False)
75-
7665

7766
def write_one_include_file(self, output_dir, incname, output_file=None):
7867
"""write one include file at the time"""
79-
8068
if incname == "vector.inc" and 'vector_size' not in self.user_set:
8169
return
8270
super().write_one_include_file(output_dir, incname, output_file)
8371

84-
8572
def check_validity(self):
8673
"""ensure that PLUGIN information are consistent"""
87-
8874
super().check_validity()
89-
9075
if self['SDE_strategy'] != 1:
9176
logger.warning('SDE_strategy different of 1 is not supported with SMD/GPU mode')
9277
self['sde_strategy'] = 1
93-
9478
if self['hel_recycling']:
9579
self['hel_recycling'] = False
9680

9781
class GPURunCard(CPPRunCard):
98-
9982
def default_setup(self):
10083
super(CPPRunCard, self).default_setup()
10184
self.add_param('cudacpp_backend', 'CUDA', include=False, hidden=False)
102-
85+
86+
#class CUDACPPRunCard(CPPRunCard):
87+
# def default_setup(self):
88+
# super(CPPRunCard, self).default_setup()
89+
# self.add_param('cudacpp_backend', 'CPP', include=False, hidden=False)
90+
10391
MEINTERFACE = CPPMEInterface
10492
RunCard = CPPRunCard

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/output.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ def add_madevent_plugin_fct(self):
272272
plugin_path = os.path.dirname(os.path.realpath( __file__ ))
273273
###files.cp(pjoin(plugin_path, 'plugin_interface.py'), pjoin(self.dir_path, 'bin', 'internal')) # AV FIXME (added by OM, but file is missing?)
274274
files.cp(pjoin(plugin_path, 'launch_plugin.py'), pjoin(self.dir_path, 'bin', 'internal'))
275-
files.ln( pjoin(self.dir_path, 'lib'), pjoin(self.dir_path, 'SubProcesses'))
275+
files.ln(pjoin(self.dir_path, 'lib'), pjoin(self.dir_path, 'SubProcesses'))
276276

277277
#------------------------------------------------------------------------------------
278-
class SIMD_ProcessExporter(PLUGIN_ProcessExporter):
279278

279+
class SIMD_ProcessExporter(PLUGIN_ProcessExporter):
280280
def change_output_args(args, cmd):
281281
""" """
282282
cmd._export_format = "madevent"
@@ -285,11 +285,10 @@ def change_output_args(args, cmd):
285285
if 'vector_size' not in ''.join(args):
286286
args.append('--vector_size=16')
287287
return args
288-
289-
290-
291-
class GPU_ProcessExporter(PLUGIN_ProcessExporter):
292288

289+
#------------------------------------------------------------------------------------
290+
291+
class GPU_ProcessExporter(PLUGIN_ProcessExporter):
293292
def change_output_args(args, cmd):
294293
""" """
295294
cmd._export_format = "madevent"
@@ -300,11 +299,12 @@ def change_output_args(args, cmd):
300299
return args
301300

302301
def finalize(self, matrix_element, cmdhistory, MG5options, outputflag):
303-
304302
misc.sprint("enter dedicated function")
305303
out = super().finalize(matrix_element, cmdhistory, MG5options, outputflag)
306-
#change RunCard class to have default for GPU
304+
# OM change RunCard class to have default for GPU
307305
text = open(pjoin(self.dir_path, 'bin', 'internal', 'launch_plugin.py'), 'r').read()
308306
text = text.replace('RunCard = CPPRunCard', 'RunCard = GPURunCard')
309307
open(pjoin(self.dir_path, 'bin', 'internal', 'launch_plugin.py'), 'w').write(text)
310308
return out
309+
310+
#------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)