[Libclc-dev] [PATCH 2/2] Add sincos

Jeroen Ketema j.ketema at imperial.ac.uk
Tue Mar 11 11:59:37 PDT 2014


---
generic/include/clc/clc.h           |  1 +
generic/include/clc/math/sincos.h   |  2 ++
generic/include/clc/math/sincos.inc |  8 ++++++++
generic/lib/SOURCES                 |  1 +
generic/lib/math/sincos.cl          |  8 ++++++++
generic/lib/math/sincos.inc         | 11 +++++++++++
6 files changed, 31 insertions(+)
create mode 100644 generic/include/clc/math/sincos.h
create mode 100644 generic/include/clc/math/sincos.inc
create mode 100644 generic/lib/math/sincos.cl
create mode 100644 generic/lib/math/sincos.inc

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 0cd6d15..f8c1853 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -50,6 +50,7 @@
#include <clc/math/rint.h>
#include <clc/math/round.h>
#include <clc/math/sin.h>
+#include <clc/math/sincos.h>
#include <clc/math/sqrt.h>
#include <clc/math/trunc.h>
#include <clc/math/native_cos.h>
diff --git a/generic/include/clc/math/sincos.h b/generic/include/clc/math/sincos.h
new file mode 100644
index 0000000..fbb9b55
--- /dev/null
+++ b/generic/include/clc/math/sincos.h
@@ -0,0 +1,2 @@
+#define __CLC_BODY <clc/math/sincos.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/sincos.inc b/generic/include/clc/math/sincos.inc
new file mode 100644
index 0000000..444ac82
--- /dev/null
+++ b/generic/include/clc/math/sincos.inc
@@ -0,0 +1,8 @@
+#define __CLC_DECLARE_SINCOS(ADDRSPACE, TYPE) \
+  _CLC_OVERLOAD _CLC_DECL TYPE sincos (TYPE x, ADDRSPACE TYPE * cosval);
+
+__CLC_DECLARE_SINCOS(global, __CLC_GENTYPE)
+__CLC_DECLARE_SINCOS(local, __CLC_GENTYPE)
+__CLC_DECLARE_SINCOS(private, __CLC_GENTYPE)
+
+#undef __CLC_DECLARE_SINCOS
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index aa14165..6ccdf48 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -33,6 +33,7 @@ math/hypot.cl
math/mad.cl
math/clc_nextafter.cl
math/nextafter.cl
+math/sincos.cl
relational/any.cl
relational/isnan.cl
shared/clamp.cl
diff --git a/generic/lib/math/sincos.cl b/generic/lib/math/sincos.cl
new file mode 100644
index 0000000..eace5ad
--- /dev/null
+++ b/generic/lib/math/sincos.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY <sincos.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/sincos.inc b/generic/lib/math/sincos.inc
new file mode 100644
index 0000000..e97f0f9
--- /dev/null
+++ b/generic/lib/math/sincos.inc
@@ -0,0 +1,11 @@
+#define __CLC_DECLARE_SINCOS(ADDRSPACE, TYPE) \
+  _CLC_OVERLOAD _CLC_DEF TYPE sincos (TYPE x, ADDRSPACE TYPE * cosval) { \
+    *cosval = cos(x); \
+    return sin(x); \
+  }
+
+__CLC_DECLARE_SINCOS(global, __CLC_GENTYPE)
+__CLC_DECLARE_SINCOS(local, __CLC_GENTYPE)
+__CLC_DECLARE_SINCOS(private, __CLC_GENTYPE)
+
+#undef __CLC_DECLARE_SINCOS
-- 
1.8.3.4 (Apple Git-47)





More information about the Libclc-dev mailing list