[llvm] 63dd08b - [llvm-exegesis] Add branch miss validation counter (#81094)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 19 01:22:00 PST 2024
Author: Aiden Grossman
Date: 2024-02-19T01:21:56-08:00
New Revision: 63dd08b1f4d2a79c02e57cc0688e40c1ecc7f6cc
URL: https://github.com/llvm/llvm-project/commit/63dd08b1f4d2a79c02e57cc0688e40c1ecc7f6cc
DIFF: https://github.com/llvm/llvm-project/commit/63dd08b1f4d2a79c02e57cc0688e40c1ecc7f6cc.diff
LOG: [llvm-exegesis] Add branch miss validation counter (#81094)
This patch adds a branch miss validation counter so that it is easy to
quantify the number of missed branches when using the loop repetition
mode.
Added:
Modified:
llvm/include/llvm/Target/TargetPfmCounters.td
llvm/lib/Target/X86/X86PfmCounters.td
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Target/TargetPfmCounters.td b/llvm/include/llvm/Target/TargetPfmCounters.td
index c56f388fbd94b0..8c4d5f50c63a24 100644
--- a/llvm/include/llvm/Target/TargetPfmCounters.td
+++ b/llvm/include/llvm/Target/TargetPfmCounters.td
@@ -42,6 +42,7 @@ def L1ICacheLoadMiss : ValidationEvent<3>;
def DataTLBLoadMiss : ValidationEvent<4>;
def DataTLBStoreMiss : ValidationEvent<5>;
def InstructionTLBLoadMiss : ValidationEvent<6>;
+def BranchPredictionMiss : ValidationEvent<7>;
// PfmValidationCounter provides a mapping between the events that are
diff --git a/llvm/lib/Target/X86/X86PfmCounters.td b/llvm/lib/Target/X86/X86PfmCounters.td
index da3acc5bbf56f7..d87a559aa353b1 100644
--- a/llvm/lib/Target/X86/X86PfmCounters.td
+++ b/llvm/lib/Target/X86/X86PfmCounters.td
@@ -24,7 +24,8 @@ defvar DefaultIntelPfmValidationCounters = [
PfmValidationCounter<L1ICacheLoadMiss, "L1-ICACHE-LOAD-MISSES">,
PfmValidationCounter<DataTLBLoadMiss, "DTLB_LOAD_MISSES:MISS_CAUSES_A_WALK">,
PfmValidationCounter<DataTLBStoreMiss, "DTLB_STORE_MISSES:MISS_CAUSES_A_WALK">,
- PfmValidationCounter<InstructionTLBLoadMiss, "ITLB_MISSES:MISS_CAUSES_A_WALK">
+ PfmValidationCounter<InstructionTLBLoadMiss, "ITLB_MISSES:MISS_CAUSES_A_WALK">,
+ PfmValidationCounter<BranchPredictionMiss, "BRANCH-MISSES">
];
def PentiumPfmCounters : ProcPfmCounters {
@@ -210,7 +211,8 @@ defvar DefaultAMDPfmValidationCounters = [
PfmValidationCounter<L1DCacheStoreMiss, "L1-DCACHE-STORE-MISSES">,
PfmValidationCounter<L1ICacheLoadMiss, "L1-ICACHE-LOAD-MISSES">,
PfmValidationCounter<DataTLBLoadMiss, "DTLB-LOAD-MISSES">,
- PfmValidationCounter<InstructionTLBLoadMiss, "ITLB-LOAD-MISSES">
+ PfmValidationCounter<InstructionTLBLoadMiss, "ITLB-LOAD-MISSES">,
+ PfmValidationCounter<BranchPredictionMiss, "BRANCH-MISSES">
];
// Set basic counters for AMD cpus that we know libpfm4 supports.
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index c193a8e5027713..570af6eafb5857 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -209,6 +209,8 @@ const char *validationEventToString(exegesis::ValidationEvent VE) {
return "data-tlb-store-misses";
case exegesis::ValidationEvent::InstructionTLBLoadMiss:
return "instruction-tlb-load-misses";
+ case exegesis::ValidationEvent::BranchPredictionMiss:
+ return "branch-prediction-misses";
}
llvm_unreachable("Unhandled exegesis::ValidationEvent enum");
}
@@ -228,6 +230,8 @@ Expected<exegesis::ValidationEvent> stringToValidationEvent(StringRef Input) {
return exegesis::ValidationEvent::DataTLBStoreMiss;
else if (Input == "instruction-tlb-load-misses")
return exegesis::ValidationEvent::InstructionTLBLoadMiss;
+ else if (Input == "branch-prediction-misses")
+ return exegesis::ValidationEvent::BranchPredictionMiss;
else
return make_error<StringError>("Invalid validation event string",
errc::invalid_argument);
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 43f03ff5413388..c5d7bd23a41d42 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -39,7 +39,8 @@ enum ValidationEvent {
L1ICacheLoadMiss,
DataTLBLoadMiss,
DataTLBStoreMiss,
- InstructionTLBLoadMiss
+ InstructionTLBLoadMiss,
+ BranchPredictionMiss
};
enum class BenchmarkPhaseSelectorE {
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index 90de3e5bcf1db6..ac279029e6b004 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -293,7 +293,9 @@ static cl::list<ValidationEvent> ValidationCounters(
clEnumValN(ValidationEvent::DataTLBStoreMiss, "data-tlb-store-misses",
"Count DTLB store misses"),
clEnumValN(ValidationEvent::InstructionTLBLoadMiss,
- "instruction-tlb-load-misses", "Count ITLB load misses")));
+ "instruction-tlb-load-misses", "Count ITLB load misses"),
+ clEnumValN(ValidationEvent::BranchPredictionMiss,
+ "branch-prediction-misses", "Branch prediction misses")));
static ExitOnError ExitOnErr("llvm-exegesis error: ");
More information about the llvm-commits
mailing list