Re: : impossible alignment requirements?
On Nov 12, 10:10 pm, Mathias Gaunard <loufo...@gmail.com> wrote:
On Nov 7, 5:17 pm, Martin Bonner <martinfro...@yahoo.co.uk> wrote:
Could you give more details please. The alignment of a type must be
<= sizeof the type. What types on Mac have an alignment of 16? (NB.
I don't doubt your statement; I am just curious as to what reasonable
implementations may do.)
It's just that the stack is 16-byte aligned, which is quite unrelated.
This is not true. Stack may be or may be not aligned, it doesn't
matter.
Problem lies with vector types both on Mac and on PC and Playstation 3
also comes to mind.
*** C++ standard is terribly outdated ***
Not having an operator new which returns _aligned_ memory seriously
hampers SIMD use in C++.
What should one do with this code?
class foo
{
public:
__m128 vec;
...
foo(void)
{
vec = _mm_setzero_ps();
}
};
foo *p = new [](10);
C++ regulatory body is obviously sitting with their collective thumbs
up their arses instead of listening to developers and their needs.
Not only that, compiler vendors are not able to provide workarounds
for such issues because that would break the standard which btw is
already broken.
Let me touch on stack alignment when you mentioned it:
There is a compiler option to force stack alignment on every
function entry to a given value. Problem is in the standard again,
if you force say 16-byte alignment:
void somefunc(void)
{
char buf[32]; // sure, this will be aligned to 16 bytes
...
for (int i = 0; i < 32; i++) {
char foo[32]; // but this won't!
__declspec(align(16)) char bar[32]; // unless you add explicit
alignment directive
}
}
Then what is the point of having forced alignment if you are not
consistent? For every performance conscious developer those
things just suck.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]