Skip to content

Commit d92efee

Browse files
author
zzhyyds
committed
small modification
1 parent 0cf712a commit d92efee

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

daxby/legion-pim/output.run

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Command exited with non-zero status 1
2+
0.23user 0.24system 0:00.28elapsed 167%CPU (0avgtext+0avgdata 214992maxresident)k
3+
0inputs+0outputs (0major+49109minor)pagefaults 0swaps

run.py

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import argparse
2+
import subprocess
3+
import os
4+
import sys
5+
6+
def run_command(command, cwd=None):
7+
"""Run a shell command and print its output."""
8+
try:
9+
result = subprocess.run(
10+
command,
11+
shell=True,
12+
cwd=cwd,
13+
text=True,
14+
check=True,
15+
executable='/bin/bash',
16+
stdout=subprocess.PIPE,
17+
stderr=subprocess.PIPE,
18+
)
19+
print(result.stdout)
20+
except subprocess.CalledProcessError as e:
21+
print(f"Command '{command}' failed with error:\n{e.stderr}")
22+
sys.exit(1)
23+
24+
def main():
25+
parser = argparse.ArgumentParser(description="Run benchmark with build command.")
26+
parser.add_argument("benchmark", type=str, help="The benchmark name (folder).")
27+
parser.add_argument("model", type=str, help="The model name (folder).")
28+
parser.add_argument(
29+
"--args", type=str, help="Additional program arguments.", default=""
30+
)
31+
parser.add_argument(
32+
"--build_cmd", type=str, help="Custom build command.", default="make"
33+
)
34+
parser.add_argument(
35+
"--run_cmd", type=str, help="Custom run command.", default="./upmem_test"
36+
)
37+
parser.add_argument(
38+
"--time_output", type=str, help="Timing output file", default="output.run"
39+
)
40+
parser.add_argument(
41+
"--compile_defines", type=str, help="Compiler Defines.", default=""
42+
)
43+
44+
args = parser.parse_args()
45+
46+
# Construct the paths to the benchmark and subcategory folders
47+
benchmark_path = os.path.join(args.benchmark, args.model)
48+
49+
if not os.path.exists(benchmark_path):
50+
print(f"Error: The path '{benchmark_path}' does not exist.")
51+
sys.exit(1)
52+
53+
# Step 1: Run the build command
54+
print(f"Building in: {benchmark_path}")
55+
build_cmd = f"{args.compile_defines} {args.build_cmd}"
56+
run_command(build_cmd, cwd=benchmark_path)
57+
58+
# Step 2: Run the benchmark with additional arguments
59+
print(f"Running benchmark in: {benchmark_path}")
60+
benchmark_command = f"/usr/bin/time -o {args.time_output} {args.run_cmd} {args.args}"
61+
print(f"Benchmark command: {benchmark_command}")
62+
run_command(benchmark_command, cwd=benchmark_path)
63+
64+
if __name__ == "__main__":
65+
main()

0 commit comments

Comments
 (0)