|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - struct alignments
I'm working on my vector and matrix math library, and now I'm prototyping my
SIMD optimizations, obviously I would like data alignment.. fact is I have
no clue how to do it ( I vaguely remember align directive)
for example something like (mixed C++ and D! :) ), what would I need for
pragma pack equivalent in D then for a struct?
#pragma pack(16)
struct Vector4d {
union {
struct { float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f; };
struct { float r, g, b, a; };
struct { float cell[4]; };
Repeat!(float, 4) tuple;
};
...
}
also somewhere down the road in the code I'd like equivalent of declspec
align too, for example something like
Vector4d opAdd( ref Vector4d v ) {
version(NORMAL) {
return Vector4d( x + v.x, y + v.y, z + v.z, w + v.w );
}
else version(SIMD) {
__declspec(align(16)) Vector4d v4_ret;
asm {
mov esi, this
mov edi, v
movaps xmm0, [esi]
addps xmm0, [edi]
movaps v4_ret, xmm0
}
return v4_ret;
}
}
or something like that, its illustrative only :)
Apr 13 2008
dominik wrote:I'm working on my vector and matrix math library, and now I'm prototyping my SIMD optimizations, obviously I would like data alignment.. fact is I have Apr 16 2008
One problem is that the stack (and hence all local variables) are only aligned to 32 bytes. This means you can only use SSE aligned loads (movaps, movapd) on static and heap variables. (This is something that D really should fix while it has the chance). Apr 16 2008
Lionello Lunesu wrote:One problem is that the stack (and hence all local variables) are only aligned to 32 bytes. This means you can only use SSE aligned loads (movaps, movapd) on static and heap variables. (This is something that D really should fix while it has the chance). Apr 16 2008
|