caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Eray Ozkural <examachine@gmail.com>
To: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Unboxing: how to do it best?
Date: Sat, 15 Jan 2011 20:33:33 +0200	[thread overview]
Message-ID: <AANLkTi=_J3Y2kOGpEExv4Hzqkw_5yUOEtuiOVus1OfX_@mail.gmail.com> (raw)
In-Reply-To: <20110115172300.GN4195@localhost>

[-- Attachment #1: Type: text/plain, Size: 4254 bytes --]

On Sat, Jan 15, 2011 at 7:23 PM, Guillaume Yziquel <
guillaume.yziquel@citycable.ch> wrote:

> Le Saturday 15 Jan 2011 à 16:00:21 (+0200), Eray Ozkural a écrit :
> >    On Sat, Jan 15, 2011 at 2:38 PM, Guillaume Yziquel
> >    <[1]guillaume.yziquel@citycable.ch> wrote:
> >
> >      Then, for instance, given a datatype, you may wish to construct the
> >      datatype of an array of such types. Such a function needs to know
> >      details about the way OCaml boxes or unboxes different kinds of
> >      arrays,
> >      and it can be done (though rather awkwardly in my case).
>
>
Awkwardly, but how? :)



> >    That's a good idea.
> >    Theoretically a functor transforms programs. Radical program rewriting
> >    would be just the thing to do with a functor, but I'd rather have it
> in
> >    the compiler.
>
> I wasn't thinking of applying functors to rewrite / specialise (whatever
> you call it) some code to a datatype.
>
>
Ok, you mean exactly like C++ type traits, where a static namespace provides
further type information. In OCaml that'd be a module, right.


> I was more thinking of having a first-class module as a regular value
> that provides, when you unpack it, sufficient information to know how to
> cross the barriers from OCaml to C or Fortran or whatever, and then send
> it or receive it via an MPI implementation (since that's what I'm
> looking at). Which means all your HPC primitives must know how to read
> properly the datatype info enclosed in your first-class module.
>

I didn't really have MPI types on my mind, but it would surely be nice to be
able to integrate nicely with MPI as well, though I think the Marshal module
isn't costly (I made a small benchmark).

What I had in mind was, say, I have this CA simulation or spiking neural net
simulation code or a cell simulation, or a quantum chromodynamics
simulation, maybe a visualization of an irregular mesh, or some other
non-trivial scientific computing application where it's difficult to reduce
everything to float arrays. Because usually you will have either vectors, or
graphs of complex atomic structures and then this boxing is going to
seriously hurt performance, as performance is hurt when you try to write any
serious algorithm in Java in an OO fashion because everything is a pointer.
When you have to start writing every algorithm in an awkward and bloated way
to maintain some sense of performance, the benefit of the language quickly
vanishes. (Main reason why Java should never be used except for toy web
apps!) And then the HPC guy will have to turn to the portable assembly of
C++, right?


> I'm saying first-class module, because it can be typed as 'value datatype.
> You only know what the 'value it is supposed to encode is, and have all
> the typing info of how to deal with it encapsulated in the first-class
> module and not leaking into the rest of your code.
>

Ok, care to give a minimal example? How do you pass and use the module
value? This sounds interesting enough. You seem to be using the module to
encapsulate encoding/decoding functions. Which is fine but how is it enough?
How would that apply to changing the memory layout of a data type (or to
provide an unboxed array of such values)? I thought you would be generating
another module that represents the same type as an array of ints, and
somehow convert the types transparently. How do you propose to do it?

>    What I would like is something like (thinking of a typical simulation
> >    datatype):
> >    type cvector4 = ][ (complex * complex * complex * complex)
> >    where ][ would be a "type operator" enforcing a flattened
> >    representation of the type expression it is applied to. It would just
> >    change the layout so it would be equivalent to the same type without
> >    the unboxing op.
>
> If I'm not mistaking tuples or records of floats are already unboxed at
> runtime. Not seeing the great benefit here.
>

Yes, but the above is not a tuple of floats.

Best,

-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct

[-- Attachment #2: Type: text/html, Size: 5666 bytes --]

  reply	other threads:[~2011-01-15 18:33 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 [this message]
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

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='AANLkTi=_J3Y2kOGpEExv4Hzqkw_5yUOEtuiOVus1OfX_@mail.gmail.com' \
    --to=examachine@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=guillaume.yziquel@citycable.ch \
    /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).