digitalmars.D.learn - Alligned gc allocation of struct
- Sjoerd Nijboer (6/6) Oct 05 2018 I've got a `struct Foo{ubyte16 field1, field2.... fieldn;}` for
- Kagamin (1/1) Oct 05 2018 GC allocations are 16 bytes aligned.
- Sjoerd Nijboer (2/3) Oct 05 2018 That's perfect. Thank you!
- Dennis (2/3) Oct 05 2018 Is that an implementation detail or well-defined behavior?
- Sjoerd Nijboer (4/7) Oct 05 2018 The GC_Allocator doesn't support alignedAllocate from the
- Stanislav Blinov (14/22) Oct 07 2018 I don't think you should rely on them being specifically 16-bytes
I've got a `struct Foo{ubyte16 field1, field2.... fieldn;}` for which I would like a heap allocation `Foo* foo = new Foo();` But the fields itsself must be 16 bytes aligned for SIMD instructions. Is there a neat way to do this in D? As far as I can tell the GC_allocator doesn't do aligned allocations by default.
Oct 05 2018
On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:GC allocations are 16 bytes aligned.That's perfect. Thank you!
Oct 05 2018
On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:GC allocations are 16 bytes aligned.Is that an implementation detail or well-defined behavior?
Oct 05 2018
On Friday, 5 October 2018 at 14:55:04 UTC, Dennis wrote:On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:The GC_Allocator doesn't support alignedAllocate from the IAllocate interface, which is kinda unfortunate. So I'm a little worried that this might change in the future.GC allocations are 16 bytes aligned.Is that an implementation detail or well-defined behavior?
Oct 05 2018
On Friday, 5 October 2018 at 20:41:15 UTC, Sjoerd Nijboer wrote:On Friday, 5 October 2018 at 14:55:04 UTC, Dennis wrote:I don't think you should rely on them being specifically 16-bytes aligned, if portability is your goal. The `GC`'s methods such as `GC.malloc` do indeed return an "aligned" memory block, but that's about it as far as the spec goes. If, however, your target is specifically amd64 and SIMD, then you can safely assume the allocations are indeed always 16-bytes aligned. On a side note, I think the `alignedAllocate` from the allocator interface in std.experimental was a poor API decision. Better have a specific allocator instance that allocates in an appropriate alignment requirement. If I ever see an allocator that supports allocating with both an unspecified alignment and arbitrary alignment, I'd steer clear from it even without looking at the implementation.On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:The GC_Allocator doesn't support alignedAllocate from the IAllocate interface, which is kinda unfortunate. So I'm a little worried that this might change in the future.GC allocations are 16 bytes aligned.Is that an implementation detail or well-defined behavior?
Oct 07 2018