From 3c939f469f81caee9c14724779300168d5bfd7f8 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 21 Dec 2012 22:13:42 +0000 Subject: XXX: Initial fmax --- generic/include/clc/clc.h | 4 ++-- generic/include/clc/clcfunc.h | 2 +- generic/include/clc/common/max.h | 1 - generic/include/clc/common/min.h | 1 - generic/include/clc/math/fmax.h | 4 ++++ generic/include/clc/math/fmax.inc | 6 ++++++ generic/lib/SOURCES | 1 + generic/lib/math/fmax.cl | 8 ++++++++ generic/lib/math/fmax.inc | 19 +++++++++++++++++++ 9 files changed, 41 insertions(+), 5 deletions(-) delete mode 100644 generic/include/clc/common/max.h delete mode 100644 generic/include/clc/common/min.h create mode 100644 generic/include/clc/math/fmax.h create mode 100644 generic/include/clc/math/fmax.inc create mode 100644 generic/lib/math/fmax.cl create mode 100644 generic/lib/math/fmax.inc diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h index 2edd808..6b73dac 100644 --- a/generic/include/clc/clc.h +++ b/generic/include/clc/clc.h @@ -65,8 +65,8 @@ #include /* 6.11.4 Common Functions */ -#include -#include +//#include +//#include /* 6.11.5 Geometric Functions */ #include diff --git a/generic/include/clc/clcfunc.h b/generic/include/clc/clcfunc.h index 46067fc..5f166c5 100644 --- a/generic/include/clc/clcfunc.h +++ b/generic/include/clc/clcfunc.h @@ -1,4 +1,4 @@ #define _CLC_OVERLOAD __attribute__((overloadable)) #define _CLC_DECL #define _CLC_DEF __attribute__((always_inline)) -#define _CLC_INLINE __attribute__((always_inline)) static inline +#define _CLC_INLINE __attribute__((always_inline)) inline diff --git a/generic/include/clc/common/max.h b/generic/include/clc/common/max.h deleted file mode 100644 index 15d9553..0000000 --- a/generic/include/clc/common/max.h +++ /dev/null @@ -1 +0,0 @@ -#define max fmax diff --git a/generic/include/clc/common/min.h b/generic/include/clc/common/min.h deleted file mode 100644 index 122a22b..0000000 --- a/generic/include/clc/common/min.h +++ /dev/null @@ -1 +0,0 @@ -#define min fmin diff --git a/generic/include/clc/math/fmax.h b/generic/include/clc/math/fmax.h new file mode 100644 index 0000000..724aae5 --- /dev/null +++ b/generic/include/clc/math/fmax.h @@ -0,0 +1,4 @@ +#define fmax __clc_fmax + +#define BODY +#include diff --git a/generic/include/clc/math/fmax.inc b/generic/include/clc/math/fmax.inc new file mode 100644 index 0000000..0a3c7d8 --- /dev/null +++ b/generic/include/clc/math/fmax.inc @@ -0,0 +1,6 @@ +_CLC_OVERLOAD _CLC_DECL GENTYPE __clc_fmax(GENTYPE a, GENTYPE b); +_CLC_OVERLOAD _CLC_DECL GENTYPE __clc_fmax(GENTYPE a, float b); + +#ifdef cl_khr_fp64 +_CLC_OVERLOAD _CLC_DECL GENTYPE __clc_fmax(GENTYPE a, double b); +#endif diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES index 9ebf008..e44a52b 100644 --- a/generic/lib/SOURCES +++ b/generic/lib/SOURCES @@ -12,6 +12,7 @@ integer/min.cl integer/sub_sat.cl integer/sub_sat.ll integer/sub_sat_impl.ll +math/fmax.cl math/hypot.cl math/mad.cl relational/any.cl diff --git a/generic/lib/math/fmax.cl b/generic/lib/math/fmax.cl new file mode 100644 index 0000000..6f22f35 --- /dev/null +++ b/generic/lib/math/fmax.cl @@ -0,0 +1,8 @@ +#include + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif + +#define BODY +#include diff --git a/generic/lib/math/fmax.inc b/generic/lib/math/fmax.inc new file mode 100644 index 0000000..962bed9 --- /dev/null +++ b/generic/lib/math/fmax.inc @@ -0,0 +1,19 @@ +#define __CLC_MAX_IMPL(x, y) x < y ? y : x; + +#if GENTYPE != float && GENTYPE != double + +_CLC_OVERLOAD _CLC_DEF GENTYPE __clc_fmax(GENTYPE x, GENTYPE y) { + return __CLC_MAX_IMPL(x, y) +} + +#endif + +_CLC_OVERLOAD _CLC_DEF GENTYPE fmax(GENTYPE x, double y) { + GENTYPE vec_y = (GENTYPE) (y); + return __CLC_MAX_IMPL(x, vec_y); +} + +_CLC_OVERLOAD _CLC_DEF GENTYPE fmax(GENTYPE x, float y) { + GENTYPE vec_y = (GENTYPE) (y); + return __CLC_MAX_IMPL(x, vec_y); +} -- cgit v1.2.3