From: skaller <skaller@users.sourceforge.net>
To: Tom <tom.primozic@gmail.com>
Cc: Caml-list List <caml-list@inria.fr>
Subject: Re: [Caml-list] More registers in modern day CPUs
Date: Thu, 06 Sep 2007 17:17:02 +1000 [thread overview]
Message-ID: <1189063022.9224.126.camel@rosella.wigram> (raw)
In-Reply-To: <c1490a380709052320l792fae9ew2013618cd5917cc0@mail.gmail.com>
On Thu, 2007-09-06 at 08:20 +0200, Tom wrote:
> (This question may not be OCaml specific,
you'd be surprised ..
> However, would it be possible to "emulate" cpu registers using
> software? By keeping registers in the main memory, but accessing them
> often enough to keep them in primary cache? That would be quite fast I
> believe...
The technique is called 'boxing'. This is one reason why Ocaml
is so fast, when you'd expect the extra dereferences required
all the time to be a big penalty. Instead, if the address is
used but not the data (eg generic operation) cache is saved
compared to an expanded representation. The cache is loaded
if the pointer is dereferenced, and subsequent derefs are
effectively free provided only a small number of boxes
is opened: there is an extra cost of one word for the
address, which is the price of the lazy loading, and is
amortised away by generic operations.
This is even faster than one might think because cache
can do speculative preload of the pointed at data.
[Does Ocaml bother to generate those instructions?]
IMHO, the main purpose of registers is to organise
the interleaving of parallel operations (memory reads
mainly) based on dependencies. They differ from main
memory (and cache) in that they're usually thread local
(whereas all the other stuff is shared) so they're
expressing coupling between data and flow of control.
for example in:
R1 = a
R2 = b
R3 = R1 + R2
R4 = c
R5 = d
R6 = R4 + R5
you'd be mainly wrong to think of these instructions as operating
on data. No. Not today. These instructions are chopping up the
control flow into parallel threads:
a b c d
| | | |
V V V V
+ +
| |
I think that's the main reason for registers, not memory operands.
Registers only need a few bits to name, so the dispatching to
functional units is easier to calculate with less hardware.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2007-09-06 7:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-06 6:20 Tom
2007-09-06 7:17 ` skaller [this message]
2007-09-06 9:07 ` [Caml-list] " Richard Jones
2007-09-06 14:55 ` Chris King
2007-09-06 15:17 ` Brian Hurt
2007-09-06 15:54 ` Harrison, John R
2007-09-06 17:10 ` David MENTRE
2007-09-06 18:27 ` Harrison, John R
2007-09-06 18:28 ` Christophe Raffalli
2007-09-06 18:48 ` Brian Hurt
2007-09-06 18:48 ` Pal-Kristian Engstad
2007-11-20 15:32 ` [Caml-list] OCalm on Sony PS3 (was Re: More registers in modern day CPUs) Mike Hogan
2007-11-21 17:20 ` Richard Jones
2007-11-21 19:05 ` [Caml-list] OCaml " Mike Hogan
2007-11-23 6:44 ` Mike Hogan
2007-12-02 10:14 ` [Caml-list] OCalm " Xavier Leroy
2007-12-02 16:22 ` Mike Hogan
2007-12-02 22:19 ` Konrad Meyer
2007-12-03 0:09 ` [Caml-list] OCaml " Mike Hogan
2007-12-03 20:16 ` minithread (was OCaml on Sony PS3) Christophe Raffalli
2007-12-04 14:25 ` [Caml-list] " David MENTRE
2007-12-04 14:37 ` Basile STARYNKEVITCH
2007-12-04 16:25 ` Mattias Engdegård
2007-12-04 17:33 ` Gerd Stolpmann
2007-12-04 18:00 ` Mike Hogan
2007-12-04 2:29 ` [Caml-list] OCalm on Sony PS3 (was Re: More registers in modern day CPUs) Gordon Henriksen
2007-09-06 20:48 ` [Caml-list] More registers in modern day CPUs Richard Jones
[not found] ` <20070906204524.GB10798@furbychan.cocan.org>
2007-09-06 20:59 ` Chris King
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=1189063022.9224.126.camel@rosella.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@inria.fr \
--cc=tom.primozic@gmail.com \
/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