Skip to content

Commit

Permalink
[libc][benchmarks] Link the memory benchmark exes to functions from L…
Browse files Browse the repository at this point in the history
…LVM 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
  • Loading branch information
Siva Chandra Reddy committed Jun 17, 2020
1 parent 5c24411 commit 438f7fc
Show file tree
Hide file tree
Showing 22 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ if(LLVM_INCLUDE_TESTS)
add_subdirectory(test)
add_subdirectory(fuzzing)
endif()

add_subdirectory(benchmarks)
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,21 @@ 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
${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)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "llvm/Support/raw_ostream.h"
#include <memory>

namespace __llvm_libc {
extern void *memcpy(void *__restrict, const void *__restrict, size_t);
} // namespace __llvm_libc

namespace llvm {
namespace libc_benchmarks {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -41,8 +45,8 @@ struct MemsetContext : public BenchmarkRunner {

BenchmarkResult benchmark(const BenchmarkOptions &Options,
StringRef FunctionName, size_t Size) override {
FunctionPrototype Function =
StringSwitch<FunctionPrototype>(FunctionName).Case("memset", &::memset);
FunctionPrototype Function = StringSwitch<FunctionPrototype>(FunctionName)
.Case("memset", &__llvm_libc::memset);
return llvm::libc_benchmarks::benchmark(
Options, PP, [this, Function, Size](ParameterType p) {
Function(DstBuffer + p.DstOffset, MemsetValue, Size);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion libc/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ add_subdirectory(HdrGen)
add_subdirectory(MPFRWrapper)
add_subdirectory(testutils)
add_subdirectory(UnitTest)
add_subdirectory(benchmarks)

0 comments on commit 438f7fc

Please sign in to comment.