Skip to content

Commit 2ab18d5

Browse files
committed
[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
1 parent 3f7aea1 commit 2ab18d5

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,23 @@ add_diff_binary(
126126
COMPILE_OPTIONS
127127
-fno-builtin
128128
)
129+
130+
add_diff_binary(
131+
sqrtf_diff
132+
SRCS
133+
sqrtf_diff.cpp
134+
DEPENDS
135+
.single_input_single_output_diff
136+
libc.src.math.sqrtf
137+
)
138+
139+
add_diff_binary(
140+
sqrtf_perf
141+
SRCS
142+
sqrtf_perf.cpp
143+
DEPENDS
144+
.single_input_single_output_diff
145+
libc.src.math.sqrtf
146+
COMPILE_OPTIONS
147+
-fno-builtin
148+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Differential test for sqrtf
2+
//----------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include "SingleInputSingleOutputDiff.h"
11+
12+
#include "src/math/sqrtf.h"
13+
14+
#include <math.h>
15+
16+
SINGLE_INPUT_SINGLE_OUTPUT_DIFF(float, __llvm_libc::sqrtf, ::sqrtf,
17+
"sqrtf_diff.log")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Differential test for sqrtf
2+
//----------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include "SingleInputSingleOutputDiff.h"
11+
12+
#include "src/math/sqrtf.h"
13+
14+
#include <math.h>
15+
16+
SINGLE_INPUT_SINGLE_OUTPUT_PERF(float, __llvm_libc::sqrtf, ::sqrtf,
17+
"sqrtf_perf.log")

0 commit comments

Comments
 (0)