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.8 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 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 4594EBBC4 for ; Thu, 5 Mar 2009 03:27:27 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsQBAAfHrklQW+UCe2dsb2JhbACUeQEBFiIEwwOECAaEBQ X-IronPort-AV: E=Sophos;i="4.38,304,1233529200"; d="scan'208";a="36112056" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 05 Mar 2009 03:27:26 +0100 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Lf3Iz-0005Uv-V1 for caml-list@inria.fr; Thu, 05 Mar 2009 02:27:25 +0000 Received: from 206-248-165-246.dsl.teksavvy.com ([206.248.165.246]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 Mar 2009 02:27:25 +0000 Received: from monnier by 206-248-165-246.dsl.teksavvy.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 Mar 2009 02:27:25 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Stefan Monnier Subject: Re: stl? Date: Wed, 04 Mar 2009 21:26:54 -0500 Message-ID: References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> <200903040159.48574.jon@ffconsultancy.com> <200903041945.23034.jon@ffconsultancy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 206-248-165-246.dsl.teksavvy.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) Cancel-Lock: sha1:3v/PHjrO7xpOmk54g3YcAWHeDP4= Sender: news X-Spam: no; 0.00; stl:01 vectors:01 functor:01 functor:01 abstracted:01 water:98 traversal:03 element:03 overhead:04 vector:05 vector:05 cycles:06 cycles:06 long:06 seem:08 > Less than it might seem. First of all, you have the allocation costs to > hold the new vector- there's 3-5 clocks right there. Let's say the vectors > are 3 elements long. So you have six loads and three stores- > assume stores are free, and loads cost 1 clock apeice- they're in L1 cache, > and they're getting preloaded. Plus the 3 clocks for the floating point > adds. So that's 12-15 clock cycles right there. Say I'm being pessimistic > by a factor of 2, and it's really only 6-8 clock cycles. Vr.s 10 clock > cycles or so for the call via functor. Now we're down into the realm of > only doubling the cost of the operation, not an order of magnitude increase. > A single mispredicted branch or L1 cache miss that has to go out to L2 > cache- not even main memory, just L2!- would blow the overhead of calling > via functor out of the water. This presumes that the indirect function call only happens once per vector. But it may very well be once per vector plus once per element (think of parameterizing list traversal over `map': since it's abstracted, not only is the call to `map' indirect, but map's own calls to the loop body are indirect as well). Stefan