Debian Codegraph @

libclc/clc/lib/amdgcn/math/clc_fmax.cl

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include <clc/clcmacro.h>
10 #include <clc/internal/clc.h>
11 #include <clc/relational/clc_isnan.h>
12
13 _CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) {
14 // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise
15 // fmax instruction flushes the values for comparison, but outputs original
16 // denormal
17 x = __builtin_canonicalizef(x);
18 y = __builtin_canonicalizef(y);
19 return __builtin_fmaxf(x, y);
20 }
21
22 #ifdef cl_khr_fp64
23
24 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
25
26 _CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) {
27 x = __builtin_canonicalize(x);
28 y = __builtin_canonicalize(y);
29 return __builtin_fmax(x, y);
30 }
31
32 #endif
33 #ifdef cl_khr_fp16
34
35 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
36
37 _CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
38 if (__clc_isnan(x))
39 return y;
40 if (__clc_isnan(y))
41 return x;
42 return (y < x) ? x : y;
43 }
44
45 #endif
46
47 #define FUNCTION __clc_fmax
48 #define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
49 #include <clc/math/gentype.inc>