std.math performance (SSE vs. real)

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 30 18:33:11 PDT 2014


On Tue, Jul 01, 2014 at 01:21:11AM +0000, Chris Cain via Digitalmars-d wrote:
> On Monday, 30 June 2014 at 21:51:22 UTC, H. S. Teoh via Digitalmars-d wrote:
> >How do you implement 80-bit reals in the library?
> 
> Is it a legitimate problem to do so? My feeling is that it should be
> possible if it's possible to implement it in C or asm since it's
> possible to do everything in D that is possible to do in C or asm.

It will be a pain, because you will need asm blocks to implement x87
instructions. And you won't be able to simulate optimizations that the
compiler can -- like common subexpression factoring, eliminating
redundant loads, etc.. Those are precisely the kind of things that you
need compiler support for, in order to have acceptable performance.

(Well, you *could* in theory implement these optimizations using CTFE to
produce asm string mixins, but you'd have to use string DSLs instead of
language-level expressions in order for this to work.  Or you'd have to
use expression templates, which will become an unmaintainable mess. Plus
you'd be reinventing much of what the compiler already does for you --
register allocation, codegen, etc.. Basically, all that work just to
move reals outside the compiler seems to be misdirected effort to me.)


T

-- 
If you think you are too small to make a difference, try sleeping in a closed room with a mosquito. -- Jan van Steenbergen


More information about the Digitalmars-d mailing list