[Libclc-dev] [PATCH 2/2] Implement native_log10
Jan Vesely via Libclc-dev
libclc-dev at lists.llvm.org
Wed Oct 11 20:36:55 PDT 2017
Use llvm instrinsic by default
Provide amdgpu workaround
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
This is the last missing native_builtin.
amdgpu/lib/SOURCES | 1 +
amdgpu/lib/math/native_log10.cl | 27 ++++++++++++++++++++++++++
amdgpu/lib/math/native_log10.inc | 25 ++++++++++++++++++++++++
generic/include/clc/clc.h | 1 +
generic/include/clc/math/native_log10.h | 27 ++++++++++++++++++++++++++
generic/include/clc/math/native_log10.inc | 23 ++++++++++++++++++++++
generic/lib/SOURCES | 1 +
generic/lib/math/native_log10.cl | 32 +++++++++++++++++++++++++++++++
generic/lib/math/native_log10.inc | 25 ++++++++++++++++++++++++
9 files changed, 162 insertions(+)
create mode 100644 amdgpu/lib/math/native_log10.cl
create mode 100644 amdgpu/lib/math/native_log10.inc
create mode 100644 generic/include/clc/math/native_log10.h
create mode 100644 generic/include/clc/math/native_log10.inc
create mode 100644 generic/lib/math/native_log10.cl
create mode 100644 generic/lib/math/native_log10.inc
diff --git a/amdgpu/lib/SOURCES b/amdgpu/lib/SOURCES
index 8cbe1d4..59d8b22 100644
--- a/amdgpu/lib/SOURCES
+++ b/amdgpu/lib/SOURCES
@@ -1,3 +1,4 @@
math/native_log.cl
+math/native_log10.cl
math/nextafter.cl
math/sqrt.cl
diff --git a/amdgpu/lib/math/native_log10.cl b/amdgpu/lib/math/native_log10.cl
new file mode 100644
index 0000000..619b634
--- /dev/null
+++ b/amdgpu/lib/math/native_log10.cl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <clc/clc.h>
+
+#define __CLC_BODY <native_log10.inc>
+#define __FLOAT_ONLY
+#include <clc/math/gentype.inc>
diff --git a/amdgpu/lib/math/native_log10.inc b/amdgpu/lib/math/native_log10.inc
new file mode 100644
index 0000000..a84b91b
--- /dev/null
+++ b/amdgpu/lib/math/native_log10.inc
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log10(__CLC_GENTYPE val) {
+ return native_log2(val) * (M_LN2_F / M_LN10_F);
+}
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 3701336..5d64751 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -104,6 +104,7 @@
#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/generic/include/clc/math/native_log10.h b/generic/include/clc/math/native_log10.h
new file mode 100644
index 0000000..e95671d
--- /dev/null
+++ b/generic/include/clc/math/native_log10.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#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/generic/include/clc/math/native_log10.inc b/generic/include/clc/math/native_log10.inc
new file mode 100644
index 0000000..7b2971f
--- /dev/null
+++ b/generic/include/clc/math/native_log10.inc
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE native_log10(__CLC_GENTYPE a);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 50f45da..b6c2019 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -121,6 +121,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/generic/lib/math/native_log10.cl b/generic/lib/math/native_log10.cl
new file mode 100644
index 0000000..a715907
--- /dev/null
+++ b/generic/lib/math/native_log10.cl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#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/generic/lib/math/native_log10.inc b/generic/lib/math/native_log10.inc
new file mode 100644
index 0000000..e9b3b7a
--- /dev/null
+++ b/generic/lib/math/native_log10.inc
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log10(__CLC_GENTYPE val) {
+ return __clc_native_log10(val);
+}
--
2.13.6
More information about the Libclc-dev
mailing list