amdgpu/math: Don't use llvm instrinsic for native_log
authorJan Vesely <jan.vesely@rutgers.edu>
Wed, 25 Oct 2017 16:49:17 +0000 (16:49 +0000)
committerJan Vesely <jan.vesely@rutgers.edu>
Wed, 25 Oct 2017 16:49:17 +0000 (16:49 +0000)
AMDGPU targets don't have insturction for it,
so it'll be expanded to C * log2 anyway.

v2: use native_log2 instead of the more precise sw implementation
v3: move to amdgpu
v4: drop old AMD copyright

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 316587

libclc/amdgpu/lib/SOURCES
libclc/amdgpu/lib/math/native_log.cl [new file with mode: 0644]
libclc/amdgpu/lib/math/native_log.inc [new file with mode: 0644]

index ce5fe66f123e6a47ca2bded4008942d1da2e2bd0..8cbe1d4256290aaa1904a9c4c5bfd8846bbea48c 100644 (file)
@@ -1,2 +1,3 @@
+math/native_log.cl
 math/nextafter.cl
 math/sqrt.cl
diff --git a/libclc/amdgpu/lib/math/native_log.cl b/libclc/amdgpu/lib/math/native_log.cl
new file mode 100644 (file)
index 0000000..3c5592f
--- /dev/null
@@ -0,0 +1,5 @@
+#include <clc/clc.h>
+
+#define __CLC_BODY <native_log.inc>
+#define __FLOAT_ONLY
+#include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/native_log.inc b/libclc/amdgpu/lib/math/native_log.inc
new file mode 100644 (file)
index 0000000..e6818dc
--- /dev/null
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log(__CLC_GENTYPE val) {
+  return native_log2(val) * (1.0f / M_LOG2E_F);
+}