[Libclc-dev] [PATCH 1/2] amdgcn/fmin: Explicitly check for NaNs
Jeroen Ketema via Libclc-dev
libclc-dev at lists.llvm.org
Wed Nov 15 10:08:12 PST 2017
This seems an incorrect fix. The llvm.minnum intrinsic requires the NaN behaviour you’re now trying to enforce through the library code. I think the proper way to fix this, is to adapt GCN codegen.
Jeroen
> On 15 Nov 2017, at 18:21, Jan Vesely via Libclc-dev <libclc-dev at lists.llvm.org> wrote:
>
> v_min instruction fails to handle certain NaNs correctly.
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> Fixes most of fmin CTS on carrizo. It still fails on denormals, but IMO
> that's CTS bug.
> EG/NI does not seem to suffer the same problem.
>
> amdgcn/lib/SOURCES | 1 +
> amdgcn/lib/math/fmin.cl | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
> create mode 100644 amdgcn/lib/math/fmin.cl
>
> diff --git a/amdgcn/lib/SOURCES b/amdgcn/lib/SOURCES
> index 8c177bd..5149f85 100644
> --- a/amdgcn/lib/SOURCES
> +++ b/amdgcn/lib/SOURCES
> @@ -1,4 +1,5 @@
> cl_khr_int64_extended_atomics/minmax_helpers.ll
> +math/fmin.cl
> math/ldexp.cl
> mem_fence/fence.cl
> mem_fence/waitcnt.ll
> diff --git a/amdgcn/lib/math/fmin.cl b/amdgcn/lib/math/fmin.cl
> new file mode 100644
> index 0000000..556d758
> --- /dev/null
> +++ b/amdgcn/lib/math/fmin.cl
> @@ -0,0 +1,32 @@
> +#include <clc/clc.h>
> +
> +#include "../../../generic/lib/clcmacro.h"
> +
> +_CLC_DEF _CLC_OVERLOAD float fmin(float x, float y)
> +{
> + if (isnan(x))
> + return y;
> + if (isnan(y))
> + return x;
> + return (y < x) ? y : x;
> +}
> +_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, fmin, float, float)
> +
> +#ifdef cl_khr_fp64
> +
> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
> +
> +_CLC_DEF _CLC_OVERLOAD double fmin(double x, double y)
> +{
> + if (isnan(x))
> + return y;
> + if (isnan(y))
> + return x;
> + return (y < x) ? y : x;
> +}
> +_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmin, double, double)
> +
> +#endif
> +
> +#define __CLC_BODY <../../../generic/lib/math/fmin.inc>
> +#include <clc/math/gentype.inc>
> --
> 2.13.6
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev
More information about the Libclc-dev
mailing list