summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/include/clc/clc.h4
-rw-r--r--generic/include/clc/clcfunc.h2
-rw-r--r--generic/include/clc/common/max.h1
-rw-r--r--generic/include/clc/common/min.h1
-rw-r--r--generic/include/clc/math/fmax.h4
-rw-r--r--generic/include/clc/math/fmax.inc6
-rw-r--r--generic/lib/SOURCES1
-rw-r--r--generic/lib/math/fmax.cl8
-rw-r--r--generic/lib/math/fmax.inc19
9 files changed, 41 insertions, 5 deletions
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 <clc/integer/sub_sat.h>
/* 6.11.4 Common Functions */
-#include <clc/common/max.h>
-#include <clc/common/min.h>
+//#include <clc/common/max.h>
+//#include <clc/common/min.h>
/* 6.11.5 Geometric Functions */
#include <clc/geometric/cross.h>
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 <clc/math/fmax.inc>
+#include <clc/math/gentype.inc>
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 <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <fmax.inc>
+#include <clc/math/gentype.inc>
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);
+}