Uses only denormal path for fp32.
Passes CTS on carrizo and turks.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Uses only denormal path for fp32.
Passes CTS on carrizo and turks.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
ping.
Jan
> Uses only denormal path for fp32.
> Passes CTS on carrizo and turks.
>
> Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
> ---
> generic/include/clc/math/fmod.h | 4 +-
> generic/include/clc/math/fmod.inc | 1 -
> generic/include/math/clc_fmod.h | 4 +
> generic/lib/SOURCES | 1 +
> generic/lib/math/clc_fmod.cl | 184
> ++++++++++++++++++++++++++++++++++++++
> generic/lib/math/fmod.cl | 14 +--
> 6 files changed, 196 insertions(+), 12 deletions(-)
> delete mode 100644 generic/include/clc/math/fmod.inc
> create mode 100644 generic/include/math/clc_fmod.h
> create mode 100644 generic/lib/math/clc_fmod.cl
>
> diff --git a/generic/include/clc/math/fmod.h
> b/generic/include/clc/math/fmod.h
> index 4906867..443eaf3 100644
> --- a/generic/include/clc/math/fmod.h
> +++ b/generic/include/clc/math/fmod.h
> @@ -1,2 +1,4 @@
> -#define __CLC_BODY <clc/math/fmod.inc>
> +#define __CLC_FUNCTION fmod
> +#define __CLC_BODY <clc/math/binary_decl_tt.inc>
> #include <clc/math/gentype.inc>
> +#undef __CLC_FUNCTION
> diff --git a/generic/include/clc/math/fmod.inc
> b/generic/include/clc/math/fmod.inc
> deleted file mode 100644
> index 39d9153..0000000
> --- a/generic/include/clc/math/fmod.inc
> +++ /dev/null
> @@ -1 +0,0 @@
> -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fmod(__CLC_GENTYPE a,
> __CLC_GENTYPE b);
> diff --git a/generic/include/math/clc_fmod.h
> b/generic/include/math/clc_fmod.h
> new file mode 100644
> index 0000000..0409785
> --- /dev/null
> +++ b/generic/include/math/clc_fmod.h
> @@ -0,0 +1,4 @@
> +#define __CLC_FUNCTION __clc_fmod
> +#define __CLC_BODY <clc/math/binary_decl_tt.inc>
> +#include <clc/math/gentype.inc>
> +#undef __CLC_FUNCTION
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index 843d44d..dfa9d0c 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -103,6 +103,7 @@ math/fdim.cl
> math/fma.cl
> math/fmax.cl
> math/fmin.cl
> +math/clc_fmod.cl
> math/fmod.cl
> math/fract.cl
> math/frexp.cl
> diff --git a/generic/lib/math/clc_fmod.cl
> b/generic/lib/math/clc_fmod.cl
> new file mode 100644
> index 0000000..a45c2b4
> --- /dev/null
> +++ b/generic/lib/math/clc_fmod.cl
> @@ -0,0 +1,184 @@
> +/*
> + * Copyright (c) 2014 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person
> obtaining a copy
> + * of this software and associated documentation files (the
> "Software"), to deal
> + * in the Software without restriction, including without
> limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense,
> and/or sell
> + * copies of the Software, and to permit persons to whom the
> Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
> EVENT SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include <clc/clc.h>
> +
> +#include <math/clc_remainder.h>
> +#include "../clcmacro.h"
> +#include "config.h"
> +#include "math.h"
> +
> +_CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y)
> +{
> + int ux = as_int(x);
> + int ax = ux & EXSIGNBIT_SP32;
> + float xa = as_float(ax);
> + int sx = ux ^ ax;
> + int ex = ax >> EXPSHIFTBITS_SP32;
> +
> + int uy = as_int(y);
> + int ay = uy & EXSIGNBIT_SP32;
> + float ya = as_float(ay);
> + int ey = ay >> EXPSHIFTBITS_SP32;
> +
> + float xr = as_float(0x3f800000 | (ax & 0x007fffff));
> + float yr = as_float(0x3f800000 | (ay & 0x007fffff));
> + int c;
> + int k = ex - ey;
> +
> + while (k > 0) {
> + c = xr >= yr;
> + xr -= c ? yr : 0.0f;
> + xr += xr;
> + --k;
There's a hard-tab here.
Otherwise looks ok to me, although I can't say that I follow everything
going on here.
Passes CTS for me on my RX 580 for both float/double which is what
really matters.
--Aaron