Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoA layout with std::array type column crashes PoolOutputModule #40982

Open
thomreis opened this issue Mar 7, 2023 · 7 comments
Open

SoA layout with std::array type column crashes PoolOutputModule #40982

thomreis opened this issue Mar 7, 2023 · 7 comments

Comments

@thomreis
Copy link
Contributor

thomreis commented Mar 7, 2023

When a PortableCollection of an SoA with a layout that contains a column of std::array type is written to an EDM ROOT file the PoolOutputModule crashes (Observed in CMSSW_13_0_0_pre4).
This problem might be related to this ROOT issue root-project/root#12007 . ROOT seems to not support branchs of type std::array<T, N>[nElem].

Below is an example of a layout that is problematic. Note that the using is needed to not confuse the macro that interprets the layout with commas.

using Array = std::array<uint32_t, 10>;

GENERATE_SOA_LAYOUT(ExampleSoALayout,
  SOA_COLUMN(Array, data)
)
using ExampleSoA = ExampleSoALayout<>;

A workaround that avoids the crash is to wrap the std::array in a struct and use that as the column type. In addition the struct needs to be declared in the classes_def.xml file.

Below is an example of a working layout with the array inside the struct and some functions to make this more transparent when accessing the array data.

template <class T, std::size_t N>
struct StdArrayStruct {
  std::array<T, N> array;

  T* data() { return array.data(); };
  const T* data() const { return array.data(); };
  T& operator[](size_t n) { return array[n]; };
  const T& operator[](size_t n) const { return array[n]; };
};

using DataArrayStruct = StdArrayStruct<uint32_t, 10>;

GENERATE_SOA_LAYOUT(ExampleSoALayout,
  SOA_COLUMN(DataArrayStruct, data)
)
using ExampleSoA = ExampleSoALayout<>;
@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 7, 2023

A new Issue was created by @thomreis Thomas Reis.

@Dr15Jones, @perrotta, @dpiparo, @rappoccio, @makortel, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@thomreis
Copy link
Contributor Author

thomreis commented Mar 7, 2023

assign heterogeneous

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 7, 2023

New categories assigned: heterogeneous

@fwyzard,@makortel you have been requested to review this Pull request/Issue and eventually sign? Thanks

@makortel
Copy link
Contributor

makortel commented Mar 7, 2023

assign core

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 7, 2023

New categories assigned: core

@Dr15Jones,@smuzaffar,@makortel you have been requested to review this Pull request/Issue and eventually sign? Thanks

@makortel
Copy link
Contributor

makortel commented Mar 7, 2023

@pcanal Could you take a look?

@makortel
Copy link
Contributor

#43076 provides a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants