Skip to content

Commit 20b8f1b

Browse files
committed
refactor performance data handling and output generation
1 parent 415c957 commit 20b8f1b

File tree

2 files changed

+239
-166
lines changed

2 files changed

+239
-166
lines changed

scoreboard/main.py

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,26 +108,48 @@ def discover_tasks(tasks_dir, task_types):
108108
directories, tasks_type_map = discover_tasks(tasks_dir, task_types)
109109

110110

111-
def load_performance_data(perf_stat_file_path):
112-
"""Load and parse performance statistics from CSV file."""
111+
def load_performance_data_threads(perf_stat_file_path: Path) -> dict:
112+
"""Load threads performance ratios (T_x/T_seq) from CSV.
113+
Expected header: Task, SEQ, OMP, TBB, STL, ALL
114+
"""
115+
perf_stats: dict[str, dict] = {}
116+
if perf_stat_file_path.exists():
117+
with open(perf_stat_file_path, "r", newline="") as csvfile:
118+
reader = csv.DictReader(csvfile)
119+
for row in reader:
120+
task_name = row.get("Task")
121+
if not task_name:
122+
continue
123+
perf_stats[task_name] = {
124+
"seq": row.get("SEQ", "?"),
125+
"omp": row.get("OMP", "?"),
126+
"tbb": row.get("TBB", "?"),
127+
"stl": row.get("STL", "?"),
128+
"all": row.get("ALL", "?"),
129+
}
130+
else:
131+
logger.warning("Threads perf stats CSV not found at %s", perf_stat_file_path)
132+
return perf_stats
113133

114-
perf_stats = dict()
134+
135+
def load_performance_data_processes(perf_stat_file_path: Path) -> dict:
136+
"""Load processes performance ratios (T_x/T_seq) from CSV.
137+
Expected header: Task, SEQ, MPI
138+
"""
139+
perf_stats: dict[str, dict] = {}
115140
if perf_stat_file_path.exists():
116141
with open(perf_stat_file_path, "r", newline="") as csvfile:
117142
reader = csv.DictReader(csvfile)
118143
for row in reader:
119144
task_name = row.get("Task")
120-
if task_name:
121-
perf_stats[task_name] = {
122-
"seq": row.get("SEQ", "?"),
123-
"omp": row.get("OMP", "?"),
124-
"tbb": row.get("TBB", "?"),
125-
"stl": row.get("STL", "?"),
126-
"all": row.get("ALL", "?"),
127-
"mpi": "N/A",
128-
}
145+
if not task_name:
146+
continue
147+
perf_stats[task_name] = {
148+
"seq": row.get("SEQ", "?"),
149+
"mpi": row.get("MPI", "?"),
150+
}
129151
else:
130-
logger.warning("Performance stats CSV not found at %s", perf_stat_file_path)
152+
logger.warning("Processes perf stats CSV not found at %s", perf_stat_file_path)
131153
return perf_stats
132154

133155

@@ -652,15 +674,29 @@ def _compute_display_deadlines_processes(n_items: int) -> list[date]:
652674
ds = _evenly_spaced_dates(n_items, s, e)
653675
return ds
654676

655-
# Locate perf CSV from CI or local runs
656-
candidates = [
677+
# Locate perf CSVs from CI or local runs (threads and processes)
678+
candidates_threads = [
679+
script_dir.parent / "build" / "perf_stat_dir" / "threads_task_run_perf_table.csv",
680+
script_dir.parent / "perf_stat_dir" / "threads_task_run_perf_table.csv",
681+
# Fallback to old single-file name
657682
script_dir.parent / "build" / "perf_stat_dir" / "task_run_perf_table.csv",
658683
script_dir.parent / "perf_stat_dir" / "task_run_perf_table.csv",
659684
]
660-
perf_stat_file_path = next((p for p in candidates if p.exists()), candidates[0])
685+
threads_csv = next((p for p in candidates_threads if p.exists()), candidates_threads[0])
661686

662-
# Read and parse performance statistics CSV
663-
perf_stats = load_performance_data(perf_stat_file_path)
687+
candidates_processes = [
688+
script_dir.parent / "build" / "perf_stat_dir" / "processes_task_run_perf_table.csv",
689+
script_dir.parent / "perf_stat_dir" / "processes_task_run_perf_table.csv",
690+
]
691+
processes_csv = next((p for p in candidates_processes if p.exists()), candidates_processes[0])
692+
693+
# Read and merge performance statistics CSVs
694+
perf_stats_threads = load_performance_data_threads(threads_csv)
695+
perf_stats_processes = load_performance_data_processes(processes_csv)
696+
perf_stats: dict[str, dict] = {}
697+
perf_stats.update(perf_stats_threads)
698+
for k, v in perf_stats_processes.items():
699+
perf_stats[k] = {**perf_stats.get(k, {}), **v}
664700

665701
# Partition tasks by tasks_type from settings.json
666702
threads_task_dirs = [

0 commit comments

Comments
 (0)