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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 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 6B3DFBBC4 for ; Fri, 20 Feb 2009 18:41:38 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvABADh6nknUnwdjlGdsb2JhbACCPZIaAQEBAQkLCAkRBL9vhA8G X-IronPort-AV: E=Sophos;i="4.38,242,1233529200"; d="scan'208";a="24449018" Received: from relay.pcl-ipout01.plus.net ([212.159.7.99]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Feb 2009 18:41:38 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugEADh6nknUnw4T/2dsb2JhbACCPdJHhA8G Received: from pih-relay06.plus.net ([212.159.14.19]) by relay.pcl-ipout01.plus.net with ESMTP; 20 Feb 2009 17:41:37 +0000 Received: from [87.113.102.88] (helo=leper.local) by pih-relay06.plus.net with esmtp (Exim) id 1LaZNZ-0007d9-Dk for caml-list@yquem.inria.fr; Fri, 20 Feb 2009 17:41:37 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] speeding up matrix multiplication (newbie question) Date: Fri, 20 Feb 2009 17:46:37 +0000 User-Agent: KMail/1.9.9 References: <243054520902200740j1d1874adib27645f6e090b073@mail.gmail.com> In-Reply-To: <243054520902200740j1d1874adib27645f6e090b073@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902201746.37679.jon@ffconsultancy.com> X-Plusnet-Relay: 60d40a9ee61730e9d185f89087e34269 X-Spam: no; 0.00; ocaml:01 multiplying:01 matrices:01 ocaml:01 arrays:01 bigarrays:01 matrices:01 higher-level:01 ocaml's:01 2009:98 frog:98 wrote:01 caml-list:01 algorithm:01 data:02 On Friday 20 February 2009 15:40:00 Erick Matsen wrote: > Hello Ocaml community--- > > I'm working on speeding up some code, and I wanted to check with > someone before implementation. > > As you can see below, the code primarily spends its time multiplying > relatively small matrices. Precision is of course important but not an > incredibly crucial issue, as the most important thing is relative > comparison between things which *should* be pretty different. Currently I'm > just using native > (double-precision) ocaml floats and the native ocaml arrays for a first > pass on the problem. > > Now I'm thinking about moving to using float32 bigarrays, and I'm hoping > that the code will double in speed. I'd like to know: is that realistic? > Any other suggestions? What exactly are you doing? Exactly how big are the matrices? What is your exact code? What is the higher-level algorithm using the matrix multiply? Are you doing a loop just over many matrix multiplies? What platform and architecture are you using? Is the code parallelized? Depending upon the answers to the above questions, you may be able to achieve huge performance improvements using tools like LLVM to generate SSE code whilst still acting upon OCaml's data structures. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e