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 62891BB81 for ; Mon, 6 Mar 2006 13:21:59 +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 k26CLwS3008998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 6 Mar 2006 13:21:59 +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 k26CLw5K008109 for ; Mon, 6 Mar 2006 12:21:58 GMT Message-ID: <440C29DC.4000701@asfandyar.cjb.net> Date: Mon, 06 Mar 2006 12:23:56 +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: I'm sure it's been discussed a few times, but here we go.... single-precision floats Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 440C2966.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 reloaded:01 iterated:01 error-prone:01 ocaml:01 cjb:98 structures:01 data:02 data:02 transform:02 floats:02 floats:02 gnu:02 dynamic:03 algorithms:03 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 Hi, I recently performed some tests on GNU C++, and found that (for a small fast fourier transform operation anyway) double precision out-performs single precision floating point. However, on the Ogre 3D engine forum, I had a lengthy discussion and a conclusion was reached that the reason single-precision floats are preferred for games (and I assume all high-performance applications that require huge amounts of data) is that more of them can fit into the cache of the processor. 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. 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. Since doing this sort of work (i.e. parallel computing) in C++ is a pain in the **** ('scuse my French :-), I want to learn a language that will make it easy and less error-prone - hence my study of OCaml. So, is there any way (I'm thinking similar to 'nativeint') to use floats in OCaml to maximize the data that can be stored and operated on in the CPUs cache such that system memory is accessed as little as possible? Thanks