From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 624677EE99 for ; Tue, 7 Jan 2014 22:51:26 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of markus.mottl@gmail.com) identity=pra; client-ip=74.125.82.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of markus.mottl@gmail.com designates 74.125.82.43 as permitted sender) identity=mailfrom; client-ip=74.125.82.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f43.google.com) identity=helo; client-ip=74.125.82.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="postmaster@mail-wg0-f43.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgMDAJN2zFJKfVIrlGdsb2JhbABZg0NJDLlqgQwIFg4BAQEBBwsLCRIqgiUBAQEEQAEUBxEMAQMMBgULDS4hAQERAQUBHAYTG4dUAQMRnVqMXIMJkQUKGScNZIQQEQEFDIxlghMHhDcEiUOMaIFsjFqDThgphHce X-IPAS-Result: AgMDAJN2zFJKfVIrlGdsb2JhbABZg0NJDLlqgQwIFg4BAQEBBwsLCRIqgiUBAQEEQAEUBxEMAQMMBgULDS4hAQERAQUBHAYTG4dUAQMRnVqMXIMJkQUKGScNZIQQEQEFDIxlghMHhDcEiUOMaIFsjFqDThgphHce X-IronPort-AV: E=Sophos;i="4.95,621,1384297200"; d="scan'208";a="43898627" Received: from mail-wg0-f43.google.com ([74.125.82.43]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Jan 2014 22:51:12 +0100 Received: by mail-wg0-f43.google.com with SMTP id k14so723439wgh.10 for ; Tue, 07 Jan 2014 13:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=PES8sdx1hq2Ebl0tELN+41krkZBbTwfMruvk641eooc=; b=irVyhImUvwjQi3iB+jeQqGoJkxQTjxvuztZ4Wm093I4OmbT3eloXEWtcmCDForXad0 Q3EE4/4v8Kh2tfhSemWaymM0TcB4LOApozxEkymglzWRsMea0j2y/7sBhZkK688bvVPz EqNMn733zaLKO0f/rHJ0NcT+31CwysEQfXIKOvTlD1mPOrEMxGSpik11+56zNsgNTfJp /Z7rG+dsz/uEE4AzgLP6boOue1cCEkLOCh4bYd89QIu8kEQcJh+i8kEOJJOyTvYQHh87 oSnTYUVhHu23dr6rvJdDuMLPqREp6L4IFzQNIu8A8mACd3u2OifOqkxTgWUarqnmqISW fP+g== MIME-Version: 1.0 X-Received: by 10.195.13.130 with SMTP id ey2mr12281785wjd.7.1389131472776; Tue, 07 Jan 2014 13:51:12 -0800 (PST) Received: by 10.195.13.41 with HTTP; Tue, 7 Jan 2014 13:51:12 -0800 (PST) In-Reply-To: References: Date: Tue, 7 Jan 2014 16:51:12 -0500 Message-ID: From: Markus Mottl To: Yotam Barnoy Cc: Ocaml Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Concurrent/parallel programming Though it may not necessarily lend itself to every problem, it is often a good idea to use vectorization to achieve high performance. If your machine learning code is mostly numeric, you may want to use bigarrays and highly optimized C or Fortran routines as building blocks for your algorithm (e.g. using Lacaml). Even without threads this will generally give a very significant performance boost. The use of bigarrays also makes it possible to release the OCaml runtime lock while a basic routine is executing, which would allow you to run several such routines on multiple cores without having to resort to more complicated multi-process solutions. Note, too, that bigarrays can in principle be used with shared memory if multiple processes are still required. Regards, Markus On Tue, Jan 7, 2014 at 2:54 PM, Yotam Barnoy wrote: > Hi List > > So far, I've been programming in ocaml using only sequential programs. In my > last project, which was an implementation of a large machine learning > algorithm, I tried to speed up computation using a little bit of parallelism > with ParMap, and it was a complete failure. It's possible that more time > would have yielded better results, but I just didn't have the time to invest > in it given how bad the initial results were. > > My question is, what are the options right now as far as parallelism is > concerned? I'm not talking about cooperative multitasking, but about really > taking advantage of multiple cores. I'm well aware of the runtime lock and > I'm ok with message passing between processes or a shared area in memory, > but I'd rather have something more high level than starting up several > processes, creating a named pipe or a socket, and trying to pass messages > through that. Also, I assume that using a shared area in memory involves > some C code? Am I wrong about that? > > I was expecting Core's Async to fill this role, but realworldocaml is fuzzy > on this topic, apparently preferring to dwell on cooperative multitasking > (which is fine but not what I'm looking for), and I couldn't find any other > documentation that was clearer. > > Thanks > Yotam -- Markus Mottl http://www.ocaml.info markus.mottl@gmail.com