Skip to content

Commit 746f164

Browse files
better formatting for the card from the start and adding the possiblitity to choose avx
1 parent 114a816 commit 746f164

3 files changed

Lines changed: 61 additions & 23 deletions

File tree

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

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,16 @@ def compile(self, *args, **opts):
2929
if not self.options['nb_core'] or self.options['nb_core'] == 'None':
3030
self.options['nb_core'] = multiprocessing.cpu_count()
3131

32-
if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
33-
import pathlib
34-
import os
35-
pjoin = os.path.join
36-
if 'cwd' in opts:
37-
path = pjoin(opts['cwd'], os.pardir, os.pardir, 'Source', 'make_opts')
38-
common_run_interface.CommonRunCmd.update_make_opts_full(
39-
path,
40-
{'FPTYPE': self.run_card['floating_type']})
32+
if 'cwd' in opts and os.path.basename(opts['cwd']) == 'Source':
33+
path = pjoin(opts['cwd'], 'make_opts')
34+
avx_type = self.run_card['avx_type'] if self.run_card['avx_type'] != 'auto' else ''
35+
common_run_interface.CommonRunCmd.update_make_opts_full(path,
36+
{'FPTYPE': self.run_card['floating_type'],
37+
'AVX': avx_type })
38+
misc.sprint('FPTYPE checked')
4139

4240

43-
44-
41+
if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
4542
cudacpp_backend = self.run_card['cudacpp_backend'].upper() # the default value is defined in banner.py
4643
logger.info("Building madevent in madevent_interface.py with '%s' matrix elements"%cudacpp_backend)
4744
if cudacpp_backend == 'FORTRAN':
@@ -56,8 +53,26 @@ def compile(self, *args, **opts):
5653
else:
5754
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)
5855

56+
57+
# Phase-Space Optimization ------------------------------------------------------------------------------------
58+
template_on = \
59+
"""#*********************************************************************
60+
# SIMD/GPU Parametrization
61+
#*********************************************************************
62+
%(floating_type)s = floating_type ! single precision(f), double precision (d), mixed (m) [double for amplitude, single for color]
63+
%(avx_type)s = avx_type ! for SIMD, technology to use for the vectorization
64+
%(cudacpp_backend)s = cudacpp_backend ! Fortran/CPP/CUDA switch mode to use
65+
"""
66+
67+
template_off = ''
68+
69+
plugin_block = banner_mod.RunBlock('simd', template_on=template_on, template_off=template_off)
70+
71+
5972
class CPPRunCard(banner_mod.RunCardLO):
6073

74+
blocks = banner_mod.RunCardLO.blocks + [plugin_block]
75+
6176
def reset_simd(self, old_value, new_value, name):
6277
if not hasattr(self, 'path'):
6378
raise Exception
@@ -75,8 +90,14 @@ def reset_makeopts(self, old_value, new_value, name):
7590
if not hasattr(self, 'path'):
7691
raise Exception
7792

93+
avx_value = self['avx_type'] if self['avx_type'] != 'auto' else ''
94+
7895
if name == 'floating_type':
79-
common_run_interface.CommonRunCmd.update_make_opts_full({'FPTYPE': new_value})
96+
common_run_interface.CommonRunCmd.update_make_opts_full({'FPTYPE': new_value, 'AVX': avx_value})
97+
elif name == 'avx_type':
98+
if new_value == 'Auto':
99+
new_value = ''
100+
common_run_interface.CommonRunCmd.update_make_opts_full({'FPTYPE': self['floating_type'], 'AVX': new_value})
80101
else:
81102
raise Exception
82103

@@ -88,10 +109,21 @@ def plugin_input(self, finput):
88109

89110
def default_setup(self):
90111
super().default_setup()
91-
self.add_param('cudacpp_backend', 'CPP', include=False, hidden=False)
92112
self.add_param('floating_type', 'd', include=False, hidden=False,
93-
fct_mod=(self.reset_makeopts,(),{}))
94-
113+
fct_mod=(self.reset_makeopts,(),{}),
114+
allowed=['m','d','f'])
115+
self.add_param('avx_type', 'auto', include=False, hidden=False,
116+
fct_mod=(self.reset_makeopts,(),{}),
117+
allowed=['auto', 'none', 'sse4', 'avx2','512y','512z'])
118+
self.add_param('cudacpp_backend', 'CPP', include=False, hidden=False,
119+
allowed=['Fortan', 'CPP', 'CUDA'])
120+
self['vector_size'] = 16 # already setup in default class (just change value)
121+
self['aloha_flag'] = '--fast-math'
122+
self['matrix_flag'] = '-O3'
123+
self.display_block.append('simd')
124+
self.display_block.append('psoptim')
125+
126+
95127

96128
def write_one_include_file(self, output_dir, incname, output_file=None):
97129
"""write one include file at the time"""
@@ -115,10 +147,13 @@ def check_validity(self):
115147

116148
class GPURunCard(CPPRunCard):
117149

150+
118151
def default_setup(self):
119-
super(CPPRunCard, self).default_setup()
120-
self.add_param('cudacpp_backend', 'CUDA', include=False, hidden=False)
121-
self.add_param('floating_type', 'd', include=False, hidden=False)
152+
153+
super().default_setup()
154+
# change default value:
155+
self['cudacpp_backend'] = 'CUDA'
156+
self['vector_size'] = 16384 # already setup in default class (just change value)
122157

123158

124159
MEINTERFACE = CPPMEInterface

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ class PLUGIN_ProcessExporter(PLUGIN_export_cpp.ProcessExporterGPU):
149149
###helas_exporter = None
150150
helas_exporter = model_handling.PLUGIN_GPUFOHelasCallWriter # this is one of the main fixes for issue #341!
151151

152+
# Default class for the run_card to use
153+
from . import launch_plugin
154+
run_card_class = launch_plugin.CPPRunCard
155+
156+
152157
# AV (default from OM's tutorial) - add a debug printout
153158
def __init__(self, *args, **kwargs):
154159
self.in_madevent_mode = False # see MR #747
@@ -203,7 +208,6 @@ def finalize(self, matrix_element, cmdhistory, MG5options, outputflag):
203208
cmdhistory is the list of command used so far.
204209
MG5options are all the options of the main interface
205210
outputflags is a list of options provided when doing the output command"""
206-
misc.sprint('Entering PLUGIN_ProcessExporter.finalize', self.in_madevent_mode, type(self))
207211
if self.in_madevent_mode:
208212
self.add_input_for_banner()
209213
if 'CUDACPP_CODEGEN_PATCHLEVEL' in os.environ: patchlevel = os.environ['CUDACPP_CODEGEN_PATCHLEVEL']
@@ -221,7 +225,8 @@ def finalize(self, matrix_element, cmdhistory, MG5options, outputflag):
221225
raise Exception('ERROR! the O/S call to patchMad.sh failed')
222226

223227
self.add_madevent_plugin_fct()
224-
return super().finalize(matrix_element, cmdhistory, MG5options, outputflag)
228+
# do not call standard finalize since is this is already done...
229+
#return super().finalize(matrix_element, cmdhistory, MG5options, outputflag)
225230

226231
# AV (default from OM's tutorial) - overload settings and add a debug printout
227232
def modify_grouping(self, matrix_element):
@@ -254,11 +259,9 @@ def add_madevent_plugin_fct(self):
254259
"""
255260

256261
plugin_path = os.path.dirname(os.path.realpath( __file__ ))
257-
files.cp(pjoin(plugin_path, 'plugin_interface.py'), pjoin(self.dir_path, 'bin', 'internal'))
258262
files.cp(pjoin(plugin_path, 'launch_plugin.py'), pjoin(self.dir_path, 'bin', 'internal'))
259263
files.ln( pjoin(self.dir_path, 'lib'), pjoin(self.dir_path, 'SubProcesses'))
260264

261-
262265
#------------------------------------------------------------------------------------
263266
class SIMD_ProcessExporter(PLUGIN_ProcessExporter):
264267

0 commit comments

Comments
 (0)