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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 6F386BC37 for ; Tue, 10 Nov 2009 16:37:52 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am0BAKkX+UrUnwcjk2dsb2JhbACCHYJVlw8BAQEBBwsKCRMEsRmRCoEygjhUBIFo X-IronPort-AV: E=Sophos;i="4.44,716,1249250400"; d="scan'208";a="50113801" Received: from relay.ptn-ipout01.plus.net ([212.159.7.35]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Nov 2009 16:37:51 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsFAB8Y+UrUnw4R/2dsb2JhbACCHYJVyGuRCoEygjhUBIFo Received: from pih-relay04.plus.net ([212.159.14.17]) by relay.ptn-ipout01.plus.net with ESMTP; 10 Nov 2009 15:37:50 +0000 Received: from [87.112.1.94] (helo=leper.local) by pih-relay04.plus.net with esmtp (Exim) id 1N7smz-0008LA-Rh for caml-list@yquem.inria.fr; Tue, 10 Nov 2009 15:37:50 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] MetaOcaml and high-performance [was: AST versus Ocaml] Date: Tue, 10 Nov 2009 15:38:54 +0000 User-Agent: KMail/1.9.9 References: <20091109042328.9330E1727F@Adric.ern.nps.edu> In-Reply-To: <20091109042328.9330E1727F@Adric.ern.nps.edu> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200911101538.54857.jon@ffconsultancy.com> X-Plusnet-Relay: 733e68847e2d8dae291fc8f1666a4ab9 X-Spam: no; 0.00; metaocaml:01 ocaml:01 oleg:01 metaocaml:01 ocaml:01 tobias:01 high-level:01 high-level:01 low-level:01 parallelism:01 parallelism:01 2048:01 2048:01 2009:98 frog:98 On Monday 09 November 2009 04:23:28 oleg@okmij.org wrote: > Because offshoring produces a portable C or Fortran code file, you can > use the code on 32 or 64-bit platform. The reason the native MetaOCaml > without offshoring does not work on amd64 is because at that time > OCaml didn't emit PIC code for amd64. So, dynamic linking was > impossible. That problem has long been fixed in later versions of > OCaml... Has the problem been fixed in MetaOCaml? > Fortunately, some people have considered MetaOCaml to be a viable > option for performance users and have reported good results. For > example, > > Tuning MetaOCaml Programs for High Performance > Diploma Thesis of Tobias Langhammer. > http://www.infosun.fmi.uni-passau.de/cl/arbeiten/Langhammer.pdf > > Here is a good quotation from the Introduction: > > ``This thesis proposes MetaOCaml for enriching the domain of > high-performance computing by multi-staged programming. MetaOCaml extends > the OCaml language. > ... > Benchmarks for all presented implementations confirm that the > execution time can be reduced significantly by high-level > optimizations. Some MetaOCaml programs even run as fast as respective > C implementations. Furthermore, in situations where optimizations in > pure MetaOCaml are limited, computation hotspots can be explicitly or > implicitly exported to C. This combination of high-level and low-level > techniques allows optimizations which cannot be obtained in pure C > without enormous effort.'' That thesis contains three benchmarks: 1. Dense float matrix-matrix multiply. 2. Blur of an int image matrix as convolution with a 3x3 stencil matrix. 3. Polynomial multiplication with distributed parallelism. I don't know about polynomial multiplication (suffice to say that it is not leveraging shared-memory parallelism which is what performance users value in today's multicore era) but the code for the first two benchmarks is probably 10-100x slower than any decent implementation. For example, his fastest 2048x2048 matrix multiply takes 167s whereas Matlab takes only 3.6s here. In essence, the performance gain (if any) from offshoring to C or Fortran is dwarfed by the lack of shared-memory parallelism. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e