1 #ifndef DataFormats_SoATemplate_interface_SoAView_h 2 #define DataFormats_SoATemplate_interface_SoAView_h 12 #define SOA_VIEW_LAYOUT(TYPE, NAME) (TYPE, NAME) 14 #define SOA_VIEW_LAYOUT_LIST(...) __VA_ARGS__ 16 #define SOA_VIEW_VALUE(LAYOUT_NAME, LAYOUT_MEMBER) (LAYOUT_NAME, LAYOUT_MEMBER, LAYOUT_MEMBER) 18 #define SOA_VIEW_VALUE_RENAME(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) (LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) 20 #define SOA_VIEW_VALUE_LIST(...) __VA_ARGS__ 46 template <
class C, SoAColumnType COLUMN_TYPE>
69 #define _DECLARE_VIEW_LAYOUT_PARAMETRIZED_TEMPLATE_IMPL(TYPE, NAME) \ 70 (using BOOST_PP_CAT(TYPE, _default) = BOOST_PP_CAT(TYPE, _StagedTemplates) < VIEW_ALIGNMENT, \ 71 VIEW_ALIGNMENT_ENFORCEMENT > ;) 73 #define _DECLARE_VIEW_LAYOUT_PARAMETRIZED_TEMPLATE(R, DATA, TYPE_NAME) \ 74 BOOST_PP_EXPAND(_DECLARE_VIEW_LAYOUT_PARAMETRIZED_TEMPLATE_IMPL TYPE_NAME) 79 #define _DECLARE_VIEW_LAYOUT_TYPE_ALIAS_IMPL(TYPE, NAME) using BOOST_PP_CAT(TypeOf_, NAME) = TYPE; 81 #define _DECLARE_VIEW_LAYOUT_TYPE_ALIAS(R, DATA, TYPE_NAME) \ 82 BOOST_PP_EXPAND(_DECLARE_VIEW_LAYOUT_TYPE_ALIAS_IMPL TYPE_NAME) 88 #define _DECLARE_VIEW_MEMBER_TYPE_ALIAS_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, CAST) \ 89 using BOOST_PP_CAT(TypeOf_, LOCAL_NAME) = \ 90 typename BOOST_PP_CAT(TypeOf_, LAYOUT_NAME)::Metadata::BOOST_PP_CAT(TypeOf_, LAYOUT_MEMBER); \ 91 using BOOST_PP_CAT(ParametersTypeOf_, LOCAL_NAME) = \ 92 typename BOOST_PP_CAT(TypeOf_, LAYOUT_NAME)::Metadata::BOOST_PP_CAT(ParametersTypeOf_, LAYOUT_MEMBER); \ 93 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, LOCAL_NAME) = \ 94 BOOST_PP_CAT(TypeOf_, LAYOUT_NAME)::Metadata::BOOST_PP_CAT(ColumnTypeOf_, LAYOUT_MEMBER); \ 95 using BOOST_PP_CAT(ConstAccessorOf_, LOCAL_NAME) = \ 96 typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 97 template ColumnType<BOOST_PP_CAT(ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 98 cms::soa::SoAAccessType::constAccess>::template Alignment<conditionalAlignment>:: \ 99 template RestrictQualifier<restrictQualify> ; \ 100 using BOOST_PP_CAT(MutableAccessorOf_, LOCAL_NAME) = \ 101 typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 102 template ColumnType<BOOST_PP_CAT(ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 103 cms::soa::SoAAccessType::mutableAccess>::template Alignment<conditionalAlignment>:: \ 104 template RestrictQualifier<restrictQualify> ; \ 105 SOA_HOST_DEVICE SOA_INLINE \ 106 const auto BOOST_PP_CAT(parametersOf_, LOCAL_NAME)() const { \ 107 return CAST(parent_.BOOST_PP_CAT(LOCAL_NAME, Parameters_)); \ 118 #define _DECLARE_VIEW_MEMBER_TYPE_ALIAS(R, DATA, LAYOUT_MEMBER_NAME) \ 119 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_TYPE_ALIAS_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 125 #define _DECLARE_VIEW_MEMBER_POINTERS_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 126 SOA_HOST_DEVICE SOA_INLINE auto* BOOST_PP_CAT(addressOf_, LOCAL_NAME)() { \ 127 return BOOST_PP_CAT(parametersOf_, LOCAL_NAME)().addr_; \ 131 #define _DECLARE_VIEW_MEMBER_POINTERS(R, DATA, LAYOUT_MEMBER_NAME) \ 132 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_POINTERS_IMPL LAYOUT_MEMBER_NAME) 138 #define _DECLARE_VIEW_MEMBER_CONST_POINTERS_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 139 SOA_HOST_DEVICE SOA_INLINE auto const* BOOST_PP_CAT(addressOf_, LOCAL_NAME)() const { \ 140 return BOOST_PP_CAT(parametersOf_, LOCAL_NAME)().addr_; \ 144 #define _DECLARE_VIEW_MEMBER_CONST_POINTERS(R, DATA, LAYOUT_MEMBER_NAME) \ 145 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_CONST_POINTERS_IMPL LAYOUT_MEMBER_NAME) 150 #define _DECLARE_VIEW_CONSTRUCTION_PARAMETERS_IMPL(LAYOUT_TYPE, LAYOUT_NAME, DATA) (DATA LAYOUT_TYPE & LAYOUT_NAME) 152 #define _DECLARE_VIEW_CONSTRUCTION_PARAMETERS(R, DATA, TYPE_NAME) \ 153 BOOST_PP_EXPAND(_DECLARE_VIEW_CONSTRUCTION_PARAMETERS_IMPL BOOST_PP_TUPLE_PUSH_BACK(TYPE_NAME, DATA)) 158 #define _DECLARE_VIEW_CONSTRUCTION_BYCOLUMN_PARAMETERS_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, DATA) \ 159 (DATA typename BOOST_PP_CAT(Metadata::ParametersTypeOf_, LOCAL_NAME)::TupleOrPointerType LOCAL_NAME) 161 #define _DECLARE_VIEW_CONSTRUCTION_BYCOLUMN_PARAMETERS(R, DATA, LAYOUT_MEMBER_NAME) \ 163 _DECLARE_VIEW_CONSTRUCTION_BYCOLUMN_PARAMETERS_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 170 #define _DECLARE_VIEW_MEMBER_INITIALIZERS_IMPL(LAYOUT, MEMBER, NAME) \ 171 (BOOST_PP_CAT(NAME, Parameters_)([&]() -> auto { \ 172 auto params = LAYOUT.metadata().BOOST_PP_CAT(parametersOf_, MEMBER)(); \ 173 if constexpr (alignmentEnforcement == AlignmentEnforcement::enforced) \ 174 if (reinterpret_cast<intptr_t>(params.addr_) % alignment) \ 175 throw std::runtime_error("In constructor by layout: misaligned column: " #NAME); \ 180 #define _DECLARE_VIEW_MEMBER_INITIALIZERS(R, DATA, LAYOUT_MEMBER_NAME) \ 181 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_INITIALIZERS_IMPL LAYOUT_MEMBER_NAME) 188 #define _UPDATE_SIZE_OF_VIEW_IMPL(LAYOUT_TYPE, LAYOUT_NAME) \ 190 if (ret != LAYOUT_NAME.metadata().size()) \ 191 throw std::runtime_error("In constructor by layout: different sizes from layouts."); \ 193 ret = LAYOUT_NAME.metadata().size(); \ 198 #define _UPDATE_SIZE_OF_VIEW(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_UPDATE_SIZE_OF_VIEW_IMPL TYPE_NAME) 205 #define _DECLARE_VIEW_MEMBER_INITIALIZERS_BYCOLUMN_IMPL(LAYOUT, MEMBER, NAME) \ 207 BOOST_PP_CAT(NAME, Parameters_)([&]() -> auto { \ 208 if constexpr (alignmentEnforcement == AlignmentEnforcement::enforced) \ 209 if (Metadata:: BOOST_PP_CAT(ParametersTypeOf_, NAME)::checkAlignment(NAME, alignment)) \ 210 throw std::runtime_error("In constructor by column: misaligned column: " #NAME); \ 216 #define _DECLARE_VIEW_MEMBER_INITIALIZERS_BYCOLUMN(R, DATA, LAYOUT_MEMBER_NAME) \ 217 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_INITIALIZERS_BYCOLUMN_IMPL LAYOUT_MEMBER_NAME) 222 #define _DECLARE_LAYOUT_LIST_IMPL(LAYOUT, NAME) (NAME) 224 #define _DECLARE_LAYOUT_LIST(R, DATA, LAYOUT_MEMBER_NAME) BOOST_PP_EXPAND(_DECLARE_LAYOUT_LIST_IMPL LAYOUT_MEMBER_NAME) 229 #define _DECLARE_VIEW_MEMBER_LIST_IMPL(LAYOUT, MEMBER, NAME) (NAME) 231 #define _DECLARE_VIEW_MEMBER_LIST(R, DATA, LAYOUT_MEMBER_NAME) \ 232 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_LIST_IMPL LAYOUT_MEMBER_NAME) 237 #define _DECLARE_VIEW_MEMBER_INITIALIZERS_FROM_OTHER_IMPL(LAYOUT, MEMBER, LOCAL_NAME, DATA) \ 238 (BOOST_PP_CAT(MEMBER, Parameters_){DATA.BOOST_PP_CAT(MEMBER, Parameters_)}) 240 #define _DECLARE_VIEW_MEMBER_INITIALIZERS_FROM_OTHER(R, DATA, LAYOUT_MEMBER_NAME) \ 241 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_INITIALIZERS_FROM_OTHER_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 246 #define _DECLARE_VIEW_MEMBER_ASSIGNMENT_FROM_OTHER_IMPL(LAYOUT, MEMBER, LOCAL_NAME, DATA) \ 247 BOOST_PP_CAT(MEMBER, Parameters_) = DATA.BOOST_PP_CAT(MEMBER, Parameters_); 249 #define _DECLARE_VIEW_MEMBER_ASSIGNMENT_FROM_OTHER(R, DATA, LAYOUT_MEMBER_NAME) \ 250 BOOST_PP_EXPAND(_DECLARE_VIEW_MEMBER_ASSIGNMENT_FROM_OTHER_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 255 #define _DECLARE_VIEW_ELEM_MEMBER_INIT_IMPL(LAYOUT, MEMBER, LOCAL_NAME, DATA) (LOCAL_NAME(DATA, LOCAL_NAME)) 257 #define _DECLARE_VIEW_ELEM_MEMBER_INIT(R, DATA, LAYOUT_MEMBER_NAME) \ 258 BOOST_PP_EXPAND(_DECLARE_VIEW_ELEM_MEMBER_INIT_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 263 #define _COLUMN_TYPE(LAYOUT_NAME, LAYOUT_MEMBER) \ 264 typename std::remove_pointer<decltype(BOOST_PP_CAT(LAYOUT_NAME, Type)()::LAYOUT_MEMBER())>::type 269 #define _DECLARE_VIEW_ELEMENT_VALUE_ARG_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, DATA) \ 270 (DATA typename BOOST_PP_CAT(Metadata::ParametersTypeOf_, LOCAL_NAME) LOCAL_NAME) 272 #define _DECLARE_VIEW_ELEMENT_VALUE_ARG(R, DATA, LAYOUT_MEMBER_NAME) \ 273 _DECLARE_VIEW_ELEMENT_VALUE_ARG_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA) 278 #define _DECLARE_CONST_VIEW_ELEMENT_VALUE_ARG_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, DATA) \ 279 (DATA typename BOOST_PP_CAT(Metadata::ParametersTypeOf_, LOCAL_NAME)::ConstType LOCAL_NAME) 281 #define _DECLARE_CONST_VIEW_ELEMENT_VALUE_ARG(R, DATA, LAYOUT_MEMBER_NAME) \ 282 _DECLARE_CONST_VIEW_ELEMENT_VALUE_ARG_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA) 287 #define _DECLARE_VIEW_CONST_ELEM_MEMBER_INIT_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, DATA) \ 288 (BOOST_PP_CAT(LOCAL_NAME, _)(DATA, LOCAL_NAME)) 291 #define _DECLARE_VIEW_CONST_ELEM_MEMBER_INIT(R, DATA, LAYOUT_MEMBER_NAME) \ 292 BOOST_PP_EXPAND(_DECLARE_VIEW_CONST_ELEM_MEMBER_INIT_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 298 #define _DECLARE_VIEW_CONST_ELEMENT_ACCESSOR_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 299 SOA_HOST_DEVICE SOA_INLINE \ 300 const typename SoAConstValueWithConf<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME), \ 301 const typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>::RefToConst \ 302 LOCAL_NAME() const { \ 303 return BOOST_PP_CAT(LOCAL_NAME, _)(); \ 307 #define _DECLARE_VIEW_CONST_ELEMENT_ACCESSOR(R, DATA, LAYOUT_MEMBER_NAME) \ 308 _DECLARE_VIEW_CONST_ELEMENT_ACCESSOR_IMPL LAYOUT_MEMBER_NAME 314 #define _DECLARE_VIEW_CONST_ELEMENT_VALUE_MEMBER_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 315 const cms::soa::ConstValueTraits<SoAConstValueWithConf<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME), \ 316 typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>, \ 317 BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)> \ 318 BOOST_PP_CAT(LOCAL_NAME, _); 321 #define _DECLARE_VIEW_CONST_ELEMENT_VALUE_MEMBER(R, DATA, LAYOUT_MEMBER_NAME) \ 322 _DECLARE_VIEW_CONST_ELEMENT_VALUE_MEMBER_IMPL LAYOUT_MEMBER_NAME 327 #define _DECLARE_VIEW_ELEMENT_VALUE_COPY_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 328 if constexpr (Metadata::BOOST_PP_CAT(ColumnTypeOf_, LOCAL_NAME) != cms::soa::SoAColumnType::scalar) \ 329 LOCAL_NAME() = other.LOCAL_NAME(); 331 #define _DECLARE_VIEW_ELEMENT_VALUE_COPY(R, DATA, LAYOUT_MEMBER_NAME) \ 332 BOOST_PP_EXPAND(_DECLARE_VIEW_ELEMENT_VALUE_COPY_IMPL LAYOUT_MEMBER_NAME) 338 #define _DECLARE_VIEW_ELEMENT_VALUE_MEMBER_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 339 SoAValueWithConf<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME), \ 340 typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)> \ 344 #define _DECLARE_VIEW_ELEMENT_VALUE_MEMBER(R, DATA, LAYOUT_MEMBER_NAME) \ 345 _DECLARE_VIEW_ELEMENT_VALUE_MEMBER_IMPL LAYOUT_MEMBER_NAME 350 #define _DECLARE_VIEW_CONST_ELEMENT_CONSTR_CALL_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 351 (BOOST_PP_CAT(LOCAL_NAME, Parameters_)) 353 #define _DECLARE_VIEW_CONST_ELEMENT_CONSTR_CALL(R, DATA, LAYOUT_MEMBER_NAME) \ 354 BOOST_PP_EXPAND(_DECLARE_VIEW_CONST_ELEMENT_CONSTR_CALL_IMPL LAYOUT_MEMBER_NAME) 362 #define _DECLARE_VIEW_ELEMENT_CONSTR_CALL_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 363 (const_cast_SoAParametersImpl(base_type::BOOST_PP_CAT(LOCAL_NAME, Parameters_))) 365 #define _DECLARE_VIEW_ELEMENT_CONSTR_CALL(R, DATA, LAYOUT_MEMBER_NAME) \ 366 BOOST_PP_EXPAND(_DECLARE_VIEW_ELEMENT_CONSTR_CALL_IMPL LAYOUT_MEMBER_NAME) 372 #define _DECLARE_VIEW_SOA_ACCESSOR_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 374 SOA_HOST_DEVICE SOA_INLINE \ 375 typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 376 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 377 cms::soa::SoAAccessType::mutableAccess>::template Alignment<conditionalAlignment>:: \ 378 template RestrictQualifier<restrictQualify>::NoParamReturnType \ 380 return typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 381 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 382 cms::soa::SoAAccessType::mutableAccess>::template Alignment<conditionalAlignment>:: \ 383 template RestrictQualifier<restrictQualify>(const_cast_SoAParametersImpl( \ 384 base_type:: BOOST_PP_CAT(LOCAL_NAME, Parameters_)))(); \ 386 SOA_HOST_DEVICE SOA_INLINE \ 387 typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 388 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 389 cms::soa::SoAAccessType::mutableAccess>::template Alignment<conditionalAlignment>:: \ 390 template RestrictQualifier<restrictQualify>::ParamReturnType \ 391 LOCAL_NAME(size_type index) { \ 392 if constexpr (rangeChecking == cms::soa::RangeChecking::enabled) { \ 393 if (index >= base_type::elements_) \ 394 SOA_THROW_OUT_OF_RANGE("Out of range index in mutable " #LOCAL_NAME "(size_type index)") \ 396 return typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 397 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 398 cms::soa::SoAAccessType::mutableAccess>::template Alignment<conditionalAlignment>:: \ 399 template RestrictQualifier<restrictQualify>(const_cast_SoAParametersImpl( \ 400 base_type:: BOOST_PP_CAT(LOCAL_NAME, Parameters_)))(index); \ 404 #define _DECLARE_VIEW_SOA_ACCESSOR(R, DATA, LAYOUT_MEMBER_NAME) \ 405 BOOST_PP_EXPAND(_DECLARE_VIEW_SOA_ACCESSOR_IMPL LAYOUT_MEMBER_NAME) 411 #define _DECLARE_VIEW_SOA_CONST_ACCESSOR_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME) \ 413 SOA_HOST_DEVICE SOA_INLINE \ 414 typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 415 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 416 cms::soa::SoAAccessType::constAccess>::template Alignment<conditionalAlignment>:: \ 417 template RestrictQualifier<restrictQualify>::NoParamReturnType \ 418 LOCAL_NAME() const { \ 419 return typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 420 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 421 cms::soa::SoAAccessType::constAccess>::template Alignment<conditionalAlignment>:: \ 422 template RestrictQualifier<restrictQualify>(BOOST_PP_CAT(LOCAL_NAME, Parameters_))(); \ 424 SOA_HOST_DEVICE SOA_INLINE \ 425 typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 426 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 427 cms::soa::SoAAccessType::constAccess>::template Alignment<conditionalAlignment>:: \ 428 template RestrictQualifier<restrictQualify>::ParamReturnType \ 429 LOCAL_NAME(size_type index) const { \ 430 if constexpr (rangeChecking == cms::soa::RangeChecking::enabled) { \ 431 if (index >= elements_) \ 432 SOA_THROW_OUT_OF_RANGE("Out of range index in const " #LOCAL_NAME "(size_type index)") \ 434 return typename cms::soa::SoAAccessors<typename BOOST_PP_CAT(Metadata::TypeOf_, LOCAL_NAME)>:: \ 435 template ColumnType<BOOST_PP_CAT(Metadata::ColumnTypeOf_, LOCAL_NAME)>::template AccessType< \ 436 cms::soa::SoAAccessType::constAccess>::template Alignment<conditionalAlignment>:: \ 437 template RestrictQualifier<restrictQualify>(BOOST_PP_CAT(LOCAL_NAME, Parameters_))(index); \ 441 #define _DECLARE_VIEW_SOA_CONST_ACCESSOR(R, DATA, LAYOUT_MEMBER_NAME) \ 442 BOOST_PP_EXPAND(_DECLARE_VIEW_SOA_CONST_ACCESSOR_IMPL LAYOUT_MEMBER_NAME) 447 #define _DECLARE_VIEW_SOA_MEMBER_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, DATA) \ 448 typename BOOST_PP_CAT(Metadata::ParametersTypeOf_, LOCAL_NAME) BOOST_PP_CAT(LOCAL_NAME, Parameters_); 450 #define _DECLARE_VIEW_SOA_MEMBER(R, DATA, LAYOUT_MEMBER_NAME) \ 451 BOOST_PP_EXPAND(_DECLARE_VIEW_SOA_MEMBER_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 456 #define _DECLARE_CONST_VIEW_SOA_MEMBER_IMPL(LAYOUT_NAME, LAYOUT_MEMBER, LOCAL_NAME, DATA) \ 457 typename BOOST_PP_CAT(Metadata::ParametersTypeOf_, LOCAL_NAME)::ConstType BOOST_PP_CAT(LOCAL_NAME, Parameters_); 459 #define _DECLARE_CONST_VIEW_SOA_MEMBER(R, DATA, LAYOUT_MEMBER_NAME) \ 460 BOOST_PP_EXPAND(_DECLARE_CONST_VIEW_SOA_MEMBER_IMPL BOOST_PP_TUPLE_PUSH_BACK(LAYOUT_MEMBER_NAME, DATA)) 467 #define _TRIVIAL_VIEW_ASSIGN_VALUE_ELEMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 468 _SWITCH_ON_TYPE(VALUE_TYPE, \ 472 NAME() = value.NAME; \ 475 NAME() = value.NAME; \ 479 #define _TRIVIAL_VIEW_ASSIGN_VALUE_ELEMENT(R, DATA, TYPE_NAME) _TRIVIAL_VIEW_ASSIGN_VALUE_ELEMENT_IMPL TYPE_NAME 483 #define _GENERATE_SOA_VIEW_PART_0(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 484 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 485 bool VIEW_ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed, \ 486 bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::enabled, \ 487 bool RANGE_CHECKING = cms::soa::RangeChecking::disabled> \ 488 struct VIEW : public CONST_VIEW<VIEW_ALIGNMENT, VIEW_ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING> { \ 492 using self_type = VIEW; \ 493 using base_type = CONST_VIEW<VIEW_ALIGNMENT, VIEW_ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING>; 497 #define _GENERATE_SOA_VIEW_PART_0_NO_DEFAULTS(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 498 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT, \ 499 bool VIEW_ALIGNMENT_ENFORCEMENT, \ 500 bool RESTRICT_QUALIFY, \ 501 bool RANGE_CHECKING> \ 502 struct VIEW : public CONST_VIEW<VIEW_ALIGNMENT, VIEW_ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING> { \ 506 using self_type = VIEW; \ 507 using base_type = CONST_VIEW<VIEW_ALIGNMENT, VIEW_ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING>; 515 #define _GENERATE_SOA_VIEW_PART_1(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 516 using size_type = cms::soa::size_type; \ 517 using byte_size_type = cms::soa::byte_size_type; \ 518 using AlignmentEnforcement = cms::soa::AlignmentEnforcement; \ 524 constexpr static byte_size_type defaultAlignment = cms::soa::CacheLineSize::defaultSize; \ 525 constexpr static byte_size_type alignment = VIEW_ALIGNMENT; \ 526 constexpr static bool alignmentEnforcement = VIEW_ALIGNMENT_ENFORCEMENT; \ 527 constexpr static byte_size_type conditionalAlignment = \ 528 alignmentEnforcement == AlignmentEnforcement::enforced ? alignment : 0; \ 529 constexpr static bool restrictQualify = RESTRICT_QUALIFY; \ 530 constexpr static bool rangeChecking = RANGE_CHECKING; \ 532 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 533 using SoAValueWithConf = cms::soa::SoAValue<COLUMN_TYPE, C, conditionalAlignment, restrictQualify>; \ 535 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 536 using SoAConstValueWithConf = cms::soa::SoAConstValue<COLUMN_TYPE, C, conditionalAlignment, restrictQualify>; \ 543 SOA_HOST_DEVICE SOA_INLINE size_type size() const { return parent_.elements_; } \ 545 _ITERATE_ON_ALL(_DECLARE_VIEW_LAYOUT_TYPE_ALIAS, ~, LAYOUTS_LIST) \ 548 _ITERATE_ON_ALL(_DECLARE_VIEW_MEMBER_TYPE_ALIAS, const_cast_SoAParametersImpl, VALUE_LIST) \ 549 _ITERATE_ON_ALL(_DECLARE_VIEW_MEMBER_POINTERS, ~, VALUE_LIST) \ 550 _ITERATE_ON_ALL(_DECLARE_VIEW_MEMBER_CONST_POINTERS, ~, VALUE_LIST) \ 553 Metadata& operator=(const Metadata&) = delete; \ 554 Metadata(const Metadata&) = delete; \ 557 SOA_HOST_DEVICE SOA_INLINE Metadata(const VIEW& parent) : parent_(parent) {} \ 558 const VIEW& parent_; \ 562 SOA_HOST_DEVICE SOA_INLINE const Metadata metadata() const { return Metadata(*this); } \ 563 SOA_HOST_DEVICE SOA_INLINE Metadata metadata() { return Metadata(*this); } \ 569 SOA_HOST_ONLY VIEW(_ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_CONSTRUCTION_PARAMETERS, BOOST_PP_EMPTY(), LAYOUTS_LIST)) \ 570 : base_type{_ITERATE_ON_ALL_COMMA(_DECLARE_LAYOUT_LIST, BOOST_PP_EMPTY(), LAYOUTS_LIST)} {} \ 573 SOA_HOST_ONLY VIEW(size_type elements, \ 574 _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_CONSTRUCTION_BYCOLUMN_PARAMETERS, \ 577 : base_type{elements, _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_MEMBER_LIST, BOOST_PP_EMPTY(), VALUE_LIST)} {} \ 580 VIEW(VIEW const&) = default; \ 581 VIEW& operator=(VIEW const&) = default; \ 584 VIEW(VIEW &&) = default; \ 585 VIEW& operator=(VIEW &&) = default; \ 591 using const_element = typename base_type::const_element; \ 593 using base_type::operator[]; \ 597 SOA_HOST_DEVICE SOA_INLINE \ 598 element(size_type index, \ 599 _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_ELEMENT_VALUE_ARG, BOOST_PP_EMPTY(), VALUE_LIST)) \ 600 : _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_ELEM_MEMBER_INIT, index, VALUE_LIST) {} \ 601 SOA_HOST_DEVICE SOA_INLINE \ 602 element& operator=(const element& other) { \ 603 _ITERATE_ON_ALL(_DECLARE_VIEW_ELEMENT_VALUE_COPY, ~, VALUE_LIST) \ 609 #define _GENERATE_SOA_VIEW_PART_2(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 610 _ITERATE_ON_ALL(_DECLARE_VIEW_ELEMENT_VALUE_MEMBER, ~, VALUE_LIST) \ 613 SOA_HOST_DEVICE SOA_INLINE \ 614 element operator[](size_type index) { \ 615 if constexpr (rangeChecking == cms::soa::RangeChecking::enabled) { \ 616 if (index >= base_type::elements_) \ 617 SOA_THROW_OUT_OF_RANGE("Out of range index in " #VIEW "::operator[]") \ 619 return element{index, _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_ELEMENT_CONSTR_CALL, ~, VALUE_LIST)}; \ 625 _ITERATE_ON_ALL(_DECLARE_VIEW_SOA_ACCESSOR, ~, VALUE_LIST) \ 628 template <typename T> \ 629 SOA_HOST_ONLY friend void dump(); \ 635 #define _GENERATE_SOA_CONST_VIEW_PART_0(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 636 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 637 bool VIEW_ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed, \ 638 bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::enabled, \ 639 bool RANGE_CHECKING = cms::soa::RangeChecking::disabled> \ 640 struct CONST_VIEW { \ 642 using self_type = CONST_VIEW; 646 #define _GENERATE_SOA_CONST_VIEW_PART_0_NO_DEFAULTS(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 647 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT, \ 648 bool VIEW_ALIGNMENT_ENFORCEMENT, \ 649 bool RESTRICT_QUALIFY, \ 650 bool RANGE_CHECKING> \ 651 struct CONST_VIEW { \ 653 using self_type = CONST_VIEW; 661 #define _GENERATE_SOA_CONST_VIEW_PART_1(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 662 using size_type = cms::soa::size_type; \ 663 using byte_size_type = cms::soa::byte_size_type; \ 664 using AlignmentEnforcement = cms::soa::AlignmentEnforcement; \ 666 template <CMS_SOA_BYTE_SIZE_TYPE, bool, bool, bool> \ 667 friend struct VIEW; \ 673 constexpr static byte_size_type defaultAlignment = cms::soa::CacheLineSize::defaultSize; \ 674 constexpr static byte_size_type alignment = VIEW_ALIGNMENT; \ 675 constexpr static bool alignmentEnforcement = VIEW_ALIGNMENT_ENFORCEMENT; \ 676 constexpr static byte_size_type conditionalAlignment = \ 677 alignmentEnforcement == AlignmentEnforcement::enforced ? alignment : 0; \ 678 constexpr static bool restrictQualify = RESTRICT_QUALIFY; \ 679 constexpr static bool rangeChecking = RANGE_CHECKING; \ 681 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 682 using SoAValueWithConf = cms::soa::SoAValue<COLUMN_TYPE, C, conditionalAlignment, restrictQualify>; \ 684 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 685 using SoAConstValueWithConf = cms::soa::SoAConstValue<COLUMN_TYPE, C, conditionalAlignment, restrictQualify>; \ 692 SOA_HOST_DEVICE SOA_INLINE size_type size() const { return parent_.elements_; } \ 694 _ITERATE_ON_ALL(_DECLARE_VIEW_LAYOUT_TYPE_ALIAS, ~, LAYOUTS_LIST) \ 697 _ITERATE_ON_ALL(_DECLARE_VIEW_MEMBER_TYPE_ALIAS, BOOST_PP_EMPTY(), VALUE_LIST) \ 698 _ITERATE_ON_ALL(_DECLARE_VIEW_MEMBER_CONST_POINTERS, ~, VALUE_LIST) \ 701 Metadata& operator=(const Metadata&) = delete; \ 702 Metadata(const Metadata&) = delete; \ 705 SOA_HOST_DEVICE SOA_INLINE Metadata(const CONST_VIEW& parent) : parent_(parent) {} \ 706 const CONST_VIEW& parent_; \ 710 SOA_HOST_DEVICE SOA_INLINE const Metadata metadata() const { return Metadata(*this); } \ 713 CONST_VIEW() = default; \ 716 SOA_HOST_ONLY CONST_VIEW(_ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_CONSTRUCTION_PARAMETERS, const, LAYOUTS_LIST)) \ 717 : elements_([&]() -> size_type { \ 720 _ITERATE_ON_ALL(_UPDATE_SIZE_OF_VIEW, BOOST_PP_EMPTY(), LAYOUTS_LIST) \ 723 _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_MEMBER_INITIALIZERS, ~, VALUE_LIST) {} \ 726 SOA_HOST_ONLY CONST_VIEW(size_type elements, \ 727 _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_CONSTRUCTION_BYCOLUMN_PARAMETERS, const, VALUE_LIST)) \ 728 : elements_(elements), _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_MEMBER_INITIALIZERS_BYCOLUMN, ~, VALUE_LIST) {} \ 731 CONST_VIEW(CONST_VIEW const&) = default; \ 732 CONST_VIEW& operator=(CONST_VIEW const&) = default; \ 735 CONST_VIEW(CONST_VIEW &&) = default; \ 736 CONST_VIEW& operator=(CONST_VIEW &&) = default; \ 739 ~CONST_VIEW() = default; \ 742 struct const_element { \ 743 SOA_HOST_DEVICE SOA_INLINE \ 744 const_element(size_type index, \ 745 _ITERATE_ON_ALL_COMMA(_DECLARE_CONST_VIEW_ELEMENT_VALUE_ARG, const, VALUE_LIST)) \ 746 : _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_CONST_ELEM_MEMBER_INIT, index, VALUE_LIST) {} \ 747 _ITERATE_ON_ALL(_DECLARE_VIEW_CONST_ELEMENT_ACCESSOR, ~, VALUE_LIST) \ 750 _ITERATE_ON_ALL(_DECLARE_VIEW_CONST_ELEMENT_VALUE_MEMBER, ~, VALUE_LIST) \ 753 SOA_HOST_DEVICE SOA_INLINE \ 754 const_element operator[](size_type index) const { \ 755 if constexpr (rangeChecking == cms::soa::RangeChecking::enabled) { \ 756 if (index >= elements_) \ 757 SOA_THROW_OUT_OF_RANGE("Out of range index in " #CONST_VIEW "::operator[]") \ 759 return const_element{index, _ITERATE_ON_ALL_COMMA(_DECLARE_VIEW_CONST_ELEMENT_CONSTR_CALL, ~, VALUE_LIST)}; \ 763 _ITERATE_ON_ALL(_DECLARE_VIEW_SOA_CONST_ACCESSOR, ~, VALUE_LIST) \ 766 template <typename T> \ 767 SOA_HOST_ONLY friend void dump(); \ 770 size_type elements_ = 0; \ 771 _ITERATE_ON_ALL(_DECLARE_CONST_VIEW_SOA_MEMBER, const, VALUE_LIST) \ 777 #define _GENERATE_SOA_CONST_VIEW(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 778 _GENERATE_SOA_CONST_VIEW_PART_0(CONST_VIEW, VIEW, \ 779 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 780 _GENERATE_SOA_CONST_VIEW_PART_1(CONST_VIEW, VIEW, \ 781 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) 783 #define GENERATE_SOA_CONST_VIEW(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 784 _GENERATE_SOA_CONST_VIEW(CONST_VIEW, BOOST_PP_CAT(CONST_VIEW, Unused_), \ 785 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) 787 #define _GENERATE_SOA_TRIVIAL_CONST_VIEW(CLASS, LAYOUTS_LIST, VALUE_LIST) \ 788 _GENERATE_SOA_CONST_VIEW_PART_0_NO_DEFAULTS(ConstViewTemplateFreeParams, ViewTemplateFreeParams, \ 789 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 790 using BOOST_PP_CAT(CLASS, _parametrized) = CLASS<VIEW_ALIGNMENT, VIEW_ALIGNMENT_ENFORCEMENT>; \ 791 _GENERATE_SOA_CONST_VIEW_PART_1(ConstViewTemplateFreeParams, ViewTemplateFreeParams, \ 792 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) 794 #define _GENERATE_SOA_VIEW(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 795 _GENERATE_SOA_VIEW_PART_0(CONST_VIEW, VIEW, SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 796 _GENERATE_SOA_VIEW_PART_1(CONST_VIEW, VIEW, SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 797 _GENERATE_SOA_VIEW_PART_2(CONST_VIEW, VIEW, SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) 799 #define GENERATE_SOA_VIEW(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ 800 _GENERATE_SOA_CONST_VIEW(CONST_VIEW, VIEW, SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 801 _GENERATE_SOA_VIEW(CONST_VIEW, VIEW, SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) 803 #define _GENERATE_SOA_TRIVIAL_VIEW(CLASS, LAYOUTS_LIST, VALUE_LIST, ...) \ 804 _GENERATE_SOA_VIEW_PART_0_NO_DEFAULTS(ConstViewTemplateFreeParams, ViewTemplateFreeParams, \ 805 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 806 using BOOST_PP_CAT(CLASS, _parametrized) = CLASS<VIEW_ALIGNMENT, VIEW_ALIGNMENT_ENFORCEMENT>; \ 807 _GENERATE_SOA_VIEW_PART_1(ConstViewTemplateFreeParams, ViewTemplateFreeParams, \ 808 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) \ 811 SOA_HOST_DEVICE SOA_INLINE constexpr element & operator=(const typename \ 812 BOOST_PP_CAT(CLASS, _parametrized)::Metadata::value_element value) { \ 813 _ITERATE_ON_ALL(_TRIVIAL_VIEW_ASSIGN_VALUE_ELEMENT, ~, __VA_ARGS__) \ 817 _GENERATE_SOA_VIEW_PART_2(ConstViewTemplateFreeParams, ViewTemplateFreeParams, \ 818 SOA_VIEW_LAYOUT_LIST(LAYOUTS_LIST), SOA_VIEW_VALUE_LIST(VALUE_LIST)) 824 #define _VIEW_FIELD_FROM_LAYOUT_IMPL(VALUE_TYPE, CPP_TYPE, NAME, DATA) (DATA, NAME, NAME) 826 #define _VIEW_FIELD_FROM_LAYOUT(R, DATA, VALUE_TYPE_NAME) \ 827 BOOST_PP_EXPAND((_VIEW_FIELD_FROM_LAYOUT_IMPL BOOST_PP_TUPLE_PUSH_BACK(VALUE_TYPE_NAME, DATA))) 829 #endif // DataFormats_SoATemplate_interface_SoAView_h
double scalar(const CLHEP::HepGenMatrix &m)
Return the matrix as a scalar. Raise an assertion if the matris is not .