summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/math/gentype.inc51
-rw-r--r--generic/include/clc/math/mad.h2
-rw-r--r--generic/include/clc/math/mad.inc1
-rw-r--r--generic/lib/SOURCES1
-rw-r--r--generic/lib/math/mad.cl4
-rw-r--r--generic/lib/math/mad.inc3
7 files changed, 63 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 0e640ba..3b78d29 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/log.h>
#include <clc/math/log2.h>
+#include <clc/math/mad.h>
#include <clc/math/sin.h>
#include <clc/math/sqrt.h>
#include <clc/math/native_cos.h>
diff --git a/generic/include/clc/math/gentype.inc b/generic/include/clc/math/gentype.inc
new file mode 100644
index 0000000..4506920
--- /dev/null
+++ b/generic/include/clc/math/gentype.inc
@@ -0,0 +1,51 @@
+#define GENTYPE float
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE float2
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE float3
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE float4
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE float8
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE float16
+#include BODY
+#undef GENTYPE
+
+#ifdef cl_khr_fp64
+#define GENTYPE double
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE double2
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE double3
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE double4
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE double8
+#include BODY
+#undef GENTYPE
+
+#define GENTYPE double16
+#include BODY
+#undef GENTYPE
+#endif
+
+#undef BODY
diff --git a/generic/include/clc/math/mad.h b/generic/include/clc/math/mad.h
new file mode 100644
index 0000000..58f7674
--- /dev/null
+++ b/generic/include/clc/math/mad.h
@@ -0,0 +1,2 @@
+#define BODY <clc/math/mad.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/mad.inc b/generic/include/clc/math/mad.inc
new file mode 100644
index 0000000..5200d67
--- /dev/null
+++ b/generic/include/clc/math/mad.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE mad(GENTYPE a, GENTYPE b, GENTYPE c);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 022abcf..1da1c91 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -7,3 +7,4 @@ integer/abs.cl
integer/add_sat.cl
integer/add_sat.ll
integer/add_sat_impl.ll
+math/mad.cl
diff --git a/generic/lib/math/mad.cl b/generic/lib/math/mad.cl
new file mode 100644
index 0000000..ff0cdbb
--- /dev/null
+++ b/generic/lib/math/mad.cl
@@ -0,0 +1,4 @@
+#include <clc/clc.h>
+
+#define BODY <mad.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/mad.inc b/generic/lib/math/mad.inc
new file mode 100644
index 0000000..aec9c06
--- /dev/null
+++ b/generic/lib/math/mad.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE mad(GENTYPE a, GENTYPE b, GENTYPE c) {
+ return a * b + c;
+}