[Libclc-dev] [PATCH 1/1] Make min follow the OCL 1.0 specs
Matt Arsenault via Libclc-dev
libclc-dev at lists.llvm.org
Mon Jul 25 14:26:40 PDT 2016
On 07/22/2016 11:18 AM, Jan Vesely via Libclc-dev wrote:
> OpenCL 1.0: "Returns y if y < x, otherwise it returns x. If x *and* y
> are infinite or NaN, the return values are undefined."
>
> OpenCL 1.1+: "Returns y if y < x, otherwise it returns x. If x *or* y
> are infinite or NaN, the return values are undefined."
>
> The 1.0 version is stricter so use that one.
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> generic/lib/shared/min.inc | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/generic/lib/shared/min.inc b/generic/lib/shared/min.inc
> index fe42864..e15e055 100644
> --- a/generic/lib/shared/min.inc
> +++ b/generic/lib/shared/min.inc
> @@ -1,9 +1,9 @@
> _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a, __CLC_GENTYPE b) {
> - return (a < b ? a : b);
> + return (b < a ? b : a);
> }
>
> #ifndef __CLC_SCALAR
> _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a, __CLC_SCALAR_GENTYPE b) {
> - return (a < (__CLC_GENTYPE)b ? a : (__CLC_GENTYPE)b);
> + return (b < (__CLC_GENTYPE)a ? (__CLC_GENTYPE)b : a);
> }
> #endif
LGTM, I don't think the change in definedness matters here though
More information about the Libclc-dev
mailing list