caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Jon Harrop <jonathandeanharrop@googlemail.com>
Cc: "'Goswin von Brederlow'" <goswin-v-b@web.de>, <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] SMP multithreading
Date: Sat, 20 Nov 2010 21:57:52 +0100	[thread overview]
Message-ID: <87hbfb3e7j.fsf@frosties.localnet> (raw)
In-Reply-To: <04be01cb88a9$d2df4810$789dd830$@com> (Jon Harrop's message of "Sat, 20 Nov 2010 11:55:26 -0000")

Jon Harrop <jonathandeanharrop@googlemail.com> writes:

>> This is actually a quick way to use multiple cores with ocaml. Find a
>> often called function that takes considerable time and offload it to C
>
> Or HLVM, F#, Scala, Clojure or any of the other languages that permit shared
> memory parallelism. C is particularly poor in this regard so I would not
> just restrict yourself to C...
>
> Cheers,
> Jon.

I'm not talking about any shared memory parallelism here. The
parallelism is completly restricted to the ocaml side. You just find
some single threaded job that takes long, rewrite it as external
function and release the ocaml lock while it is running.

For example in my code I compute the sha256 sum of a block of
data. Since I use a C library for sha256 anyway the function is already
external. All I had to do was switch the interface from using string to
Bigarray and add enter/leave_blocking_section(). After that multiple
threads can compute the sha256 sum for blocks of data in parallel and my
code run 3.7 times faster with 4 cores.

MfG
        Goswin



  reply	other threads:[~2010-11-20 20:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-15 17:27 Wolfgang Draxinger
2010-11-16  6:46 ` [Caml-list] " Edgar Friendly
2010-11-16 17:04   ` Gerd Stolpmann
2010-11-16 20:35     ` Eray Ozkural
2010-11-16 22:13       ` Gerd Stolpmann
2010-11-16 23:04         ` Eray Ozkural
2010-11-16 23:52           ` Wolfgang Draxinger
2010-11-17  1:55             ` Eray Ozkural
2010-11-17  3:41             ` Jon Harrop
2010-11-17  3:47           ` Jon Harrop
2010-11-17  4:27             ` Eray Ozkural
2010-11-17  6:50               ` Gabriel Kerneis
2010-11-17 13:41                 ` Eray Ozkural
2010-11-17 21:15                   ` Jon Harrop
2010-11-18  0:28                     ` Eray Ozkural
2010-11-18  1:00                       ` Eray Ozkural
2010-11-16 19:07   ` Norman Hardy
2010-11-17 16:34   ` David Allsopp
2010-11-19 13:57     ` Eray Ozkural
2010-11-16 12:47 ` Sylvain Le Gall
2010-11-17 11:12   ` [Caml-list] " Goswin von Brederlow
2010-11-17 11:34     ` Sylvain Le Gall
2010-11-17 23:08       ` [Caml-list] " Christophe Raffalli
2010-11-19  9:01         ` Christophe TROESTLER
2010-11-19 15:58           ` Goswin von Brederlow
2010-11-20 11:55             ` Jon Harrop
2010-11-20 20:57               ` Goswin von Brederlow [this message]
     [not found] ` <AANLkTinyN2hHxm6ha2Yq4nx6NxY3So=BhFN_-EHKYfyc@mail.gmail.com>
2010-11-16 14:11   ` Wolfgang Draxinger

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=87hbfb3e7j.fsf@frosties.localnet \
    --to=goswin-v-b@web.de \
    --cc=caml-list@yquem.inria.fr \
    --cc=jonathandeanharrop@googlemail.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).