3D Math Data structures/SIMD

Lukas Pinkowski Lukas.Pinkowski at web.de
Sat Dec 22 03:50:54 PST 2007


Sascha Katzner wrote:

> Lukas Pinkowski wrote:
>> SIMD instructions are pretty 'old' now, but the compilers support them
>> only through non-portable extensions, or handwritten assembly.
> 
> One reason could be that, it is a performance penalty for the OS to save
> the SIMD registers (XMM1, XMM2...etc.). You can verify that with the
> test programm attached to this posting. If you uncomment lines 27-30 the
> programm is ~50% slower (9.8s vs 6.7s on a Core 2 Duo E6750 on Vista).
> 
> SSE is great if you do a lot of heavy computations in your program, but
> if you only do a dot product here and a cross product there you better
> not use SSE, because your whole program runs a lot slower if you use SSE
> instructions.
> 
> LLAP,
> Sascha Katzner

Hi, that's because the OS needs to backup both SSE-registers and the
x87-stack. 
On my Athlon64 3800+ on openSUSE 10.2 (GCC 4.1.2), when I compile the
equivalent C++-code once with SSE and once with x87, they are equally fast
(see attached code). And that's even without using GCC's SIMD extension.
I'll try to make an example with SIMD operations (though I don't think that
there we'll be a significant performance gain for this easy code, if at
all).
(Note: Using double in test.cc because float yields different results for
SSE and x87)

As I don't have GDC installed (it fails to build for me), I can't test it
with GDC. But I've read often enough that DMD doesn't generate fast FP
code.

Of course, by disabling the x87, we loose D's real type, but that's OK for
applications where 80bit precision is not required. It would be a _compiler
option_ anyway, and if you're into numerics you really should know what
you're doing!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cc
Type: text/x-csrc
Size: 1082 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20071222/b1cb017a/attachment.c>


More information about the Digitalmars-d mailing list