Skip to content

Commit e18247d

Browse files
committed
Modify FLV coupling view handling, given sometimes the size is zero
1 parent c03fdfd commit e18247d

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

madgraph/iolibs/template_files/madmatrix/cpp_hel_amps_h.inc

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,36 @@ namespace mg5amcCpu
4949

5050
struct FLV_COUPLING_VIEW {
5151

52-
const int* partner1;
53-
const int* partner2;
54-
const fptype* value;
52+
const int* const partner1;
53+
const int* const partner2;
54+
const fptype* const value;
5555

56-
__host__ __device__ FLV_COUPLING_VIEW() = default;
5756
__host__ __device__
58-
FLV_COUPLING_VIEW(const int* partner1_base,
59-
const int* partner2_base,
60-
const fptype* value_base,
61-
const int n)
62-
: partner1(partner1_base + n),
63-
partner2(partner2_base + n),
64-
value(value_base + 2*n) {}
57+
FLV_COUPLING_VIEW(const int* p1, const int* p2, const fptype* v)
58+
: partner1(p1), partner2(p2), value(v) {}
6559
};
6660

61+
template<int SIZE, int STRIDE>
62+
class FLV_COUPLING_ARRAY {
63+
64+
static_assert(SIZE >= 0, "flvCOUPs SIZE must be non-negative");
65+
static_assert(STRIDE > 0, "flvCOUPs STRIDE must be positive");
66+
const int* const partner1;
67+
const int* const partner2;
68+
const fptype* const value;
69+
70+
public:
71+
__host__ __device__
72+
FLV_COUPLING_ARRAY(const int* p1, const int* p2, const fptype* v)
73+
: partner1(p1), partner2(p2), value(v) {}
74+
75+
__host__ __device__
76+
FLV_COUPLING_VIEW operator[](const int i) const {
77+
return FLV_COUPLING_VIEW{
78+
partner1 + i*STRIDE,
79+
partner2 + i*STRIDE,
80+
value + i*2*STRIDE
81+
};
82+
}
83+
};
6784
%(function_declarations)s

madmatrix/model_handling.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,9 +2304,7 @@ def super_get_matrix_element_calls(self, matrix_element, color_amplitudes, multi
23042304
fptype* denominators = DEN_ACCESS::ieventAccessRecord( allDenominators, ievt0 );
23052305
#endif
23062306
// Create an array of views over the Flavor Couplings
2307-
FLV_COUPLING_VIEW flvCOUPs[nIPF];
2308-
for ( int idflv = 0; idflv < nIPF; idflv++ )
2309-
flvCOUPs[idflv] = FLV_COUPLING_VIEW{ cIPF_partner1, cIPF_partner2, cIPF_value, idflv * nMF };
2307+
FLV_COUPLING_ARRAY<nIPF, nMF> flvCOUPs{ cIPF_partner1, cIPF_partner2, cIPF_value };
23102308
23112309
// Reset color flows (reset jamp_sv) at the beginning of a new event or event page
23122310
for( int i = 0; i < ncolor; i++ ) { jamp_sv[i] = cxzero_sv(); }

0 commit comments

Comments
 (0)