From: Don Syme <Don.Syme@microsoft.com> To: Xavier Leroy <Xavier.Leroy@inria.fr>, Jason Ganetsky <jason.ganetsky@gmail.com> Cc: "caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr> Subject: RE: [Caml-list] Multiprocessor support in OCaml Date: Sun, 22 Apr 2007 12:55:51 +0100 Message-ID: <7E24A64DB2F6F34E8C6002C4EB2344970872A237F1@EA-EXMSG-C315.europe.corp.microsoft.com> (raw) In-Reply-To: <462B3929.9080608@inria.fr> Just to mention there is a way of getting multiple concurrently executing OCaml threads in a program, which I discovered a while back: you can statically link multiple independent copies of the OCaml runtime, each into its own DLL (on Windows). This allows multiple independent OCaml threads to run concurrently. I presume this technique works well enough for SMP up to 2-4 processors, though have never done any serious performance testing. The OCaml programs must not, of course, trade OCaml values, but can communicate in-process by other means (e.g. shared C memory or some other message passing technique). Regards, Don P.S. I've only used this technique on Windows. -----Original Message----- From: caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Xavier Leroy Sent: 22 April 2007 11:30 To: Jason Ganetsky Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Multiprocessor support in OCaml > Anyway, I have recently written an OCaml thread pool implementation, on > top of the Thread and Event modules. I did this for the purpose of > exploiting an SMP system I have, and was a disappointed to read today > that OCaml doesn't support multiprocessor systems. You are correct that OCaml *threads* do not exploit multiprocessing. Basically, only one OCaml thread can run at a time. You can still get parallelism in several ways. First, external C libraries called from OCaml can run in parallel with OCaml code provided the OCaml/C interface for these libraries makes uses of the "blocking section" mechanism. Second, process-level parallelism works very well with programs written in message-passing style, using e.g. OcamlMPI or OCamlP3L. > I played around with it a little, and discovered that by liberally > calling Thread.yield, I do cajole my threads into running on multiple > processors. This is an illusion. Thread.yield gives more opportunities to the OS scheduler to reschedule a Caml thread on a different processor, but you're not gaining parallelism this way and you might actually lose performance (because of cache ping-pong effects and the like). - Xavier Leroy _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
next prev parent reply index Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-04-22 7:42 Jason Ganetsky 2007-04-22 8:44 ` [Caml-list] " Richard Jones 2007-04-22 10:30 ` Xavier Leroy 2007-04-22 11:55 ` Don Syme [this message] 2007-04-22 10:58 ` Erik de Castro Lopo 2007-04-22 13:29 ` Jon Harrop 2007-04-22 17:31 ` Zheng Li [not found] ` <ab351c020704221052v50ce66b6maec299889a2c1f1f@mail.gmail.com> 2007-04-22 17:52 ` [Caml-list] " Jason Ganetsky 2007-04-23 8:10 ` Richard Jones
Reply instructions: You may reply publically 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=7E24A64DB2F6F34E8C6002C4EB2344970872A237F1@EA-EXMSG-C315.europe.corp.microsoft.com \ --to=don.syme@microsoft.com \ --cc=Xavier.Leroy@inria.fr \ --cc=caml-list@yquem.inria.fr \ --cc=jason.ganetsky@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
caml-list - the Caml user's mailing list Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list AGPL code for this site: git clone https://public-inbox.org/ public-inbox