Skip to content

Commit

Permalink
Try to make it build on clang
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Dec 30, 2024
1 parent 4e38e35 commit 4c24059
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
2 changes: 0 additions & 2 deletions nanobenchmarks/function_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <string>
#include <string_view>

#include "base/macros.hpp"

namespace principia {
namespace nanobenchmarks {
namespace _function_registry {
Expand Down
23 changes: 23 additions & 0 deletions nanobenchmarks/microarchitectures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,36 @@
#include <vector>

#include "base/cpuid.hpp"
#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_CLANG.
#include "glog/logging.h"

BENCHMARK_EXTERN_C_FUNCTION(identity);
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 {
Expand Down
18 changes: 15 additions & 3 deletions nanobenchmarks/performance_settings_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include <utility>
#include <string_view>

#include "absl/flags/flag.h"
#include "base/macros.hpp" // 🧙 For OS_WIN.
#include "glog/logging.h"

#if OS_WIN
#include <windows.h>
#include <powersetting.h>
#include <powrprof.h>

#include "absl/flags/flag.h"
#include "glog/logging.h"

ABSL_FLAG(bool,
keep_perf_boost,
false,
Expand All @@ -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:
Expand Down Expand Up @@ -295,6 +299,14 @@ WindowsPerformanceSettingsController::ReadAndPrintAllowThrottlingACDC() const {
"PROCESSOR_THROTTLE DC={} ({})", dc, ProcessorThrottleToString(dc));
return {ac, dc};
}
#else

not_null<std::unique_ptr<PerformanceSettingsController>>
PerformanceSettingsController::New() {
return make_not_null_unique<PerformanceSettingsController>();
}

#endif

} // namespace internal
} // namespace _performance_settings_controller
Expand Down

0 comments on commit 4c24059

Please sign in to comment.