caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Alexy Khrabrov <deliverable@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Efficient OCaml multicore -- roadmap?
Date: Thu, 24 Mar 2011 15:57:55 +0100	[thread overview]
Message-ID: <1300978675.8429.227.camel@thinkpad> (raw)
In-Reply-To: <4587C749-DEFE-47B9-8D9A-44FE5980B58F@gmail.com>

Am Donnerstag, den 24.03.2011, 09:44 -0400 schrieb Alexy Khrabrov:
> Where does the OCaml team stand on the multicore issues?  A year or so ago, when there was a prototype parallel GC implementation, IIRC, Xavier said it has to be done right.  So what are the official plans and the status of integrating what volunteers had done?
> 
> WIth Scala having a robust actors model and AKKA kernel, and Clojure built around efficient shared memory concurrency with agents and references and STM, and Haskell also really parallel, OCaml is lacking behind.  Furthermore, F# builds on strongly parallel .NET, overcoming granddaddy.  With multicores common even in laptops and iPads, we need an efficient  multicore OCaml!  Due to the model different from Haskell or Scala and Clojure, now all on github, OCaml is both more stable and also is slower to advance -- what do folks think about this situation?  How do you do shared memory parallelism now?

I'm a bit reluctant to answering to this at all, because there is a big
misunderstanding in the world about what parallelism is good for. Some
people think it is a technique for doing micro optimizations in their
code (i.e. parallelize some inner loops). Questions about "shared memory
concurrency" often go into this direction because existing code can
profit from it. Although there is nothing wrong in principal about this,
one should be very aware that the usefulness is very limited - often
only code speedups of a few percent of the total runtime can be
achieved, and it is often restricted to two cores. If you look at
programs that are designed for parallelism, the whole story is a
completely different one, though.

So, here is my answer to your latter question: I've started a library
for using independent processes as workers that can communicate via
explicit shared memory (see
https://godirepo.camlcity.org/svn/lib-ocamlnet2/trunk/code/src/netmulticore/, and https://godirepo.camlcity.org/svn/lib-ocamlnet2/trunk/code/examples/multicore/chameneos.ml for a coding sample). This seems at least to be a solution in the Unix world for coarse-grained parallelism that is not dominated by the communication overhead between the processes. Available features:

- manage worker processes
- the processes can use files, shared memory, and semaphores
- processes can communicate to each other by sending messages to
  "camlboxes". By tricky implementation, there is only overhead for 
  serialization but not deserialization which makes message passing
  really fast

Of course, this is all very experimental. At least it demonstrates that
exploiting shared memory between independent processes is possible. For
getting a real programming environment, one needs to put more effort
into this, though, especially we would need data structures that can
live in shared memory (e.g. hashtables).

The resulting programming model is of course not the usual
multi-threading model. In particular, values are not automatically put
into shared memory. This has to be explicitly managed. IMHO, this is not
a weakness, but rather a strong point (and not everybody will understand
this - it's a somehow comparable to banning "goto" from higher-level
languages). It also means that you cannot use parallelism for doing
micro optimizations - the whole program has to be re-designed.

Generally, I'd say there is right now no perfect solution to the
problem. As language developer, you have to foresee future hardware to
some degree. When more and more cores are added, the characteristics of
the hardware will gradually shift from SMP to NUMA, and the more it
does, message passing techniques will become more attractive.

I'd like to see Ocaml doing here well. Let the others focus on SMP
architectures (which will, at a certain point of hardware development,
only be found in laptops but not in real compute hardware).

Gerd

> 
> Cheers,
> Alexy
> 


-- 
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


  reply	other threads:[~2011-03-24 14:58 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24 13:44 Alexy Khrabrov
2011-03-24 14:57 ` Gerd Stolpmann [this message]
2011-03-24 15:03   ` Joel Reymont
2011-03-24 15:28     ` Guillaume Yziquel
2011-03-24 15:48       ` Gerd Stolpmann
2011-03-24 15:38     ` Gerd Stolpmann
2011-03-25 19:49   ` Richard W.M. Jones
     [not found] <2054357367.219171.1300974318806.JavaMail.root@zmbs4.inria.fr>
2011-03-24 23:13 ` Fabrice Le Fessant
2011-03-25  9:55   ` Alain Frisch
2011-03-25 11:44     ` Gerd Stolpmann
     [not found]   ` <1396338209.232813.1301046980856.JavaMail.root@zmbs4.inria.fr>
2011-03-25 10:23     ` Fabrice Le Fessant
2011-03-25 12:07       ` Gerd Stolpmann
2011-04-16 12:12         ` Jon Harrop
2011-03-25 10:51   ` Hugo Ferreira
2011-03-25 12:25     ` Gerd Stolpmann
2011-03-25 12:58       ` Hugo Ferreira
     [not found]       ` <341494683.237537.1301057887481.JavaMail.root@zmbs4.inria.fr>
2011-03-25 13:10         ` Fabrice Le Fessant
2011-03-25 13:41           ` Dario Teixeira
2011-03-30 18:12             ` Jon Harrop
2011-03-25 15:44           ` Hugo Ferreira
2011-03-25 18:24             ` Martin Jambon
2011-03-25 19:19               ` Hugo Ferreira
2011-03-25 20:26                 ` Gerd Stolpmann
2011-03-26  9:11                   ` Hugo Ferreira
2011-03-26 10:31                   ` Richard W.M. Jones
2011-03-30 16:56                     ` Jon Harrop
2011-03-30 19:24                       ` Richard W.M. Jones
2011-04-20 21:44                   ` Jon Harrop
2011-04-19  9:57                 ` Eray Ozkural
2011-04-19 10:05                   ` Hugo Ferreira
2011-04-19 20:26                   ` Gerd Stolpmann
2011-04-20  7:59                     ` Hugo Ferreira
2011-04-20 12:30                       ` Markus Mottl
2011-04-20 12:53                         ` Hugo Ferreira
2011-04-20 13:22                           ` Markus Mottl
2011-04-20 14:00                       ` Edgar Friendly
2011-04-19 22:49                 ` Jon Harrop
2011-03-30 17:02               ` Jon Harrop
2011-04-20 19:23               ` Jon Harrop
2011-04-20 20:05                 ` Alexy Khrabrov
2011-04-20 23:00                   ` Jon Harrop
     [not found]                   ` <76544177.594058.1303341821437.JavaMail.root@zmbs4.inria.fr>
2011-04-21  7:48                     ` Fabrice Le Fessant
2011-04-21  8:35                       ` Hugo Ferreira
2011-04-23 17:32                         ` Jon Harrop
2011-04-21  9:09                       ` Alain Frisch
     [not found]                         ` <20110421.210304.1267840107736400776.Christophe.Troestler+ocaml@umons.ac.be>
2011-04-21 19:53                           ` Hezekiah M. Carty
2011-04-22  8:34                           ` Alain Frisch
     [not found]                         ` <799994864.610698.1303412613509.JavaMail.root@zmbs4.inria.fr>
2011-04-22  8:06                           ` Fabrice Le Fessant
2011-04-22  9:11                             ` Gerd Stolpmann
2011-04-23 10:17                               ` Eray Ozkural
2011-04-23 13:47                                 ` Alexy Khrabrov
2011-04-23 17:39                                   ` Eray Ozkural
2011-04-23 20:18                                     ` Alexy Khrabrov
2011-04-23 21:18                                       ` Jon Harrop
2011-04-24  0:33                                       ` Eray Ozkural
2011-04-28 14:42                                         ` orbitz
2011-04-23 19:02                                 ` Jon Harrop
2011-04-22  9:44                             ` Vincent Aravantinos
2011-04-21 10:09                       ` Philippe Strauss
2011-04-23 17:44                         ` Jon Harrop
2011-04-23 17:05                       ` Jon Harrop
2011-04-20 20:30                 ` Gerd Stolpmann
2011-04-20 23:33                   ` Jon Harrop
2011-03-25 20:27             ` Philippe Strauss
2011-04-19 22:47           ` Jon Harrop
     [not found]           ` <869445701.579183.1303253283515.JavaMail.root@zmbs4.inria.fr>
2011-04-20  9:25             ` Fabrice Le Fessant
2011-03-25 18:45   ` Andrei Formiga
2011-03-30 17:00     ` Jon Harrop
2011-04-13  3:36   ` Lucas Dixon
2011-04-13 13:01     ` Gerd Stolpmann
2011-04-13 13:09       ` Lucas Dixon
2011-04-13 23:04       ` Goswin von Brederlow
2011-04-16 13:54     ` 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=1300978675.8429.227.camel@thinkpad \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=deliverable@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).