From 438f7fc068f9ba5555052c4af0b10f5e816c3a01 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Mon, 15 Jun 2020 13:54:53 -0700 Subject: [PATCH] [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc. Summary: To get the target order correct, the benchmarks directory has been moved one level higher. Previously, it was living in the utils directory. The utils directory is a collection of utils which are to be used by the tests and implementations. However, benchmarks *use* the implementations. So, moving it out of utils helps us setup proper target level dependencies. Reviewers: gchatelet Differential Revision: https://reviews.llvm.org/D81910 --- libc/CMakeLists.txt | 2 ++ libc/{utils => }/benchmarks/CMakeLists.txt | 11 ++++++----- libc/{utils => }/benchmarks/JSON.cpp | 0 libc/{utils => }/benchmarks/JSON.h | 0 libc/{utils => }/benchmarks/JSONTest.cpp | 0 libc/{utils => }/benchmarks/LibcBenchmark.cpp | 0 libc/{utils => }/benchmarks/LibcBenchmark.h | 0 libc/{utils => }/benchmarks/LibcBenchmarkTest.cpp | 0 libc/{utils => }/benchmarks/LibcMemoryBenchmark.cpp | 0 libc/{utils => }/benchmarks/LibcMemoryBenchmark.h | 0 libc/{utils => }/benchmarks/LibcMemoryBenchmarkMain.cpp | 0 libc/{utils => }/benchmarks/LibcMemoryBenchmarkMain.h | 0 libc/{utils => }/benchmarks/LibcMemoryBenchmarkTest.cpp | 0 libc/{utils => }/benchmarks/Memcmp.cpp | 0 libc/{utils => }/benchmarks/Memcpy.cpp | 4 ++++ libc/{utils => }/benchmarks/Memset.cpp | 8 ++++++-- libc/{utils => }/benchmarks/RATIONALE.md | 0 libc/{utils => }/benchmarks/README.md | 0 libc/{utils => }/benchmarks/configuration_big.json | 0 libc/{utils => }/benchmarks/configuration_small.json | 0 libc/{utils => }/benchmarks/render.py3 | 0 libc/utils/CMakeLists.txt | 1 - 22 files changed, 18 insertions(+), 8 deletions(-) rename libc/{utils => }/benchmarks/CMakeLists.txt (94%) rename libc/{utils => }/benchmarks/JSON.cpp (100%) rename libc/{utils => }/benchmarks/JSON.h (100%) rename libc/{utils => }/benchmarks/JSONTest.cpp (100%) rename libc/{utils => }/benchmarks/LibcBenchmark.cpp (100%) rename libc/{utils => }/benchmarks/LibcBenchmark.h (100%) rename libc/{utils => }/benchmarks/LibcBenchmarkTest.cpp (100%) rename libc/{utils => }/benchmarks/LibcMemoryBenchmark.cpp (100%) rename libc/{utils => }/benchmarks/LibcMemoryBenchmark.h (100%) rename libc/{utils => }/benchmarks/LibcMemoryBenchmarkMain.cpp (100%) rename libc/{utils => }/benchmarks/LibcMemoryBenchmarkMain.h (100%) rename libc/{utils => }/benchmarks/LibcMemoryBenchmarkTest.cpp (100%) rename libc/{utils => }/benchmarks/Memcmp.cpp (100%) rename libc/{utils => }/benchmarks/Memcpy.cpp (94%) rename libc/{utils => }/benchmarks/Memset.cpp (89%) rename libc/{utils => }/benchmarks/RATIONALE.md (100%) rename libc/{utils => }/benchmarks/README.md (100%) rename libc/{utils => }/benchmarks/configuration_big.json (100%) rename libc/{utils => }/benchmarks/configuration_small.json (100%) rename libc/{utils => }/benchmarks/render.py3 (100%) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index b774eac..58613fd 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -99,3 +99,5 @@ if(LLVM_INCLUDE_TESTS) add_subdirectory(test) add_subdirectory(fuzzing) endif() + +add_subdirectory(benchmarks) diff --git a/libc/utils/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt similarity index 94% rename from libc/utils/benchmarks/CMakeLists.txt rename to libc/benchmarks/CMakeLists.txt index 24741e0..6f3cfdb 100644 --- a/libc/utils/benchmarks/CMakeLists.txt +++ b/libc/benchmarks/CMakeLists.txt @@ -174,7 +174,7 @@ function(add_libc_benchmark_configuration target configuration) add_libc_benchmark_analysis(${conf_target} ${run_target}) endfunction() -function(add_libc_benchmark name file) +function(add_libc_benchmark name file entrypoint_target) set(libc_target libc-${name}-benchmark) add_executable(${libc_target} EXCLUDE_FROM_ALL @@ -182,12 +182,13 @@ function(add_libc_benchmark name file) LibcMemoryBenchmarkMain.h LibcMemoryBenchmarkMain.cpp ) - target_link_libraries(${libc_target} PUBLIC json) + + get_target_property(entrypoint_object_file ${entrypoint_target} "OBJECT_FILE_RAW") + target_link_libraries(${libc_target} PUBLIC json ${entrypoint_object_file}) foreach(configuration "small" "big") add_libc_benchmark_configuration(${libc_target} ${configuration}) endforeach() endfunction() -add_libc_benchmark(memcpy Memcpy.cpp) -add_libc_benchmark(memcmp Memcmp.cpp) -add_libc_benchmark(memset Memset.cpp) +add_libc_benchmark(memcpy Memcpy.cpp libc.src.string.memcpy) +add_libc_benchmark(memset Memset.cpp libc.src.string.memset) diff --git a/libc/utils/benchmarks/JSON.cpp b/libc/benchmarks/JSON.cpp similarity index 100% rename from libc/utils/benchmarks/JSON.cpp rename to libc/benchmarks/JSON.cpp diff --git a/libc/utils/benchmarks/JSON.h b/libc/benchmarks/JSON.h similarity index 100% rename from libc/utils/benchmarks/JSON.h rename to libc/benchmarks/JSON.h diff --git a/libc/utils/benchmarks/JSONTest.cpp b/libc/benchmarks/JSONTest.cpp similarity index 100% rename from libc/utils/benchmarks/JSONTest.cpp rename to libc/benchmarks/JSONTest.cpp diff --git a/libc/utils/benchmarks/LibcBenchmark.cpp b/libc/benchmarks/LibcBenchmark.cpp similarity index 100% rename from libc/utils/benchmarks/LibcBenchmark.cpp rename to libc/benchmarks/LibcBenchmark.cpp diff --git a/libc/utils/benchmarks/LibcBenchmark.h b/libc/benchmarks/LibcBenchmark.h similarity index 100% rename from libc/utils/benchmarks/LibcBenchmark.h rename to libc/benchmarks/LibcBenchmark.h diff --git a/libc/utils/benchmarks/LibcBenchmarkTest.cpp b/libc/benchmarks/LibcBenchmarkTest.cpp similarity index 100% rename from libc/utils/benchmarks/LibcBenchmarkTest.cpp rename to libc/benchmarks/LibcBenchmarkTest.cpp diff --git a/libc/utils/benchmarks/LibcMemoryBenchmark.cpp b/libc/benchmarks/LibcMemoryBenchmark.cpp similarity index 100% rename from libc/utils/benchmarks/LibcMemoryBenchmark.cpp rename to libc/benchmarks/LibcMemoryBenchmark.cpp diff --git a/libc/utils/benchmarks/LibcMemoryBenchmark.h b/libc/benchmarks/LibcMemoryBenchmark.h similarity index 100% rename from libc/utils/benchmarks/LibcMemoryBenchmark.h rename to libc/benchmarks/LibcMemoryBenchmark.h diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp similarity index 100% rename from libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp rename to libc/benchmarks/LibcMemoryBenchmarkMain.cpp diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.h b/libc/benchmarks/LibcMemoryBenchmarkMain.h similarity index 100% rename from libc/utils/benchmarks/LibcMemoryBenchmarkMain.h rename to libc/benchmarks/LibcMemoryBenchmarkMain.h diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp similarity index 100% rename from libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp rename to libc/benchmarks/LibcMemoryBenchmarkTest.cpp diff --git a/libc/utils/benchmarks/Memcmp.cpp b/libc/benchmarks/Memcmp.cpp similarity index 100% rename from libc/utils/benchmarks/Memcmp.cpp rename to libc/benchmarks/Memcmp.cpp diff --git a/libc/utils/benchmarks/Memcpy.cpp b/libc/benchmarks/Memcpy.cpp similarity index 94% rename from libc/utils/benchmarks/Memcpy.cpp rename to libc/benchmarks/Memcpy.cpp index ef031d3..eb30853 100644 --- a/libc/utils/benchmarks/Memcpy.cpp +++ b/libc/benchmarks/Memcpy.cpp @@ -13,6 +13,10 @@ #include "llvm/Support/raw_ostream.h" #include +namespace __llvm_libc { +extern void *memcpy(void *__restrict, const void *__restrict, size_t); +} // namespace __llvm_libc + namespace llvm { namespace libc_benchmarks { diff --git a/libc/utils/benchmarks/Memset.cpp b/libc/benchmarks/Memset.cpp similarity index 89% rename from libc/utils/benchmarks/Memset.cpp rename to libc/benchmarks/Memset.cpp index f891b7b..e93b057 100644 --- a/libc/utils/benchmarks/Memset.cpp +++ b/libc/benchmarks/Memset.cpp @@ -12,6 +12,10 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/raw_ostream.h" +namespace __llvm_libc { +void *memset(void *, int, size_t); +} // namespace __llvm_libc + namespace llvm { namespace libc_benchmarks { @@ -41,8 +45,8 @@ struct MemsetContext : public BenchmarkRunner { BenchmarkResult benchmark(const BenchmarkOptions &Options, StringRef FunctionName, size_t Size) override { - FunctionPrototype Function = - StringSwitch(FunctionName).Case("memset", &::memset); + FunctionPrototype Function = StringSwitch(FunctionName) + .Case("memset", &__llvm_libc::memset); return llvm::libc_benchmarks::benchmark( Options, PP, [this, Function, Size](ParameterType p) { Function(DstBuffer + p.DstOffset, MemsetValue, Size); diff --git a/libc/utils/benchmarks/RATIONALE.md b/libc/benchmarks/RATIONALE.md similarity index 100% rename from libc/utils/benchmarks/RATIONALE.md rename to libc/benchmarks/RATIONALE.md diff --git a/libc/utils/benchmarks/README.md b/libc/benchmarks/README.md similarity index 100% rename from libc/utils/benchmarks/README.md rename to libc/benchmarks/README.md diff --git a/libc/utils/benchmarks/configuration_big.json b/libc/benchmarks/configuration_big.json similarity index 100% rename from libc/utils/benchmarks/configuration_big.json rename to libc/benchmarks/configuration_big.json diff --git a/libc/utils/benchmarks/configuration_small.json b/libc/benchmarks/configuration_small.json similarity index 100% rename from libc/utils/benchmarks/configuration_small.json rename to libc/benchmarks/configuration_small.json diff --git a/libc/utils/benchmarks/render.py3 b/libc/benchmarks/render.py3 similarity index 100% rename from libc/utils/benchmarks/render.py3 rename to libc/benchmarks/render.py3 diff --git a/libc/utils/CMakeLists.txt b/libc/utils/CMakeLists.txt index 8a7ee53..c6e877f 100644 --- a/libc/utils/CMakeLists.txt +++ b/libc/utils/CMakeLists.txt @@ -4,4 +4,3 @@ add_subdirectory(HdrGen) add_subdirectory(MPFRWrapper) add_subdirectory(testutils) add_subdirectory(UnitTest) -add_subdirectory(benchmarks) -- 2.7.4