[SDK] Standardize rocprofiler-sdk counter definition YAML schema (#370)
* Convert YAML Format
Convert YAML format and reader to properly read the YAML.
Comparison between output's from the YAML show only changes in ordering
of architectures (and ids).
* Test fixes
* Add script for converting the YAML schema to source/scripts
* Update documentation
* Change the extra counter code block to YAML
* Add missing new line at EOF
* remove name issues
---------
Co-authored-by: Benjamin Welton <bewelton@amd.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
[ROCm/rocprofiler-sdk commit: 33e43e66d3]
This commit is contained in:
@@ -107,6 +107,7 @@ loadYAML(const std::string& filename, std::optional<ArchMetric> add_metric)
|
||||
{
|
||||
// Stores metrics that are added via the API
|
||||
static MetricMap added_metrics;
|
||||
YAML::Node append_yaml;
|
||||
|
||||
MetricMap ret;
|
||||
auto override = getCustomCounterDefinition().wlock([&](auto& data) {
|
||||
@@ -121,62 +122,53 @@ loadYAML(const std::string& filename, std::optional<ArchMetric> add_metric)
|
||||
std::ifstream file(filename);
|
||||
counter_data << file.rdbuf();
|
||||
}
|
||||
|
||||
if(!override.data.empty())
|
||||
else
|
||||
{
|
||||
ROCP_INFO << "Adding Override Config Data: " << override.data;
|
||||
counter_data << override.data;
|
||||
}
|
||||
|
||||
auto yaml = YAML::Load(counter_data.str());
|
||||
auto header = yaml["rocprofiler-sdk"]["counters"];
|
||||
uint64_t current_id = 0;
|
||||
|
||||
for(auto it = yaml.begin(); it != yaml.end(); ++it)
|
||||
if(!override.data.empty() && override.append)
|
||||
{
|
||||
auto counter_name = it->first.as<std::string>();
|
||||
if(counter_name == "schema-version") continue;
|
||||
auto counter_def = it->second;
|
||||
auto def_iterator = counter_def["architectures"];
|
||||
|
||||
for(auto def_it = def_iterator.begin(); def_it != def_iterator.end(); ++def_it)
|
||||
append_yaml = YAML::Load(override.data);
|
||||
if(append_yaml["rocprofiler-sdk"] && append_yaml["rocprofiler-sdk"]["counters"])
|
||||
{
|
||||
auto archs = def_it->first.as<std::string>();
|
||||
auto def = def_it->second;
|
||||
// To save space in the YAML file, we combine architectures with the same
|
||||
// definition into a single entry. Split these out into separate entries.
|
||||
// architectures:
|
||||
// gfx10/gfx1010/gfx1030/gfx1031/.....9:
|
||||
// expression: 400*SQ_WAIT_INST_LDS/SQ_WAVES/GRBM_GUI_ACTIVE
|
||||
std::vector<std::string> result;
|
||||
std::stringstream ss(archs);
|
||||
std::string arch_name;
|
||||
|
||||
while(std::getline(ss, arch_name, '/'))
|
||||
for(const auto& counter : append_yaml["rocprofiler-sdk"]["counters"])
|
||||
{
|
||||
auto& metricVec = ret.emplace(arch_name, std::vector<Metric>()).first->second;
|
||||
header.push_back(counter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(const auto& counter : header)
|
||||
{
|
||||
auto counter_name = counter["name"].as<std::string>();
|
||||
auto description = counter["description"].as<std::string>();
|
||||
for(const auto& definition : counter["definitions"])
|
||||
{
|
||||
for(const auto& arch : definition["architectures"])
|
||||
{
|
||||
auto& metricVec =
|
||||
ret.emplace(arch.as<std::string>(), std::vector<Metric>()).first->second;
|
||||
if(metricVec.empty())
|
||||
{
|
||||
const auto constants = get_constants(current_id);
|
||||
metricVec.insert(metricVec.end(), constants.begin(), constants.end());
|
||||
current_id += constants.size();
|
||||
}
|
||||
|
||||
std::string description;
|
||||
if(def["description"])
|
||||
description = def["description"].as<std::string>();
|
||||
else if(counter_def["description"])
|
||||
description = counter_def["description"].as<std::string>();
|
||||
metricVec.emplace_back(
|
||||
arch_name,
|
||||
arch.as<std::string>(),
|
||||
counter_name,
|
||||
(def["block"] ? def["block"].as<std::string>() : ""),
|
||||
(def["event"] ? def["event"].as<std::string>() : ""),
|
||||
(definition["block"] ? definition["block"].as<std::string>() : ""),
|
||||
(definition["event"] ? definition["event"].as<std::string>() : ""),
|
||||
description,
|
||||
(def["expression"] ? def["expression"].as<std::string>() : ""),
|
||||
(definition["expression"] ? definition["expression"].as<std::string>() : ""),
|
||||
"",
|
||||
current_id);
|
||||
current_id++;
|
||||
ROCP_TRACE << fmt::format("Inserted info {}: {}", arch_name, metricVec.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,11 +755,33 @@ TEST(core, public_api_iterate_agents)
|
||||
TEST(core, check_load_counter_def_append)
|
||||
{
|
||||
const std::string test_yaml = R"(
|
||||
TEST_YAML_LOAD:
|
||||
architectures:
|
||||
gfx950/gfx942/gfx10/gfx1010/gfx1030/gfx1031/gfx11/gfx1032/gfx1102/gfx906/gfx1100/gfx1101/gfx908/gfx90a/gfx9/gfx12/gfx1200/gfx1201:
|
||||
expression: reduce(GRBM_GUI_ACTIVE,max)*CU_NUM
|
||||
description: 'Unit: cycles'
|
||||
rocprofiler-sdk:
|
||||
counters-schema-version: 1
|
||||
counters:
|
||||
- name: TEST_YAML_LOAD
|
||||
description: cycles
|
||||
properties: []
|
||||
definitions:
|
||||
- architectures:
|
||||
- gfx950
|
||||
- gfx942
|
||||
- gfx10
|
||||
- gfx1010
|
||||
- gfx1030
|
||||
- gfx1031
|
||||
- gfx11
|
||||
- gfx1032
|
||||
- gfx1102
|
||||
- gfx906
|
||||
- gfx1100
|
||||
- gfx1101
|
||||
- gfx908
|
||||
- gfx90a
|
||||
- gfx9
|
||||
- gfx12
|
||||
- gfx1200
|
||||
- gfx1201
|
||||
expression: reduce(GRBM_GUI_ACTIVE,max)*CU_NUM
|
||||
)";
|
||||
ASSERT_EQ(hsa_init(), HSA_STATUS_SUCCESS);
|
||||
test_init();
|
||||
@@ -782,17 +804,61 @@ TEST_YAML_LOAD:
|
||||
TEST(core, check_load_counter_def)
|
||||
{
|
||||
const std::string test_yaml = R"(
|
||||
GRBM_GUI_ACTIVE:
|
||||
architectures:
|
||||
gfx950/gfx942/gfx941/gfx10/gfx1010/gfx1030/gfx1031/gfx11/gfx1032/gfx1102/gfx906/gfx1100/gfx1101/gfx940/gfx908/gfx900/gfx90a/gfx9/gfx12/gfx1200/gfx1201:
|
||||
block: GRBM
|
||||
event: 2
|
||||
description: The GUI is Active
|
||||
TEST_YAML_LOAD:
|
||||
architectures:
|
||||
gfx950/gfx942/gfx10/gfx1010/gfx1030/gfx1031/gfx11/gfx1032/gfx1102/gfx906/gfx1100/gfx1101/gfx908/gfx90a/gfx9/gfx12/gfx1200/gfx1201:
|
||||
expression: reduce(GRBM_GUI_ACTIVE,max)
|
||||
description: cycles
|
||||
rocprofiler-sdk:
|
||||
counters-schema-version: 1
|
||||
counters:
|
||||
- name: GRBM_GUI_ACTIVE
|
||||
description: The GUI is Active
|
||||
properties: []
|
||||
definitions:
|
||||
- architectures:
|
||||
- gfx950
|
||||
- gfx942
|
||||
- gfx941
|
||||
- gfx10
|
||||
- gfx1010
|
||||
- gfx1030
|
||||
- gfx1031
|
||||
- gfx11
|
||||
- gfx1032
|
||||
- gfx1102
|
||||
- gfx906
|
||||
- gfx1100
|
||||
- gfx1101
|
||||
- gfx940
|
||||
- gfx908
|
||||
- gfx900
|
||||
- gfx90a
|
||||
- gfx9
|
||||
- gfx12
|
||||
- gfx1200
|
||||
- gfx1201
|
||||
block: GRBM
|
||||
event: 2
|
||||
- name: TEST_YAML_LOAD
|
||||
description: cycles
|
||||
properties: []
|
||||
definitions:
|
||||
- architectures:
|
||||
- gfx950
|
||||
- gfx942
|
||||
- gfx10
|
||||
- gfx1010
|
||||
- gfx1030
|
||||
- gfx1031
|
||||
- gfx11
|
||||
- gfx1032
|
||||
- gfx1102
|
||||
- gfx906
|
||||
- gfx1100
|
||||
- gfx1101
|
||||
- gfx908
|
||||
- gfx90a
|
||||
- gfx9
|
||||
- gfx12
|
||||
- gfx1200
|
||||
- gfx1201
|
||||
expression: reduce(GRBM_GUI_ACTIVE,max)
|
||||
)";
|
||||
ASSERT_EQ(hsa_init(), HSA_STATUS_SUCCESS);
|
||||
test_init();
|
||||
|
||||
+8177
-3897
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user