Add files forgotten in the previous commit
authorJeroen Ketema <j.ketema@imperial.ac.uk>
Fri, 13 Jun 2014 12:33:40 +0000 (12:33 +0000)
committerJeroen Ketema <j.ketema@imperial.ac.uk>
Fri, 13 Jun 2014 12:33:40 +0000 (12:33 +0000)
llvm-svn: 210896

libclc/generic/lib/math/exp.cl [new file with mode: 0644]
libclc/generic/lib/math/exp.inc [new file with mode: 0644]

diff --git a/libclc/generic/lib/math/exp.cl b/libclc/generic/lib/math/exp.cl
new file mode 100644 (file)
index 0000000..dbf4a93
--- /dev/null
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY <exp.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/lib/math/exp.inc b/libclc/generic/lib/math/exp.inc
new file mode 100644 (file)
index 0000000..525fb59
--- /dev/null
@@ -0,0 +1,10 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE exp(__CLC_GENTYPE val) {
+  // exp(x) = exp2(x * log2(e))
+#if __CLC_FPSIZE == 32
+  return exp2(val * M_LOG2E_F);
+#elif __CLC_FPSIZE == 64
+  return exp2(val * M_LOG2E);
+#else
+#error unknown _CLC_FPSIZE
+#endif
+}