diff --git a/DataFormats/SoATemplate/interface/SoALayout.h b/DataFormats/SoATemplate/interface/SoALayout.h index 3e5a53cd83097..97e7fa3dc2979 100644 --- a/DataFormats/SoATemplate/interface/SoALayout.h +++ b/DataFormats/SoATemplate/interface/SoALayout.h @@ -493,10 +493,17 @@ _ITERATE_ON_ALL(_DEFINE_METADATA_MEMBERS, ~, __VA_ARGS__) \ \ struct value_element { \ - SOA_HOST_DEVICE SOA_INLINE value_element( \ - _ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__) \ - ) : \ - _ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_INITIALIZERS, ~, __VA_ARGS__) \ + SOA_HOST_DEVICE SOA_INLINE value_element \ + BOOST_PP_IF( \ + BOOST_PP_SEQ_SIZE(_ITERATE_ON_ALL(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__) ), \ + (_ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__)):, \ + ()) \ + BOOST_PP_TUPLE_ENUM(BOOST_PP_IF( \ + BOOST_PP_SEQ_SIZE(_ITERATE_ON_ALL(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__)), \ + BOOST_PP_SEQ_TO_TUPLE(_ITERATE_ON_ALL(_VALUE_ELEMENT_INITIALIZERS, ~, __VA_ARGS__)), \ + () \ + ) \ + ) \ {} \ \ _ITERATE_ON_ALL(_DEFINE_VALUE_ELEMENT_MEMBERS, ~, __VA_ARGS__) \ diff --git a/DataFormats/SoATemplate/test/SoALayoutAndView_t.cu b/DataFormats/SoATemplate/test/SoALayoutAndView_t.cu index 34dda3bd7a803..d8a92a56bf37a 100644 --- a/DataFormats/SoATemplate/test/SoALayoutAndView_t.cu +++ b/DataFormats/SoATemplate/test/SoALayoutAndView_t.cu @@ -67,6 +67,11 @@ GENERATE_SOA_VIEW(SoAFullDeviceConstViewTemplate, using SoAFullDeviceView = SoAFullDeviceViewTemplate; +// These SoAs validate that the generating macros do not get confused in the special case where there are +// no columns and only scalar elements in the SoA. +GENERATE_SOA_LAYOUT(TestSoALayoutNoColumn, SOA_SCALAR(double, r)) +GENERATE_SOA_LAYOUT(TestSoALayoutNoColumn2, SOA_SCALAR(double, r), SOA_SCALAR(double, r2)) + // Eigen cross product kernel (on store) __global__ void crossProduct(SoAHostDeviceView soa, const unsigned int numElements) { int i = blockIdx.x * blockDim.x + threadIdx.x; diff --git a/DataFormats/SoATemplate/test/SoALayoutAndView_t.hip.cc b/DataFormats/SoATemplate/test/SoALayoutAndView_t.hip.cc index a70b9fb1d933b..a1cadfd0bd6c2 100644 --- a/DataFormats/SoATemplate/test/SoALayoutAndView_t.hip.cc +++ b/DataFormats/SoATemplate/test/SoALayoutAndView_t.hip.cc @@ -69,6 +69,12 @@ GENERATE_SOA_VIEW(SoAFullDeviceConstViewTemplate, using SoAFullDeviceView = SoAFullDeviceViewTemplate; + +// These SoAs validate that the generating macros do not get confused in the special case where there are +// no columns and only scalar elements in the SoA. +GENERATE_SOA_LAYOUT(TestSoALayoutNoColumn, SOA_SCALAR(double, r)) +GENERATE_SOA_LAYOUT(TestSoALayoutNoColumn2, SOA_SCALAR(double, r), SOA_SCALAR(double, r2)) + // Eigen cross product kernel (on store) __global__ void crossProduct(SoAHostDeviceView soa, const int numElements) { int i = blockIdx.x * blockDim.x + threadIdx.x;