From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: Caml-list@yquem.inria.fr Delivered-To: Caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id AD251BB81 for ; Mon, 6 Mar 2006 17:59:35 +0100 (CET) Received: from outmail.freedom2surf.net (outmail1.freedom2surf.net [194.106.33.237]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k26GxZIh013330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 6 Mar 2006 17:59:35 +0100 Received: from [10.0.0.1] (i-195-137-83-147.freedom2surf.net [195.137.83.147]) by outmail.freedom2surf.net (8.12.10/8.12.10) with ESMTP id k26GxW5K032055 for ; Mon, 6 Mar 2006 16:59:34 GMT Message-ID: <440C6AEA.3030600@asfandyar.cjb.net> Date: Mon, 06 Mar 2006 17:01:30 +0000 From: Asfand Yar Qazi User-Agent: Mozilla Thunderbird 1.0.7 (X11/20060217) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Caml-list@yquem.inria.fr Subject: Re: [Caml-list] I'm sure it's been discussed a few times, but here we go.... single-precision floats References: <440C29DC.4000701@asfandyar.cjb.net> <1141650798.13144.138.camel@budgie.wigram> In-Reply-To: <1141650798.13144.138.camel@budgie.wigram> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 440C6A77.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 reloaded:01 recursive:01 gcc:01 ocaml:01 gcc:01 stack:01 doubles:01 iterated:01 haskell:01 mlton:01 threads:01 haskell:01 cjb:98 2006:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=DNS_FROM_RFC_WHOIS autolearn=disabled version=3.0.3 skaller wrote: > On Mon, 2006-03-06 at 12:23 +0000, Asfand Yar Qazi wrote: > > >>All the OCaml discussions about floating point precision I have seen so far >>evolve around how fast operations are performed on them - but the critical >>thing for things like collision detection, etc. in games is the amount of data >>that can fit into the CPU cache and be operated on before the cache must be >>reloaded. Obviously, twice as many single precision floats can fit into any >>CPU's cache than double precision floats. > > > No, it isn't obvious. I have some routines using the Taka algorithm > which is heavily recursive and therefore depends heavily on > cache use. > > Code for gcc and Felix uses single precision floats. > It is competing with Ocaml .. which is not only using > double precision .. it might be boxing as well!??? > [Perhaps gcc is passing the single precision floats > as double anyhow ..?] > > http://felix.sourceforge.net/current/speed/en_flx_perf_0012.html > > This is an older set of results. On my newer AMD64x2 3800, > gcc opt wins, but Ocaml is second. Point taken - but I'm not experienced enough to comment - perhaps John Carmack would be a good person to contacta about this :-) > > The effect of cache usage ignoring FP calculation speed is > seen here: > > http://felix.sourceforge.net/current/speed/en_flx_perf_0005.html > > where Felix trashes everything by a clear margin simply because > it happens to use one less word on the stack than it's nearest > competitor. > > Perhaps Xavier can explain how Ocaml manages to be so dang > fast on the FP stuff .. if you try C or Felix with > doubles they drop right off the chart. > > >>We're talking huge dynamic data structures with millions of floating point >>coordinates that all have to be iterated over many times a second - preferably >>by using multithreaded algorithms, so that multiple CPUs can be used >>efficiently. > > > Ocaml doesn't currently permit multi-processing. > Felix does, it might be a better alternative for games > and possibly High Performance Computing apps. > Other options include Haskell and MLton. > Ah, didn't know that. On some comments made by Tim Sweeny (Epic Games of Unreal Engine fame), I thought functional programming make multi-threaded coding easy. I'm referring to some slides found here: http://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf Here's what he says about 'Performance' for example: § When updating 10,000 objects at 60 FPS, everything is performance-sensitive § But: – Productivity is just as important – Will gladly sacrifice 10% of our performance for 10% higher productivity – We never use assembly language § There is not a simple set of “hotspots” to optimize! That’s all! Somebody commented about it here (http://www.gamedev.net/community/forums/topic.asp?topic_id=373751) by saying: The bottom line is that C/C++ is becoming way too costly to be used in the future. Both in terms of money (bugs cost money) but also in terms of performance. It's very, very hard to leverage multiple threads in C/C++, and it's only getting worse as we get more cores in our systems -- in contrast, concurrency in languages such as Haskell is almost as simple as single-threaded programming (due to it being purely functional, and having STM). That's why I thought about learning OCaml - I thought it had the same functional programming ability as Haskell, but with more (non-functional) features. But I still want to learn it, it seems a thousand light years different (in a good way) than C++.