summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2012-08-21 10:48:35 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2012-08-21 10:48:35 +0000
commita9652818973fd27ac904b60dabe12d75ab192ff9 (patch)
tree2fadd01fd84d7679dad988942c1c9f8b2aa9bccd
parent1e8ef6c06fd23e593f67fb5b8e4bb89eb657e8d6 (diff)
Add rsqrt builtin. Based on patch by Cassie Epps!
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@162274 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/math/rsqrt.h1
-rw-r--r--test/rsqrt.cl6
3 files changed, 8 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 4f49760..565b505 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -53,6 +53,7 @@
#include <clc/math/native_log2.h>
#include <clc/math/native_sin.h>
#include <clc/math/native_sqrt.h>
+#include <clc/math/rsqrt.h>
/* 6.11.3 Integer Functions */
#include <clc/integer/abs.h>
diff --git a/generic/include/clc/math/rsqrt.h b/generic/include/clc/math/rsqrt.h
new file mode 100644
index 0000000..8fd2cbf
--- /dev/null
+++ b/generic/include/clc/math/rsqrt.h
@@ -0,0 +1 @@
+#define rsqrt(x) (1.f/sqrt(x))
diff --git a/test/rsqrt.cl b/test/rsqrt.cl
new file mode 100644
index 0000000..13ad216
--- /dev/null
+++ b/test/rsqrt.cl
@@ -0,0 +1,6 @@
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+__kernel void foo(float4 *x, double4 *y) {
+ x[1] = rsqrt(x[0]);
+ y[1] = rsqrt(y[0]);
+}