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

Adds topdown support for Skylake and Cascade Lake #629

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
11 changes: 8 additions & 3 deletions src/caliper/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern const char* builtin_umpire_option_specs;
extern const char* builtin_kokkos_option_specs;

extern const char* builtin_papi_hsw_option_specs;
extern const char* builtin_papi_skl_option_specs;
extern const char* builtin_papi_spr_option_specs;

extern void add_submodule_controllers_and_services();
Expand Down Expand Up @@ -1380,7 +1381,7 @@ struct ConfigManager::ConfigManagerImpl {
ConfigManagerImpl()
: builtin_option_specs_list({
#ifdef CALIPER_HAVE_GOTCHA
builtin_gotcha_option_specs,
builtin_gotcha_option_specs,
#endif
#ifdef CALIPER_HAVE_MPI
builtin_mpi_option_specs,
Expand All @@ -1406,13 +1407,17 @@ struct ConfigManager::ConfigManagerImpl {
#ifdef CALIPER_HAVE_KOKKOS
builtin_kokkos_option_specs,
#endif
builtin_base_option_specs
builtin_base_option_specs
})
{
#ifdef CALIPER_HAVE_PAPI
#ifdef CALIPER_HAVE_ARCH
if (std::string(CALIPER_HAVE_ARCH) == "sapphirerapids") {
std::string cali_arch = CALIPER_HAVE_ARCH;
Log(2).stream() << "ConfigManager: detected architecture " << cali_arch << std::endl;
if (cali_arch == "sapphirerapids") {
builtin_option_specs_list.push_back(builtin_papi_spr_option_specs);
} else if (cali_arch == "skylake" || cali_arch == "skylake_avx512" || cali_arch == "cascadelake") {
builtin_option_specs_list.push_back(builtin_papi_skl_option_specs);
} else {
builtin_option_specs_list.push_back(builtin_papi_hsw_option_specs);
}
Expand Down
207 changes: 75 additions & 132 deletions src/caliper/controllers/controllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,81 @@ const char* builtin_papi_hsw_option_specs = R"json(
]
)json";

const char* builtin_papi_skl_option_specs = R"json(
[
{
"name" : "topdown.toplevel",
"description" : "Top-down analysis for Intel CPUs (top level)",
"type" : "bool",
"category" : "metric",
"services" : [ "topdown" ],
"config" : { "CALI_TOPDOWN_LEVEL": "top" },
"query" :
[
{ "level": "local", "select":
[
"any(topdown.retiring) as \"Retiring\"",
"any(topdown.backend_bound) as \"Backend bound\"",
"any(topdown.frontend_bound) as \"Frontend bound\"",
"any(topdown.bad_speculation) as \"Bad speculation\""
]
},
{ "level": "cross", "select":
[
"any(any#topdown.retiring) as \"Retiring\"",
"any(any#topdown.backend_bound) as \"Backend bound\"",
"any(any#topdown.frontend_bound) as \"Frontend bound\"",
"any(any#topdown.bad_speculation) as \"Bad speculation\""
]
}
]
},
{
"name" : "topdown.all",
"description" : "Top-down analysis for Intel CPUs (all levels)",
"type" : "bool",
"category" : "metric",
"services" : [ "topdown" ],
"config" : { "CALI_TOPDOWN_LEVEL": "all" },
"query" :
[
{ "level": "local", "select":
[
"any(topdown.retiring) as \"Retiring\"",
"any(topdown.light_operations) as \"Light operations\"",
"any(topdown.heavy_operations) as \"Heavy operations\"",
"any(topdown.backend_bound) as \"Backend bound\"",
"any(topdown.memory_bound) as \"Memory bound\"",
"any(topdown.core_bound) as \"Core bound\"",
"any(topdown.frontend_bound) as \"Frontend bound\"",
"any(topdown.fetch_latency) as \"Fetch latency\"",
"any(topdown.fetch_bandwidth) as \"Fetch bandwidth\"",
"any(topdown.bad_speculation) as \"Bad speculation\"",
"any(topdown.branch_mispredicts) as \"Branch mispredicts\"",
"any(topdown.machine_clears) as \"Machine clears\""
]
},
{ "level": "cross", "select":
[
"any(any#topdown.retiring) as \"Retiring\"",
"any(any#topdown.light_operations) as \"Light operations\"",
"any(any#topdown.heavy_operations) as \"Heavy operations\"",
"any(any#topdown.backend_bound) as \"Backend bound\"",
"any(any#topdown.memory_bound) as \"Memory bound\"",
"any(any#topdown.core_bound) as \"Core bound\"",
"any(any#topdown.frontend_bound) as \"Frontend bound\"",
"any(any#topdown.fetch_latency) as \"Fetch latency\"",
"any(any#topdown.fetch_bandwidth) as \"Fetch bandwidth\"",
"any(any#topdown.bad_speculation) as \"Bad speculation\"",
"any(any#topdown.branch_mispredicts) as \"Branch mispredicts\"",
"any(any#topdown.machine_clears) as \"Machine clears\""
]
}
]
}
]
)json";

#ifdef CALIPER_WITH_PAPI_RDPMC
const char* builtin_papi_spr_option_specs = R"json(
[
Expand Down Expand Up @@ -1261,60 +1336,6 @@ const char* builtin_papi_spr_option_specs = R"json(
]
}
]
},
{
"name" : "topdown-counters.toplevel",
"description" : "Raw counter values for Intel top-down analysis (top level)",
"type" : "bool",
"category" : "metric",
"services" : [ "papi" ],
"config" :
{
"CALI_PAPI_COUNTERS":
"perf::slots,perf::topdown-retiring"
},
"query" :
[
{ "level": "local", "select":
[
"inclusive_sum(sum#papi.slots) as slots",
"inclusive_sum(sum#papi.perf::topdown-retiring) as topdown_retiring"
]
},
{ "level": "cross", "select":
[
"sum(inclusive#sum#papi.slots) as slots",
"sum(inclusive#sum#papi.perf::topdown-retiring) as topdown_retiring"
]
}
]
},
{
"name" : "topdown-counters.all",
"description" : "Raw counter values for Intel top-down analysis (all levels)",
"type" : "bool",
"category" : "metric",
"services" : [ "papi" ],
"config" :
{
"CALI_PAPI_COUNTERS":
"perf::slots,perf::topdown-retiring"
},
"query" :
[
{ "level": "local", "select":
[
"inclusive_sum(sum#papi.slots) as slots",
"inclusive_sum(sum#papi.perf::topdown-retiring) as topdown_retiring"
]
},
{ "level": "cross", "select":
[
"sum(inclusive#sum#papi.slots) as slots",
"sum(inclusive#sum#papi.perf::topdown-retiring) as topdown_retiring"
]
}
]
}
]
)json";
Expand Down Expand Up @@ -1390,84 +1411,6 @@ const char* builtin_papi_spr_option_specs = R"json(
]
}
]
},
{
"name" : "topdown-counters.toplevel",
"description" : "Raw counter values for Intel top-down analysis (top level)",
"type" : "bool",
"category" : "metric",
"services" : [ "papi" ],
"config" :
{
"CALI_PAPI_COUNTERS":
"perf::slots,perf::topdown-retiring,perf::topdown-bad-spec,perf::topdown-fe-bound,perf::topdown-be-bound,INT_MISC:UOP_DROPPING"
},
"query" :
[
{ "level": "local", "select":
[
"inclusive_sum(sum#papi.perf::slots) as slots",
"inclusive_sum(sum#papi.perf::topdown-retiring) as topdown_retiring",
"inclusive_sum(sum#papi.perf::topdown-bad-spec) as topdown_bad_spec",
"inclusive_sum(sum#papi.perf::topdown-fe-bound) as topdown_fe_bound",
"inclusive_sum(sum#papi.perf::topdown-be-bound) as topdown_be_bound",
"inclusive_sum(sum#papi.INT_MISC:UOP_DROPPING) as int_mist:uop_dropping"
]
},
{ "level": "cross", "select":
[
"sum(inclusive#sum#papi.perf::slots) as slots",
"sum(inclusive#sum#papi.perf::topdown-retiring) as topdown_retiring",
"sum(inclusive#sum#papi.perf::topdown-bad-spec) as topdown_bad_spec",
"sum(inclusive#sum#papi.perf::topdown-fe-bound) as topdown_fe_bound",
"sum(inclusive#sum#papi.perf::topdown-be-bound) as topdown_be_bound",
"sum(inclusive#sum#papi.INT_MISC:UOP_DROPPING) as int_mist:uop_dropping"
]
}
]
},
{
"name" : "topdown-counters.all",
"description" : "Raw counter values for Intel top-down analysis (all levels)",
"type" : "bool",
"category" : "metric",
"services" : [ "papi" ],
"config" :
{
"CALI_PAPI_COUNTERS":
"perf::slots,perf::topdown-retiring,perf::topdown-bad-spec,perf::topdown-fe-bound,perf::topdown-be-bound,INT_MISC:UOP_DROPPING,perf_raw::r8400,perf_raw::r8500,perf_raw::r8600,perf_raw::r8700"
},
"query" :
[
{ "level": "local", "select":
[
"inclusive_sum(sum#papi.perf::slots) as slots",
"inclusive_sum(sum#papi.perf::topdown-retiring) as topdown_retiring",
"inclusive_sum(sum#papi.perf::topdown-bad-spec) as topdown_bad_spec",
"inclusive_sum(sum#papi.perf::topdown-fe-bound) as topdown_fe_bound",
"inclusive_sum(sum#papi.perf::topdown-be-bound) as topdown_be_bound",
"inclusive_sum(sum#papi.INT_MISC:UOP_DROPPING) as int_mist:uop_dropping",
"inclusive_sum(sum#papi.perf_raw::r8400) as topdown_heavy_ops",
"inclusive_sum(sum#papi.perf_raw::r8500) as topdown_br_mispredict",
"inclusive_sum(sum#papi.perf_raw::r8600) as topdown_fetch_lat",
"inclusive_sum(sum#papi.perf_raw::r8700) as topdown_mem_bound"
]
},
{ "level": "cross", "select":
[
"sum(inclusive#sum#papi.perf::slots) as slots",
"sum(inclusive#sum#papi.perf::topdown-retiring) as topdown_retiring",
"sum(inclusive#sum#papi.perf::topdown-bad-spec) as topdown_bad_spec",
"sum(inclusive#sum#papi.perf::topdown-fe-bound) as topdown_fe_bound",
"sum(inclusive#sum#papi.perf::topdown-be-bound) as topdown_be_bound",
"sum(inclusive#sum#papi.INT_MISC:UOP_DROPPING) as int_mist:uop_dropping",
"sum(inclusive#sum#papi.perf_raw::r8400) as topdown_heavy_ops",
"sum(inclusive#sum#papi.perf_raw::r8500) as topdown_br_mispredict",
"sum(inclusive#sum#papi.perf_raw::r8600) as topdown_fetch_lat",
"sum(inclusive#sum#papi.perf_raw::r8700) as topdown_mem_bound"
]
}
]
}
]
)json";
Expand Down
3 changes: 2 additions & 1 deletion src/services/topdown/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set(CALIPER_TOPDOWN_SOURCES
IntelTopdown.cpp
TopdownCalculator.cpp
HaswellTopdown.cpp)
HaswellTopdown.cpp
SkylakeTopdown.cpp)


if (WITH_PAPI_RDPMC)
Expand Down
28 changes: 12 additions & 16 deletions src/services/topdown/IntelTopdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "HaswellTopdown.h"
#include "SapphireRapidsTopdown.h"
#include "SkylakeTopdown.h"

#include "caliper/SnapshotRecord.h"

Expand Down Expand Up @@ -41,18 +42,12 @@ class IntelTopdown
unsigned num_ret_computed;
unsigned num_ret_skipped;

topdown::IntelTopdownLevel m_level;
topdown::IntelTopdownLevel m_level;
std::shared_ptr<topdown::TopdownCalculator> m_calculator;

bool find_counter_attrs(CaliperMetadataAccessInterface& db)
{
return m_calculator->find_counter_attrs(db);
}
bool find_counter_attrs(CaliperMetadataAccessInterface& db) { return m_calculator->find_counter_attrs(db); }

void make_result_attrs(CaliperMetadataAccessInterface& db)
{
m_calculator->make_result_attrs(db);
}
void make_result_attrs(CaliperMetadataAccessInterface& db) { m_calculator->make_result_attrs(db); }

void postprocess_snapshot_cb(std::vector<Entry>& rec)
{
Expand Down Expand Up @@ -139,12 +134,9 @@ class IntelTopdown
num_bsp_skipped(0),
m_level(calculator->get_level()),
m_calculator(calculator)
{
}
{}

~IntelTopdown()
{
}
~IntelTopdown() {}

public:

Expand All @@ -167,11 +159,15 @@ class IntelTopdown

std::shared_ptr<topdown::TopdownCalculator> calculator;
#if defined(CALIPER_HAVE_ARCH)
if (std::string(CALIPER_HAVE_ARCH) == "sapphirerapids") {
std::string cali_arch = CALIPER_HAVE_ARCH;
if (cali_arch == "sapphirerapids") {
calculator = std::shared_ptr<topdown::TopdownCalculator>(new topdown::SapphireRapidsTopdown(level));
} else if (cali_arch == "skylake" || cali_arch == "skylake_avx512" || cali_arch == "cascadelake") {
calculator = std::shared_ptr<topdown::TopdownCalculator>(new topdown::SkylakeTopdown(level));
} else {
#endif
calculator = std::shared_ptr<topdown::TopdownCalculator>(new topdown::HaswellTopdown(level)); // Default type of calculation
calculator = std::shared_ptr<topdown::TopdownCalculator>(new topdown::HaswellTopdown(level)
); // Default type of calculation
#if defined(CALIPER_HAVE_ARCH)
}
#endif
Expand Down
Loading
Loading