On Thu, 2010-04-01 at 04:33 -0700, Micha?? Kr??l wrote:
> Module: Mesa
> Branch: master
> Commit: 3ff175d6de89ad92d167362355501f99d06f0f97
> URL:    
> http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ff175d6de89ad92d167362355501f99d06f0f97
> 
> Author: Luca Barbieri <l...@luca-barbieri.com>
> Date:   Wed Mar 24 18:12:45 2010 +0100
> 
> gallium/util: add fast half float conversion functions
> 
> This adds a fast half float conversion facility to Gallium.
> 
> Mesa already contains such a facility, but using a much worse algorithm.
> 
> This one is an implementation of
> www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
> and uses a branch-less algorithm with some lookup tables small enough
> to fit in the L1 cache.
> 
> Ideally, Mesa should start using these functions too, but I'm not sure
> how to arrange that with the current build system.
> 
> A new "u_gctors.cpp" is added that defines a global C++ constructor
> allowing to initialize to conversion lookup tables at library init.
> 
> ---
> 
>  src/gallium/auxiliary/Makefile          |    4 +
>  src/gallium/auxiliary/util/u_gctors.cpp |   17 ++++
>  src/gallium/auxiliary/util/u_half.c     |  123 
> +++++++++++++++++++++++++++++++
>  src/gallium/auxiliary/util/u_half.h     |   55 ++++++++++++++
>  4 files changed, 199 insertions(+), 0 deletions(-)
[..]
> diff --git a/src/gallium/auxiliary/util/u_gctors.cpp 
> b/src/gallium/auxiliary/util/u_gctors.cpp
> new file mode 100644
> index 0000000..9ea9819
> --- /dev/null
> +++ b/src/gallium/auxiliary/util/u_gctors.cpp
> @@ -0,0 +1,17 @@
> +/* this file uses the C++ global constructor mechanism to automatically
> +   initialize global data
> +
> +   __attribute__((constructor)) allows to do this in C, but is GCC-only
> +*/
> +
> +extern "C" void util_half_init_tables(void);
> +
> +struct util_gctor_t
> +{
> +     util_gctor_t()
> +     {
> +             util_half_init_tables();
> +     }
> +};
> +
> +static struct util_gctor_t util_gctor;

This constructor scheme is not working for me. I think that's because
there isn't any symbol here that's used elsewhere, hence the linker is
not linking this file.

> diff --git a/src/gallium/auxiliary/util/u_half.c 
> b/src/gallium/auxiliary/util/u_half.c
> new file mode 100644
> index 0000000..8865acb
> --- /dev/null
> +++ b/src/gallium/auxiliary/util/u_half.c
> @@ -0,0 +1,123 @@
> +#include "util/u_half.h"
> +
> +/* see www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
> + * "Fast Half Float Conversions" by Jeroen van der Zijp, Nov 2008
> + */
> +
> +/* Note that using a 64K * 4 table is a terrible idea since it will not fit
> + * in the L1 cache and will massively pollute the L2 cache as well
> + *
> + * These should instead fit in the L1 cache.
> + *
> + * TODO: we could use a denormal bias table instead of the mantissa/offset
> + * tables: this would reduce the L1 cache usage from 8704 to 2304 bytes
> + * but would involve more computation
> + *
> + * Note however that if denormals are never encountered, the L1 cache usage
> + * is only about 4608 bytes anyway.
> + */

Please put copyright headers. *Especially* when basing your work from
external references, as it gives the impression that this code was
copied, and not your own creation.

Jose


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to