[Kstars-devel] Precision in KStars

Daniel Baboiu daniel.baboiu at shaw.ca
Tue Jun 25 19:30:00 UTC 2013


Long ago I had some experience with floating point DP versus SP. Working on a large system with differential equations, we were limited by the available memory, so we thought to get some breathing space by converting to SP. The equations were solved to 4 decimal places anyway, so SP seemed reasonable. However, the resulting program was slower (apparently, on CPU, all operations were done in DP anyway, with conversions before and after the operation). Not only that, but the program was numerically unstable, although precision should have been sufficient...

On modern CPUs, speedup might be obtained with SSE instructions, although I think these concern mainly integer operations.

----- Original Message -----
From: "Aleksey Khudyakov" <alexey.skladnoy at gmail.com>
To:  "KStars Development Mailing List" <kstars-devel at kde.org>
Sent: Tuesday, June 25, 2013 10:26:13 AM
Subject: Re: [Kstars-devel] Precision in KStars

On 25.06.2013 18:09, Henry de Valence wrote:
> On Tue, Jun 25, 2013 at 4:46 AM, Aleksey Khudyakov
> <alexey.skladnoy at gmail.com>  wrote:
>>
>> Is it possible to select between float/double at compile time by using typedef
>> and maybe bunch of #defines? This way it's possible to use float for speed
>> and fall back to double it won't work out.
>
> I suppose that this is possible, but I don't think that it's a great
> idea. It would be better from a code maintenance point of view to just
> have one set of codepaths. IMO if floats are good enough, we should
> always use them; if not, we should just accept the speed losses.
>
Floats are definitely not suitable for use everywhere. It's too easy to 
run into rounding issues. In my opinion they should be treated as 
optimization. They could be used speed up computation on GPU (they 
aren't fast on CPU AFAIK) or to reduce memory footprint.


More information about the Kstars-devel mailing list