data alignment in VS6
Yo,
I''m having trouble aligning data to 16-byte boundaries for SSE instructions. This is the way I try to do it:
__declspec(align(16)) float vector[4];
(declared globally)
However, this gets flagged by the compiler with the message:
fatal error C1600: unsupported data type
If I try __declspec(align(2)) it compiles OK (but is pretty useless . I''m compiling on Visual Studio 6 C++ Standard Edition (so no MS processor pack) with Service Pack 5.
Is it something that I''m doing wrong, or is it my cheap compiler?
Thanks for your help,
Pete
Is it declared on the stack? You can''t align stack variables, only member or global variables.
If I had my way, I''d have all of you shot!
codeka.com - Just click it.
Can you use:
#pragma pack(2)
or am I way off base?
---
Make it work.
Make it fast.
"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
#pragma pack(2)
or am I way off base?
---
Make it work.
Make it fast.
"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
I tried:
class Vector
{
__declspec(align(32)) float vector[4];
};
Vector vector;
But VC still blew a gasket. I tried #pragma pack (16), but that didn''t affect the memory allocation at all.
class Vector
{
__declspec(align(32)) float vector[4];
};
Vector vector;
But VC still blew a gasket. I tried #pragma pack (16), but that didn''t affect the memory allocation at all.
Can't you just manually add padding fields until the class has the right memory layout?
#pragma pack
should also work...
And is it a good idea to call a global variable vector?
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
[edited by - Paradigm Shifter on September 3, 2002 8:01:34 AM]
#pragma pack
should also work...
And is it a good idea to call a global variable vector?
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
[edited by - Paradigm Shifter on September 3, 2002 8:01:34 AM]
> Can''t you just manually add padding fields until the class has the right memory layout?
That would ensure correct alignment within the class, but wouldn''t guarantee an instance of the class will be aligned.
> And is it a good idea to call a global variable vector?
Nope, my code is a big hack at the moment
That would ensure correct alignment within the class, but wouldn''t guarantee an instance of the class will be aligned.
> And is it a good idea to call a global variable vector?
Nope, my code is a big hack at the moment
Isn''t there a VS compile option that sets the alignment amount...? I believe the default IS 16.
#pragma pack(16) means 16 byte boundaries.
Use #pragma pack(2) for 2 byte boundaries.
---
Make it work.
Make it fast.
"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
Use #pragma pack(2) for 2 byte boundaries.
---
Make it work.
Make it fast.
"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
I''m not sure why it''s not working. But don''t forget that using
Actually, looking in the documentation, it says that error is usually a result of applying a service pack and not the corresponding processor pack... I don''t know if that has anything to do with you, but when I tried
malloc
or new
will not align data, even it''s got a __declspec(align)
modifier. You need to use _aligned_malloc
or overload operator new
yourself.Actually, looking in the documentation, it says that error is usually a result of applying a service pack and not the corresponding processor pack... I don''t know if that has anything to do with you, but when I tried
__declspec(align(16))
with VS.NET, it worked OK. If I had my way, I''d have all of you shot!
codeka.com - Just click it.This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement