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.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 5A382BC69 for ; Thu, 8 Feb 2007 13:08:20 +0100 (CET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l18C8IBw004211 for ; Thu, 8 Feb 2007 13:08:19 +0100 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.7) with ESMTP id l18C8ETJ013774; Thu, 8 Feb 2007 21:08:14 +0900 (JST) Date: Thu, 08 Feb 2007 21:08:09 +0900 (JST) Message-Id: <20070208.210809.51860500.garrigue@math.nagoya-u.ac.jp> To: gava@univ-paris12.fr Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Multiplication of matrix in C and OCaml From: Jacques Garrigue In-Reply-To: <45CAED1C.3040503@univ-paris12.fr> References: <45CA63F5.6020301@univ-paris12.fr> <20070208.111401.55511744.garrigue@math.nagoya-u.ac.jp> <45CAED1C.3040503@univ-paris12.fr> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Miltered: at concorde with ID 45CB12B2.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 gava:01 gava:01 gcc:01 gcc:01 mult:01 inlined:01 inlined:01 mult:01 bug:01 pointer:01 sizeof:01 12.:98 1.4:98 polymorphic:01 From: Fr=E9d=E9ric Gava > > gcc -O3 monomorphic: 4.7s > > Now, I also found a strange result: > > gcc -O3 monomorphic: 1.4s > = > Why two different times for the same program ? What is monomorphic ? The second one is a misprint fron "gcc -O3 polymorphic". By monomorphic I mean that add and mult are used directly (actually inlined with -O3), rather than being passed as parameter to generic_multiply, which should be faster. The funny thing is that this results in correct code even with -O3, because the inlined version does not discard its result, as does the add and mult optimized functions. So the polymorphic code, completely broken, ends up being 3 times faster :-) By the way there was another evident bug in your code: you do pointer arithmetic on void*, which is clearly wrong. Yet, this can be easily corrected by passing sizeof(complexe) as an extra argument to generic_multiply, and adjusting offsets with it. Jacques Garrigue