FreeBSD Most wanted

Narvi narvi at haldjas.folklore.ee
Sun Mar 7 09:44:59 PST 2004


On Sat, 6 Mar 2004, stephan mantler wrote:

> Narvi wrote:
> >>"Familiarity with the target machine and its instruction set is a
> >>prerequisite for designing a good code generator.  Unfortunately, in a
> >>general discussion of code generation it is not possible to describe
> >>the nuances of any target machine in sufficient detail to be able to
> >>generate good code for a complete language on that machine."
> >>  -- The "Dragon" Book, pp 519
> >
> > Sure - but code generation is but one part of the compiler and usualy not
> > the largest.
>
> Well, it is still a crucial part of the compiler and deeply tied into the
> rest. It is also the reason why simply using the Intel C++ compiler instead
> of .NET2003 (both at full optimization) made our vector math library run
> five times faster... guess who knows the target architecture ;-)  In this

Umm... It soudns far more plausible that Intel's compiler was able to
make use of vectorisiation so that it uses SSE2 instead of x87 fpu. This
is for the most part not ASM, but code analysis / rewriting. Sure, you
need to be able to isse the SSE2 opcoides but that is a tiny part.

Knowing any amount of SSE2 tricks will not help you one bit if the
compiler cannot flatten the loop so you can make use of SIMD / vector
instructions. Once you have that part done, you canthen relatively easily
(at least in comparison to the ananlysis you need to be able to do)
interface this to SSE2 && SSE and Altivec and VIS.

> highly specific example hand optimized assembler code is another four times
> faster for some functions, but I think this is not a problem of compilers per
> se. I guess the C/C++ language simply isn't giving the compiler all the
> information it would need. I haven't yet tried Intel's feedback optimization
> feature, but it will be interesting to see what it will do to our library.
>

Its not all the information, its that it is unable to assume some things.
If you have a compiler that can do interfile optimisations and profile
feedback, it might generate better code.  alternatively, if you want to
see what the compiler can achieve, rewrite the routines in fortran (no i'm
not kidding). In C, it is often very hard for the compiler to make
assumptions about array overlap or aliasing.

> Also, to get a bit closer to the original topic. I can't remember where I
> read this (DDJ probably), but apparently programmers who have a deep
> understanding of computer architecture through low level programming also
> produce "better" code in high level languages. My interpretation is that
> they are simply feeding the compiler a better foundation to work with.
>

The understanding would probably be about things like memory hierarchy and
not ASM though.

> Cheers,
> -stephan
>
> --
> stephan mantler             | web www.stephanmantler.com
> ----------------------------| net step at stephanmantler.com
> It's not an adventure       | fon +43 (699) 104 128 42
> until something f--ks up.   | fax +43 (699) 404 128 42
>


More information about the freebsd-chat mailing list