[libclc] r243132 - Fix double implementation of log

Tom Stellard thomas.stellard at amd.com
Fri Jul 24 11:07:14 PDT 2015


Author: tstellar
Date: Fri Jul 24 13:07:14 2015
New Revision: 243132

URL: http://llvm.org/viewvc/llvm-project?rev=243132&view=rev
Log:
Fix double implementation of log

We need to use M_LOG2E instead of M_LOG2E_F.

Added:
    libclc/trunk/generic/include/clc/math/log.inc
    libclc/trunk/generic/lib/math/log.cl
Modified:
    libclc/trunk/generic/include/clc/math/log.h
    libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/log.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/log.h?rev=243132&r1=243131&r2=243132&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/math/log.h (original)
+++ libclc/trunk/generic/include/clc/math/log.h Fri Jul 24 13:07:14 2015
@@ -1,4 +1,24 @@
-#undef log
+/*
+ * 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.
+ */
 
-// log(x) = log2(x) * (1/log2(e))
-#define log(val) (log2(val) * 0.693147181f)
+#define __CLC_BODY <clc/math/log.inc>
+#include <clc/math/gentype.inc>

Added: libclc/trunk/generic/include/clc/math/log.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/log.inc?rev=243132&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/log.inc (added)
+++ libclc/trunk/generic/include/clc/math/log.inc Fri Jul 24 13:07:14 2015
@@ -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 log(__CLC_GENTYPE a);

Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=243132&r1=243131&r2=243132&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Jul 24 13:07:14 2015
@@ -91,6 +91,7 @@ math/half_sqrt.cl
 math/hypot.cl
 math/clc_ldexp.cl
 math/ldexp.cl
+math/log.cl
 math/log10.cl
 math/log1p.cl
 math/log2.cl

Added: libclc/trunk/generic/lib/math/log.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/log.cl?rev=243132&view=auto
==============================================================================
--- libclc/trunk/generic/lib/math/log.cl (added)
+++ libclc/trunk/generic/lib/math/log.cl Fri Jul 24 13:07:14 2015
@@ -0,0 +1,26 @@
+#include <clc/clc.h>
+#include "../clcmacro.h"
+
+/*
+ *log(x) = log2(x) * (1/log2(e))
+ */
+
+_CLC_OVERLOAD _CLC_DEF float log(float x)
+{
+    return log2(x) * (1.0f / M_LOG2E_F);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, log, float);
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_OVERLOAD _CLC_DEF double log(double x)
+{
+    return log2(x) * (1.0 / M_LOG2E);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, log, double);
+
+#endif // cl_khr_fp64





More information about the cfe-commits mailing list