Closed YunHsiao closed 9 months ago
Hi @YunHsiao ,
If you knew ahead of time the final array size you could go the other way and pre-allocate your array and reference the individual elements
using FloatP = Packet<float, 8>;
Array<FloatP, 3> v;
FloatP& a = v[0];
FloatP& b = v[1];
FloatP& c = v[2];
If that's perhaps a bit too unwieldy for your purposes I would say having an Array<FloatP*, 3>
would be the way to go.
Oh I just realized the data structure layout I use is is not quite right:
using FloatP = Packet<float, 8>;
// Declare a custom struct `MyStruct` using DRJIT_STRUCT infrastructures
using FloatX = DynamicArray<FloatP>;
using MyStructX_DoNotUse = MyStruct<FloatX>; // Total SoA layout, very painful to use packet-wise on struct member level
using MyStructP = MyStruct<FloatP>;
using MyStructX = DynamicArray<MyStructP>; // AoSoA layout, much better for packet traversal
Falls straight into the trap, haha. Closing this.
By requiring array element types to be default constructible, references are no longer a valid array element type:
Is there any workarounds for making a vector made of references without copying?