From: Kuba Ober <ober.14@osu.edu>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] ocaml doesn't need to optimize on amd64??
Date: Thu, 10 Jan 2008 11:36:47 -0500 [thread overview]
Message-ID: <200801101136.48170.ober.14@osu.edu> (raw)
In-Reply-To: <47862F53.1050605@janestcapital.com>
On Thursday 10 January 2008, you wrote:
> Kuba Ober wrote:
> >On Wednesday 09 January 2008, you wrote:
> >>On Wed, Jan 09, 2008 at 09:22:00AM -0500, Kuba Ober wrote:
> >>>Jon & al,
> >>>
> >>>why do you think that OCaml doesn't need to do certain
> >>>optimizations on amd64? Or does it apply only to 64 bit mode?
> >>>I run my benchmarks on amd64 (in 32 bit mode) and OCaml is worse
> >>>off than gcc.
> >>
> >>Register pressure. The extra eight registers in AMD64 make a huge
> >>difference to a lot of code generators. Of course, to access them
> >>you need to run in 64 bit mode.
> >
> >Don't current x32 processors "emulate" extra registers anyway? I don't
> > know what's the preferred way of telling the on-chip code dissector that
> > you intend the data to say in virtual registers, but it must be something
> > simple, like common, fixed memory locations or stack locations accessed
> > in a certain way. I'm sure if you google on Intel's site you'll find it.
> > In any event, the x32 chips have a notion of "many" virtual registers,
> > it's just the old x32 opcodes that don't have it. Isn't it so?
>
> Short answer: no.
>
> The problem is that the code generated code needs to spill and fill
> registers on 32-bit x86 a lot more. The extra registers are usefull in
> reordering instructions, and executing things in parallel (at the
> instruction level), but they can't avoid the memory accesses. Now,
> there are a lot of tricks the CPUs play in order to reduce the costs of
> these memory accesses, but they can't eliminate the memory accesses.
> And that's the problem: you've now increases the memory pressure of the
> CPUs.
If a thread keeps those "virtual registers" in an isolated memory page that's
accessed by nothing else, the CPU's caching will barely need to access the
memory, as there won't be pressure from other cores or CPUs in the system to
actually use that memory for anything. It will only get evicted to RAM if the
cache pressure is high.
The "spill and fill" problem is really only appropriate in the context of the
x86 registers actually existing somewhere. As far as I know, they are a
virtual concept, there's no piece of silicon in modern x86 CPUs that can be
called "the AX register". The actual opcodes referencing ax, bx, ...
registers is recompiled on the fly by the CPU into a RISC-like code running
on many more registers. Sure, the code rewriter has to work harder when
there's more opcodes to move stuff around, but I think that it's implemented
to actually recognize certain opcode patterns as "virtual register accesses".
I don't have any hard references on hand, but that's my impression so far. I
can try and dig up relevant Intel references.
Cheers, Kuba
prev parent reply other threads:[~2008-01-10 16:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-09 14:22 Kuba Ober
2008-01-09 17:14 ` [Caml-list] " Jon Harrop
2008-01-10 22:56 ` Jon Harrop
2008-01-11 0:42 ` Peng Zang
2008-01-11 13:14 ` Kuba Ober
2008-01-12 16:20 ` Will Farr
2008-01-14 12:16 ` Kuba Ober
[not found] ` <20080110024359.GA15544@mulga.csse.unimelb.edu.au>
2008-01-10 13:56 ` Kuba Ober
[not found] ` <47862F53.1050605@janestcapital.com>
2008-01-10 16:36 ` Kuba Ober [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200801101136.48170.ober.14@osu.edu \
--to=ober.14@osu.edu \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox