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=2.1 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id B4087BBC4 for ; Fri, 20 Feb 2009 16:40:02 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkICAC9dnknRVcbhk2dsb2JhbACUGD8BAQEBCQkKCREDr20xhnyIRQEDAQOEDAaESQ X-IronPort-AV: E=Sophos;i="4.38,242,1233529200"; d="scan'208";a="23291573" Received: from rv-out-0506.google.com ([209.85.198.225]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 Feb 2009 16:40:01 +0100 Received: by rv-out-0506.google.com with SMTP id k40so7959811rvb.57 for ; Fri, 20 Feb 2009 07:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=mOGaZJP1yAJI2PIaR8G9aTgDjU0PwgmfS5zEtzwdjTo=; b=WKS/MENhpKdP7mVfqYQkZcO4Leb14IyBpa2Uu2PZXQgFmC3wkAWxZNgoNH3P0Wipph xfqon9ayDETUJosqdj0FPuIHyDThaycRpyCVFXJ79KwkLIHyHzVuh8Aj/v1GPrsEaDGF tTOYusvIIE8TNPyOeloQbVu/MHA8Fk0AIn2qU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; b=jtMmOe1OXakUJIAmPqRQs3iVaE2vZkYkYNAh/1PFwlUy2B1RQhEGMr2YKjgAwwj46x p2wMFrwR5f6CsayfkZ/7YBlE7+9d7FXcrJrrdVibtBUHK7iH77RHKUZKT7Qq9syDLYWA fAFb69NAOh4HqZtV37zcVx1qu3sgzOrvV39h0= MIME-Version: 1.0 Sender: ematsen@gmail.com Received: by 10.141.36.10 with SMTP id o10mr476008rvj.237.1235144400997; Fri, 20 Feb 2009 07:40:00 -0800 (PST) Date: Fri, 20 Feb 2009 07:40:00 -0800 X-Google-Sender-Auth: 4ce26c649624bde4 Message-ID: <243054520902200740j1d1874adib27645f6e090b073@mail.gmail.com> Subject: speeding up matrix multiplication (newbie question) From: Erick Matsen To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.01; ocaml:01 multiplying:01 matrices:01 ocaml:01 arrays:01 bigarrays:01 oldify:01 oldify:01 cumulative:98 2.78:98 0.28:98 0.26:98 0.26:98 0.90:98 0.22:98 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? Thank you, Erick -------- profiling information -------- % cumulative self self total time seconds seconds calls s/call s/call name 30.27 7.44 7.44 836419 0.00 0.00 camlMat__mul_vec_263 15.42 11.23 3.79 335237785 0.00 0.00 camlMat__get_447 14.65 14.83 3.60 334624076 0.00 0.00 camlNumber__mul_185 13.75 18.21 3.38 682814594 0.00 0.00 caml_apply2 11.31 20.99 2.78 334624076 0.00 0.00 camlNumber__add_183 6.02 22.47 1.48 335724401 0.00 0.00 caml_apply3 1.14 22.75 0.28 480860 0.00 0.00 camlDiagd__fun_304 1.06 23.01 0.26 159338 0.00 0.00 caml_oldify_local_roots 1.06 23.27 0.26 79634 0.00 0.00 sweep_slice 0.90 23.49 0.22 79828 0.00 0.00 mark_slice 0.65 23.65 0.16 10455018 0.00 0.00 camlQtree__code_begin 0.61 23.80 0.15 1517329 0.00 0.00 caml_oldify_one 0.57 23.94 0.14 17592082 0.00 0.00 camlMat__n_cols_458 0.57 24.08 0.14 13102569 0.00 0.00 caml_modify 0.57 24.22 0.14 522761 0.00 0.00 camlArray__mapi_142 ...