From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C244FBC8E for ; Fri, 25 Feb 2005 18:23:42 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1PHNgv8008611 for ; Fri, 25 Feb 2005 18:23:42 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA19334 for ; Fri, 25 Feb 2005 18:23:41 +0100 (MET) Received: from smtp01.isp.itmonitor.net (smtp01.isp.itmonitor.net [207.158.33.182]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1PHNena023151 for ; Fri, 25 Feb 2005 18:23:41 +0100 Received: from tfb.com (host-66-81-25-79.rev.o1.com [66.81.25.79]) by smtp01.isp.itmonitor.net (Postfix) with ESMTP id D6683A5D00C; Fri, 25 Feb 2005 09:23:39 -0800 (PST) Message-ID: <421F5F43.8050602@tfb.com> Date: Fri, 25 Feb 2005 09:24:19 -0800 From: Ken Rose Reply-To: rose@acm.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christophe TROESTLER Cc: "O'Caml Mailing List" Subject: Re: [Caml-list] NBody (one more question) References: <20050207.195724.87945401.Christophe.Troestler@umh.ac.be> <20050208104312.GA10035@yquem.inria.fr> <20050224.231855.40627447.debian00@tiscali.be> In-Reply-To: <20050224.231855.40627447.debian00@tiscali.be> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 421F5F1E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 421F5F1C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 christophe:01 troestler:01 wrote:01 gcc:01 gcc:01 -wall:01 -lm:01 ocaml:01 -wall:01 -lm:01 ocaml:01 translated:01 suppressing:01 compile:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Christophe TROESTLER wrote: > When I compile the C code with -O0 (with gcc -o nbody.gcc -Wall > --fast-math nbody.c -lm), I get a time of 1.513s which is comparable > to OCaml (1.607s). But as soon as I turn on -O options (as with gcc > -o nbody.gcc -Wall -O1 --fast-math nbody.c -lm), the running time > drops down to 0.871s (0.58%). Can somebody tell me what is the > optimization that has such an effect and whether it could be applied > to OCaml ? (I am not saying or asking it to be done -- it is not up > to me to decide -- I just want to understand -- and I am not versed > enough in assembly to do it myself unfortunately :( ). I'm not familiar with the OCaml code generator, but gcc without optimization produces very naive code. Each source statement is translated separately, and all variable values are read from & written back to memory. (Only changed values are written, obviously) It doesn't do any instruction scheduling beyond what the processor may require for correctness. It really doesn't do anything more sophisticated than suppressing moves that have the same register as source & destination. So it might be just about anything, from using registers to some common-subexpression elimination to a number of others. - ken