Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 10, 2013 Struct's alignment | ||||
---|---|---|---|---|
| ||||
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. |
August 10, 2013 Re: Struct's alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | Sorry, not class, but struct. |
August 10, 2013 Re: Struct's alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | 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
|
August 10, 2013 Re: Struct's alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | 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 |
August 10, 2013 Re: Struct's alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | 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 |
August 13, 2013 Re: Struct's alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | 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. |
Copyright © 1999-2021 by the D Language Foundation