math: Implement native_log10
authorJan Vesely <jan.vesely@rutgers.edu>
Wed, 25 Oct 2017 16:49:22 +0000 (16:49 +0000)
committerJan Vesely <jan.vesely@rutgers.edu>
Wed, 25 Oct 2017 16:49:22 +0000 (16:49 +0000)
Use llvm instrinsic by default
Provide amdgpu workaround

v2: drop old amd copyrights

Reviewer: Aaron Watry
Reviewed-by: Vedran Miletić <vedran@miletic.net>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 316588

libclc/amdgpu/lib/SOURCES
libclc/amdgpu/lib/math/native_log10.cl [new file with mode: 0644]
libclc/amdgpu/lib/math/native_log10.inc [new file with mode: 0644]
libclc/generic/include/clc/clc.h
libclc/generic/include/clc/math/native_log10.h [new file with mode: 0644]
libclc/generic/include/clc/math/native_log10.inc [new file with mode: 0644]
libclc/generic/lib/SOURCES
libclc/generic/lib/math/native_log10.cl [new file with mode: 0644]
libclc/generic/lib/math/native_log10.inc [new file with mode: 0644]

index 8cbe1d4..59d8b22 100644 (file)
@@ -1,3 +1,4 @@
 math/native_log.cl
+math/native_log10.cl
 math/nextafter.cl
 math/sqrt.cl
diff --git a/libclc/amdgpu/lib/math/native_log10.cl b/libclc/amdgpu/lib/math/native_log10.cl
new file mode 100644 (file)
index 0000000..2e7c11e
--- /dev/null
@@ -0,0 +1,5 @@
+#include <clc/clc.h>
+
+#define __CLC_BODY <native_log10.inc>
+#define __FLOAT_ONLY
+#include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/native_log10.inc b/libclc/amdgpu/lib/math/native_log10.inc
new file mode 100644 (file)
index 0000000..96b1a0a
--- /dev/null
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log10(__CLC_GENTYPE val) {
+  return native_log2(val) * (M_LN2_F / M_LN10_F);
+}
index 3701336..5d64751 100644 (file)
 #include <clc/math/native_exp10.h>
 #include <clc/math/native_exp2.h>
 #include <clc/math/native_log.h>
+#include <clc/math/native_log10.h>
 #include <clc/math/native_log2.h>
 #include <clc/math/native_powr.h>
 #include <clc/math/native_recip.h>
diff --git a/libclc/generic/include/clc/math/native_log10.h b/libclc/generic/include/clc/math/native_log10.h
new file mode 100644 (file)
index 0000000..b877efd
--- /dev/null
@@ -0,0 +1,5 @@
+#define __CLC_BODY <clc/math/native_log10.inc>
+#define __FLOAT_ONLY
+#include <clc/math/gentype.inc>
+#undef __CLC_BODY
+#undef __FLOAT_ONLY
diff --git a/libclc/generic/include/clc/math/native_log10.inc b/libclc/generic/include/clc/math/native_log10.inc
new file mode 100644 (file)
index 0000000..ce5a994
--- /dev/null
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE native_log10(__CLC_GENTYPE a);
index ededcdb..7f09f9a 100644 (file)
@@ -120,6 +120,7 @@ math/logb.cl
 math/mad.cl
 math/modf.cl
 math/native_log.cl
+math/native_log10.cl
 math/native_log2.cl
 math/tables.cl
 math/clc_nextafter.cl
diff --git a/libclc/generic/lib/math/native_log10.cl b/libclc/generic/lib/math/native_log10.cl
new file mode 100644 (file)
index 0000000..9741daa
--- /dev/null
@@ -0,0 +1,10 @@
+#include <clc/clc.h>
+
+#define __CLC_FUNCTION __clc_native_log10
+#define __CLC_INTRINSIC "llvm.log10"
+#undef cl_khr_fp64
+#include <clc/math/unary_intrin.inc>
+
+#define __CLC_BODY <native_log10.inc>
+#define __FLOAT_ONLY
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/lib/math/native_log10.inc b/libclc/generic/lib/math/native_log10.inc
new file mode 100644 (file)
index 0000000..a2f3d1a
--- /dev/null
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log10(__CLC_GENTYPE val) {
+  return __clc_native_log10(val);
+}