From 4c24059ef01d187f8945b8545e04ea0cb9368db1 Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Mon, 30 Dec 2024 12:10:38 +0100 Subject: [PATCH 1/2] Try to make it build on clang --- nanobenchmarks/function_registry.hpp | 2 -- nanobenchmarks/microarchitectures.cpp | 23 +++++++++++++++++++ .../performance_settings_controller.cpp | 18 ++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/nanobenchmarks/function_registry.hpp b/nanobenchmarks/function_registry.hpp index 0b056df9f7..6ee6cd5fa1 100644 --- a/nanobenchmarks/function_registry.hpp +++ b/nanobenchmarks/function_registry.hpp @@ -5,8 +5,6 @@ #include #include -#include "base/macros.hpp" - namespace principia { namespace nanobenchmarks { namespace _function_registry { diff --git a/nanobenchmarks/microarchitectures.cpp b/nanobenchmarks/microarchitectures.cpp index e0af7168b1..e149e36822 100644 --- a/nanobenchmarks/microarchitectures.cpp +++ b/nanobenchmarks/microarchitectures.cpp @@ -6,6 +6,7 @@ #include #include "base/cpuid.hpp" +#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_CLANG. #include "glog/logging.h" BENCHMARK_EXTERN_C_FUNCTION(identity); @@ -13,6 +14,28 @@ BENCHMARK_EXTERN_C_FUNCTION(sqrtps_xmm0_xmm0); BENCHMARK_EXTERN_C_FUNCTION(sqrtsd_xmm0_xmm0); BENCHMARK_EXTERN_C_FUNCTION(mulsd_xmm0_xmm0); BENCHMARK_EXTERN_C_FUNCTION(mulsd_xmm0_xmm0_4x); +#if PRINCIPIA_COMPILER_CLANG +asm(R"( +.intel_syntax +identity: + ret +sqrtps_xmm0_xmm0: + sqrtps xmm0, xmm0 + ret +sqrtsd_xmm0_xmm0: + sqrtsd xmm0, xmm0 + ret +mulsd_xmm0_xmm0: + mulsd xmm0, xmm0 + ret +mulsd_xmm0_xmm0_4x: + mulsd xmm0, xmm0 + mulsd xmm0, xmm0 + mulsd xmm0, xmm0 + mulsd xmm0, xmm0 + ret +)"); +#endif namespace principia { namespace nanobenchmarks { diff --git a/nanobenchmarks/performance_settings_controller.cpp b/nanobenchmarks/performance_settings_controller.cpp index 16246229c9..3ff1d25b3f 100644 --- a/nanobenchmarks/performance_settings_controller.cpp +++ b/nanobenchmarks/performance_settings_controller.cpp @@ -6,13 +6,15 @@ #include #include +#include "absl/flags/flag.h" +#include "base/macros.hpp" // 🧙 For OS_WIN. +#include "glog/logging.h" + +#if OS_WIN #include #include #include -#include "absl/flags/flag.h" -#include "glog/logging.h" - ABSL_FLAG(bool, keep_perf_boost, false, @@ -23,12 +25,14 @@ ABSL_FLAG(bool, keep_throttling, false, "Whether to allow processor throttling during benchmark execution"); +#endif namespace principia { namespace nanobenchmarks { namespace _performance_settings_controller { namespace internal { +#if OS_WIN class WindowsPerformanceSettingsController : public PerformanceSettingsController { public: @@ -295,6 +299,14 @@ WindowsPerformanceSettingsController::ReadAndPrintAllowThrottlingACDC() const { "PROCESSOR_THROTTLE DC={} ({})", dc, ProcessorThrottleToString(dc)); return {ac, dc}; } +#else + +not_null> +PerformanceSettingsController::New() { + return make_not_null_unique(); +} + +#endif } // namespace internal } // namespace _performance_settings_controller From 58ad6fc070d15737dae85a5d4606c0f4b1423098 Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Mon, 30 Dec 2024 12:23:49 +0100 Subject: [PATCH 2/2] sourcery --- include_what_you_using_all_the_things.ps1 | 1 + nanobenchmarks/examples.cpp | 2 +- nanobenchmarks/main.cpp | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include_what_you_using_all_the_things.ps1 b/include_what_you_using_all_the_things.ps1 index cc3b1393c8..5b825de3c4 100644 --- a/include_what_you_using_all_the_things.ps1 +++ b/include_what_you_using_all_the_things.ps1 @@ -7,6 +7,7 @@ --project:geometry ` --project:integrators ` --project:journal ` + --project:nanobenchmarks ` --project:ksp_plugin ` --project:ksp_plugin_test ` --project:mathematica ` diff --git a/nanobenchmarks/examples.cpp b/nanobenchmarks/examples.cpp index 56727e745b..2d3e539fe5 100644 --- a/nanobenchmarks/examples.cpp +++ b/nanobenchmarks/examples.cpp @@ -1,6 +1,6 @@ #include -#include "nanobenchmarks/function_registry.hpp" +#include "nanobenchmarks/function_registry.hpp" // 🧙 For BENCHMARK_FUNCTION etc. #include "numerics/cbrt.hpp" namespace principia { diff --git a/nanobenchmarks/main.cpp b/nanobenchmarks/main.cpp index 42ecb90cbb..00deceba04 100644 --- a/nanobenchmarks/main.cpp +++ b/nanobenchmarks/main.cpp @@ -20,13 +20,11 @@ #include "absl/flags/parse.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" -#include "base/array.hpp" -#include "base/cpuid.hpp" #include "mathematica/logger.hpp" +#include "mathematica/mathematica.hpp" #include "nanobenchmarks/function_registry.hpp" #include "nanobenchmarks/microarchitectures.hpp" #include "nanobenchmarks/performance_settings_controller.hpp" -#include "numerics/cbrt.hpp" #include "testing_utilities/statistics.hpp" ABSL_FLAG(std::size_t,