Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch > #33720

Re: floating-point range

From Terje Mathisen <terje.mathisen@tmsw.no>
Newsgroups comp.arch
Subject Re: floating-point range
Date 2016-02-18 07:42 +0100
Organization Aioe.org NNTP Server
Message-ID <na3p4h$545$1@gioia.aioe.org> (permalink)
References (1 earlier) <i8b7cb5nn8ioj863g7b90bljpuq47857sj@4ax.com> <na1frv$usi$1@dont-email.me> <na1iqc$do$1@gioia.aioe.org> <na1n5i$noa$1@dont-email.me> <na25j3$j29$1@news.albasani.net>

Show all headers | View raw


BGB wrote:
> for some use-cases (in graphics), it is actually not all that uncommon
> to shave the half-floats to 10 or 12 bits. this can allow, say, shoving
> a 3 element vector into a 32-bit word (10.10.10, 11.11.10, 10.12.10, ...).

This is a standard (fixed-point) format used quite a lot, enough so that 
GPUs have special hw to crack them into 3 16 or 32-bit values for 
calculations. It is better than the normal 24/32-bit RGB/A when you 
don't need the Alpha channel.
>
> generally, one can alternate between using them as FP values and using
> them as integers.
>
> if using them as FP, it is more common to do intermediate calculations
> using float32, and if integers, good old 16 or 32-bit int.

Right, you never do any significant calculations with so low resolution.
>
> there is apparently some some variation as to whether FP16
> implementations follow IEEE rules, ex: provide NaN/Inf and denormals.
> some implementations don't, opting either to make 0x0000 and 0x8000
> special cases or to just ignore 0 as being special (treating it as an
> arbitrarily small value conventionally understood as zero).

As long as you handle these by expanding them to FP32 (which was done on 
Larrabee, the only GPU I've worked on), you get exactly the same Inf/NaN 
handling as the float format gets. (Which might of course include 
forcing all denormals to zero.)
>
> dropping these can allow a cheaper/faster implementation, and
> potentially increase the maximum usable value from 65535 to 131071
> (though, another option is to treat anything in the extended range as
> undefined).
>
> I think typically FP8 variants omit NaN/Inf and denormals (maybe with a
> few special-case values).

See above.

If you implement calculations in FP8 then the cost of handling all the 
special cases should actually be quite small, since you can do the 
actual calculations with combinations of small lookup tables (separate 
exponent and mantissa, each needing 64-256 bytes, and a little bit a 
wired logic.

The extreme case would combine them and use 7-bit by 7-bit lookup tables 
(16 KB) with the sign handled by wires, i.e. for FMUL8 you return the 
XOR of the input signs, for FADD/FSUB you store an indicator in the sign 
bit which is used to select the sign of the larger of the inputs.

Terje

-- 
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Back to comp.arch | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

floating-point range jgk@panix.com (Joe keane) - 2015-12-26 21:45 +0000
  Re: floating-point range MitchAlsup <MitchAlsup@aol.com> - 2015-12-26 18:49 -0800
    Re: floating-point range Quadibloc <jsavard@ecn.ab.ca> - 2015-12-26 20:19 -0800
  Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-27 09:53 +0100
    Re: floating-point range Morten Reistad <first@last.name.invalid> - 2016-02-16 18:23 +0100
      Re: floating-point range Robert Wessel <robertwessel2@yahoo.com> - 2016-02-16 12:28 -0600
        Re: floating-point range Robert Wessel <robertwessel2@yahoo.com> - 2016-02-16 12:41 -0600
          Re: floating-point range Morten Reistad <first@last.name.invalid> - 2016-02-16 21:43 +0100
            Re: floating-point range Robert Wessel <robertwessel2@yahoo.com> - 2016-02-16 17:27 -0600
              Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-17 08:35 +0100
              Re: floating-point range nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-17 09:51 +0000
                Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-17 11:42 +0100
                Re: floating-point range nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-17 11:56 +0000
                Re: floating-point range BGB <cr88192@hotmail.com> - 2016-02-17 09:56 -0600
                Re: floating-point range nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-17 16:14 +0000
                Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-18 07:42 +0100
                Re: floating-point range BGB <cr88192@hotmail.com> - 2016-02-18 10:09 -0600
                Re: floating-point range jim.brakefield@ieee.org - 2016-02-18 12:33 -0800
                Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-18 22:08 +0100
                Re: floating-point range BGB <cr88192@hotmail.com> - 2016-02-18 15:45 -0600
                Re: floating-point range MitchAlsup <MitchAlsup@aol.com> - 2016-02-18 16:42 -0800
                Re: floating-point range BGB <cr88192@hotmail.com> - 2016-02-19 08:04 -0600
                Re: floating-point range nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-19 11:55 +0000
                Re: floating-point range BGB <cr88192@hotmail.com> - 2016-02-19 08:24 -0600
                Re: floating-point range MitchAlsup <MitchAlsup@aol.com> - 2016-02-19 07:09 -0800
                Re: floating-point range BGB <cr88192@hotmail.com> - 2016-02-19 10:51 -0600
                Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-19 18:02 +0100
                Re: floating-point range Quadibloc <jsavard@ecn.ab.ca> - 2016-02-19 11:55 -0800
                Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-19 21:14 +0100
                Re: floating-point range MitchAlsup <MitchAlsup@aol.com> - 2016-02-19 16:20 -0800
                Re: floating-point range Terje Mathisen <terje.mathisen@tmsw.no> - 2016-02-20 10:14 +0100
                Re: floating-point range anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-20 12:51 +0000
                Re: floating-point range anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-20 12:30 +0000
                Re: floating-point range paul wallich <pw@panix.com> - 2016-02-19 12:37 -0500
                Re: floating-point range Quadibloc <jsavard@ecn.ab.ca> - 2016-02-19 11:58 -0800
                Re: floating-point range jim.brakefield@ieee.org - 2016-02-19 14:29 -0800
                Re: floating-point range "James Van Buskirk" <not_valid@comcast.net> - 2016-02-17 10:21 -0700
                Re: floating-point range nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-17 17:34 +0000
          Re: floating-point range Quadibloc <jsavard@ecn.ab.ca> - 2016-02-17 11:13 -0800
      Re: floating-point range "wolfgang kern" <nowhere@never.at> - 2016-02-16 19:39 +0100
      Re: floating-point range MitchAlsup <MitchAlsup@aol.com> - 2016-02-16 16:36 -0800
  Re: floating-point range Piotr Wyderski <peter.pan@neverland.mil> - 2016-02-19 11:40 +0100

csiph-web