Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AMD L2 Prefetches metric and Code cleanups #126

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hbt/src/perf_event/AmdEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void addAmdEvents(const CpuInfo& cpu_info, PmuDeviceManager& pmu_manager) {
// to addEvents in json_events/generated/intel/JsonEvents.h
switch (cpu_info.cpu_arch) {
case CpuArch::MILAN:
case CpuArch::BERGAMO:
milan::addEvents(pmu_manager);
#ifdef FACEBOOK
milan::addEventsFb(pmu_manager);
Expand Down
14 changes: 6 additions & 8 deletions hbt/src/perf_event/AmdEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ constexpr PmuMsr kUnhaltedCycles{.amdCore = {.event = 0x76}};
constexpr PmuMsr kL1ICacheFillMisses{
.amdCore = {.event = 0x64, .unitMask = 0x7}}; // Same as e=0x60,u=0x10

// L1 dCache
constexpr PmuMsr kL1DCacheMisses{
.amdCore = {.event = 0x41, .unitMask = 0x1f}}; // AMD recommended way

// L2 Cache
constexpr PmuMsr kL2ICacheFillMisses{
.amdCore = {.event = 0x64, .unitMask = 0x1}};
Expand All @@ -134,10 +130,12 @@ constexpr PmuMsr kL2DCacheMisses{.amdCore = {.event = 0x64, .unitMask = 0x8}};
// L2 with Prefetcher
constexpr PmuMsr kL2Accesses{.amdCore = {.event = 0x64, .unitMask = 0x7f}};
constexpr PmuMsr kL2Misses{.amdCore = {.event = 0x64, .unitMask = 0x9}};
constexpr PmuMsr kL2PrefetcherHitsInL2{.amdCore = {.event = 0x70}};
constexpr PmuMsr kL2PrefetcherHitsInL3{.amdCore = {.event = 0x71}};
constexpr PmuMsr kL2PrefetcherMissesInL3{.amdCore = {.event = 0x72}};

constexpr PmuMsr kL2PrefetcherHitsInL2{
.amdCore = {.event = 0x70, .unitMask = 0x1f}};
constexpr PmuMsr kL2PrefetcherHitsInL3{
.amdCore = {.event = 0x71, .unitMask = 0x1f}};
constexpr PmuMsr kL2PrefetcherMissesInL3{
.amdCore = {.event = 0x72, .unitMask = 0x1f}};
// Flops
constexpr PmuMsr kRetiredX87Flops{.amdCore = {.event = 0x2, .unitMask = 0x7}};
constexpr PmuMsr kRetiredSseAvxFlops{
Expand Down
15 changes: 14 additions & 1 deletion hbt/src/perf_event/json_events/generated/CpuArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#pragma once

#include <cstdint>
#include <iostream>

namespace facebook::hbt::perf_event {

enum class CpuFamily { AMD, INTEL, UNKNOWN };
Expand Down Expand Up @@ -37,6 +40,8 @@ inline CpuFamily makeCpuFamily(uint32_t cpu_family) {
enum class CpuArch {
// AMD Architectures
MILAN,
GENOA,
BERGAMO,
// Intel Architectures Sorted by model id.
BDW,
BDW_DE,
Expand All @@ -62,6 +67,10 @@ inline std::ostream& operator<<(std::ostream& os, CpuArch ev) {
switch (ev) {
case CpuArch::MILAN:
return os << "MILAN";
case CpuArch::GENOA:
return os << "GENOA";
case CpuArch::BERGAMO:
return os << "BERGAMO";
case CpuArch::BDW:
return os << "BDW";
case CpuArch::BDW_DE:
Expand Down Expand Up @@ -107,8 +116,12 @@ inline CpuArch makeCpuArch(
auto cpu_family = makeCpuFamily(cpu_family_num);
if (cpu_family == CpuFamily::AMD) {
switch (cpu_model_num) {
case 1:
case 0x01:
return CpuArch::MILAN;
case 0x11:
return CpuArch::GENOA;
case 0xA0:
return CpuArch::BERGAMO;
}
} else if (cpu_family == CpuFamily::INTEL) {
switch (cpu_model_num) {
Expand Down