|
|
Go to the documentation of this file. 1 #ifndef DataFormats_SoATemplate_interface_SoALayout_h 2 #define DataFormats_SoATemplate_interface_SoALayout_h 60 #define _DECLARE_SOA_STREAM_INFO_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 64 os << " Scalar " BOOST_PP_STRINGIZE(NAME) " at offset " << offset << " has size " << sizeof(CPP_TYPE) \ 65 << " and padding " << ((sizeof(CPP_TYPE) - 1) / alignment + 1) * alignment - sizeof(CPP_TYPE) \ 67 offset += ((sizeof(CPP_TYPE) - 1) / alignment + 1) * alignment; \ 70 os << " Column " BOOST_PP_STRINGIZE(NAME) " at offset " << offset << " has size " \ 71 << sizeof(CPP_TYPE) * elements_ << " and padding " \ 72 << cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment) - (elements_ * sizeof(CPP_TYPE)) \ 74 offset += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment); \ 77 os << " Eigen value " BOOST_PP_STRINGIZE(NAME) " at offset " << offset << " has dimension " \ 78 << "(" << CPP_TYPE::RowsAtCompileTime << " x " << CPP_TYPE::ColsAtCompileTime << ")" \ 79 << " and per column size " \ 80 << sizeof(CPP_TYPE::Scalar) * elements_ \ 82 << cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 83 - (elements_ * sizeof(CPP_TYPE::Scalar)) \ 85 offset += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 86 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 90 #define _DECLARE_SOA_STREAM_INFO(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_STREAM_INFO_IMPL TYPE_NAME) 96 #define _DEFINE_METADATA_MEMBERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 97 _SWITCH_ON_TYPE(VALUE_TYPE, \ 99 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 100 return cms::soa::alignSize(sizeof(CPP_TYPE), ParentClass::alignment); \ 102 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE; \ 103 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::scalar; \ 104 SOA_HOST_DEVICE SOA_INLINE \ 105 CPP_TYPE const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 106 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 108 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 109 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::scalar>::DataType<CPP_TYPE>; \ 110 SOA_HOST_DEVICE SOA_INLINE \ 111 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 112 return BOOST_PP_CAT(ParametersTypeOf_, NAME) (parent_.BOOST_PP_CAT(NAME, _)); \ 114 SOA_HOST_DEVICE SOA_INLINE \ 115 CPP_TYPE* BOOST_PP_CAT(addressOf_, NAME)() { \ 116 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 119 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 120 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::column>::DataType<CPP_TYPE>; \ 121 SOA_HOST_DEVICE SOA_INLINE \ 122 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 123 return BOOST_PP_CAT(ParametersTypeOf_, NAME) (parent_.BOOST_PP_CAT(NAME, _)); \ 125 SOA_HOST_DEVICE SOA_INLINE \ 126 CPP_TYPE const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 127 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 129 SOA_HOST_DEVICE SOA_INLINE \ 130 CPP_TYPE* BOOST_PP_CAT(addressOf_, NAME)() { \ 131 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 133 SOA_HOST_DEVICE SOA_INLINE \ 134 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 135 return cms::soa::alignSize(parent_.elements_ * sizeof(CPP_TYPE), ParentClass::alignment); \ 137 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE; \ 138 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::column;, \ 140 using BOOST_PP_CAT(ParametersTypeOf_, NAME) = \ 141 cms::soa::SoAParameters_ColumnType<cms::soa::SoAColumnType::eigen>::DataType<CPP_TYPE>; \ 142 SOA_HOST_DEVICE SOA_INLINE \ 143 BOOST_PP_CAT(ParametersTypeOf_, NAME) BOOST_PP_CAT(parametersOf_, NAME)() const { \ 144 return BOOST_PP_CAT(ParametersTypeOf_, NAME) ( \ 145 parent_.BOOST_PP_CAT(NAME, _), \ 146 parent_.BOOST_PP_CAT(NAME, Stride_)); \ 148 SOA_HOST_DEVICE SOA_INLINE \ 149 byte_size_type BOOST_PP_CAT(NAME, Pitch()) const { \ 150 return cms::soa::alignSize(parent_.elements_ * sizeof(CPP_TYPE::Scalar), ParentClass::alignment) \ 151 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 153 using BOOST_PP_CAT(TypeOf_, NAME) = CPP_TYPE ; \ 154 constexpr static cms::soa::SoAColumnType BOOST_PP_CAT(ColumnTypeOf_, NAME) = cms::soa::SoAColumnType::eigen; \ 155 SOA_HOST_DEVICE SOA_INLINE \ 156 CPP_TYPE::Scalar const* BOOST_PP_CAT(addressOf_, NAME)() const { \ 157 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 159 SOA_HOST_DEVICE SOA_INLINE \ 160 CPP_TYPE::Scalar* BOOST_PP_CAT(addressOf_, NAME)() { \ 161 return parent_.metadata().BOOST_PP_CAT(parametersOf_, NAME)().addr_; \ 165 #define _DEFINE_METADATA_MEMBERS(R, DATA, TYPE_NAME) _DEFINE_METADATA_MEMBERS_IMPL TYPE_NAME 168 #define _DECLARE_MEMBER_TRIVIAL_CONSTRUCTION_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 169 _SWITCH_ON_TYPE(VALUE_TYPE, \ 171 (BOOST_PP_CAT(NAME, _)(nullptr)), \ 173 (BOOST_PP_CAT(NAME, _)(nullptr)), \ 175 (BOOST_PP_CAT(NAME, ElementsWithPadding_)(0)) \ 176 (BOOST_PP_CAT(NAME, _)(nullptr)) \ 177 (BOOST_PP_CAT(NAME, Stride_)(0)) \ 181 #define _DECLARE_MEMBER_TRIVIAL_CONSTRUCTION(R, DATA, TYPE_NAME) \ 182 BOOST_PP_EXPAND(_DECLARE_MEMBER_TRIVIAL_CONSTRUCTION_IMPL TYPE_NAME) 185 #define _DECLARE_MEMBER_COPY_CONSTRUCTION_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 186 _SWITCH_ON_TYPE(VALUE_TYPE, \ 188 (BOOST_PP_CAT(NAME, _){other.BOOST_PP_CAT(NAME, _)}), \ 190 (BOOST_PP_CAT(NAME, _){other.BOOST_PP_CAT(NAME, _)}), \ 192 (BOOST_PP_CAT(NAME, ElementsWithPadding_){other.BOOST_PP_CAT(NAME, ElementsWithPadding_)}) \ 193 (BOOST_PP_CAT(NAME, _){other.BOOST_PP_CAT(NAME, _)}) \ 194 (BOOST_PP_CAT(NAME, Stride_){other.BOOST_PP_CAT(NAME, Stride_)}) \ 198 #define _DECLARE_MEMBER_COPY_CONSTRUCTION(R, DATA, TYPE_NAME) \ 199 BOOST_PP_EXPAND(_DECLARE_MEMBER_COPY_CONSTRUCTION_IMPL TYPE_NAME) 202 #define _DECLARE_MEMBER_ASSIGNMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 203 _SWITCH_ON_TYPE(VALUE_TYPE, \ 205 BOOST_PP_CAT(NAME, _) = other.BOOST_PP_CAT(NAME, _);, \ 207 BOOST_PP_CAT(NAME, _) = other.BOOST_PP_CAT(NAME, _);, \ 209 BOOST_PP_CAT(NAME, ElementsWithPadding_) = other.BOOST_PP_CAT(NAME, ElementsWithPadding_); \ 210 BOOST_PP_CAT(NAME, _) = other.BOOST_PP_CAT(NAME, _); \ 211 BOOST_PP_CAT(NAME, Stride_) = other.BOOST_PP_CAT(NAME, Stride_); \ 215 #define _DECLARE_MEMBER_ASSIGNMENT(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_MEMBER_ASSIGNMENT_IMPL TYPE_NAME) 221 #define _DEFINE_VALUE_ELEMENT_MEMBERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 222 _SWITCH_ON_TYPE(VALUE_TYPE, \ 233 #define _DEFINE_VALUE_ELEMENT_MEMBERS(R, DATA, TYPE_NAME) _DEFINE_VALUE_ELEMENT_MEMBERS_IMPL TYPE_NAME 239 #define _VALUE_ELEMENT_CTOR_ARGS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 240 _SWITCH_ON_TYPE(VALUE_TYPE, \ 250 #define _VALUE_ELEMENT_CTOR_ARGS(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_VALUE_ELEMENT_CTOR_ARGS_IMPL TYPE_NAME) 256 #define _VALUE_ELEMENT_INITIALIZERS_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 257 _SWITCH_ON_TYPE(VALUE_TYPE, \ 267 #define _VALUE_ELEMENT_INITIALIZERS(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_VALUE_ELEMENT_INITIALIZERS_IMPL TYPE_NAME) 273 #define _ASSIGN_SOA_COLUMN_OR_SCALAR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 274 _SWITCH_ON_TYPE(VALUE_TYPE, \ 276 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE*>(curMem); \ 277 curMem += cms::soa::alignSize(sizeof(CPP_TYPE), alignment); \ 280 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE*>(curMem); \ 281 curMem += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE), alignment); \ 284 BOOST_PP_CAT(NAME, Stride_) = cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) \ 285 / sizeof(CPP_TYPE::Scalar); \ 286 BOOST_PP_CAT(NAME, ElementsWithPadding_) = BOOST_PP_CAT(NAME, Stride_) \ 287 * CPP_TYPE::RowsAtCompileTime * CPP_TYPE::ColsAtCompileTime; \ 288 BOOST_PP_CAT(NAME, _) = reinterpret_cast<CPP_TYPE::Scalar*>(curMem); \ 289 curMem += cms::soa::alignSize(elements_ * sizeof(CPP_TYPE::Scalar), alignment) * CPP_TYPE::RowsAtCompileTime \ 290 * CPP_TYPE::ColsAtCompileTime; \ 292 if constexpr (alignmentEnforcement == AlignmentEnforcement::enforced) \ 293 if (reinterpret_cast<intptr_t>(BOOST_PP_CAT(NAME, _)) % alignment) \ 294 throw std::runtime_error("In layout constructor: misaligned column: " #NAME); 297 #define _ASSIGN_SOA_COLUMN_OR_SCALAR(R, DATA, TYPE_NAME) _ASSIGN_SOA_COLUMN_OR_SCALAR_IMPL TYPE_NAME 303 #define _ACCUMULATE_SOA_ELEMENT_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 304 _SWITCH_ON_TYPE(VALUE_TYPE, \ 306 ret += cms::soa::alignSize(sizeof(CPP_TYPE), alignment); \ 309 ret += cms::soa::alignSize(elements * sizeof(CPP_TYPE), alignment); \ 312 ret += cms::soa::alignSize(elements * sizeof(CPP_TYPE::Scalar), alignment) * CPP_TYPE::RowsAtCompileTime \ 313 * CPP_TYPE::ColsAtCompileTime; \ 317 #define _ACCUMULATE_SOA_ELEMENT(R, DATA, TYPE_NAME) _ACCUMULATE_SOA_ELEMENT_IMPL TYPE_NAME 323 #define _DECLARE_SOA_ACCESSOR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 324 _SWITCH_ON_TYPE(VALUE_TYPE, \ 326 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE& NAME() { return *BOOST_PP_CAT(NAME, _); } \ 329 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE* NAME() { return BOOST_PP_CAT(NAME, _); } \ 330 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE& NAME(size_type index) { return BOOST_PP_CAT(NAME, _)[index]; } \ 338 #define _DECLARE_SOA_ACCESSOR(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_ACCESSOR_IMPL TYPE_NAME) 344 #define _DECLARE_SOA_CONST_ACCESSOR_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 345 _SWITCH_ON_TYPE(VALUE_TYPE, \ 347 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE NAME() const { return *(BOOST_PP_CAT(NAME, _)); } \ 350 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE const* NAME() const { return BOOST_PP_CAT(NAME, _); } \ 351 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE NAME(size_type index) const { return *(BOOST_PP_CAT(NAME, _) + index); } \ 354 SOA_HOST_DEVICE SOA_INLINE CPP_TYPE::Scalar const* NAME() const { return BOOST_PP_CAT(NAME, _); } \ 355 SOA_HOST_DEVICE SOA_INLINE size_type BOOST_PP_CAT(NAME, Stride)() { return BOOST_PP_CAT(NAME, Stride_); } \ 359 #define _DECLARE_SOA_CONST_ACCESSOR(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_CONST_ACCESSOR_IMPL TYPE_NAME) 365 #define _STREAMER_READ_SOA_DATA_MEMBER_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 366 _SWITCH_ON_TYPE(VALUE_TYPE, \ 368 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), sizeof(CPP_TYPE)); \ 371 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), sizeof(CPP_TYPE) * onfile.elements_); \ 374 memcpy(BOOST_PP_CAT(NAME, _), onfile.BOOST_PP_CAT(NAME, _), \ 375 sizeof(CPP_TYPE::Scalar) * BOOST_PP_CAT(NAME, ElementsWithPadding_)); \ 379 #define _STREAMER_READ_SOA_DATA_MEMBER(R, DATA, TYPE_NAME) \ 380 BOOST_PP_EXPAND(_STREAMER_READ_SOA_DATA_MEMBER_IMPL TYPE_NAME) 386 #define _DECLARE_SOA_DATA_MEMBER_IMPL(VALUE_TYPE, CPP_TYPE, NAME) \ 387 _SWITCH_ON_TYPE(VALUE_TYPE, \ 389 CPP_TYPE* BOOST_PP_CAT(NAME, _) = nullptr; \ 392 CPP_TYPE * BOOST_PP_CAT(NAME, _) = nullptr; \ 395 size_type BOOST_PP_CAT(NAME, ElementsWithPadding_); \ 396 CPP_TYPE::Scalar * BOOST_PP_CAT(NAME, _) = nullptr; \ 397 byte_size_type BOOST_PP_CAT(NAME, Stride_) = 0; \ 401 #define _DECLARE_SOA_DATA_MEMBER(R, DATA, TYPE_NAME) BOOST_PP_EXPAND(_DECLARE_SOA_DATA_MEMBER_IMPL TYPE_NAME) 404 #define _DO_RANGECHECK true 406 #define _DO_RANGECHECK false 413 #define GENERATE_SOA_LAYOUT(CLASS, ...) \ 414 template <CMS_SOA_BYTE_SIZE_TYPE ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 415 bool ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed> \ 418 using self_type = CLASS; \ 419 using AlignmentEnforcement = cms::soa::AlignmentEnforcement; \ 425 using size_type = cms::soa::size_type; \ 426 using byte_size_type = cms::soa::byte_size_type; \ 427 constexpr static byte_size_type defaultAlignment = 128; \ 428 constexpr static byte_size_type alignment = ALIGNMENT; \ 429 constexpr static bool alignmentEnforcement = ALIGNMENT_ENFORCEMENT; \ 430 constexpr static byte_size_type conditionalAlignment = \ 431 alignmentEnforcement == cms::soa::AlignmentEnforcement::enforced ? alignment : 0; \ 433 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 434 using SoAValueWithConf = cms::soa::SoAValue<COLUMN_TYPE, C, conditionalAlignment>; \ 436 template <cms::soa::SoAColumnType COLUMN_TYPE, class C> \ 437 using SoAConstValueWithConf = cms::soa::SoAConstValue<COLUMN_TYPE, C, conditionalAlignment>; \ 439 template <CMS_SOA_BYTE_SIZE_TYPE VIEW_ALIGNMENT = cms::soa::CacheLineSize::defaultSize, \ 440 bool VIEW_ALIGNMENT_ENFORCEMENT = cms::soa::AlignmentEnforcement::relaxed, \ 441 bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::enabled, \ 442 bool RANGE_CHECKING = cms::soa::RangeChecking::disabled> \ 443 struct ViewTemplateFreeParams; \ 447 void soaToStreamInternal(std::ostream & os) const { \ 448 os << #CLASS "(" << elements_ << " elements, byte alignement= " << alignment << ", @"<< mem_ <<"): " \ 450 os << " sizeof(" #CLASS "): " << sizeof(CLASS) << std::endl; \ 451 byte_size_type offset = 0; \ 452 _ITERATE_ON_ALL(_DECLARE_SOA_STREAM_INFO, ~, __VA_ARGS__) \ 453 os << "Final offset = " << offset << " computeDataSize(...): " << computeDataSize(elements_) \ 459 static constexpr byte_size_type computeDataSize(size_type elements) { \ 460 byte_size_type ret = 0; \ 461 _ITERATE_ON_ALL(_ACCUMULATE_SOA_ELEMENT, ~, __VA_ARGS__) \ 470 SOA_HOST_DEVICE SOA_INLINE size_type size() const { return parent_.elements_; } \ 471 SOA_HOST_DEVICE SOA_INLINE byte_size_type byteSize() const { return parent_.byteSize_; } \ 472 SOA_HOST_DEVICE SOA_INLINE byte_size_type alignment() const { return CLASS::alignment; } \ 473 SOA_HOST_DEVICE SOA_INLINE std::byte* data() { return parent_.mem_; } \ 474 SOA_HOST_DEVICE SOA_INLINE const std::byte* data() const { return parent_.mem_; } \ 475 SOA_HOST_DEVICE SOA_INLINE std::byte* nextByte() const { return parent_.mem_ + parent_.byteSize_; } \ 476 SOA_HOST_DEVICE SOA_INLINE CLASS cloneToNewAddress(std::byte* addr) const { \ 477 return CLASS(addr, parent_.elements_); \ 480 _ITERATE_ON_ALL(_DEFINE_METADATA_MEMBERS, ~, __VA_ARGS__) \ 482 struct value_element { \ 483 SOA_HOST_DEVICE SOA_INLINE value_element( \ 484 _ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_CTOR_ARGS, ~, __VA_ARGS__) \ 486 _ITERATE_ON_ALL_COMMA(_VALUE_ELEMENT_INITIALIZERS, ~, __VA_ARGS__) \ 489 _ITERATE_ON_ALL(_DEFINE_VALUE_ELEMENT_MEMBERS, ~, __VA_ARGS__) \ 492 Metadata& operator=(const Metadata&) = delete; \ 493 Metadata(const Metadata&) = delete; \ 496 SOA_HOST_DEVICE SOA_INLINE Metadata(const CLASS& parent) : parent_(parent) {} \ 497 const CLASS& parent_; \ 498 using ParentClass = CLASS; \ 503 SOA_HOST_DEVICE SOA_INLINE const Metadata metadata() const { return Metadata(*this); } \ 504 SOA_HOST_DEVICE SOA_INLINE Metadata metadata() { return Metadata(*this); } \ 507 _GENERATE_SOA_TRIVIAL_CONST_VIEW(CLASS, \ 508 SOA_VIEW_LAYOUT_LIST( \ 509 SOA_VIEW_LAYOUT(BOOST_PP_CAT(CLASS, _parametrized) , BOOST_PP_CAT(instance_, CLASS))), \ 510 SOA_VIEW_VALUE_LIST(_ITERATE_ON_ALL_COMMA( \ 511 _VIEW_FIELD_FROM_LAYOUT, BOOST_PP_CAT(instance_, CLASS), __VA_ARGS__))) \ 513 template <bool RESTRICT_QUALIFY, bool RANGE_CHECKING> \ 514 using ConstViewTemplate = ConstViewTemplateFreeParams<ALIGNMENT, ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, \ 517 using ConstView = ConstViewTemplate<cms::soa::RestrictQualify::enabled, cms::soa::RangeChecking::disabled>; \ 520 _GENERATE_SOA_TRIVIAL_VIEW(CLASS, \ 521 SOA_VIEW_LAYOUT_LIST( \ 522 SOA_VIEW_LAYOUT(BOOST_PP_CAT(CLASS, _parametrized), BOOST_PP_CAT(instance_, CLASS))), \ 523 SOA_VIEW_VALUE_LIST(_ITERATE_ON_ALL_COMMA( \ 524 _VIEW_FIELD_FROM_LAYOUT, BOOST_PP_CAT(instance_, CLASS), __VA_ARGS__)), \ 527 template <bool RESTRICT_QUALIFY, bool RANGE_CHECKING> \ 528 using ViewTemplate = ViewTemplateFreeParams<ALIGNMENT, ALIGNMENT_ENFORCEMENT, RESTRICT_QUALIFY, RANGE_CHECKING>; \ 530 using View = ViewTemplate<cms::soa::RestrictQualify::enabled, cms::soa::RangeChecking::disabled>; \ 537 _ITERATE_ON_ALL_COMMA(_DECLARE_MEMBER_TRIVIAL_CONSTRUCTION, ~, __VA_ARGS__) {} \ 540 SOA_HOST_ONLY CLASS(std::byte* mem, size_type elements) : mem_(mem), elements_(elements), byteSize_(0) { \ 541 organizeColumnsFromBuffer(); \ 545 SOA_HOST_ONLY CLASS(CLASS const& other) \ 546 : mem_(other.mem_), \ 547 elements_(other.elements_), \ 548 byteSize_(other.byteSize_), \ 549 _ITERATE_ON_ALL_COMMA(_DECLARE_MEMBER_COPY_CONSTRUCTION, ~, __VA_ARGS__) {} \ 551 SOA_HOST_ONLY CLASS& operator=(CLASS const& other) { \ 553 elements_ = other.elements_; \ 554 byteSize_ = other.byteSize_; \ 555 _ITERATE_ON_ALL(_DECLARE_MEMBER_ASSIGNMENT, ~, __VA_ARGS__) \ 560 template <typename T> \ 561 void ROOTReadStreamer(T & onfile) { \ 562 auto size = onfile.metadata().size(); \ 563 _ITERATE_ON_ALL(_STREAMER_READ_SOA_DATA_MEMBER, ~, __VA_ARGS__) \ 567 template <typename T> \ 568 SOA_HOST_ONLY friend void dump(); \ 572 void organizeColumnsFromBuffer() { \ 573 if constexpr (alignmentEnforcement == cms::soa::AlignmentEnforcement::enforced) \ 574 if (reinterpret_cast<intptr_t>(mem_) % alignment) \ 575 throw std::runtime_error("In " #CLASS "::" #CLASS ": misaligned buffer"); \ 576 auto curMem = mem_; \ 577 _ITERATE_ON_ALL(_ASSIGN_SOA_COLUMN_OR_SCALAR, ~, __VA_ARGS__) \ 579 byteSize_ = computeDataSize(elements_); \ 580 if (mem_ + byteSize_ != curMem) \ 581 throw std::runtime_error("In " #CLASS "::" #CLASS ": unexpected end pointer."); \ 586 size_type elements_; \ 587 size_type const scalar_ = 1; \ 588 byte_size_type byteSize_; \ 589 _ITERATE_ON_ALL(_DECLARE_SOA_DATA_MEMBER, ~, __VA_ARGS__) \ 597 #endif // DataFormats_SoATemplate_interface_SoALayout_h