//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "utils/testutils/StreamWrapper.h"
-#include "utils/testutils/Timer.h"
+#include "test/src/math/differential_testing/Timer.h"
+
+#include <fstream>
namespace __llvm_libc {
namespace testing {
static uint64_t run_diff_in_range(Func myFunc, Func otherFunc,
UIntType startingBit, UIntType endingBit,
- UIntType N,
- testutils::OutputFileStream &log) {
+ UIntType N, std::ofstream &log) {
uint64_t result = 0;
if (endingBit < startingBit) {
return result;
static void run_perf_in_range(Func myFunc, Func otherFunc,
UIntType startingBit, UIntType endingBit,
- UIntType N, testutils::OutputFileStream &log) {
+ UIntType N, std::ofstream &log) {
auto runner = [=](Func func) {
volatile T result;
if (endingBit < startingBit) {
}
static void run_perf(Func myFunc, Func otherFunc, const char *logFile) {
- testutils::OutputFileStream log(logFile);
+ std::ofstream log(logFile);
log << " Performance tests with inputs in denormal range:\n";
run_perf_in_range(myFunc, otherFunc, /* startingBit= */ UIntType(0),
/* endingBit= */ FPBits::MAX_SUBNORMAL, 1'000'001, log);
static void run_diff(Func myFunc, Func otherFunc, const char *logFile) {
uint64_t diffCount = 0;
- testutils::OutputFileStream log(logFile);
+ std::ofstream log(logFile);
log << " Diff tests with inputs in denormal range:\n";
diffCount += run_diff_in_range(
myFunc, otherFunc, /* startingBit= */ UIntType(0),
+add_library(
+ libc_diff_test_utils
+ Timer.cpp
+ Timer.h
+)
+
+# A convenience target to build all differential tests.
+add_custom_target(libc-math-differential-tests)
function(add_diff_binary target_name)
cmake_parse_arguments(
${fq_target_name}
PRIVATE
${LIBC_SOURCE_DIR}
- ${LIBC_BUILD_DIR}
- ${LIBC_BUILD_DIR}/include
)
if(DIFF_COMPILE_OPTIONS)
target_compile_options(
target_link_libraries(
${fq_target_name}
- PRIVATE ${link_object_files} libc_test_utils)
+ PRIVATE ${link_object_files} libc_test_utils libc_diff_test_utils)
set_target_properties(${fq_target_name}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
libc.src.__support.FPUtil.fp_bits
${fq_deps_list}
)
+ add_dependencies(libc-math-differential-tests ${fq_target_name})
endfunction()
add_header_library(
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "utils/testutils/StreamWrapper.h"
-#include "utils/testutils/Timer.h"
+#include "test/src/math/differential_testing/Timer.h"
+
+#include <fstream>
namespace __llvm_libc {
namespace testing {
static void runDiff(Func myFunc, Func otherFunc, const char *logFile) {
UIntType diffCount = 0;
- testutils::OutputFileStream log(logFile);
+ std::ofstream log(logFile);
log << "Starting diff for values from 0 to " << UIntMax << '\n'
<< "Only differing results will be logged.\n\n";
for (UIntType bits = 0;; ++bits) {
}
static void runPerfInRange(Func myFunc, Func otherFunc, UIntType startingBit,
- UIntType endingBit,
- testutils::OutputFileStream &log) {
+ UIntType endingBit, std::ofstream &log) {
auto runner = [=](Func func) {
volatile T result;
for (UIntType bits = startingBit;; ++bits) {
}
static void runPerf(Func myFunc, Func otherFunc, const char *logFile) {
- testutils::OutputFileStream log(logFile);
+ std::ofstream log(logFile);
log << " Performance tests with inputs in denormal range:\n";
runPerfInRange(myFunc, otherFunc, /* startingBit= */ UIntType(0),
/* endingBit= */ FPBits::MAX_SUBNORMAL, log);