[Mesa-dev] [GSoC2016] Interested in implementing "Soft" double precision floating point support

Connor Abbott cwabbott0 at gmail.com
Thu Mar 10 23:45:18 UTC 2016


On Thu, Mar 10, 2016 at 9:30 AM, tournier.elie <tournier.elie at gmail.com> wrote:
> First, thank you all for your answers.
>
> So if I summarize what was said, we need
> Ian:
>  - add
>  - negate
>  - absolute value
>  - multiply
>  - reciprocal
>  - convert to single precision
>  - convert from single precision
> Roland:
>  - sqrt
>  - comparaison (< / == / >)
>  - floor/ceil

One thing to note is that since Intel hw doesn't support reciprocal,
sqrt, rsqrt, or floor/ceil/truncate for doubles, our fp64
implementation (not merged yet, but soon will be) already includes
routines for emulating those things:
https://github.com/Igalia/mesa/blob/i965-fp64/src/compiler/nir/nir_lower_double_ops.c
and I suspect that since we're using the GLSL precision rules and
relying on the presence of 32-bit floating point operations (which
basically all GPU's support), it's a lot simpler than most other
softfloat libraries. To use this, you'd have to port it from NIR to
GLSL, but that shouldn't be too difficult. After that, the only thing
you'd need to implement would be add, multiply, absolute value,
negate, convert to/from single precision, and comparison.

> I will contact Pat Brown (His name appear in the contact field in [1]) to
> know if we need the function below for implement gpu_shader_fp64.
>  - pow
>  - exp
>  - log
>
> About the license
>
> Like I mentioned in the project description, there are quite a few
> existing C implementations of these functions.  Finding one of those
> that you can understand and that has a compatible license is probably
> the best place to start.
>
> Main Mesa code is under MIT license.
> If I chose to use a GNU GPL license file like Linux kernel [3], my code must
> be under GNU GPL and probably all the project too. Am I right?
>
> [1] https://www.opengl.org/registry/specs/ARB/gpu_shader_fp64.txt
> [2] http://www.mesa3d.org/license.html
> [3]
> https://github.com/torvalds/linux/blob/097f70b3c4d84ffccca15195bdfde3a37c0a7c0f/arch/arm/nwfpe/softfloat.c
>
> 2016-03-10 2:18 GMT+01:00 Roland Scheidegger <sroland at vmware.com>:
>>
>> Am 09.03.2016 um 23:51 schrieb Ian Romanick:
>> > On 03/09/2016 02:25 AM, tournier.elie wrote:
>> >> Hi everyone.
>> >>
>> >> My name is Elie TOURNIER, I am enrolled in a French Engineering school
>> >> (Telecom Physique Strasbourg) specialized in Medical ICT.
>> >> I'm interested in implementing "Soft" double precision floating point
>> >> support [1].
>> >> Taking this subject seem to be a good way to get my feet wet in the
>> >> Mesa
>> >> code and discover how some of its components works.
>> >>
>> >> I come to you in order to become know but also to retrieve valuable
>> >> information for the success of this project.
>> >>
>> >> I would like to know more about the following things to understand your
>> >> requirements :
>> >> 1- "/Each double precision value would be stored in a uvec2/" The IEEE
>> >> double precision floating point standard representation requires a 64
>> >> bit: 1 for sign, 11 for exponent and the others for fraction [2].
>> >> -> How double precision value must be stored?
>> >
>> > As Emil mentioned, on GLSL 1.30, a uvec2 consists of two, 32-bit
>> > unsigned integers.  Each double precision value would be stored in a
>> > uvec2.
>> >
>> >> 2- Where can I find |GL_ARB_gpu_shader_fp64 |documentation|?
>> >> |
>> >>
>> >>
>> >> This is my first exposure to Mesa. Please excuse me if I am asking
>> >> basic
>> >> questions.
>> >
>> > For this particular project, you wouldn't need Mesa at all for quite
>> > some time.  All of the initial project should be done in "raw" GLSL
>> > 1.30, and any OpenGL implementation capable of GLSL 1.30 can be used.
>> > You would implement (and test!) a library of functions like 'uvec2
>> > addDouble(uvec2 a, uvec2 b)' that would provide all of the required
>> > double precision operations.
>> >
>> > The set of required functions should be pretty small.  I think:
>> >
>> >  - add
>> >  - negate
>> >  - absolute value
>> >  - multiply
>> >  - reciprocal
>> >  - convert to single precision
>> >  - convert from single precision
>> >  - pow (maybe?)
>> >  - exp (maybe?)
>> >  - log (maybe?)
>>
>> I don't think you need exp/log. At least glsl dosen't require it, though
>> the project isn't clear about it.
>> (pow all hw I know of with exactly one exception (that would be intel
>> graphics...) implements it as log2/mul/exp2 even for f32 anyway).
>> I think though you need sqrt (or rsqrt). And some functions for
>> rounding, plus comparison operations. Maybe min/max too (albeit if you
>> have comparisons you can emulate them of course).
>>
>> Roland
>>
>>
>> >
>> > I think everything else could be implemented using those functions.
>> >
>> > Like I mentioned in the project description, there are quite a few
>> > existing C implementations of these functions.  Finding one of those
>> > that you can understand and that has a compatible license is probably
>> > the best place to start.
>> >
>> >> Please point me to the right resources so that I can better understand
>> >> the project. I would also be happy to fix a bug to familiarize myself
>> >> with the source code. Any suggestions on bugs that are relevant to the
>> >> project will be of great help.
>> >>
>> >> Regards,
>> >> Elie
>> >>
>> >> [1]
>> >>
>> >> http://www.x.org/wiki/SummerOfCodeIdeas/#softdoubleprecisionfloatingpointsupport
>> >> [2] http://steve.hollasch.net/cgindex/coding/ieeefloat.html#storage
>> >>
>> >> PS: If you have any questions, please don't hesitate to contact me.
>> >>
>> >>
>> >> _______________________________________________
>> >> mesa-dev mailing list
>> >> mesa-dev at lists.freedesktop.org
>> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> >
>> > _______________________________________________
>> > mesa-dev mailing list
>> > mesa-dev at lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> >
>>
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>


More information about the mesa-dev mailing list