Enable single pass counter collection (#833)
[ROCm/rocprofiler-compute commit: 6a77d241ed]
This commit is contained in:
@@ -17,14 +17,23 @@ import yaml
|
||||
ROOT_DIR = Path(__file__).parent.parent
|
||||
SOURCE_DIR = ROOT_DIR.joinpath("utils")
|
||||
TARGET_DIR = ROOT_DIR.joinpath("src", "rocprof_compute_soc", "analysis_configs")
|
||||
SETS_TARGET_DIR = ROOT_DIR.joinpath(
|
||||
"src", "rocprof_compute_soc", "profile_configs", "sets"
|
||||
)
|
||||
DOC_TARGET_DIR = ROOT_DIR.joinpath("docs", "data")
|
||||
AUTOGEN_TEXT = "# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_config.yaml. Generated by utils/split_config.py\n"
|
||||
HASH_FILE = ROOT_DIR.joinpath("utils", "autogen_hash.yaml")
|
||||
HASH_FILE_MAP = {}
|
||||
GFX_VERSIONS = ["gfx908", "gfx90a", "gfx940", "gfx941", "gfx942", "gfx950"]
|
||||
METRIC_ID_TO_NAME_MAP = {gfx_version: {} for gfx_version in GFX_VERSIONS}
|
||||
|
||||
|
||||
def get_autogen_text(config_file="utils/unified_config.yaml"):
|
||||
return f"# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from {config_file}. Generated by utils/split_config.py\n"
|
||||
|
||||
|
||||
def update_analysis_config():
|
||||
global METRIC_ID_TO_NAME_MAP
|
||||
|
||||
# Read the unified config file
|
||||
with open(SOURCE_DIR.joinpath("unified_config.yaml")) as file:
|
||||
unified_config = yaml.safe_load(file)
|
||||
@@ -38,6 +47,7 @@ def update_analysis_config():
|
||||
key: value["plain"]
|
||||
for key, value in panel_config.get("metrics_description", {}).items()
|
||||
}
|
||||
panel_id_int = panel_config["id"]
|
||||
# Convert int into str with 4 digits
|
||||
panel_id = str(panel_config["id"]).zfill(4)
|
||||
# Replace parentehsis, hyphen, slash and space with underscore
|
||||
@@ -57,19 +67,28 @@ def update_analysis_config():
|
||||
|
||||
# Select metrics from current gfx arch
|
||||
new_panel_config["Panel Config"]["data source"] = []
|
||||
for data_source_config in panel_config["data source"]:
|
||||
for data_source_index, data_source_config in enumerate(
|
||||
panel_config["data source"]
|
||||
):
|
||||
data_source_config = copy.deepcopy(data_source_config)
|
||||
if "metric_table" in data_source_config:
|
||||
data_source_config["metric_table"]["metric"] = data_source_config[
|
||||
"metric_table"
|
||||
]["metric"][gfx_version]
|
||||
|
||||
build_metric_id_mapping(
|
||||
panel_id_int,
|
||||
data_source_index,
|
||||
data_source_config["metric_table"]["metric"],
|
||||
gfx_version,
|
||||
)
|
||||
new_panel_config["Panel Config"]["data source"].append(data_source_config)
|
||||
# Write panel config to file
|
||||
filename = Path(
|
||||
TARGET_DIR.joinpath(gfx_version, f"{panel_id}_{panel_title}.yaml")
|
||||
)
|
||||
with open(filename, "w") as file:
|
||||
file.write(AUTOGEN_TEXT)
|
||||
file.write(get_autogen_text())
|
||||
yaml.dump(new_panel_config, file, sort_keys=False)
|
||||
print(f"File write: {filename}")
|
||||
# Calculate hash of filename
|
||||
@@ -78,6 +97,56 @@ def update_analysis_config():
|
||||
).hexdigest()
|
||||
|
||||
|
||||
def build_metric_id_mapping(panel_id, data_source_index, metrics, gfx_version):
|
||||
# Build metric id to metric name mapping
|
||||
global METRIC_ID_TO_NAME_MAP
|
||||
for metric_index, metric_name in enumerate(metrics.keys()):
|
||||
metric_id = f"{panel_id // 100}.{data_source_index + 1}.{metric_index}"
|
||||
METRIC_ID_TO_NAME_MAP[gfx_version][str(metric_id)] = metric_name
|
||||
|
||||
|
||||
def update_sets_config():
|
||||
# Create directory if it doesn't exist
|
||||
if not SETS_TARGET_DIR.exists():
|
||||
SETS_TARGET_DIR.mkdir()
|
||||
print(f"Created directory: {SETS_TARGET_DIR}")
|
||||
|
||||
# Read the unified config file
|
||||
with open(SOURCE_DIR.joinpath("unified_sets.yaml")) as file:
|
||||
unified_sets = yaml.safe_load(file)
|
||||
|
||||
# Create per gfx version file
|
||||
for gfx_version in GFX_VERSIONS:
|
||||
new_sets = {"sets": []}
|
||||
|
||||
for sets in unified_sets["sets"]:
|
||||
# Create new set object for each set
|
||||
current_set = {
|
||||
"title": sets["title"],
|
||||
"set_option": sets["set_option"],
|
||||
"description": sets["description"],
|
||||
"metric": [],
|
||||
}
|
||||
|
||||
for metric_id in sets["metric"][gfx_version]:
|
||||
current_set["metric"].append(
|
||||
{metric_id: METRIC_ID_TO_NAME_MAP[gfx_version][str(metric_id)]}
|
||||
)
|
||||
|
||||
new_sets["sets"].append(current_set)
|
||||
|
||||
# Write gfx version sets to file
|
||||
filename = Path(SETS_TARGET_DIR.joinpath(f"{gfx_version}_sets.yaml"))
|
||||
with open(filename, "w") as file:
|
||||
file.write(get_autogen_text("utils/unified_sets.yaml"))
|
||||
yaml.dump(new_sets, file, sort_keys=False)
|
||||
print(f"File write: {filename}")
|
||||
# Calculate hash of filename
|
||||
HASH_FILE_MAP[str(filename.relative_to(ROOT_DIR))] = hashlib.sha256(
|
||||
filename.read_bytes()
|
||||
).hexdigest()
|
||||
|
||||
|
||||
def update_documentation():
|
||||
# Documentation sections
|
||||
section_panel_map = {
|
||||
@@ -153,7 +222,7 @@ def update_documentation():
|
||||
# Write documentation metrics description file
|
||||
filename = Path(DOC_TARGET_DIR.joinpath("metrics_description.yaml"))
|
||||
with open(filename, "w") as file:
|
||||
file.write(AUTOGEN_TEXT)
|
||||
file.write(get_autogen_text())
|
||||
yaml.dump(section_metric_map, file, sort_keys=False)
|
||||
print(f"File write: {filename}")
|
||||
# Calculate hash of filename
|
||||
@@ -165,12 +234,13 @@ def update_documentation():
|
||||
def update_hash():
|
||||
# Write hash file
|
||||
with open(HASH_FILE, "w") as file:
|
||||
file.write(AUTOGEN_TEXT)
|
||||
file.write(get_autogen_text())
|
||||
yaml.dump(HASH_FILE_MAP, file, sort_keys=False)
|
||||
print(f"File write: {HASH_FILE}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_analysis_config()
|
||||
update_sets_config()
|
||||
update_documentation()
|
||||
update_hash()
|
||||
|
||||
مرجع در شماره جدید
Block a user