summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-01-31 17:09:18 -0500
committerTom Stellard <thomas.stellard@amd.com>2013-01-31 17:09:18 -0500
commitc3acb9cd5e9010a4f802d3612a391d4a7e7e0604 (patch)
tree99e305c513459b0d604a15283d85a77584f35be5
parentb93257cc6afed59364b0d3b9c3d08ef38638c689 (diff)
XXX: fmax workingfmax
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/math/binary_decl.inc6
-rw-r--r--generic/include/clc/math/fmax.h9
-rw-r--r--generic/include/clc/math/fmax.inc6
-rw-r--r--generic/include/clc/math/gentype.inc4
-rw-r--r--generic/lib/math/binary_impl.inc18
-rw-r--r--generic/lib/math/fmax.cl4
-rw-r--r--generic/lib/math/fmax.inc19
8 files changed, 43 insertions, 24 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 6b73dac..4b5c721 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -38,6 +38,7 @@
#include <clc/math/fabs.h>
#include <clc/math/floor.h>
#include <clc/math/fma.h>
+#include <clc/math/fmax.h>
#include <clc/math/hypot.h>
#include <clc/math/log.h>
#include <clc/math/log2.h>
diff --git a/generic/include/clc/math/binary_decl.inc b/generic/include/clc/math/binary_decl.inc
new file mode 100644
index 0000000..1a49e26
--- /dev/null
+++ b/generic/include/clc/math/binary_decl.inc
@@ -0,0 +1,6 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, GENTYPE b);
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, float b);
+
+#ifdef cl_khr_fp64
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, double b);
+#endif
diff --git a/generic/include/clc/math/fmax.h b/generic/include/clc/math/fmax.h
index 724aae5..d26e5d6 100644
--- a/generic/include/clc/math/fmax.h
+++ b/generic/include/clc/math/fmax.h
@@ -1,4 +1,11 @@
+#undef fmax
#define fmax __clc_fmax
-#define BODY <clc/math/fmax.inc>
+#define BODY <clc/math/binary_decl.inc>
+#define FUNCTION __clc_fmax
+
#include <clc/math/gentype.inc>
+
+#undef BODY
+#undef FUNCTION
+
diff --git a/generic/include/clc/math/fmax.inc b/generic/include/clc/math/fmax.inc
index 0a3c7d8..1a49e26 100644
--- a/generic/include/clc/math/fmax.inc
+++ b/generic/include/clc/math/fmax.inc
@@ -1,6 +1,6 @@
-_CLC_OVERLOAD _CLC_DECL GENTYPE __clc_fmax(GENTYPE a, GENTYPE b);
-_CLC_OVERLOAD _CLC_DECL GENTYPE __clc_fmax(GENTYPE a, float b);
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, GENTYPE b);
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, float b);
#ifdef cl_khr_fp64
-_CLC_OVERLOAD _CLC_DECL GENTYPE __clc_fmax(GENTYPE a, double b);
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, double b);
#endif
diff --git a/generic/include/clc/math/gentype.inc b/generic/include/clc/math/gentype.inc
index 4506920..b525c4b 100644
--- a/generic/include/clc/math/gentype.inc
+++ b/generic/include/clc/math/gentype.inc
@@ -1,6 +1,8 @@
#define GENTYPE float
+#define SCALAR
#include BODY
#undef GENTYPE
+#undef SCALAR
#define GENTYPE float2
#include BODY
@@ -23,9 +25,11 @@
#undef GENTYPE
#ifdef cl_khr_fp64
+#define SCALAR
#define GENTYPE double
#include BODY
#undef GENTYPE
+#undef SCALAR
#define GENTYPE double2
#include BODY
diff --git a/generic/lib/math/binary_impl.inc b/generic/lib/math/binary_impl.inc
new file mode 100644
index 0000000..b6c6612
--- /dev/null
+++ b/generic/lib/math/binary_impl.inc
@@ -0,0 +1,18 @@
+
+#ifndef SCALAR
+
+_CLC_OVERLOAD _CLC_DEF GENTYPE __clc_fmax(GENTYPE x, GENTYPE y) {
+ return FUNCTION_IMPL(x, y);
+}
+
+#endif
+
+_CLC_OVERLOAD _CLC_DEF GENTYPE __clc_fmax(GENTYPE x, double y) {
+ GENTYPE vec_y = (GENTYPE) (y);
+ return FUNCTION_IMPL(x, vec_y);
+}
+
+_CLC_OVERLOAD _CLC_DEF GENTYPE __clc_fmax(GENTYPE x, float y) {
+ GENTYPE vec_y = (GENTYPE) (y);
+ return FUNCTION_IMPL(x, vec_y);
+}
diff --git a/generic/lib/math/fmax.cl b/generic/lib/math/fmax.cl
index 6f22f35..186d331 100644
--- a/generic/lib/math/fmax.cl
+++ b/generic/lib/math/fmax.cl
@@ -4,5 +4,7 @@
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif
-#define BODY <fmax.inc>
+#define FUNCTION_IMPL(x, y) ((x) < (y) ? (y) : (x))
+
+#define BODY <binary_impl.inc>
#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/fmax.inc b/generic/lib/math/fmax.inc
deleted file mode 100644
index 962bed9..0000000
--- a/generic/lib/math/fmax.inc
+++ /dev/null
@@ -1,19 +0,0 @@
-#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);
-}