From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4B2EEBC69 for ; Sun, 22 Apr 2007 13:55:56 +0200 (CEST) Received: from smtp-dub.microsoft.com (smtp-dub.microsoft.com [213.199.138.181]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3MBttMI013446 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Sun, 22 Apr 2007 13:55:56 +0200 Received: from dub-exhub-c302.europe.corp.microsoft.com (65.53.213.92) by DUB-EXGWY-E802.partners.extranet.microsoft.com (10.251.129.2) with Microsoft SMTP Server (TLS) id 8.1.85.3; Sun, 22 Apr 2007 12:55:54 +0100 Received: from EA-EXMSG-C315.europe.corp.microsoft.com ([65.53.221.65]) by dub-exhub-c302.europe.corp.microsoft.com ([65.53.213.92]) with mapi; Sun, 22 Apr 2007 12:55:54 +0100 From: Don Syme To: Xavier Leroy , Jason Ganetsky Cc: "caml-list@yquem.inria.fr" Date: Sun, 22 Apr 2007 12:55:51 +0100 Subject: RE: [Caml-list] Multiprocessor support in OCaml Thread-Topic: [Caml-list] Multiprocessor support in OCaml Thread-Index: AceEyT+H7mQqzCUKTWKQ30jpTGKqMAACvGhg Message-ID: <7E24A64DB2F6F34E8C6002C4EB2344970872A237F1@EA-EXMSG-C315.europe.corp.microsoft.com> References: <462B3929.9080608@inria.fr> In-Reply-To: <462B3929.9080608@inria.fr> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Miltered: at concorde with ID 462B4D4B.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syme:01 syme:01 ocaml:01 ocaml:01 threads:01 statically:01 runtime:01 threads:01 parallelism:01 parallelism:01 ocamlmpi:01 scheduler:01 beginner's:01 bug:01 reschedule:98 Just to mention there is a way of getting multiple concurrently executing O= Caml threads in a program, which I discovered a while back: you can statica= lly link multiple independent copies of the OCaml runtime, each into its ow= n DLL (on Windows). This allows multiple independent OCaml threads to run c= oncurrently. I presume this technique works well enough for SMP up to 2-4 processors, th= ough have never done any serious performance testing. The OCaml programs must not, of course, trade OCaml values, but can communi= cate 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.inri= a.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