Skip to content

Commit 25fd917

Browse files
committed
add compare to benchmark action
1 parent 0738185 commit 25fd917

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

devops/actions/run-tests/benchmark_v2/action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ runs:
100100
101101
# TODO accomodate for different GPUs and backends
102102
SAVE_NAME="Baseline_PVC_L0"
103+
SAVE_TIMESTAMP="$(date +'%Y%m%d_%H%M%S')"
103104
if [ -n "$BUILD_HASH" ]; then
104105
SAVE_NAME="Commit_PVC_$BUILD_HASH"
105106
fi
@@ -112,14 +113,17 @@ runs:
112113
--results-dir "./llvm-ci-perf-results/$RUNNER_NAME" \
113114
--output-dir "./llvm-ci-perf-results/$RUNNER_NAME" \
114115
--preset Minimal
116+
--timestamp-override "$SAVE_TIMESTAMP"
115117
echo "-----"
118+
python3 ./devops/scripts/benchmarks/compare.py to_hist \
119+
--name Baseline_PVC_L0 \
120+
--compare_file "./llvm-ci-perf-results/$RUNNER_NAME/results/$SAVE_NAME_$SAVE_TIMESTAMP.json"
121+
--results_dir "./llvm-ci-perf-results/$RUNNER_NAME/results/"
122+
116123
- name: Push compute-benchmarks results
117124
if: inputs.upload_results == 'true' && always()
118125
shell: bash
119126
run: |
120-
# TODO redo configuration
121-
# $(python ./devops/scripts/benchmarking/load_config.py ./devops constants)
122-
123127
cd "./llvm-ci-perf-results"
124128
git config user.name "SYCL Benchmarking Bot"
125129
git config user.email "[email protected]"

devops/scripts/benchmarks/compare.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def print_regression(entry: dict):
292292
if regressions:
293293
print("#\n# Regressions:\n#\n")
294294
for test in regressions: print_regression(test)
295+
exit(1) # Exit 1 to trigger github test failure
295296
else:
296297
print("Unsupported operation: exiting.")
297298
exit(1)

devops/scripts/benchmarks/history.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from options import Compare, options
1212
from datetime import datetime, timezone
1313
from utils.utils import run
14+
from utils.validate import Validate
1415

1516

1617
class BenchmarkHistory:
@@ -30,15 +31,18 @@ def load_result(self, file_path: Path) -> BenchmarkRun:
3031
def load(self, n: int):
3132
results_dir = Path(self.dir) / "results"
3233
if not results_dir.exists() or not results_dir.is_dir():
33-
return []
34+
print(f"Warning: {results_dir} is not a valid directory: no historic results loaded.")
35+
return
3436

3537
# Get all JSON files in the results directory
3638
benchmark_files = list(results_dir.glob("*.json"))
3739

3840
# Extract timestamp and sort files by it
3941
def extract_timestamp(file_path: Path) -> str:
4042
try:
41-
return file_path.stem.split("_")[-1]
43+
# Assumes results are stored as <name>_YYYYMMDD_HHMMSS.json
44+
ts = file_path.stem[-len("YYYYMMDD_HHMMSS"):]
45+
return ts if Validate.timestamp(ts) else ""
4246
except IndexError:
4347
return ""
4448

@@ -98,7 +102,11 @@ def save(self, save_name, results: list[Result], to_file=True):
98102
os.makedirs(results_dir, exist_ok=True)
99103

100104
# Use formatted timestamp for the filename
101-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
105+
timestamp = (
106+
datetime.now().strftime("%Y%m%d_%H%M%S")
107+
if options.timestamp_override is None else
108+
options.timestamp_override
109+
)
102110
file_path = Path(os.path.join(results_dir, f"{save_name}_{timestamp}.json"))
103111
with file_path.open("w") as file:
104112
json.dump(serialized, file, indent=4)

devops/scripts/benchmarks/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from history import BenchmarkHistory
1818
from utils.utils import prepare_workdir
1919
from utils.compute_runtime import *
20+
from utils.validate import Validate
2021
from presets import enabled_suites, presets
2122

2223
import argparse
@@ -481,6 +482,11 @@ def validate_and_parse_env_args(env_args):
481482
help="Specify a custom results directory",
482483
default=options.custom_results_dir,
483484
)
485+
parser.add_argument(
486+
"--timestamp-override",
487+
type=str,
488+
help="Used in CI to enforce use of same timestamp across scripts",
489+
)
484490

485491
args = parser.parse_args()
486492
additional_env_vars = validate_and_parse_env_args(args.env)
@@ -518,6 +524,10 @@ def validate_and_parse_env_args(env_args):
518524
if not os.path.isdir(args.output_dir):
519525
parser.error("Specified --output-dir is not a valid path")
520526
options.output_directory = os.path.abspath(args.output_dir)
527+
if args.timestamp_override is not None:
528+
if not Validate.timestamp(args.timestamp_override):
529+
parser.error("--timestamp_override is not a valid timestamp")
530+
options.timestamp_override = args.timestamp_override
521531

522532
benchmark_filter = re.compile(args.filter) if args.filter else None
523533

devops/scripts/benchmarks/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Options:
4646
custom_results_dir = None
4747

4848
regression_threshold: float = 0.05
49+
timestamp_override: str = None
4950

5051

5152
options = Options()

0 commit comments

Comments
 (0)