Skip to content

Commit d56d252

Browse files
committed
Fix messy performance logic by moving file adjustment commands out of run_perf and into the ci script, no longer names directories as latest
1 parent 4b98ca5 commit d56d252

6 files changed

Lines changed: 31 additions & 43 deletions

File tree

.gitlab/performance.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
# Directory storing benchmark data is set in scripts/spheral_ats.py
1414
- INSTALL_DIR=$PERF_INSTALL_DIR/${SPEC//%/_}
1515
- cd $INSTALL_DIR
16+
- INSTALL_BENCHMARK_DIR=$(./bin/spheral-ats --get-benchmark)
17+
- PERF_OUT_DIR=$INSTALL_BENCHMARK_DIR/$(date +%s)
18+
- mkdir PERF_OUT_DIR
1619
- echo "Running performance tests using install at $INSTALL_DIR"
17-
- rm -rf perf_logs
18-
- find tests/ -name '*.cali' -print -delete
20+
- rm -rf perf_logs gpu_perf_logs
1921
- ./bin/spheral-ats --ciRun --numNodes 2 --logs perf_logs $INSTALL_DIR/$PERF_ATS_FILE
20-
- ./bin/spheral-ats --gpu --ciRun --numNodes 2 --logs perf_logs $INSTALL_DIR/$PERF_ATS_FILE
22+
- cp perf_logs/*.cali $PERF_OUT_DIR
23+
- ./bin/spheral-ats --gpu --ciRun --numNodes 2 --logs gpu_perf_logs $INSTALL_DIR/$PERF_ATS_FILE
24+
# Copy caliper files to the benchmark directory and don't complain if you cant
25+
- cp gpu_perf_logs/*.cali $PERF_OUT_DIR 2>/dev/null || true
2126

2227
toss_gcc_mpi_perf:
2328
extends: [.toss_perf_shell, .gcc_mpi, .run_perf]

.gitlab/scripts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ clean_old_perfs:
257257
# Prevent this job from getting artifacts
258258
dependencies: []
259259
script:
260-
- BENCHMARK_LOC=$(python3 $SCRIPT_DIR/spheral_ats.py --get-benchmark)
260+
- BENCHMARK_LOC=$(python3 $SCRIPT_DIR/spheral_ats.py --get-top-benchmark)
261261
- cd $BENCHMARK_LOC
262262
- find . -mindepth 2 -type d -mtime +200 -print -exec rm -rf {} +
263263

scripts/devtools/performance_analysis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,14 @@ def main():
292292
ref_files = curdata.metadata["benchmark_dir"].iloc[0]
293293
except:
294294
raise Exception("No reference or benchmark data specified")
295-
# If we using benchmark reference data, only grab the current install/machine
295+
# If using benchmark reference data, only grab the current install/machine
296296
# Get install config and machine name from current data
297297
install_config = curdata.metadata["install_config"].iloc[0]
298298
machine_name = curdata.metadata["cluster"].iloc[0]
299-
ref_loc = os.path.join(ref_files, install_config, machine_name, "latest")
299+
ref_loc = os.path.join(ref_files, install_config, machine_name)
300300
if (not os.path.exists(ref_loc)):
301301
raise Exception(f"Benchmark location {ref_loc} does not exists")
302+
ref_dir = sorted(glob.glob(os.path.join(ref_loc, "*")))[-1]
302303
cali_ref_files = glob.glob(os.path.join(ref_loc, "*.cali"), recursive=True)
303304

304305
if (len(cali_ref_files) == 0):

scripts/lc/plot_hist_data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ def extract_data(cali_file):
5151
return runday, rtimes
5252

5353
def get_spec(cali_file):
54-
# If cali_file is just a dir, grab a cali file from latest
54+
# If cali_file is just a dir, grab the latest caliper file
5555
if os.path.isdir(cali_file):
56-
cali_file = glob.glob(os.path.join(cali_file, "latest/*.cali"))[0]
56+
perf_dir = sorted(glob.glob(os.path.join(cali_file, "*")))[-1]
57+
cali_file = glob.glob(os.path.join(perf_dir, "*.cali"))[0]
5758
gls = cr.read_caliper_globals(cali_file)
5859
return gls["spec"]
5960

scripts/spheral_ats.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,20 @@ def main():
126126
help="Set number of threads per rank to use. Currently only used by run_perf.py.")
127127
parser.add_argument("--batch", action="store_true", help="Submit job as batch.")
128128
parser.add_argument("--delay", action="store_true", help="Defer job until after 7 pm.")
129-
parser.add_argument("--get-benchmark", action="store_true", help="Print benchmark location and stop.")
129+
parser.add_argument("--get-top-benchmark", action="store_true",
130+
help="Print top benchmark location and stop.")
131+
parser.add_argument("--get-benchmark", action="store_true",
132+
help="Print benchmark location for this particular install and stop.")
130133
parser.add_argument("--gpu", action="store_true", help="Run GPU tests.")
131134
parser.add_argument("--cpx", action="store_true", help="Enable CPX mode, allowing 6 GPUs per device.")
132135
options, unknown_options = parser.parse_known_args()
133136
if (options.atsHelp):
134137
subprocess.run(f"{ats_exe} --help", shell=True, check=True, text=True)
135138
return
136-
if (options.get_benchmark):
139+
if (options.get_top_benchmark):
137140
print(benchmark_dir)
138141
return
142+
139143
#---------------------------------------------------------------------------
140144
# Setup machine info classes
141145
#---------------------------------------------------------------------------
@@ -144,6 +148,11 @@ def main():
144148
test_log_name = "gpu-"+test_log_name
145149
temp_uname = os.uname()
146150
hostname = temp_uname[1].rstrip("0123456789")
151+
if (options.get_benchmark):
152+
import SpheralConfigs
153+
path = os.path.join(benchmark_dir, SpheralConfigs.configs(), hostname)
154+
print(path)
155+
return
147156
sys_type = os.getenv("SYS_TYPE")
148157
# Use ATS to for some machine specific functions
149158
if "MACHINE_TYPE" not in os.environ:

tests/run_perf.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,15 @@
2626
num_threads = opts["threads"]
2727

2828
# Adding --ciRun to the command line arguments of spheral-ats
29-
# triggers move of Caliper files to benchmark location
30-
benchmark_dir = None
3129
test_runs = 1 # Number of times to run each test
32-
CIRun = False
3330
if "cirun" in opts and opts["cirun"]:
34-
CIRun = True
3531
test_runs = 3
36-
benchmark_dir = opts["benchmark_dir"]
3732
is_rerun = False
3833
if "rerun" in opts and opts["rerun"]:
3934
is_rerun = True
4035
#---------------------------------------------------------------------------
4136
# Hardware configuration
4237
#---------------------------------------------------------------------------
43-
# This should be {$SYS_TYPE}_{compiler name}_{compiler version}_{mpi or cuda info}
44-
spheral_install_config = SpheralConfigs.config()
4538
mpi_enabled = SpheralConfigs.mpi_enabled()
4639
# Retrieve the host name and remove any numbers
4740
temp_uname = os.uname()
@@ -65,41 +58,20 @@
6558
def gather_files(manager):
6659
'''
6760
Function to gather Caliper file when ATS is finished running.
68-
Used by ATS for gathering benchmark Caliper files.
6961
'''
70-
instpath = os.path.join(benchmark_dir, spheral_install_config)
71-
macpath = os.path.join(instpath, hostname)
72-
outdir = os.path.join(macpath, "latest")
73-
if (not is_rerun):
74-
if (os.path.exists(outdir)):
75-
# Move existing benchmark data to a different directory
76-
log(f"Renaming existing {outdir} to {int(time.time())}", echo=True)
77-
os.rename(outdir, os.path.join(macpath, f"{int(time.time())}"))
78-
log(f"Creating {outdir}", echo=True)
79-
os.makedirs(outdir)
8062
filtered = [test for test in manager.testlist if test.status is PASSED]
81-
# Set read/write/execute permissions for owner and group
82-
perms = stat.S_IRWXU | stat.S_IRWXG
63+
logdir = log.directory
64+
log(f"Copying caliper files to {logdir}")
8365
for test in filtered:
8466
run_dir = test.directory
8567
cali_filename = test.options["caliper_filename"]
8668
cfile = os.path.join(run_dir, cali_filename)
8769
test_name = test.options["label"]
88-
outfile = os.path.join(outdir, cali_filename)
89-
log(f"Moving {cali_filename} to {outdir}", echo=True)
90-
if (CIRun):
91-
shutil.move(cfile, outfile)
92-
os.chmod(outfile, perms)
93-
shutil.chown(outfile, group="sduser")
94-
if (CIRun):
95-
cpaths = [outdir, macpath, instpath, benchmark_dir]
96-
for p in cpaths:
97-
os.chmod(p, perms)
98-
shutil.chown(p, group="sduser")
70+
outfile = os.path.join(logdir, cali_filename)
71+
shutil.move(cfile, outfile)
9972

10073
# If running CI, run gather_files on exit
101-
if (benchmark_dir):
102-
onExit(gather_files)
74+
onExit(gather_files)
10375
glue(keep=True, independent=True, ngpu=0, nt=1)
10476

10577
#---------------------------------------------------------------------------

0 commit comments

Comments
 (0)