Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Fix 826" (actually: fix iconfig-channel mapping) #852

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MG5aMC/mg5amcnlo
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
#ifndef COLORAMPS_H
#define COLORAMPS_H 1

#include <map>

namespace mgOnGpu
{

__device__ constexpr bool icolamp[%(nb_channel)s][%(nb_color)s] = {
__device__ std::map<int,int> diag_to_channel = {
%(diag_to_channel)s
};
__device__ constexpr bool icolamp[%(nb_channel)s][%(nb_color)s] = {
%(is_LC)s
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
// Event-by-event random choice of color #402
if( channelId != 0 ) // no event-by-event choice of color if channelId == 0 (fix FPE #783)
{
const unsigned int channelIdC = channelId - 1; // coloramps.h uses the C array indexing starting at 0
const unsigned int channelIdC = mgOnGpu::diag_to_channel[channelId]; // coloramps.h uses a channel ordering not the diagram id
fptype targetamp[ncolor] = { 0 };
for( int icolC = 0; icolC < ncolor; icolC++ )
{
Expand Down Expand Up @@ -115,7 +115,7 @@
// - firstprivate: give each thread its own copy, and initialise with value from outside
#define _OMPLIST0 allcouplings, allMEs, allmomenta, allrndcol, allrndhel, allselcol, allselhel, cGoodHel, cNGoodHel, npagV2
#ifdef MGONGPU_SUPPORTS_MULTICHANNEL
#define _OMPLIST1 , allDenominators, allNumerators, channelId, mgOnGpu::icolamp
#define _OMPLIST1 , allDenominators, allNumerators, channelId, mgOnGpu::icolamp,mgOnGpu::diag_to_channel
#else
#define _OMPLIST1
#endif
Expand Down Expand Up @@ -187,7 +187,7 @@
// Event-by-event random choice of color #402
if( channelId != 0 ) // no event-by-event choice of color if channelId == 0 (fix FPE #783)
{
const unsigned int channelIdC = channelId - 1; // coloramps.h uses the C array indexing starting at 0
const unsigned int channelIdC = mgOnGpu::diag_to_channel[channelId]; // coloramps.h uses a channel ordering not the diagram id
fptype_sv targetamp[ncolor] = { 0 };
for( int icolC = 0; icolC < ncolor; icolC++ )
{
Expand Down
34 changes: 31 additions & 3 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,8 +1433,7 @@ def generate_process_files(self):
self.edit_check_sa()
self.edit_mgonGPU()
self.edit_processidfile() # AV new file (NB this is Sigma-specific, should not be a symlink to Subprocesses)
if self.include_multi_channel:
self.edit_coloramps() # AV new file (NB this is Sigma-specific, should not be a symlink to Subprocesses)

self.edit_testxxx() # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
self.edit_memorybuffers() # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
self.edit_memoryaccesscouplings() # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
Expand Down Expand Up @@ -1512,19 +1511,47 @@ def edit_processidfile(self):
ff.write(template % replace_dict)
ff.close()


def generate_subprocess_directory_end(self, **opt):
""" opt contain all local variable of the fortran original function"""
if self.include_multi_channel:
#self.edit_coloramps() # AV new file (NB this is Sigma-specific, should not be a symlink to Subprocesses)
subproc_diagrams_for_config = opt['subproc_diagrams_for_config']
misc.sprint(len(subproc_diagrams_for_config))
self.edit_coloramps( subproc_diagrams_for_config)

# AV - new method
def edit_coloramps(self):
def edit_coloramps(self, config_subproc_map):
"""Generate coloramps.h"""


###misc.sprint('Entering PLUGIN_OneProcessExporter.edit_coloramps')
template = open(pjoin(self.template_path,'gpu','coloramps.h'),'r').read()
ff = open(pjoin(self.path, 'coloramps.h'),'w')
# The following five lines from OneProcessExporterCPP.get_sigmaKin_lines (using OneProcessExporterCPP.get_icolamp_lines)
replace_dict={}

lines = []
# Output only configs that have some corresponding diagrams
iconfig = 0
for config in config_subproc_map:
if set(config) == set([0]):
continue
lines.append(" {%i, %i}," % (config[0], iconfig))
iconfig += 1
replace_dict['diag_to_channel'] = '\n'.join(lines)
misc.sprint(replace_dict)

if self.include_multi_channel: # NB unnecessary as edit_coloramps is not called otherwise...
multi_channel = self.get_multi_channel_dictionary(self.matrix_elements[0].get('diagrams'), self.include_multi_channel)
replace_dict['is_LC'] = self.get_icolamp_lines(multi_channel, self.matrix_elements[0], 1)
replace_dict['nb_channel'] = len(multi_channel)
replace_dict['nb_color'] = max(1,len(self.matrix_elements[0].get('color_basis')))

misc.sprint(multi_channel)
misc.sprint(self.path, os.getcwd())
#raise Exception

# AV extra formatting (e.g. gg_tt was "{{true,true};,{true,false};,{false,true};};")
replace_dict['is_LC'] = replace_dict['is_LC'].replace(',',', ').replace('{{',' { ').replace('};, {',' },\n { ').replace('};};',' }')
ff.write(template % replace_dict)
Expand Down Expand Up @@ -1676,6 +1703,7 @@ def get_reset_jamp_lines(self, color_amplitudes):
if ret_lines != '' : ret_lines = ' // Reset jamp (reset color flows)\n' + ret_lines # AV THIS SHOULD NEVER HAPPEN!
return ret_lines


#------------------------------------------------------------------------------------

import madgraph.core.helas_objects as helas_objects
Expand Down
Loading