digitalmars.D.learn - Struct's alignment
- Temtaime (15/15) Aug 10 2013 Hello, guys!
- Temtaime (1/1) Aug 10 2013 Sorry, not class, but struct.
- Manfred Nowak (4/5) Aug 10 2013 Maybey nothing than thinking---that the adress is printed in the number ...
- novice2 (15/15) Aug 10 2013 i guess, because of allocated on stack:
- bearophile (6/6) Aug 10 2013 Related?
- Kapps (3/18) Aug 13 2013 Perhaps core.simd (http://dlang.org/phobos/core_simd.html) could
Hello, guys! I have Matrix class(that contains an array of 16 floats) and SSE code to mult it. It's neccessary to have an array alignment 16. I'm figured out simple test-code: align(16) struct S { align(16) int a; } void main() { align(16) S s; writeln(cast(void *)&s.a); } And it prints 18FCC8, but must ends with "0". What i'm doing wrong? Thanks.
Aug 10 2013
Temtaime wrote:What i'm doing wrong?Maybey nothing than thinking---that the adress is printed in the number of bits, whereas it is printed in the number of bytes. -manfred
Aug 10 2013
i guess, because of allocated on stack: import std.stdio; align(16) struct S { align(16) int a; } S sGlobal; void main() { S sLocal; writefln("0x%08X 0x%08X", cast(uint) &sGlobal, cast(uint) &sLocal); } 0x00162110 0x0012FE14 but, IMHO, this is not good
Aug 10 2013
Related? http://d.puremagic.com/issues/show_bug.cgi?id=2278 Perhaps related: http://forum.dlang.org/thread/mailman.990.1370788529.13711.digitalmars-d-ldc puremagic.com?page=3#post-pecxybsbjdsnuljtyqjm:40forum.dlang.org Bye, bearophile
Aug 10 2013
On Saturday, 10 August 2013 at 20:36:24 UTC, Temtaime wrote:Hello, guys! I have Matrix class(that contains an array of 16 floats) and SSE code to mult it. It's neccessary to have an array alignment 16. I'm figured out simple test-code: align(16) struct S { align(16) int a; } void main() { align(16) S s; writeln(cast(void *)&s.a); } And it prints 18FCC8, but must ends with "0". What i'm doing wrong? Thanks.Perhaps core.simd (http://dlang.org/phobos/core_simd.html) could be of help. I believe that those types should be aligned.
Aug 13 2013