[PATCH] D97504: [llvm-exegesis] Disable the LBR check on AMD
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 14:44:23 PST 2021
oontvoo created this revision.
oontvoo added reviewers: ondrasej, courbet.
Herald added a subscriber: mstojanovic.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
https://bugs.llvm.org/show_bug.cgi?id=48918
The bug reported a hang (or very very slow runtime) on a Zen2. Unfortunately, we don't have the hardware right now to debug it and I was not able to reproduce the bug on a HSW.
Theory we've got is that the lbr-checking code could be confused on AMD.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97504
Files:
llvm/tools/llvm-exegesis/lib/Target.h
llvm/tools/llvm-exegesis/lib/X86/Target.cpp
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Index: llvm/tools/llvm-exegesis/llvm-exegesis.cpp
===================================================================
--- llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -11,6 +11,8 @@
///
//===----------------------------------------------------------------------===//
+#include <iostream>
+
#include "lib/Analysis.h"
#include "lib/BenchmarkResult.h"
#include "lib/BenchmarkRunner.h"
@@ -297,9 +299,14 @@
const LLVMState State(CpuName);
+ std::cout << State.getSubtargetInfo().getCPU().str();
+ // std::cout << "*** CPU name = " << std::cout <<
+ // State.getSubtargetInfo().getCPU().str()
+ // State.getTargetMachine().getTargetFeatureString().str();
+
// Preliminary check to ensure features needed for requested
// benchmark mode are present on target CPU and/or OS.
- ExitOnErr(State.getExegesisTarget().checkFeatureSupport());
+ ExitOnErr(State.getExegesisTarget().checkFeatureSupport(State));
const std::unique_ptr<BenchmarkRunner> Runner =
ExitOnErr(State.getExegesisTarget().createBenchmarkRunner(
Index: llvm/tools/llvm-exegesis/lib/X86/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -719,7 +719,7 @@
return Arch == Triple::x86_64 || Arch == Triple::x86;
}
- Error checkFeatureSupport() const override {
+ Error checkFeatureSupport(const LLVMState &state) const override {
// LBR is the only feature we conditionally support now.
// So if LBR is not requested, then we should be able to run the benchmarks.
if (LbrSamplingPeriod == 0)
@@ -727,13 +727,18 @@
#if defined(__linux__) && defined(HAVE_LIBPFM) && \
defined(LIBPFM_HAS_FIELD_CYCLES)
- // If the kernel supports it, the hardware still may not have it.
- return X86LbrCounter::checkLbrSupport();
-#else
+ // FIXME: Fix this.
+ // https://bugs.llvm.org/show_bug.cgi?id=48918
+ // For now, don't do the check if we see an AMD machine because
+ // the counter uses some intel-specific magic and it could
+ // be confuse and think the AMD machine actually has LBR support.
+ if (state.getSubtargetInfo().getCPU().compare_lower("amd") != 0)
+ // If the kernel supports it, the hardware still may not have it.
+ return X86LbrCounter::checkLbrSupport();
+#endif
return llvm::make_error<llvm::StringError>(
"LBR not supported on this kernel and/or platform",
llvm::errc::not_supported);
-#endif
}
std::unique_ptr<SavedState> withSavedState() const override {
Index: llvm/tools/llvm-exegesis/lib/Target.h
===================================================================
--- llvm/tools/llvm-exegesis/lib/Target.h
+++ llvm/tools/llvm-exegesis/lib/Target.h
@@ -145,7 +145,9 @@
// Checks hardware and software support for current benchmark mode.
// Returns an error if the target host does not have support to run the
// benchmark.
- virtual Error checkFeatureSupport() const { return Error::success(); }
+ virtual Error checkFeatureSupport(const LLVMState &) const {
+ return Error::success();
+ }
// Creates a snippet generator for the given mode.
std::unique_ptr<SnippetGenerator>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97504.326518.patch
Type: text/x-patch
Size: 3311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210225/a3882c8d/attachment.bin>
More information about the llvm-commits
mailing list