From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 68F67BC37 for ; Sun, 27 Dec 2009 13:46:36 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhAFAGrlNkvZSMDji2dsb2JhbACBSXaZGwEBAQoLCgcRBbUMhDMEiVo X-IronPort-AV: E=Sophos;i="4.47,458,1257116400"; d="scan'208";a="42795238" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail1-smtp-roc.national.inria.fr with ESMTP; 27 Dec 2009 13:46:35 +0100 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id 7BD6E14A839C0; Sun, 27 Dec 2009 13:45:56 +0100 (CET) Received: from [95.208.117.111] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NOsVO-0006T9-00; Sun, 27 Dec 2009 13:45:54 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1NOsVN-00043S-Ta; Sun, 27 Dec 2009 13:45:53 +0100 From: Goswin von Brederlow To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: multicore wish References: <4B2D2BC1.6020204@msu.edu> <200912221912.51017.jon@ffconsultancy.com> <87r5qk5x1j.fsf@frosties.localdomain> <200912241706.51917.jon@ffconsultancy.com> Date: Sun, 27 Dec 2009 13:45:53 +0100 In-Reply-To: <200912241706.51917.jon@ffconsultancy.com> (Jon Harrop's message of "Thu, 24 Dec 2009 17:06:51 +0000") Message-ID: <87bphkk2ke.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.22 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX19y6QbD03xlSJA+5zOwvXsseOaWjLGzeA+xL/jV FvhKS+md64lKkzBt6n1fPkYnqVCRBi7e9daX2GS/BRD5JQHekf odynHt0Eo= X-Spam: no; 0.00; ocaml:01 ocaml:01 locality:01 ocaml's:01 bigarray:01 marshaling:01 stubs:01 2009:98 dry:98 ruin:98 pices:98 mfg:98 threads:01 threads:01 closures:01 Jon Harrop writes: > On Thursday 24 December 2009 13:19:52 Goswin von Brederlow wrote: >> Jon Harrop writes: >> > No, in OCaml I fork every child. That is the only transparent way to give >> > the child a coherent view of the heap but it is extremely slow (~1ms): >> >> So if you add a (sleep 60) to the ocaml code then ocaml gets even >> more worse than F#? You are comparing an implementation that is >> specifically optimized to use things F# is good at and ocaml is >> bad. To give a fair comparison you need to optimize the implementation >> to the language. > > Post a better OCaml solution if you can. > >> >> Each process then has a work queue which is works through. So they will >> >> always use the local data. Only when a queue runs dry they steal from >> >> another process and ruin locality. >> > >> > You are correctly describing the efficient solution based upon >> > work-stealing queues that F# uses but OCaml cannot express it. >> >> You mean that you didn't implement that way. > > No, I mean OCaml cannot express it. > >> I can easily express that with closures and pre-forked worker threads. > > OCaml's threads do not run in parallel so that will not work. >> Or just implement it properly in ocaml. The problem part is the >> GC. The rest is easy. > > No kidding. There is one implementation: http://www.algo-prog.info/ocmc/web/ But as said maybe not a verry good one. I tried implementing parallel threads under the original GC by forking multiple instances of the same program and using a Bigarray to mmap /dev/null for shared memory between the instances. That works for sharing primitive types, flat records (records of primitive types) and even fixed (or bound) sized structures but it gets more and more complex to share each and needs some Obj magic, marshaling or C stubs (except for primitive types). It works but is a real hack. I hope someone will pick up the pices and update OCaml4Multicore to the latest ocaml or maybe for ocaml to add it directly. If not then I fear ocaml will be left behind soon. MfG Goswin