From bed2e12ae4aae204b09b42b0c090d41165d78c5f Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Fri, 31 May 2024 16:47:59 +0200 Subject: [PATCH 1/6] try to fix the segfault on issue 826 --- MG5aMC/mg5amcnlo | 2 +- .../iolibs/template_files/gpu/coloramps.h | 7 +++- .../gpu/process_sigmaKin_function.inc | 4 +-- .../CUDACPP_SA_OUTPUT/model_handling.py | 34 +++++++++++++++++-- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/MG5aMC/mg5amcnlo b/MG5aMC/mg5amcnlo index f9f9579188..10378b3c09 160000 --- a/MG5aMC/mg5amcnlo +++ b/MG5aMC/mg5amcnlo @@ -1 +1 @@ -Subproject commit f9f95791884846ce82b5bf7997726222d8ffbe5e +Subproject commit 10378b3c0971e1a241fd9dc365e592c92d1f13ba diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h index 3972cf8e9a..1a11eb0e11 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h @@ -6,10 +6,15 @@ #ifndef COLORAMPS_H #define COLORAMPS_H 1 +#include + namespace mgOnGpu { - __device__ constexpr bool icolamp[%(nb_channel)s][%(nb_color)s] = { + __device__ std::map diag_to_channel = { + %(diag_to_channel)s + }; + __device__ constexpr bool icolamp[%(nb_channel)s][%(nb_color)s] = { %(is_LC)s }; diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc index 1ac5ecb303..1b12e4007b 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc @@ -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++ ) { @@ -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++ ) { diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py index 53213121d9..3e685227dc 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py @@ -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) @@ -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) @@ -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 From 41ddc38569b8e40b3e10b1a5fe43ee0486dc8810 Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Fri, 31 May 2024 17:25:25 +0200 Subject: [PATCH 2/6] fix a issue for omp compilation --- .../iolibs/template_files/gpu/process_sigmaKin_function.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc index 1b12e4007b..60f44b907d 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc @@ -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 From 5b6d065e49786c62211607a0e8f291e8fd274dbc Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Tue, 4 Jun 2024 00:18:19 +0200 Subject: [PATCH 3/6] increase readibility and move from map to array --- .../iolibs/template_files/gpu/coloramps.h | 23 +++++++-- .../gpu/process_sigmaKin_function.inc | 6 +-- .../CUDACPP_SA_OUTPUT/model_handling.py | 49 ++++++++++++++++--- 3 files changed, 65 insertions(+), 13 deletions(-) diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h index 1a11eb0e11..9a211494d3 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h @@ -10,10 +10,27 @@ namespace mgOnGpu { + // Summary of numbering and indexing conventions for the relevant concepts (see issue #826 and PR #852) + // - Diagram number (no variable) in [1, N_diagrams]: all values are allowed (N_diagrams distinct values) + // => this number is displayed for information before each block of code in CPPProcess.cc + // - Channel number ("channelId" in C, CHANNEL_ID in F) in [1, N_diagrams]: not all values are allowed (N_config <= N_diagrams distinct values) + // 0 is allowed to fallback to no multi-channel mode. + // => this number (with indexing like ps/pdf output) is passed around as an API argument between cudacpp functions + // - Channel number in C indexing: "channelIdC" = channelIdC_to_iconfig[channelId] + // => this number (with C indexing) is used as the index of the channelIdC_to_iconfig array below + // This correspond to iconfig on the fortran side (with iconfig = channelIdC + 1) + //NOTE: All those ordering are event by event specific (with the intent to have those fix within a vector size/wrap + + // Map channelId to channelIdC + // This array has N_diagrams+1 elements, but only N_config <= N_diagrams valid (non-zero) values + // The 0 entry is a fall back to still write events even if no multi-channel is setup (wrong color selected in that mode) + __device__ constexpr int channelId_to_channelIdC[%(nb_diag_plus_one)i] = { + 0, // channelId=0: This value means not multi-channel, color will be wrong anyway -> pick the first +%(diag_to_channel)s + }; - __device__ std::map diag_to_channel = { - %(diag_to_channel)s - }; + // Map iconfigC (in C indexing, i.e. iconfig-1) to the set of allowed colors + // This array has N_config <= N_diagrams elements __device__ constexpr bool icolamp[%(nb_channel)s][%(nb_color)s] = { %(is_LC)s }; diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc index 60f44b907d..a7524ab176 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc @@ -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 = mgOnGpu::diag_to_channel[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int channelIdC = mgOnGpu::channelId_to_channelIdC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype targetamp[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { @@ -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,mgOnGpu::diag_to_channel +#define _OMPLIST1 , allDenominators, allNumerators, channelId, mgOnGpu::icolamp,mgOnGpu::channelId_to_channelIdC #else #define _OMPLIST1 #endif @@ -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 = mgOnGpu::diag_to_channel[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int channelIdC = mgOnGpu::channelId_to_channelIdC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype_sv targetamp[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py index 3e685227dc..1780de04fc 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py @@ -1531,21 +1531,45 @@ def edit_coloramps(self, config_subproc_map): # 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 + + iconfig_to_diag = {} + diag_to_iconfig = {} + iconfig = 0 for config in config_subproc_map: if set(config) == set([0]): continue - lines.append(" {%i, %i}," % (config[0], iconfig)) iconfig += 1 + iconfig_to_diag[iconfig] = config[0] + diag_to_iconfig[config[0]] = iconfig + + misc.sprint(iconfig_to_diag) + misc.sprint(diag_to_iconfig) + + # Note that if the last diagram is/are not mapped to a channel nb_diag + # will be smaller than the true number of diagram. This is fine for color + # but maybe not for something else. + nb_diag = max(config[0] for config in config_subproc_map) + # Output which diagrams correspond ot a channel to get information for valid color + lines = [] + # Note: line for index 0 (no multi-channel is hardcoded in the template, so here we fill the array from index 1) + for diag in range(1, nb_diag+1): + if diag in diag_to_iconfig: + iconfig = diag_to_iconfig[diag] + channel = iconfig -1 # C convention + text = " %(channel)i, // channelId=%(diag)i (diagram=%(diag)i) i.e. channelIdC=%(channel)i --> iconfig=%(iconfig)i " + else: + iconfig = -1 + channel = -1 + text = " -1, // channelId=%(diag)i (diagram=%(diag)i): Not consider as a channel of integration (presence of 4 point interaction?)" + lines.append(text % {'diag': diag, 'channel': channel, 'iconfig': iconfig}) + 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_diag_plus_one'] = max(config[0] for config in config_subproc_map)+1 replace_dict['nb_color'] = max(1,len(self.matrix_elements[0].get('color_basis'))) misc.sprint(multi_channel) @@ -1553,8 +1577,19 @@ def edit_coloramps(self, config_subproc_map): #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) + split = replace_dict['is_LC'].split(';,') + misc.sprint(replace_dict['is_LC']) + for i in range(len(split)): + misc.sprint(split[i]) + split[i] = ' ' + split[i].replace(',',', ').replace('{{', '{') + misc.sprint(split[i]) + if '};};' in split[i]: + split[i] = split[i][:-4] + '}, // channelIdC=%i' % i + elif 'false' in split[i] or 'true' in split[i]: + split[i] += ', // channelIdC=%i' % i + misc.sprint(split[i]) + replace_dict['is_LC'] = '\n'.join(split) + ff.write(template % replace_dict) ff.close() # AV - new method From 63494ef7b72a9f0cdc71b1ec78628d14273b37d1 Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Tue, 4 Jun 2024 15:05:32 +0200 Subject: [PATCH 4/6] change to Andrea convention of naming (but removing step variable) --- .../iolibs/template_files/gpu/coloramps.h | 18 ++++++++++-------- .../gpu/process_sigmaKin_function.inc | 13 +++++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h index 9a211494d3..3d03a60630 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/coloramps.h @@ -13,18 +13,20 @@ namespace mgOnGpu // Summary of numbering and indexing conventions for the relevant concepts (see issue #826 and PR #852) // - Diagram number (no variable) in [1, N_diagrams]: all values are allowed (N_diagrams distinct values) // => this number is displayed for information before each block of code in CPPProcess.cc - // - Channel number ("channelId" in C, CHANNEL_ID in F) in [1, N_diagrams]: not all values are allowed (N_config <= N_diagrams distinct values) - // 0 is allowed to fallback to no multi-channel mode. + // - Channel number (CHANNEL_ID) in [0, N_diagrams]: not all values are allowed (N_config <= N_diagrams distinct values) // => this number (with indexing like ps/pdf output) is passed around as an API argument between cudacpp functions - // - Channel number in C indexing: "channelIdC" = channelIdC_to_iconfig[channelId] - // => this number (with C indexing) is used as the index of the channelIdC_to_iconfig array below - // This correspond to iconfig on the fortran side (with iconfig = channelIdC + 1) + // 0 is allowed to fallback to no multi-channel mode. + // - Channel number in C indexing: "IconfiC", this is the equivalent of the Fortran iconfig + // iconfigC = iconfig -1 + // provides a continuous index [0, N_config-1] for array + // iconfigC = ChannelId_to_iconfigC[channelId] //NOTE: All those ordering are event by event specific (with the intent to have those fix within a vector size/wrap - // Map channelId to channelIdC - // This array has N_diagrams+1 elements, but only N_config <= N_diagrams valid (non-zero) values + // Map channelId to iconfigC + // This array has N_diagrams+1 elements, but only N_config <= N_diagrams valid values + // unvalid values are set to -1 // The 0 entry is a fall back to still write events even if no multi-channel is setup (wrong color selected in that mode) - __device__ constexpr int channelId_to_channelIdC[%(nb_diag_plus_one)i] = { + __device__ constexpr int channelId_to_iconfigC[%(nb_diag_plus_one)i] = { 0, // channelId=0: This value means not multi-channel, color will be wrong anyway -> pick the first %(diag_to_channel)s }; diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc index a7524ab176..6bb586bad5 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc @@ -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 = mgOnGpu::channelId_to_channelIdC[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype targetamp[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { @@ -80,7 +80,7 @@ targetamp[icolC] = 0; else targetamp[icolC] = targetamp[icolC - 1]; - if( mgOnGpu::icolamp[channelIdC][icolC] ) targetamp[icolC] += jamp2_sv[icolC]; + if( mgOnGpu::icolamp[iconfigC][icolC] ) targetamp[icolC] += jamp2_sv[icolC]; } //printf( "sigmaKin: ievt=%%4d rndcol=%%f\n", ievt, allrndcol[ievt] ); for( int icolC = 0; icolC < ncolor; icolC++ ) @@ -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,mgOnGpu::channelId_to_channelIdC +#define _OMPLIST1 , allDenominators, allNumerators, channelId, mgOnGpu::icolamp,mgOnGpu::channelId_to_iconfigC #else #define _OMPLIST1 #endif @@ -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 = mgOnGpu::channelId_to_channelIdC[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype_sv targetamp[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { @@ -195,9 +195,10 @@ targetamp[icolC] = fptype_sv{ 0 }; else targetamp[icolC] = targetamp[icolC - 1]; - if( mgOnGpu::icolamp[channelIdC][icolC] ) targetamp[icolC] += jamp2_sv[icolC]; + if( mgOnGpu::icolamp[iconfigC][icolC] ) targetamp[icolC] += jamp2_sv[icolC]; } #if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT + const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype_sv targetamp2[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { @@ -205,7 +206,7 @@ targetamp2[icolC] = fptype_sv{ 0 }; else targetamp2[icolC] = targetamp2[icolC - 1]; - if( mgOnGpu::icolamp[channelIdC][icolC] ) targetamp2[icolC] += jamp2_sv[ncolor + icolC]; + if( mgOnGpu::icolamp[iconfigC][icolC] ) targetamp2[icolC] += jamp2_sv[ncolor + icolC]; } #endif for( int ieppV = 0; ieppV < neppV; ++ieppV ) From 2bcea7659c2e9b15ff22b5dd5684c0328ff8f6a7 Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Tue, 4 Jun 2024 15:23:26 +0200 Subject: [PATCH 5/6] trying to fix git issue --- .../template_files/gpu/process_sigmaKin_function.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc index 6bb586bad5..2ec052e3a1 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/madgraph/iolibs/template_files/gpu/process_sigmaKin_function.inc @@ -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 iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype targetamp[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { @@ -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,mgOnGpu::channelId_to_iconfigC +#define _OMPLIST1 , allDenominators, allNumerators, channelId, mgOnGpu::icolamp, mgOnGpu::channelId_to_iconfigC #else #define _OMPLIST1 #endif @@ -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 iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype_sv targetamp[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { @@ -198,7 +198,7 @@ if( mgOnGpu::icolamp[iconfigC][icolC] ) targetamp[icolC] += jamp2_sv[icolC]; } #if defined MGONGPU_CPPSIMD and defined MGONGPU_FPTYPE_DOUBLE and defined MGONGPU_FPTYPE2_FLOAT - const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id + const unsigned int iconfigC = mgOnGpu::channelId_to_iconfigC[channelId]; // coloramps.h uses a channel ordering not the diagram id fptype_sv targetamp2[ncolor] = { 0 }; for( int icolC = 0; icolC < ncolor; icolC++ ) { From 92a828413286c2320a38187d16048b3f0c2f14c3 Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Tue, 4 Jun 2024 15:43:55 +0200 Subject: [PATCH 6/6] better comment in coloramps --- .../PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py index 1780de04fc..2690a69cdb 100644 --- a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py @@ -1554,14 +1554,14 @@ def edit_coloramps(self, config_subproc_map): # Note: line for index 0 (no multi-channel is hardcoded in the template, so here we fill the array from index 1) for diag in range(1, nb_diag+1): if diag in diag_to_iconfig: - iconfig = diag_to_iconfig[diag] - channel = iconfig -1 # C convention - text = " %(channel)i, // channelId=%(diag)i (diagram=%(diag)i) i.e. channelIdC=%(channel)i --> iconfig=%(iconfig)i " + iconfigf = diag_to_iconfig[diag] + iconfigc = iconfigf - 1 # C convention + text = " %(iconfigc)i, // channelId=%(diag)i (diagram=%(diag)i) --> iconfig=%(iconfigf)i (f77 conv) and iconfigC=%(iconfigc)i (c conv)" else: - iconfig = -1 - channel = -1 + iconfigc = -1 + iconfigf = -1 text = " -1, // channelId=%(diag)i (diagram=%(diag)i): Not consider as a channel of integration (presence of 4 point interaction?)" - lines.append(text % {'diag': diag, 'channel': channel, 'iconfig': iconfig}) + lines.append(text % {'diag': diag, 'iconfigc': iconfigc, 'iconfigf':iconfigf}) replace_dict['diag_to_channel'] = '\n'.join(lines) @@ -1584,9 +1584,9 @@ def edit_coloramps(self, config_subproc_map): split[i] = ' ' + split[i].replace(',',', ').replace('{{', '{') misc.sprint(split[i]) if '};};' in split[i]: - split[i] = split[i][:-4] + '}, // channelIdC=%i' % i + split[i] = split[i][:-4] + '}, // iconfigC=%i, diag=%i' % (i, iconfig_to_diag[i+1]) elif 'false' in split[i] or 'true' in split[i]: - split[i] += ', // channelIdC=%i' % i + split[i] += ', // iconfigC=%i, diag=%i' % (i, iconfig_to_diag[i+1]) misc.sprint(split[i]) replace_dict['is_LC'] = '\n'.join(split) ff.write(template % replace_dict)