Re: [Haskell-cafe] 16 bit floating point data in Haskell?

Hi,
Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal"
software. Think of huge data sets in computer graphics (particle clouds,
volumetric data, images etc.) Some data (normals, density, temperature and
so on) can be easily represented as float 16 making files 200 GB instead of
300 GB. Good benefits.
Cheers,
Oleksandr.
On Sun, Sep 27, 2009 at 9:19 PM, Peter Verswyvelen
He meant 16-bit floats, which have sizeOf 2 On GPUs this is common and implemented in hardware (at least on the old GPUs).
On DPSs you commonly had 24-bit floats too.
But these days I guess 32-bit is the minimum one would want to use? Most of the time I just use double anyway :)
On Sun, Sep 27, 2009 at 9:47 PM, Ross Mellgren
wrote: What about the built-in Float type?
Prelude Foreign.Storable> sizeOf (undefined :: Float) 4 Prelude Foreign.Storable> sizeOf (undefined :: Double) 8
Or maybe you mean something that can be used with FFI calls to C, in which case Foreign.C.Types (CFloat).
Both instance the Floating, RealFloat, RealFrac, etc, classes so should operate largely the same as (modulo precision) a Double.
-Ross
On Sep 27, 2009, at 2:42 PM, Olex P wrote:
Hi guys,
Do we have anything like half precision floats in Haskell? Maybe in some non standard libraries? Or I have to use FFI + OpenEXR library to achieve this?
Cheers, Oleksandr. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Olex P wrote:
Hi,
Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal" software. Think of huge data sets in computer graphics (particle clouds, volumetric data, images etc.) Some data (normals, density, temperature and so on) can be easily represented as float 16 making files 200 GB instead of 300 GB. Good benefits.
I think, if you're going to want any kind of performance and portability, then you'll have to use the FFI to wrap some C code that performs the primops. From there you can define the instances for Floating, RealFloat, etc. to use them like normal types in Haskell. There are a number of embedded systems that still use 24-bit floating registers, so it'd be nice to provide both Float16 and Float24. But since these aren't natively supported in C, it's not clear how best to write the primops so they're portable across GPUs and embedded systems. -- Live well, ~wren

Okay looks like FFI is the only way to go, Thanks.
Cheers,
Oleksandr.
On Sun, Sep 27, 2009 at 9:50 PM, wren ng thornton
Olex P wrote:
Hi,
Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal" software. Think of huge data sets in computer graphics (particle clouds, volumetric data, images etc.) Some data (normals, density, temperature and so on) can be easily represented as float 16 making files 200 GB instead of 300 GB. Good benefits.
I think, if you're going to want any kind of performance and portability, then you'll have to use the FFI to wrap some C code that performs the primops. From there you can define the instances for Floating, RealFloat, etc. to use them like normal types in Haskell.
There are a number of embedded systems that still use 24-bit floating registers, so it'd be nice to provide both Float16 and Float24. But since these aren't natively supported in C, it's not clear how best to write the primops so they're portable across GPUs and embedded systems.
-- Live well, ~wren
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Olex P
-
wren ng thornton