[Libclc-dev] [PATCH 1/2] Add cross for double3 and double4
Jeroen Ketema
j.ketema at imperial.ac.uk
Tue Mar 11 11:59:16 PDT 2014
---
generic/include/clc/geometric/cross.h | 5 +++++
generic/lib/geometric/cross.cl | 14 ++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/generic/include/clc/geometric/cross.h b/generic/include/clc/geometric/cross.h
index 74117c0..eee0cc8 100644
--- a/generic/include/clc/geometric/cross.h
+++ b/generic/include/clc/geometric/cross.h
@@ -1,2 +1,7 @@
_CLC_OVERLOAD _CLC_DECL float3 cross(float3 p0, float3 p1);
_CLC_OVERLOAD _CLC_DECL float4 cross(float4 p0, float4 p1);
+
+#ifdef cl_khr_fp64
+_CLC_OVERLOAD _CLC_DECL double3 cross(double3 p0, double3 p1);
+_CLC_OVERLOAD _CLC_DECL double4 cross(double4 p0, double4 p1);
+#endif
diff --git a/generic/lib/geometric/cross.cl b/generic/lib/geometric/cross.cl
index 4c1bc6f..3b4ca6c 100644
--- a/generic/lib/geometric/cross.cl
+++ b/generic/lib/geometric/cross.cl
@@ -9,3 +9,17 @@ _CLC_OVERLOAD _CLC_DEF float4 cross(float4 p0, float4 p1) {
return (float4)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
p0.x*p1.y - p0.y*p1.x, 0.f);
}
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_OVERLOAD _CLC_DEF double3 cross(double3 p0, double3 p1) {
+ return (double3)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
+ p0.x*p1.y - p0.y*p1.x);
+}
+
+_CLC_OVERLOAD _CLC_DEF double4 cross(double4 p0, double4 p1) {
+ return (double4)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
+ p0.x*p1.y - p0.y*p1.x, 0.f);
+}
+#endif
--
1.8.3.4 (Apple Git-47)
More information about the Libclc-dev
mailing list