|
|
Go to the documentation of this file. 1 #ifndef DataFormats_SoATemplate_interface_SoALayout_h 2 #define DataFormats_SoATemplate_interface_SoALayout_h 62 #define _DECLARE_SOA_STREAM_INFO_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 66 os << " Scalar " BOOST_PP_STRINGIZE(NAME) " at offset " << offset << " has size " << sizeof(CPP_TYPE) \ 67 << " and padding " << ((sizeof(CPP_TYPE) - 1) / alignment + 1) * alignment - sizeof(CPP_TYPE) \ 69 offset += ((sizeof(CPP_TYPE) - 1) / alignment + 1) * alignment; \ 72 os << " Column " BOOST_PP_STRINGIZE(NAME) " at offset " << offset << " has size " \ 73 << sizeof(CPP_TYPE) * elements_ << " and padding " \ 74 << cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment) - (elements_ * sizeof(CPP_TYPE)) \ 76 offset += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment); \ 79 os << " Eigen value " BOOST_PP_STRINGIZE(NAME) " at offset " << offset << " has dimension " \ 80 << "(" << CPP_TYPE::RowsAtCompileTime << " x " << CPP_TYPE::ColsAtCompileTime << ")" \ 81 << " and per column size " \ 82 << sizeof(CPP_TYPE::Scalar) * elements_ \ 84 << cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 85 - (elements_ * sizeof(CPP_TYPE::Scalar)) \ 87 offset += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 88 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 92 #define _DECLARE_SOA_STREAM_INFO(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_STREAM_INFO_IMPL TYPE_NAME) 98 #define _DEFINE_METADATA_MEMBERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 99 _SWITCH_ON_TYPE(VALUE_TYPE, \ 101 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 102 return cms::soa::alignSize(sizeof(CPP_TYPE), ParentClass::alignment); \ 104 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE; \ 105 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::scalar; \ 106 SOA_HOST_DEVICE SOA_INLINE \ 107 CPP_TYPE const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 108 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 110 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 111 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::scalar>::DataType<CPP_TYPE>; \ 112 SOA_HOST_DEVICE SOA_INLINE \ 113 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 114 return BOOST_PP_CAT(ParametersTypeOf_, NAME) (parent_.BOOST_PP_CAT(NAME, _)); \ 116 SOA_HOST_DEVICE SOA_INLINE \ 117 CPP_TYPE* BOOST_PP_CAT(addressOf_, NAME)() { \ 118 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 121 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 122 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::column>::DataType<CPP_TYPE>; \ 123 SOA_HOST_DEVICE SOA_INLINE \ 124 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 125 return BOOST_PP_CAT(ParametersTypeOf_, NAME) (parent_.BOOST_PP_CAT(NAME, _)); \ 127 SOA_HOST_DEVICE SOA_INLINE \ 128 CPP_TYPE const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 129 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 131 SOA_HOST_DEVICE SOA_INLINE \ 132 CPP_TYPE* BOOST_PP_CAT(addressOf_, NAME)() { \ 133 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 135 SOA_HOST_DEVICE SOA_INLINE \ 136 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 137 return cms::soa::alignSize(parent_.elements_ * sizeof(CPP_TYPE), ParentClass::alignment); \ 139 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE; \ 140 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::column;, \ 142 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 143 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::eigen>::DataType<CPP_TYPE>; \ 144 SOA_HOST_DEVICE SOA_INLINE \ 145 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 146 return BOOST_PP_CAT(ParametersTypeOf_, NAME) ( \ 147 parent_.BOOST_PP_CAT(NAME, _), \ 148 parent_.BOOST_PP_CAT(NAME, Stride_)); \ 150 SOA_HOST_DEVICE SOA_INLINE \ 151 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 152 return cms::soa::alignSize(parent_.elements_ * sizeof(CPP_TYPE::Scalar), ParentClass::alignment) \ 153 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 155 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE ; \ 156 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::eigen; \ 157 SOA_HOST_DEVICE SOA_INLINE \ 158 CPP_TYPE::Scalar const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 159 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 161 SOA_HOST_DEVICE SOA_INLINE \ 162 CPP_TYPE::Scalar* BOOST_PP_CAT(addressOf_, NAME)() { \ 163 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 167 #define _DEFINE_METADATA_MEMBERS(R, DATA, TYPE_NAME) _DEFINE_METADATA_MEMBERS_IMPL TYPE_NAME 170 #define _DECLARE_MEMBER_TRIVIAL_CONSTRUCTION_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 171 _SWITCH_ON_TYPE(VALUE_TYPE, \ 173 (BOOST_PP_CAT(NAME, _)(nullptr)), \ 175 (BOOST_PP_CAT(NAME, _)(nullptr)), \ 177 (BOOST_PP_CAT(NAME, ElementsWithPadding_)(0)) \ 178 (BOOST_PP_CAT(NAME, _)(nullptr)) \ 179 (BOOST_PP_CAT(NAME, Stride_)(0)) \ 183 #define _DECLARE_MEMBER_TRIVIAL_CONSTRUCTION(R, DATA, TYPE_NAME) \ 184 BOOST_PP_EXPAND(_DECLARE_MEMBER_TRIVIAL_CONSTRUCTION_IMPL TYPE_NAME) 187 #define _DECLARE_MEMBER_COPY_CONSTRUCTION_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 188 _SWITCH_ON_TYPE(VALUE_TYPE, \ 190 (BOOST_PP_CAT(NAME, _){other.BOOST_PP_CAT(NAME, _)}), \ 192 (BOOST_PP_CAT(NAME, _){other.BOOST_PP_CAT(NAME, _)}), \ 194 (BOOST_PP_CAT(NAME, ElementsWithPadding_){other.BOOST_PP_CAT(NAME, ElementsWithPadding_)}) \ 195 (BOOST_PP_CAT(NAME, _){other.BOOST_PP_CAT(NAME, _)}) \ 196 (BOOST_PP_CAT(NAME, Stride_){other.BOOST_PP_CAT(NAME, Stride_)}) \ 200 #define _DECLARE_MEMBER_COPY_CONSTRUCTION(R, DATA, TYPE_NAME) \ 201 BOOST_PP_EXPAND(_DECLARE_MEMBER_COPY_CONSTRUCTION_IMPL TYPE_NAME) 204 #define _DECLARE_MEMBER_ASSIGNMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 205 _SWITCH_ON_TYPE(VALUE_TYPE, \ 207 BOOST_PP_CAT(NAME, _) = other.BOOST_PP_CAT(NAME, _);, \ 209 BOOST_PP_CAT(NAME, _) = other.BOOST_PP_CAT(NAME, _);, \ 211 BOOST_PP_CAT(NAME, ElementsWithPadding_) = other.BOOST_PP_CAT(NAME, ElementsWithPadding_); \ 212 BOOST_PP_CAT(NAME, _) = other.BOOST_PP_CAT(NAME, _); \ 213 BOOST_PP_CAT(NAME, Stride_) = other.BOOST_PP_CAT(NAME, Stride_); \ 217 #define _DECLARE_MEMBER_ASSIGNMENT(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_MEMBER_ASSIGNMENT_IMPL TYPE_NAME) 223 #define _DEFINE_VALUE_ELEMENT_MEMBERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 224 _SWITCH_ON_TYPE(VALUE_TYPE, \ 235 #define _DEFINE_VALUE_ELEMENT_MEMBERS(R, DATA, TYPE_NAME) _DEFINE_VALUE_ELEMENT_MEMBERS_IMPL TYPE_NAME 241 #define _VALUE_ELEMENT_CTOR_ARGS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 242 _SWITCH_ON_TYPE(VALUE_TYPE, \ 252 #define _VALUE_ELEMENT_CTOR_ARGS(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_VALUE_ELEMENT_CTOR_ARGS_IMPL TYPE_NAME) 258 #define _VALUE_ELEMENT_INITIALIZERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 259 _SWITCH_ON_TYPE(VALUE_TYPE, \ 269 #define _VALUE_ELEMENT_INITIALIZERS(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_VALUE_ELEMENT_INITIALIZERS_IMPL TYPE_NAME) 275 #define _ROOT_FREE_SOA_COLUMN_OR_SCALAR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 276 delete[] BOOST_PP_CAT(NAME, _); \ 277 BOOST_PP_CAT(NAME, _) = nullptr; \ 280 #define _ROOT_FREE_SOA_COLUMN_OR_SCALAR(R, DATA, TYPE_NAME) _ROOT_FREE_SOA_COLUMN_OR_SCALAR_IMPL TYPE_NAME 286 #define _ASSIGN_SOA_COLUMN_OR_SCALAR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 287 _SWITCH_ON_TYPE(VALUE_TYPE, \ 289 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE*>(curMem); \ 290 curMem += cms::soa::alignSize(sizeof(CPP_TYPE), alignment); \ 293 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE*>(curMem); \ 294 curMem += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment); \ 297 BOOST_PP_CAT(NAME, Stride_) = cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 298 / sizeof(CPP_TYPE::Scalar); \ 299 BOOST_PP_CAT(NAME, ElementsWithPadding_) = BOOST_PP_CAT(NAME, Stride_) \ 300 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 301 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE::Scalar*>(curMem); \ 302 curMem += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) * CPP_TYPE::RowsAtCompileTime \ 303 * CPP_TYPE::ColsAtCompileTime; \ 305 if constexpr (alignmentEnforcement == AlignmentEnforcement::enforced) \ 306 if (reinterpret_cast<intptr_t>(BOOST_PP_CAT(NAME, _)) % alignment) \ 307 throw std::runtime_error("In layout constructor: misaligned column: " #NAME); 310 #define _ASSIGN_SOA_COLUMN_OR_SCALAR(R, DATA, TYPE_NAME) _ASSIGN_SOA_COLUMN_OR_SCALAR_IMPL TYPE_NAME 316 #define _ACCUMULATE_SOA_ELEMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 317 _SWITCH_ON_TYPE(VALUE_TYPE, \ 319 ret += cms::soa::alignSize(sizeof(CPP_TYPE), alignment); \ 322 ret += cms::soa::alignSize(elements * sizeof(CPP_TYPE), alignment); \ 325 ret += cms::soa::alignSize(elements * sizeof(CPP_TYPE::Scalar), alignment) * CPP_TYPE::RowsAtCompileTime \ 326 * CPP_TYPE::ColsAtCompileTime; \ 330 #define _ACCUMULATE_SOA_ELEMENT(R, DATA, TYPE_NAME) _ACCUMULATE_SOA_ELEMENT_IMPL TYPE_NAME 336 #define _DECLARE_SOA_ACCESSOR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 337 _SWITCH_ON_TYPE(VALUE_TYPE, \ 339 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE& NAME() { return *BOOST_PP_CAT(NAME, _); } \ 342 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE* NAME() { return BOOST_PP_CAT(NAME, _); } \ 343 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE& NAME(size_type index) { return BOOST_PP_CAT(NAME, _)[index]; } \ 351 #define _DECLARE_SOA_ACCESSOR(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_ACCESSOR_IMPL TYPE_NAME) 357 #define _DECLARE_SOA_CONST_ACCESSOR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 358 _SWITCH_ON_TYPE(VALUE_TYPE, \ 360 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE NAME() const { return *(BOOST_PP_CAT(NAME, _)); } \ 363 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE const* NAME() const { return BOOST_PP_CAT(NAME, _); } \ 364 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE NAME(size_type index) const { return *(BOOST_PP_CAT(NAME, _) + index); } \ 367 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE::Scalar const* NAME() const { return BOOST_PP_CAT(NAME, _); } \ 368 SOA_HOST_DEVICE SOA_INLINE size_type BOOST_PP_CAT(NAME, Stride)() { return BOOST_PP_CAT(NAME, Stride_); } \ 372 #define _DECLARE_SOA_CONST_ACCESSOR(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_CONST_ACCESSOR_IMPL TYPE_NAME) 378 #define _STREAMER_READ_SOA_DATA_MEMBER_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 379 _SWITCH_ON_TYPE(VALUE_TYPE, \ 381 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), sizeof(CPP_TYPE)); \ 384 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), sizeof(CPP_TYPE) * onfile.elements_); \ 387 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), \ 388 sizeof(CPP_TYPE::Scalar) * BOOST_PP_CAT(NAME, ElementsWithPadding_)); \ 392 #define _STREAMER_READ_SOA_DATA_MEMBER(R, DATA, TYPE_NAME) \ 393 BOOST_PP_EXPAND(_STREAMER_READ_SOA_DATA_MEMBER_IMPL TYPE_NAME) 399 #define _DECLARE_SOA_DATA_MEMBER_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 400 _SWITCH_ON_TYPE(VALUE_TYPE, \ 402 CPP_TYPE* BOOST_PP_CAT(NAME, _) EDM_REFLEX_SIZE(scalar_) = nullptr; \ 405 CPP_TYPE * BOOST_PP_CAT(NAME, _) EDM_REFLEX_SIZE(elements_) = nullptr; \ 408 size_type BOOST_PP_CAT(NAME, ElementsWithPadding_) = 0; \ 409 CPP_TYPE::Scalar * BOOST_PP_CAT(NAME, _) EDM_REFLEX_SIZE(BOOST_PP_CAT(NAME, ElementsWithPadding_)) = nullptr; \ 410 byte_size_type BOOST_PP_CAT(NAME, Stride_) = 0; \ 414 #define _DECLARE_SOA_DATA_MEMBER(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_DATA_MEMBER_IMPL TYPE_NAME) 417 #define _DO_RANGECHECK true 419 #define _DO_RANGECHECK false 426 #define GENERATE_SOA_LAYOUT(CLASS, ...) \ 427 template <CMS_SOA_BYTE_SIZE_TYPE ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 428 bool ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed> \ 431 using self_type = CLASS; \ 432 using AlignmentEnforcement = cms::soa::AlignmentEnforcement; \ 438 using size_type = cms::soa::size_type; \ 439 using byte_size_type = cms::soa::byte_size_type; \ 440 constexpr static byte_size_type defaultAlignment = 128; \ 441 constexpr static byte_size_type alignment = ALIGNMENT; \ 442 constexpr static bool alignmentEnforcement = ALIGNMENT_ENFORCEMENT; \ 443 constexpr static byte_size_type conditionalAlignment = \ 444 alignmentEnforcement == cms::soa::AlignmentEnforcement::enforced ? alignment : 0; \ 446 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 447 using SoAValueWithConf = cms::soa::SoAValue<COLUMN_TYPE, C, conditionalAlignment>; \ 449 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 450 using SoAConstValueWithConf = cms::soa::SoAConstValue<COLUMN_TYPE, C, conditionalAlignment>; \ 452 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 453 bool VIEW_ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed, \ 454 bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::enabled, \ 455 bool RANGE_CHECKING = cms::soa::RangeChecking::disabled> \ 456 struct ViewTemplateFreeParams; \ 460 void soaToStreamInternal(std::ostream & os) const { \ 461 os << #CLASS "(" << elements_ << " elements, byte alignement= " << alignment << ", @"<< mem_ <<"): " \ 463 os << " sizeof(" #CLASS "): " << sizeof(CLASS) << std::endl; \ 464 byte_size_type offset = 0; \ 465 _ITERATE_ON_ALL(_DECLARE_SOA_STREAM_INFO, ~, __VA_ARGS__) \ 466 os << "Final offset = " << offset << " computeDataSize(...): " << computeDataSize(elements_) \ 472 static constexpr byte_size_type computeDataSize(size_type elements) { \ 473 byte_size_type ret = 0; \ 474 _ITERATE_ON_ALL(_ACCUMULATE_SOA_ELEMENT, ~, __VA_ARGS__) \ 483 SOA_HOST_DEVICE SOA_INLINE size_type size() const { return parent_.elements_; } \ 484 SOA_HOST_DEVICE SOA_INLINE byte_size_type byteSize() const { return parent_.byteSize_; } \ 485 SOA_HOST_DEVICE SOA_INLINE byte_size_type alignment() const { return CLASS::alignment; } \ 486 SOA_HOST_DEVICE SOA_INLINE std::byte* data() { return parent_.mem_; } \ 487 SOA_HOST_DEVICE SOA_INLINE const std::byte* data() const { return parent_.mem_; } \ 488 SOA_HOST_DEVICE SOA_INLINE std::byte* nextByte() const { return parent_.mem_ + parent_.byteSize_; } \ 489 SOA_HOST_DEVICE SOA_INLINE CLASS cloneToNewAddress(std::byte* addr) const { \ 490 return CLASS(addr, parent_.elements_); \ 493 _ITERATE_ON_ALL(_DEFINE_METADATA_MEMBERS, ~, __VA_ARGS__) \ 495 struct value_element { \ 496 SOA_HOST_DEVICE SOA_INLINE value_element \ 498 BOOST_PP_SEQ_SIZE(_ITERATE_ON_ALL(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__) ), \ 499 (_ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__)):, \ 501 BOOST_PP_TUPLE_ENUM(BOOST_PP_IF( \ 502 BOOST_PP_SEQ_SIZE(_ITERATE_ON_ALL(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__)), \ 503 BOOST_PP_SEQ_TO_TUPLE(_ITERATE_ON_ALL(_VALUE_ELEMENT_INITIALIZERS, ~, __VA_ARGS__)), \ 509 _ITERATE_ON_ALL(_DEFINE_VALUE_ELEMENT_MEMBERS, ~, __VA_ARGS__) \ 512 Metadata& operator=(const Metadata&) = delete; \ 513 Metadata(const Metadata&) = delete; \ 516 SOA_HOST_DEVICE SOA_INLINE Metadata(const CLASS& parent) : parent_(parent) {} \ 517 const CLASS& parent_; \ 518 using ParentClass = CLASS; \ 523 SOA_HOST_DEVICE SOA_INLINE const Metadata metadata() const { return Metadata(*this); } \ 524 SOA_HOST_DEVICE SOA_INLINE Metadata metadata() { return Metadata(*this); } \ 527 _GENERATE_SOA_TRIVIAL_CONST_VIEW(CLASS, \ 528 SOA_VIEW_LAYOUT_LIST( \ 529 SOA_VIEW_LAYOUT(BOOST_PP_CAT(CLASS, _parametrized) , BOOST_PP_CAT(instance_, CLASS))), \ 530 SOA_VIEW_VALUE_LIST(_ITERATE_ON_ALL_COMMA( \ 531 _VIEW_FIELD_FROM_LAYOUT, BOOST_PP_CAT(instance_, CLASS), __VA_ARGS__))) \ 533 template <bool RESTRICT_QUALIFY, bool RANGE_CHECKING> \ 534 using ConstViewTemplate = ConstViewTemplateFreeParams<ALIGNMENT, ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, \ 537 using ConstView = ConstViewTemplate<cms::soa::RestrictQualify::enabled, cms::soa::RangeChecking::disabled>; \ 540 _GENERATE_SOA_TRIVIAL_VIEW(CLASS, \ 541 SOA_VIEW_LAYOUT_LIST( \ 542 SOA_VIEW_LAYOUT(BOOST_PP_CAT(CLASS, _parametrized), BOOST_PP_CAT(instance_, CLASS))), \ 543 SOA_VIEW_VALUE_LIST(_ITERATE_ON_ALL_COMMA( \ 544 _VIEW_FIELD_FROM_LAYOUT, BOOST_PP_CAT(instance_, CLASS), __VA_ARGS__)), \ 547 template <bool RESTRICT_QUALIFY, bool RANGE_CHECKING> \ 548 using ViewTemplate = ViewTemplateFreeParams<ALIGNMENT, ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING>; \ 550 using View = ViewTemplate<cms::soa::RestrictQualify::enabled, cms::soa::RangeChecking::disabled>; \ 557 _ITERATE_ON_ALL_COMMA(_DECLARE_MEMBER_TRIVIAL_CONSTRUCTION, ~, __VA_ARGS__) {} \ 560 SOA_HOST_ONLY CLASS(std::byte* mem, size_type elements) : mem_(mem), elements_(elements), byteSize_(0) { \ 561 organizeColumnsFromBuffer(); \ 565 SOA_HOST_ONLY CLASS(CLASS const& other) \ 566 : mem_(other.mem_), \ 567 elements_(other.elements_), \ 568 byteSize_(other.byteSize_), \ 569 _ITERATE_ON_ALL_COMMA(_DECLARE_MEMBER_COPY_CONSTRUCTION, ~, __VA_ARGS__) {} \ 571 SOA_HOST_ONLY CLASS& operator=(CLASS const& other) { \ 573 elements_ = other.elements_; \ 574 byteSize_ = other.byteSize_; \ 575 _ITERATE_ON_ALL(_DECLARE_MEMBER_ASSIGNMENT, ~, __VA_ARGS__) \ 580 template <typename T> \ 581 void ROOTReadStreamer(T & onfile) { \ 582 auto size = onfile.metadata().size(); \ 583 _ITERATE_ON_ALL(_STREAMER_READ_SOA_DATA_MEMBER, ~, __VA_ARGS__) \ 587 void ROOTStreamerCleaner() { \ 589 _ITERATE_ON_ALL(_ROOT_FREE_SOA_COLUMN_OR_SCALAR, ~, __VA_ARGS__) \ 593 template <typename T> \ 594 SOA_HOST_ONLY friend void dump(); \ 598 void organizeColumnsFromBuffer() { \ 599 if constexpr (alignmentEnforcement == cms::soa::AlignmentEnforcement::enforced) \ 600 if (reinterpret_cast<intptr_t>(mem_) % alignment) \ 601 throw std::runtime_error("In " #CLASS "::" #CLASS ": misaligned buffer"); \ 602 auto curMem = mem_; \ 603 _ITERATE_ON_ALL(_ASSIGN_SOA_COLUMN_OR_SCALAR, ~, __VA_ARGS__) \ 605 byteSize_ = computeDataSize(elements_); \ 606 if (mem_ + byteSize_ != curMem) \ 607 throw std::runtime_error("In " #CLASS "::" #CLASS ": unexpected end pointer."); \ 611 std::byte* mem_ EDM_REFLEX_TRANSIENT; \ 612 size_type elements_; \ 613 size_type const scalar_ = 1; \ 614 byte_size_type byteSize_ EDM_REFLEX_TRANSIENT; \ 615 _ITERATE_ON_ALL(_DECLARE_SOA_DATA_MEMBER, ~, __VA_ARGS__) \ 623 #endif // DataFormats_SoATemplate_interface_SoALayout_h