|
|
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 _soa_impl_os << " Scalar " BOOST_PP_STRINGIZE(NAME) " at offset " << _soa_impl_offset \ 67 << " has size " << sizeof(CPP_TYPE) \ 68 << " and padding " << ((sizeof(CPP_TYPE) - 1) / alignment + 1) * alignment - sizeof(CPP_TYPE) \ 70 _soa_impl_offset += ((sizeof(CPP_TYPE) - 1) / alignment + 1) * alignment; \ 73 _soa_impl_os << " Column " BOOST_PP_STRINGIZE(NAME) " at offset " << _soa_impl_offset << " has size " \ 74 << sizeof(CPP_TYPE) * elements_ << " and padding " \ 75 << cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment) - (elements_ * sizeof(CPP_TYPE)) \ 77 _soa_impl_offset += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment); \ 80 _soa_impl_os << " Eigen value " BOOST_PP_STRINGIZE(NAME) " at offset " << _soa_impl_offset << " has dimension " \ 81 << "(" << CPP_TYPE::RowsAtCompileTime << " x " << CPP_TYPE::ColsAtCompileTime << ")" \ 82 << " and per column size " \ 83 << sizeof(CPP_TYPE::Scalar) * elements_ \ 85 << cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 86 - (elements_ * sizeof(CPP_TYPE::Scalar)) \ 88 _soa_impl_offset += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 89 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 93 #define _DECLARE_SOA_STREAM_INFO(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_STREAM_INFO_IMPL TYPE_NAME) 99 #define _DEFINE_METADATA_MEMBERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 100 _SWITCH_ON_TYPE(VALUE_TYPE, \ 102 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 103 return cms::soa::alignSize(sizeof(CPP_TYPE), ParentClass::alignment); \ 105 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE; \ 106 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::scalar; \ 107 SOA_HOST_DEVICE SOA_INLINE \ 108 CPP_TYPE const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 109 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 111 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 112 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::scalar>::DataType<CPP_TYPE>; \ 113 SOA_HOST_DEVICE SOA_INLINE \ 114 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 115 return BOOST_PP_CAT(ParametersTypeOf_, NAME) (parent_.BOOST_PP_CAT(NAME, _)); \ 117 SOA_HOST_DEVICE SOA_INLINE \ 118 CPP_TYPE* BOOST_PP_CAT(addressOf_, NAME)() { \ 119 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 122 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 123 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::column>::DataType<CPP_TYPE>; \ 124 SOA_HOST_DEVICE SOA_INLINE \ 125 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 126 return BOOST_PP_CAT(ParametersTypeOf_, NAME) (parent_.BOOST_PP_CAT(NAME, _)); \ 128 SOA_HOST_DEVICE SOA_INLINE \ 129 CPP_TYPE const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 130 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 132 SOA_HOST_DEVICE SOA_INLINE \ 133 CPP_TYPE* BOOST_PP_CAT(addressOf_, NAME)() { \ 134 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 136 SOA_HOST_DEVICE SOA_INLINE \ 137 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 138 return cms::soa::alignSize(parent_.elements_ * sizeof(CPP_TYPE), ParentClass::alignment); \ 140 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE; \ 141 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::column;, \ 143 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 144 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::eigen>::DataType<CPP_TYPE>; \ 145 SOA_HOST_DEVICE SOA_INLINE \ 146 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 147 return BOOST_PP_CAT(ParametersTypeOf_, NAME) ( \ 148 parent_.BOOST_PP_CAT(NAME, _), \ 149 parent_.BOOST_PP_CAT(NAME, Stride_)); \ 151 SOA_HOST_DEVICE SOA_INLINE \ 152 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 153 return cms::soa::alignSize(parent_.elements_ * sizeof(CPP_TYPE::Scalar), ParentClass::alignment) \ 154 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 156 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE ; \ 157 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::eigen; \ 158 SOA_HOST_DEVICE SOA_INLINE \ 159 CPP_TYPE::Scalar const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 160 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 162 SOA_HOST_DEVICE SOA_INLINE \ 163 CPP_TYPE::Scalar* BOOST_PP_CAT(addressOf_, NAME)() { \ 164 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 168 #define _DEFINE_METADATA_MEMBERS(R, DATA, TYPE_NAME) _DEFINE_METADATA_MEMBERS_IMPL TYPE_NAME 171 #define _DECLARE_MEMBER_TRIVIAL_CONSTRUCTION_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 172 _SWITCH_ON_TYPE(VALUE_TYPE, \ 174 (BOOST_PP_CAT(NAME, _)(nullptr)), \ 176 (BOOST_PP_CAT(NAME, _)(nullptr)), \ 178 (BOOST_PP_CAT(NAME, ElementsWithPadding_)(0)) \ 179 (BOOST_PP_CAT(NAME, _)(nullptr)) \ 180 (BOOST_PP_CAT(NAME, Stride_)(0)) \ 184 #define _DECLARE_MEMBER_TRIVIAL_CONSTRUCTION(R, DATA, TYPE_NAME) \ 185 BOOST_PP_EXPAND(_DECLARE_MEMBER_TRIVIAL_CONSTRUCTION_IMPL TYPE_NAME) 188 #define _DECLARE_MEMBER_COPY_CONSTRUCTION_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 189 _SWITCH_ON_TYPE(VALUE_TYPE, \ 191 (BOOST_PP_CAT(NAME, _){_soa_impl_other.BOOST_PP_CAT(NAME, _)}), \ 193 (BOOST_PP_CAT(NAME, _){_soa_impl_other.BOOST_PP_CAT(NAME, _)}), \ 195 (BOOST_PP_CAT(NAME, ElementsWithPadding_){_soa_impl_other.BOOST_PP_CAT(NAME, ElementsWithPadding_)}) \ 196 (BOOST_PP_CAT(NAME, _){_soa_impl_other.BOOST_PP_CAT(NAME, _)}) \ 197 (BOOST_PP_CAT(NAME, Stride_){_soa_impl_other.BOOST_PP_CAT(NAME, Stride_)}) \ 201 #define _DECLARE_MEMBER_COPY_CONSTRUCTION(R, DATA, TYPE_NAME) \ 202 BOOST_PP_EXPAND(_DECLARE_MEMBER_COPY_CONSTRUCTION_IMPL TYPE_NAME) 205 #define _DECLARE_MEMBER_ASSIGNMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 206 _SWITCH_ON_TYPE(VALUE_TYPE, \ 208 BOOST_PP_CAT(NAME, _) = _soa_impl_other.BOOST_PP_CAT(NAME, _);, \ 210 BOOST_PP_CAT(NAME, _) = _soa_impl_other.BOOST_PP_CAT(NAME, _);, \ 212 BOOST_PP_CAT(NAME, ElementsWithPadding_) = _soa_impl_other.BOOST_PP_CAT(NAME, ElementsWithPadding_); \ 213 BOOST_PP_CAT(NAME, _) = _soa_impl_other.BOOST_PP_CAT(NAME, _); \ 214 BOOST_PP_CAT(NAME, Stride_) = _soa_impl_other.BOOST_PP_CAT(NAME, Stride_); \ 218 #define _DECLARE_MEMBER_ASSIGNMENT(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_MEMBER_ASSIGNMENT_IMPL TYPE_NAME) 224 #define _DEFINE_VALUE_ELEMENT_MEMBERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 225 _SWITCH_ON_TYPE(VALUE_TYPE, \ 236 #define _DEFINE_VALUE_ELEMENT_MEMBERS(R, DATA, TYPE_NAME) _DEFINE_VALUE_ELEMENT_MEMBERS_IMPL TYPE_NAME 242 #define _VALUE_ELEMENT_CTOR_ARGS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 243 _SWITCH_ON_TYPE(VALUE_TYPE, \ 253 #define _VALUE_ELEMENT_CTOR_ARGS(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_VALUE_ELEMENT_CTOR_ARGS_IMPL TYPE_NAME) 259 #define _VALUE_ELEMENT_INITIALIZERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 260 _SWITCH_ON_TYPE(VALUE_TYPE, \ 270 #define _VALUE_ELEMENT_INITIALIZERS(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_VALUE_ELEMENT_INITIALIZERS_IMPL TYPE_NAME) 276 #define _ROOT_FREE_SOA_COLUMN_OR_SCALAR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 277 delete[] BOOST_PP_CAT(NAME, _); \ 278 BOOST_PP_CAT(NAME, _) = nullptr; \ 281 #define _ROOT_FREE_SOA_COLUMN_OR_SCALAR(R, DATA, TYPE_NAME) _ROOT_FREE_SOA_COLUMN_OR_SCALAR_IMPL TYPE_NAME 287 #define _ASSIGN_SOA_COLUMN_OR_SCALAR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 288 _SWITCH_ON_TYPE(VALUE_TYPE, \ 290 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE*>(_soa_impl_curMem); \ 291 _soa_impl_curMem += cms::soa::alignSize(sizeof(CPP_TYPE), alignment); \ 294 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE*>(_soa_impl_curMem); \ 295 _soa_impl_curMem += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment); \ 298 BOOST_PP_CAT(NAME, Stride_) = cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 299 / sizeof(CPP_TYPE::Scalar); \ 300 BOOST_PP_CAT(NAME, ElementsWithPadding_) = BOOST_PP_CAT(NAME, Stride_) \ 301 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 302 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE::Scalar*>(_soa_impl_curMem); \ 303 _soa_impl_curMem += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 304 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 306 if constexpr (alignmentEnforcement == AlignmentEnforcement::enforced) \ 307 if (reinterpret_cast<intptr_t>(BOOST_PP_CAT(NAME, _)) % alignment) \ 308 throw std::runtime_error("In layout constructor: misaligned column: " #NAME); 311 #define _ASSIGN_SOA_COLUMN_OR_SCALAR(R, DATA, TYPE_NAME) _ASSIGN_SOA_COLUMN_OR_SCALAR_IMPL TYPE_NAME 317 #define _ACCUMULATE_SOA_ELEMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 318 _SWITCH_ON_TYPE(VALUE_TYPE, \ 320 _soa_impl_ret += cms::soa::alignSize(sizeof(CPP_TYPE), alignment); \ 323 _soa_impl_ret += cms::soa::alignSize(elements * sizeof(CPP_TYPE), alignment); \ 326 _soa_impl_ret += cms::soa::alignSize(elements * sizeof(CPP_TYPE::Scalar), alignment) \ 327 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 331 #define _ACCUMULATE_SOA_ELEMENT(R, DATA, TYPE_NAME) _ACCUMULATE_SOA_ELEMENT_IMPL TYPE_NAME 337 #define _DECLARE_SOA_ACCESSOR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 338 _SWITCH_ON_TYPE(VALUE_TYPE, \ 340 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE& NAME() { return *BOOST_PP_CAT(NAME, _); } \ 343 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE* NAME() { return BOOST_PP_CAT(NAME, _); } \ 344 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE& NAME(size_type _soa_impl_index) { \ 345 return BOOST_PP_CAT(NAME, _)[_soa_impl_index]; \ 354 #define _DECLARE_SOA_ACCESSOR(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_ACCESSOR_IMPL TYPE_NAME) 360 #define _DECLARE_SOA_CONST_ACCESSOR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 361 _SWITCH_ON_TYPE(VALUE_TYPE, \ 363 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE NAME() const { return *(BOOST_PP_CAT(NAME, _)); } \ 366 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE const* NAME() const { return BOOST_PP_CAT(NAME, _); } \ 367 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE NAME(size_type _soa_impl_index) const { \ 368 return *(BOOST_PP_CAT(NAME, _) + _soa_impl_index); \ 372 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE::Scalar const* NAME() const { return BOOST_PP_CAT(NAME, _); } \ 373 SOA_HOST_DEVICE SOA_INLINE size_type BOOST_PP_CAT(NAME, Stride)() { return BOOST_PP_CAT(NAME, Stride_); } \ 377 #define _DECLARE_SOA_CONST_ACCESSOR(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_CONST_ACCESSOR_IMPL TYPE_NAME) 383 #define _STREAMER_READ_SOA_DATA_MEMBER_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 384 _SWITCH_ON_TYPE(VALUE_TYPE, \ 386 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), sizeof(CPP_TYPE)); \ 389 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), sizeof(CPP_TYPE) * onfile.elements_); \ 392 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), \ 393 sizeof(CPP_TYPE::Scalar) * BOOST_PP_CAT(NAME, ElementsWithPadding_)); \ 397 #define _STREAMER_READ_SOA_DATA_MEMBER(R, DATA, TYPE_NAME) \ 398 BOOST_PP_EXPAND(_STREAMER_READ_SOA_DATA_MEMBER_IMPL TYPE_NAME) 404 #define _DECLARE_SOA_DATA_MEMBER_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 405 _SWITCH_ON_TYPE(VALUE_TYPE, \ 407 CPP_TYPE* BOOST_PP_CAT(NAME, _) EDM_REFLEX_SIZE(scalar_) = nullptr; \ 410 CPP_TYPE * BOOST_PP_CAT(NAME, _) EDM_REFLEX_SIZE(elements_) = nullptr; \ 413 size_type BOOST_PP_CAT(NAME, ElementsWithPadding_) = 0; \ 414 CPP_TYPE::Scalar * BOOST_PP_CAT(NAME, _) EDM_REFLEX_SIZE(BOOST_PP_CAT(NAME, ElementsWithPadding_)) = nullptr; \ 415 byte_size_type BOOST_PP_CAT(NAME, Stride_) = 0; \ 419 #define _DECLARE_SOA_DATA_MEMBER(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_DATA_MEMBER_IMPL TYPE_NAME) 422 #define _DO_RANGECHECK true 424 #define _DO_RANGECHECK false 431 #define GENERATE_SOA_LAYOUT(CLASS, ...) \ 432 template <CMS_SOA_BYTE_SIZE_TYPE ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 433 bool ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed> \ 436 using self_type = CLASS; \ 437 using AlignmentEnforcement = cms::soa::AlignmentEnforcement; \ 443 using size_type = cms::soa::size_type; \ 444 using byte_size_type = cms::soa::byte_size_type; \ 445 constexpr static byte_size_type defaultAlignment = 128; \ 446 constexpr static byte_size_type alignment = ALIGNMENT; \ 447 constexpr static bool alignmentEnforcement = ALIGNMENT_ENFORCEMENT; \ 448 constexpr static byte_size_type conditionalAlignment = \ 449 alignmentEnforcement == cms::soa::AlignmentEnforcement::enforced ? alignment : 0; \ 451 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 452 using SoAValueWithConf = cms::soa::SoAValue<COLUMN_TYPE, C, conditionalAlignment>; \ 454 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 455 using SoAConstValueWithConf = cms::soa::SoAConstValue<COLUMN_TYPE, C, conditionalAlignment>; \ 457 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 458 bool VIEW_ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed, \ 459 bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ 460 bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ 461 struct ViewTemplateFreeParams; \ 465 void soaToStreamInternal(std::ostream & _soa_impl_os) const { \ 466 _soa_impl_os << #CLASS "(" << elements_ << " elements, byte alignement= " << alignment << ", @"<< mem_ <<"): " \ 468 _soa_impl_os << " sizeof(" #CLASS "): " << sizeof(CLASS) << std::endl; \ 469 byte_size_type _soa_impl_offset = 0; \ 470 _ITERATE_ON_ALL(_DECLARE_SOA_STREAM_INFO, ~, __VA_ARGS__) \ 471 _soa_impl_os << "Final offset = " << _soa_impl_offset << " computeDataSize(...): " << computeDataSize(elements_) \ 473 _soa_impl_os << std::endl; \ 477 static constexpr byte_size_type computeDataSize(size_type elements) { \ 478 byte_size_type _soa_impl_ret = 0; \ 479 _ITERATE_ON_ALL(_ACCUMULATE_SOA_ELEMENT, ~, __VA_ARGS__) \ 480 return _soa_impl_ret; \ 488 SOA_HOST_DEVICE SOA_INLINE size_type size() const { return parent_.elements_; } \ 489 SOA_HOST_DEVICE SOA_INLINE byte_size_type byteSize() const { return parent_.byteSize_; } \ 490 SOA_HOST_DEVICE SOA_INLINE byte_size_type alignment() const { return CLASS::alignment; } \ 491 SOA_HOST_DEVICE SOA_INLINE std::byte* data() { return parent_.mem_; } \ 492 SOA_HOST_DEVICE SOA_INLINE const std::byte* data() const { return parent_.mem_; } \ 493 SOA_HOST_DEVICE SOA_INLINE std::byte* nextByte() const { return parent_.mem_ + parent_.byteSize_; } \ 494 SOA_HOST_DEVICE SOA_INLINE CLASS cloneToNewAddress(std::byte* _soa_impl_addr) const { \ 495 return CLASS(_soa_impl_addr, parent_.elements_); \ 498 _ITERATE_ON_ALL(_DEFINE_METADATA_MEMBERS, ~, __VA_ARGS__) \ 500 struct value_element { \ 501 SOA_HOST_DEVICE SOA_INLINE value_element \ 503 BOOST_PP_SEQ_SIZE(_ITERATE_ON_ALL(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__) ), \ 504 (_ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__)):, \ 506 BOOST_PP_TUPLE_ENUM(BOOST_PP_IF( \ 507 BOOST_PP_SEQ_SIZE(_ITERATE_ON_ALL(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__)), \ 508 BOOST_PP_SEQ_TO_TUPLE(_ITERATE_ON_ALL(_VALUE_ELEMENT_INITIALIZERS, ~, __VA_ARGS__)), \ 514 _ITERATE_ON_ALL(_DEFINE_VALUE_ELEMENT_MEMBERS, ~, __VA_ARGS__) \ 517 Metadata& operator=(const Metadata&) = delete; \ 518 Metadata(const Metadata&) = delete; \ 521 SOA_HOST_DEVICE SOA_INLINE Metadata(const CLASS& _soa_impl_parent) : parent_(_soa_impl_parent) {} \ 522 const CLASS& parent_; \ 523 using ParentClass = CLASS; \ 528 SOA_HOST_DEVICE SOA_INLINE const Metadata metadata() const { return Metadata(*this); } \ 529 SOA_HOST_DEVICE SOA_INLINE Metadata metadata() { return Metadata(*this); } \ 532 _GENERATE_SOA_TRIVIAL_CONST_VIEW(CLASS, \ 533 SOA_VIEW_LAYOUT_LIST( \ 534 SOA_VIEW_LAYOUT(BOOST_PP_CAT(CLASS, _parametrized) , BOOST_PP_CAT(instance_, CLASS))), \ 535 SOA_VIEW_VALUE_LIST(_ITERATE_ON_ALL_COMMA( \ 536 _VIEW_FIELD_FROM_LAYOUT, BOOST_PP_CAT(instance_, CLASS), __VA_ARGS__))) \ 538 template <bool RESTRICT_QUALIFY, bool RANGE_CHECKING> \ 539 using ConstViewTemplate = ConstViewTemplateFreeParams<ALIGNMENT, ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, \ 542 using ConstView = ConstViewTemplate<cms::soa::RestrictQualify::Default, cms::soa::RangeChecking::Default>; \ 545 _GENERATE_SOA_TRIVIAL_VIEW(CLASS, \ 546 SOA_VIEW_LAYOUT_LIST( \ 547 SOA_VIEW_LAYOUT(BOOST_PP_CAT(CLASS, _parametrized), BOOST_PP_CAT(instance_, CLASS))), \ 548 SOA_VIEW_VALUE_LIST(_ITERATE_ON_ALL_COMMA( \ 549 _VIEW_FIELD_FROM_LAYOUT, BOOST_PP_CAT(instance_, CLASS), __VA_ARGS__)), \ 552 template <bool RESTRICT_QUALIFY, bool RANGE_CHECKING> \ 553 using ViewTemplate = ViewTemplateFreeParams<ALIGNMENT, ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING>; \ 555 using View = ViewTemplate<cms::soa::RestrictQualify::Default, cms::soa::RangeChecking::Default>; \ 562 _ITERATE_ON_ALL_COMMA(_DECLARE_MEMBER_TRIVIAL_CONSTRUCTION, ~, __VA_ARGS__) {} \ 565 SOA_HOST_ONLY CLASS(std::byte* mem, size_type elements) : mem_(mem), elements_(elements), byteSize_(0) { \ 566 organizeColumnsFromBuffer(); \ 570 SOA_HOST_ONLY CLASS(CLASS const& _soa_impl_other) \ 571 : mem_(_soa_impl_other.mem_), \ 572 elements_(_soa_impl_other.elements_), \ 573 byteSize_(_soa_impl_other.byteSize_), \ 574 _ITERATE_ON_ALL_COMMA(_DECLARE_MEMBER_COPY_CONSTRUCTION, ~, __VA_ARGS__) {} \ 576 SOA_HOST_ONLY CLASS& operator=(CLASS const& _soa_impl_other) { \ 577 mem_ = _soa_impl_other.mem_; \ 578 elements_ = _soa_impl_other.elements_; \ 579 byteSize_ = _soa_impl_other.byteSize_; \ 580 _ITERATE_ON_ALL(_DECLARE_MEMBER_ASSIGNMENT, ~, __VA_ARGS__) \ 585 template <typename T> \ 586 void ROOTReadStreamer(T & onfile) { \ 587 _ITERATE_ON_ALL(_STREAMER_READ_SOA_DATA_MEMBER, ~, __VA_ARGS__) \ 591 void ROOTStreamerCleaner() { \ 593 _ITERATE_ON_ALL(_ROOT_FREE_SOA_COLUMN_OR_SCALAR, ~, __VA_ARGS__) \ 597 template <typename T> \ 598 SOA_HOST_ONLY friend void dump(); \ 602 void organizeColumnsFromBuffer() { \ 603 if constexpr (alignmentEnforcement == cms::soa::AlignmentEnforcement::enforced) \ 604 if (reinterpret_cast<intptr_t>(mem_) % alignment) \ 605 throw std::runtime_error("In " #CLASS "::" #CLASS ": misaligned buffer"); \ 606 auto _soa_impl_curMem = mem_; \ 607 _ITERATE_ON_ALL(_ASSIGN_SOA_COLUMN_OR_SCALAR, ~, __VA_ARGS__) \ 609 byteSize_ = computeDataSize(elements_); \ 610 if (mem_ + byteSize_ != _soa_impl_curMem) \ 611 throw std::runtime_error("In " #CLASS "::" #CLASS ": unexpected end pointer."); \ 615 std::byte* mem_ EDM_REFLEX_TRANSIENT; \ 616 size_type elements_; \ 617 size_type const scalar_ = 1; \ 618 byte_size_type byteSize_ EDM_REFLEX_TRANSIENT; \ 619 _ITERATE_ON_ALL(_DECLARE_SOA_DATA_MEMBER, ~, __VA_ARGS__) \ 627 #endif // DataFormats_SoATemplate_interface_SoALayout_h