[Libclc-dev] [PATCH 3/3] math: Implement mix builtin
Aaron Watry
awatry at gmail.com
Wed Jun 11 14:59:59 PDT 2014
Signed-off-by: Aaron Watry <awatry at gmail.com>
---
generic/include/clc/clc.h | 1 +
generic/include/clc/math/mix.h | 2 ++
generic/include/clc/math/mix.inc | 5 +++++
generic/lib/SOURCES | 1 +
generic/lib/math/mix.cl | 8 ++++++++
generic/lib/math/mix.inc | 9 +++++++++
6 files changed, 26 insertions(+)
create mode 100644 generic/include/clc/math/mix.h
create mode 100644 generic/include/clc/math/mix.inc
create mode 100644 generic/lib/math/mix.cl
create mode 100644 generic/lib/math/mix.inc
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 167cbfa..e4d65ba 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -45,6 +45,7 @@
#include <clc/math/log.h>
#include <clc/math/log2.h>
#include <clc/math/mad.h>
+#include <clc/math/mix.h>
#include <clc/math/nextafter.h>
#include <clc/math/pow.h>
#include <clc/math/rint.h>
diff --git a/generic/include/clc/math/mix.h b/generic/include/clc/math/mix.h
new file mode 100644
index 0000000..c3c95c1
--- /dev/null
+++ b/generic/include/clc/math/mix.h
@@ -0,0 +1,2 @@
+#define __CLC_BODY <clc/math/mix.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/mix.inc b/generic/include/clc/math/mix.inc
new file mode 100644
index 0000000..52cb10a
--- /dev/null
+++ b/generic/include/clc/math/mix.inc
@@ -0,0 +1,5 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mix(__CLC_GENTYPE a, __CLC_GENTYPE b, __CLC_GENTYPE c);
+
+#ifndef __CLC_SCALAR
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mix(__CLC_GENTYPE a, __CLC_GENTYPE b, __CLC_SCALAR_GENTYPE c);
+#endif
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 553a9b9..9fbe361 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -31,6 +31,7 @@ math/fmax.cl
math/fmin.cl
math/hypot.cl
math/mad.cl
+math/mix.cl
math/clc_nextafter.cl
math/nextafter.cl
math/sincos.cl
diff --git a/generic/lib/math/mix.cl b/generic/lib/math/mix.cl
new file mode 100644
index 0000000..294f332
--- /dev/null
+++ b/generic/lib/math/mix.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY <mix.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/mix.inc b/generic/lib/math/mix.inc
new file mode 100644
index 0000000..1e8b936
--- /dev/null
+++ b/generic/lib/math/mix.inc
@@ -0,0 +1,9 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mix(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE a) {
+ return mad( y - x, a, x );
+}
+
+#ifndef __CLC_SCALAR
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mix(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_SCALAR_GENTYPE a) {
+ return mix(x, y, (__CLC_GENTYPE)a);
+}
+#endif
--
1.9.1
More information about the Libclc-dev
mailing list