caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jonathandeanharrop@googlemail.com>
To: "'Eray Ozkural'" <examachine@gmail.com>,
	"'Caml List'" <caml-list@inria.fr>
Subject: RE: [Caml-list] Unboxing: how to do it best?
Date: Sun, 16 Jan 2011 17:03:57 -0000	[thread overview]
Message-ID: <005d01cbb59f$63623880$2a26a980$@com> (raw)
In-Reply-To: <AANLkTi=g2bny3VaSEOhYxEJRO_iGur365FgEsJe6d-_G@mail.gmail.com>

Eray wrote:
> It's obvious that avoiding pointer chasing, improving locality and
reducing storage
> will in some cases improve performance considerably.

Yes. Generic hash tables are my favourite example where this hurts. Java and
OCaml can be over an order of magnitude slower than .NET due to boxing in
that case.

> I've found many discussions about unboxing, but I haven't seen any
solutions that
> would satisfy high-performance-computing programmers, who would probably
like to
> have better (i.e. fine-grained) control over memory layout (unboxing
double arrays
> isn't enough). In C++ this is trivial, because C++ is just an abstraction
of assembly
> code. To cut it short, could not we have basically the same affordances of
C++ in
> ocaml by annotating type definitions to indicate where unboxing would be
forced?
> Such annotations aren't a new idea in programming languages, specifically
HPF was
> based largely on parallel storage annotations.

Yes, .NET already does what you are describing: unboxed types are called
"value types". For example, you can allocate an array of structs and refer
to them by array index rather than reference in order to avoid all
allocations and garbage collections. Some people have used this approach to
write low-latency software that never incurs a garbage collection during
steady state operation. I have recently been writing prototype garbage
collectors in F# using the same technique to great effect.

HPC programmers using OCaml will have to settle for generating code from
OCaml when you need to escape its data representation. HLVM is an example of
how this might be done and was specifically designed with HPC in mind.

Cheers,
Jon.



      parent reply	other threads:[~2011-01-16 17:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-15 12:02 Eray Ozkural
2011-01-15 12:38 ` Guillaume Yziquel
2011-01-15 14:00   ` Eray Ozkural
2011-01-15 17:23     ` Guillaume Yziquel
2011-01-15 18:33       ` Eray Ozkural
2011-01-16 16:53         ` Jon Harrop
2011-01-18 23:49         ` Guillaume Yziquel
2011-01-15 12:41 ` bluestorm
2011-01-15 13:37   ` Eray Ozkural
2011-01-16 17:03 ` Jon Harrop [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='005d01cbb59f$63623880$2a26a980$@com' \
    --to=jonathandeanharrop@googlemail.com \
    --cc=caml-list@inria.fr \
    --cc=examachine@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;
as well as URLs for NNTP newsgroup(s).