[libc-commits] [libc] 2ab18d5 - [libc] Add differential and performance targets for sqrtf

Hedin GarcĂ­a via libc-commits libc-commits at lists.llvm.org
Mon Aug 2 12:30:20 PDT 2021


Author: Hedin Garca
Date: 2021-08-02T19:29:48Z
New Revision: 2ab18d57d77633b6071c639c223b178754b36b4d

URL: https://github.com/llvm/llvm-project/commit/2ab18d57d77633b6071c639c223b178754b36b4d
DIFF: https://github.com/llvm/llvm-project/commit/2ab18d57d77633b6071c639c223b178754b36b4d.diff

LOG: [libc] Add differential and performance targets for sqrtf

Comparing the runtime of the sqrt functions from LLVM libc with the system libc:
|function       |perf - LLVM libc          |perf - MSVCRT
|sqrtf - Windows|44.05 sec (44051715500 ns)| 417.84 sec (417843359900 ns) = 6.96 mins

|function       |perf - LLVM libc          |perf - glibc
|sqrtf - Linux  |30.48 sec (30479458632 ns)|43.72 sec (43716901527 ns)

By running the differential test:
|function       |diff
|sqrtf - Windows|0 differing results
|sqrtf - Linux  |0 differing results

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107229

Added: 
    libc/test/src/math/differential_testing/sqrtf_diff.cpp
    libc/test/src/math/differential_testing/sqrtf_perf.cpp

Modified: 
    libc/test/src/math/differential_testing/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/test/src/math/
diff erential_testing/CMakeLists.txt b/libc/test/src/math/
diff erential_testing/CMakeLists.txt
index 82f912cc7315d..a986697996a5f 100644
--- a/libc/test/src/math/
diff erential_testing/CMakeLists.txt
+++ b/libc/test/src/math/
diff erential_testing/CMakeLists.txt
@@ -126,3 +126,23 @@ add_
diff _binary(
   COMPILE_OPTIONS
     -fno-builtin
 )
+
+add_
diff _binary(
+  sqrtf_
diff 
+  SRCS
+    sqrtf_
diff .cpp
+  DEPENDS
+    .single_input_single_output_
diff 
+    libc.src.math.sqrtf
+)
+
+add_
diff _binary(
+  sqrtf_perf
+  SRCS
+    sqrtf_perf.cpp
+  DEPENDS
+    .single_input_single_output_
diff 
+    libc.src.math.sqrtf
+  COMPILE_OPTIONS
+    -fno-builtin
+)

diff  --git a/libc/test/src/math/
diff erential_testing/sqrtf_
diff .cpp b/libc/test/src/math/
diff erential_testing/sqrtf_
diff .cpp
new file mode 100644
index 0000000000000..7081c0b2e4877
--- /dev/null
+++ b/libc/test/src/math/
diff erential_testing/sqrtf_
diff .cpp
@@ -0,0 +1,17 @@
+//===-- Differential test for sqrtf
+//----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SingleInputSingleOutputDiff.h"
+
+#include "src/math/sqrtf.h"
+
+#include <math.h>
+
+SINGLE_INPUT_SINGLE_OUTPUT_DIFF(float, __llvm_libc::sqrtf, ::sqrtf,
+                                "sqrtf_
diff .log")

diff  --git a/libc/test/src/math/
diff erential_testing/sqrtf_perf.cpp b/libc/test/src/math/
diff erential_testing/sqrtf_perf.cpp
new file mode 100644
index 0000000000000..29b6d5fcfcf12
--- /dev/null
+++ b/libc/test/src/math/
diff erential_testing/sqrtf_perf.cpp
@@ -0,0 +1,17 @@
+//===-- Differential test for sqrtf
+//----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SingleInputSingleOutputDiff.h"
+
+#include "src/math/sqrtf.h"
+
+#include <math.h>
+
+SINGLE_INPUT_SINGLE_OUTPUT_PERF(float, __llvm_libc::sqrtf, ::sqrtf,
+                                "sqrtf_perf.log")


        


More information about the libc-commits mailing list