Skip to content

Commit

Permalink
fixing issue of stefan with nprocesses>1
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermattelaer committed Aug 31, 2023
1 parent 9fc9873 commit 5b22a92
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
38 changes: 38 additions & 0 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/launch_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import madgraph.various.misc as misc
import madgraph.interface.extended_cmd as extended_cmd
import logging

logger = logging.getLogger('cmdprint') # for stdout

try:
import madgraph
except:
import internal.madevent_interface as madevent_interface
else:
import madgraph.interface.madevent_interface as madevent_interface

class CPPMEInterface(madevent_interface.MadEventCmdShell):

def compile(self, *args, **opts):
""" """
import multiprocessing
if not self.options['nb_core'] or self.options['nb_core'] == 'None':
self.options['nb_core'] = multiprocessing.cpu_count()

if args and args[0][0] == 'madevent' and hasattr(self, 'run_card'):
cudacpp_backend = self.run_card['cudacpp_backend'] # the default value is defined in banner.py
logger.info("Building madevent in madevent_interface.py with '%s' matrix elements"%cudacpp_backend)
if cudacpp_backend == 'FORTRAN':
args[0][0] = 'madevent_fortran_link'
elif cudacpp_backend == 'CPP':
args[0][0] = 'madevent_cpp_link'
elif cudacpp_backend == 'CUDA':
args[0][0] = 'madevent_cuda_link'
else:
raise Exception("Invalid cudacpp_backend='%s': only 'FORTRAN', 'CPP', 'CUDA' are supported")
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)
else:
return misc.compile(nb_core=self.options['nb_core'], *args, **opts)

MEINTERFACE = CPPMEInterface
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ namespace mg5amcCpu
{
// nprocesses>1 was last observed for "mirror processes" in uux_ttx in the 270 branch (see issue #343 and PRs #360 and #396)
constexpr int nprocesses = %(nproc)i;
static_assert( nprocesses == 1, "Assume nprocesses == 1" );
// process_id corresponds to the index of DSIG1 Fortran functions (must be 1 because cudacpp is unable to handle DSIG2)
static_assert( nprocesses == 1 || nprocesses == 2, "Assume nprocesses == 1 or 2" );
constexpr int process_id = %(proc_id)i; // code generation source: %(proc_id_source)s
static_assert( process_id == 1, "Assume process_id == 1" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,13 @@ def get_sigmaKin_lines(self, color_amplitudes, write=True):
replace_dict = super().get_sigmaKin_lines(color_amplitudes, write=False)
replace_dict['proc_id'] = self.proc_id if self.proc_id>0 else 1
replace_dict['proc_id_source'] = 'madevent + cudacpp exporter' if self.proc_id>0 else 'standalone_cudacpp' # FIXME? use self.in_madevent_mode instead?

# Extract denominator (avoid to extend size for mirroring)
den_factors = [str(me.get_denominator_factor()) for me in \
self.matrix_elements]
replace_dict['den_factors'] = ",".join(den_factors)
misc.sprint(replace_dict['den_factors'])

if write:
file = self.read_template_file(self.process_sigmaKin_function_template) % replace_dict
file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_sigmaKin_function.inc (copyright)
Expand Down

0 comments on commit 5b22a92

Please sign in to comment.