Skip to content

[libclc] Optimize generic CLC fmin/fmax #128506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions libclc/clc/lib/generic/math/clc_fmax.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/relational/clc_isnan.h>

_CLC_DEFINE_BINARY_BUILTIN(float, __clc_fmax, __builtin_fmaxf, float, float);
#define FUNCTION __clc_fmax
#define __CLC_FUNCTION(x) __builtin_elementwise_max
#define __CLC_BODY <clc/shared/binary_def.inc>

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_DEFINE_BINARY_BUILTIN(double, __clc_fmax, __builtin_fmax, double, double);

#endif

#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
if (__clc_isnan(x))
return y;
if (__clc_isnan(y))
return x;
return (x < y) ? y : x;
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmax, half, half)

#endif
#include <clc/math/gentype.inc>
29 changes: 4 additions & 25 deletions libclc/clc/lib/generic/math/clc_fmin.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/relational/clc_isnan.h>

_CLC_DEFINE_BINARY_BUILTIN(float, __clc_fmin, __builtin_fminf, float, float);
#define FUNCTION __clc_fmin
#define __CLC_FUNCTION(x) __builtin_elementwise_min
#define __CLC_BODY <clc/shared/binary_def.inc>

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_DEFINE_BINARY_BUILTIN(double, __clc_fmin, __builtin_fmin, double, double);

#endif

#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) {
if (__clc_isnan(x))
return y;
if (__clc_isnan(y))
return x;
return (y < x) ? y : x;
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmin, half, half)

#endif
#include <clc/math/gentype.inc>
Loading