Skip to content

Commit cf822a0

Browse files
better formatting for the card from the start and adding the possiblitity to choose avx
1 parent 95e9fd0 commit cf822a0

3 files changed

Lines changed: 66 additions & 19 deletions

File tree

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

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ def compile(self, *args, **opts):
3030
import multiprocessing
3131
if not self.options['nb_core'] or self.options['nb_core'] == 'None':
3232
self.options['nb_core'] = multiprocessing.cpu_count()
33-
if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
34-
import pathlib
35-
import os
36-
pjoin = os.path.join
37-
if 'cwd' in opts:
38-
path = pjoin(opts['cwd'], os.pardir, os.pardir, 'Source', 'make_opts')
39-
common_run_interface.CommonRunCmd.update_make_opts_full(
40-
path,
41-
{'FPTYPE': self.run_card['floating_type']})
33+
34+
if 'cwd' in opts and os.path.basename(opts['cwd']) == 'Source':
35+
path = pjoin(opts['cwd'], 'make_opts')
36+
avx_type = self.run_card['avx_type'] if self.run_card['avx_type'] != 'auto' else ''
37+
common_run_interface.CommonRunCmd.update_make_opts_full(path,
38+
{'FPTYPE': self.run_card['floating_type'],
39+
'AVX': avx_type })
40+
misc.sprint('FPTYPE checked')
41+
42+
43+
if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
4244
cudacpp_backend = self.run_card['cudacpp_backend'].upper() # the default value is defined in banner.py
4345
logger.info("Building madevent in madevent_interface.py with '%s' matrix elements"%cudacpp_backend)
4446
if cudacpp_backend == 'FORTRAN':
@@ -53,7 +55,26 @@ def compile(self, *args, **opts):
5355
else:
5456
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)
5557

58+
59+
# Phase-Space Optimization ------------------------------------------------------------------------------------
60+
template_on = \
61+
"""#*********************************************************************
62+
# SIMD/GPU Parametrization
63+
#*********************************************************************
64+
%(floating_type)s = floating_type ! single precision(f), double precision (d), mixed (m) [double for amplitude, single for color]
65+
%(avx_type)s = avx_type ! for SIMD, technology to use for the vectorization
66+
%(cudacpp_backend)s = cudacpp_backend ! Fortran/CPP/CUDA switch mode to use
67+
"""
68+
69+
template_off = ''
70+
71+
plugin_block = banner_mod.RunBlock('simd', template_on=template_on, template_off=template_off)
72+
73+
5674
class CPPRunCard(banner_mod.RunCardLO):
75+
76+
blocks = banner_mod.RunCardLO.blocks + [plugin_block]
77+
5778
def reset_simd(self, old_value, new_value, name):
5879
if not hasattr(self, 'path'):
5980
logger.warning('WARNING! CPPRunCard instance has no attribute path')
@@ -67,12 +88,17 @@ def reset_simd(self, old_value, new_value, name):
6788

6889
def reset_makeopts(self, old_value, new_value, name):
6990

70-
misc.sprint("PASS IN RESET MAKEOPTS", old_value, new_value, name)
7191
if not hasattr(self, 'path'):
7292
raise Exception
7393

94+
avx_value = self['avx_type'] if self['avx_type'] != 'auto' else ''
95+
7496
if name == 'floating_type':
75-
common_run_interface.CommonRunCmd.update_make_opts_full({'FPTYPE': new_value})
97+
common_run_interface.CommonRunCmd.update_make_opts_full({'FPTYPE': new_value, 'AVX': avx_value})
98+
elif name == 'avx_type':
99+
if new_value == 'Auto':
100+
new_value = ''
101+
common_run_interface.CommonRunCmd.update_make_opts_full({'FPTYPE': self['floating_type'], 'AVX': new_value})
76102
else:
77103
raise Exception
78104

@@ -84,9 +110,22 @@ def plugin_input(self, finput):
84110

85111
def default_setup(self):
86112
super().default_setup()
87-
self.add_param('cudacpp_backend', 'CPP', include=False, hidden=False)
88113
self.add_param('floating_type', 'd', include=False, hidden=False,
89-
fct_mod=(self.reset_makeopts,(),{}))
114+
fct_mod=(self.reset_makeopts,(),{}),
115+
allowed=['m','d','f'])
116+
self.add_param('avx_type', 'auto', include=False, hidden=False,
117+
fct_mod=(self.reset_makeopts,(),{}),
118+
allowed=['auto', 'none', 'sse4', 'avx2','512y','512z'])
119+
self.add_param('cudacpp_backend', 'CPP', include=False, hidden=False,
120+
allowed=['Fortan', 'CPP', 'CUDA'])
121+
self['vector_size'] = 16 # already setup in default class (just change value)
122+
self['aloha_flag'] = '--fast-math'
123+
self['matrix_flag'] = '-O3'
124+
self.display_block.append('simd')
125+
self.display_block.append('psoptim')
126+
127+
128+
>>>>>>> 746f16476 (better formatting for the card from the start and adding the possiblitity to choose avx)
90129

91130
def write_one_include_file(self, output_dir, incname, output_file=None):
92131
"""write one include file at the time"""
@@ -104,10 +143,13 @@ def check_validity(self):
104143
self['hel_recycling'] = False
105144

106145
class GPURunCard(CPPRunCard):
146+
107147
def default_setup(self):
108-
super(CPPRunCard, self).default_setup()
109-
self.add_param('cudacpp_backend', 'CUDA', include=False, hidden=False)
110-
self.add_param('floating_type', 'd', include=False, hidden=False)
148+
149+
super().default_setup()
150+
# change default value:
151+
self['cudacpp_backend'] = 'CUDA'
152+
self['vector_size'] = 16384 # already setup in default class (just change value)
111153

112154

113155
MEINTERFACE = CPPMEInterface

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

Lines changed: 7 additions & 2 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']
@@ -237,7 +241,8 @@ def finalize(self, matrix_element, cmdhistory, MG5options, outputflag):
237241
raise Exception('ERROR! the O/S call to patchMad.sh failed')
238242
# Additional patching (OM)
239243
self.add_madevent_plugin_fct() # Added by OM
240-
return super().finalize(matrix_element, cmdhistory, MG5options, outputflag)
244+
# do not call standard finalize since is this is already done...
245+
#return super().finalize(matrix_element, cmdhistory, MG5options, outputflag)
241246

242247
# AV (default from OM's tutorial) - overload settings and add a debug printout
243248
def modify_grouping(self, matrix_element):

0 commit comments

Comments
 (0)