Skip to content

Commit 1673bb2

Browse files
committed
Cleaned up performance.py, reverted some changes to gitlab/scripts.yaml and install-from-dev-pkg, fixed recursive module bug from last commit
1 parent 230c1e2 commit 1673bb2

File tree

5 files changed

+108
-118
lines changed

5 files changed

+108
-118
lines changed

.gitlab/scripts.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@
8484

8585
.update_tpls:
8686
stage: update_tpls
87-
variables:
88-
GIT_STRATEGY: none
8987
script:
90-
- ./$SCRIPT_DIR/devtools/tpl-manager.py --spec-list="$SCRIPT_DIR/devtools/spec-list.json" --spheral-spack-dir=$UPSTREAM_DIR
88+
- ./$SCRIPT_DIR/devtools/tpl-manager.py --no-upstream --spec-list="$SCRIPT_DIR/devtools/spec-list.json" --spheral-spack-dir=$UPSTREAM_DIR
9189

9290
.toss_update_permissions:
9391
stage: update_permissions
@@ -114,8 +112,6 @@
114112

115113
.build_dev_pkg:
116114
stage: generate_buildcache
117-
variables:
118-
GIT_STRATEGY: none
119115
extends: [.spheral_rev_str]
120116
script:
121117
- INSTALL_DIR=/usr/gapps/Spheral/$SYS_TYPE/spheral-$SPHERAL_REV_STR
@@ -145,7 +141,7 @@
145141
- tar -xzf $DEV_PKG_NAME.tar.gz
146142
- cd $DEV_PKG_NAME
147143

148-
- env INSTALL_DIR=$INSTALL_DIR SPEC=$SPEC SPACK_PKG_NAME=$SPACK_PKG_NAME SCRIPT_DIR=$SCRIPT_DIR
144+
- env INSTALL_DIR=$INSTALL_DIR SPEC=$SPEC SPACK_PKG_NAME=$SPACK_PKG_NAME BUILD_ALLOC="" SCRIPT_DIR=$SCRIPT_DIR
149145
bash ./$SCRIPT_DIR/lc/install-from-dev-pkg.sh
150146

151147
artifacts:

scripts/gitlab/performance_analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def main():
6767
# Get historical timing data
6868
cali_ref_dir = os.path.join(benchmark_dir, install_config, test_name)
6969
if (not os.path.exists(cali_ref_dir)):
70-
os.mkdir(cali_ref_dir)
70+
os.makedirs(cali_ref_dir)
7171
shutils.copyfile(cfile, os.path.join(cali_ref_dir, cali_file))
7272

7373
if __name__=="__main__":

scripts/lc/install-from-dev-pkg.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ trap 'echo "# $BASH_COMMAND"' DEBUG
22

33
SPACK_PKG_NAME=${SPACK_PKG_NAME:-'spheral'}
44
SPACK_URL=${SPACK_URL:-'https://github.com/spack/spack'}
5+
BUILD_ALLOC=${BUILD_ALLOC}
56
SCRIPT_DIR=${SCRIPT_DIR:-'scripts'}
67

78
if [[ -z "${SPEC}" ]]; then
@@ -19,6 +20,7 @@ echo $SPEC
1920
echo $SPACK_URL
2021
echo $INSTALL_DIR
2122
echo $SCRIPT_DIR
23+
echo $BUILD_ALLOC
2224

2325
rm -rf $INSTALL_DIR
2426
mkdir -p $INSTALL_DIR
@@ -34,12 +36,12 @@ spack mirror add --unsigned spheral-mirror $PWD/resources/mirror
3436
spack mirror add --unsigned spheral-cache $PWD/resources
3537
spack buildcache update-index $PWD/resources/mirror
3638

37-
spack install --fresh --deprecated --no-check-signature --only dependencies $SPACK_PKG_NAME@develop%$SPEC
39+
$BUILD_ALLOC spack install --fresh --deprecated --no-check-signature --only dependencies $SPACK_PKG_NAME@develop%$SPEC
3840

39-
./$SCRIPT_DIR/devtools/tpl-manager.py --spack-url $SPACK_URL --no-upstream --spheral-spack-dir $INSTALL_DIR/spheral-spack-tpls --spec $SPEC
41+
$BUILD_ALLOC ./$SCRIPT_DIR/devtools/tpl-manager.py --spack-url $SPACK_URL --no-upstream --spheral-spack-dir $INSTALL_DIR/spheral-spack-tpls --spec $SPEC
4042

4143
HOST_CONFIG_FILE=$(ls -t | grep -E "*\.cmake" | head -1)
42-
./$SCRIPT_DIR/devtools/host-config-build.py --host-config $HOST_CONFIG_FILE -i $INSTALL_DIR --build --no-clean
44+
$BUILD_ALLOC ./$SCRIPT_DIR/devtools/host-config-build.py --host-config $HOST_CONFIG_FILE -i $INSTALL_DIR --build --no-clean
4345

4446

4547

src/SimulationControl/SpheralTestUtilities.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# SpheralTestUtilities -- small helper functions used in Spheral unit tests.
22

3-
import mpi
43
import sys
54
from math import *
65
from collections import Iterable
@@ -133,6 +132,7 @@ def checkNeighbors(neighborList, answer):
133132
# Print statistic about the H tensors for a set of NodeLists.
134133
#-------------------------------------------------------------------------------
135134
def hstats(nodeSet):
135+
import mpi
136136
for nodes in nodeSet:
137137
hmin, hmax, havg = 1e50, -1e50, 0.0
138138
hratmin, hratmax, hratavg = 1e50, -1e50, 0.0

tests/performance.py

+99-107
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
# Current install configuration from Spack
2424
spheral_install_config = SpheralConfigs.config()
2525

26+
def add_timer_cmds(cali_name, test_name):
27+
return f"--caliperFilename {cali_name} --adiakData 'test_name: {test_name}, install_config: {spheral_install_config}'"
28+
2629
# Consolidate Caliper files after run
2730
def gather_files(manager):
2831
filtered = [test for test in manager.testlist if test.status is PASSED]
@@ -34,120 +37,109 @@ def gather_files(manager):
3437
outdir = os.path.join(output_loc, spheral_install_config, test_name)
3538
if (not os.path.exists(outdir)):
3639
log(f"Creating {outdir}")
37-
os.mkdir(outdir)
40+
os.makedirs(outdir)
3841
outfile = os.path.join(outdir, cali_filename)
3942
log(f"Copying {cali_filename} to {outdir}")
4043
shutil.copy(cfile, outfile)
41-
42-
if (output_loc):
43-
onExit(gather_files)
44-
glue(keep=True)
45-
46-
def add_timer_cmds(cali_name, test_name):
47-
return f"--caliperFilename {cali_name} --adiakData 'test_name: {test_name}, install_config: {spheral_install_config}'"
48-
49-
if ("power" in spheral_sys_arch):
50-
num_nodes = 1
51-
num_cores = 40
52-
elif ("broadwell" in spheral_sys_arch):
53-
num_nodes = 2
54-
num_cores = 36
55-
56-
# Select which timing regions to compare (for CI)
57-
regions = ["CheapRK2",
58-
"CheapRK2PreInit",
59-
"ConnectivityMap_computeConnectivity",
60-
"ConnectivityMap_patch",
61-
"CheapRK2EvalDerivs",
62-
"CheapRK2EndStep"]
63-
# Select which timers to compare (for CI)
64-
timers = ["sum#inclusive#sum#time.duration"] # Means the sum of the time from all ranks
65-
66-
# 3D convection test
67-
test_dir = os.path.join(SpheralConfigs.test_install_path(), "unit/Boundary")
68-
69-
group(name="3D Convection test")
70-
test_file = "testPeriodicBoundary-3d.py"
71-
test_path = os.path.join(test_dir, test_file)
72-
test_name = "3DCONV"
73-
74-
# Test with varying number of ranks
75-
ranks = [1, 2, 4]
76-
# We want 20 points per unit length
77-
ref_len = 1.
78-
sph_point_rho = 20. / ref_len
79-
sph_per_core = 300
80-
for i, n in enumerate(ranks):
81-
caliper_filename = f"{test_name}_{i}_{int(time.time())}.cali"
82-
timer_cmds = add_timer_cmds(caliper_filename, test_name)
83-
ncores = int(num_nodes*num_cores/n)
84-
total_sph_nodes = sph_per_core * ncores
85-
npd = int(np.cbrt(total_sph_nodes))
86-
new_len = npd * ref_len / sph_point_rho
87-
inps = f"--nx {npd} --ny {npd} --nz {npd} --x1 {new_len} --y1 {new_len} --z1 {new_len} --steps 100 {timer_cmds}"
88-
t = test(script=test_path, clas=inps,
89-
label=test_name,
90-
np=ncores,
91-
caliper_filename=caliper_filename,
92-
regions=regions,
93-
timers=timers,
94-
install_config=spheral_install_config)
95-
96-
endgroup()
97-
98-
# NOH tests
99-
test_dir = os.path.join(SpheralConfigs.test_install_path(), "functional/Hydro/Noh")
100-
101-
# General input for all Noh tests
102-
gen_noh_inps = "--crksph False --cfl 0.25 --Cl 1.0 --Cq 1.0 --xfilter 0.0 "+\
103-
"--nPerh 2.01 --graphics False --clearDirectories False --doCompare False "+\
104-
"--dataDir None --vizTime None --vizCycle None"
105-
106-
group(name="NOH 2D tests")
107-
test_file = "Noh-cylindrical-2d.py"
108-
nRadial = 100
109-
test_path = os.path.join(test_dir, test_file)
110-
test_name = "NC2D"
111-
112-
# Test with varying number of ranks
113-
ranks = [1, 2, 4]
114-
for i, n in enumerate(ranks):
115-
caliper_filename = f"{test_name}_{i}_{int(time.time())}.cali"
116-
timer_cmds = add_timer_cmds(caliper_filename, test_name)
117-
inps = f"{gen_noh_inps} --nRadial {nRadial} --steps 10 {timer_cmds}"
118-
ncores = int(num_nodes*num_cores/n)
119-
t = test(script=test_path, clas=inps,
120-
label=test_name,
121-
np=ncores,
122-
caliper_filename=caliper_filename,
123-
regions=regions,
124-
timers=timers,
125-
install_config=spheral_install_config)
126-
127-
endgroup()
128-
129-
group(name="NOH 3D tests")
130-
test_file = "Noh-spherical-3d.py"
131-
test_path = os.path.join(test_dir, test_file)
132-
test_name = "NS3D"
133-
134-
# Test with varying number of SPH nodes per rank
135-
npcore = [100, 200, 300]
136-
for i, n in enumerate(npcore):
137-
caliper_filename = f"{test_name}_{i}_{int(time.time())}.cali"
138-
ncores = int(num_nodes*num_cores)
139-
total_sph_nodes = n*ncores
140-
npd = int(np.cbrt(total_sph_nodes))
141-
node_inps = f"--nx {npd} --ny {npd} --nz {npd}"
44+
# Setup Spheral performance tests
45+
def spheral_setup_test(test_path, test_name, test_num, inps, ncores, threads=1):
46+
'General method for creating an individual performance test'
47+
global regions, timers, spheral_install_config
48+
caliper_filename = f"{test_name}_{test_num}_{int(time.time())}.cali"
14249
timer_cmds = add_timer_cmds(caliper_filename, test_name)
143-
inps = f"{gen_noh_inps} {node_inps} --steps 10 {timer_cmds}"
144-
# WIP: Path to benchmark timing data
145-
t = test(script=test_path, clas=inps,
50+
finps = f"{inps} {timer_cmds}"
51+
t = test(script=test_path, clas=finps,
14652
label=test_name,
14753
np=ncores,
54+
nt=threads,
14855
caliper_filename=caliper_filename,
14956
regions=regions,
15057
timers=timers,
15158
install_config=spheral_install_config)
152-
# Add a wait to ensure all timer files are done
153-
wait()
59+
return t
60+
61+
def main():
62+
if (output_loc):
63+
onExit(gather_files)
64+
glue(keep=True)
65+
if ("power" in spheral_sys_arch):
66+
num_nodes = 1
67+
num_cores = 40
68+
elif ("broadwell" in spheral_sys_arch):
69+
num_nodes = 2
70+
num_cores = 36
71+
# Select which timing regions to compare (for CI)
72+
regions = ["CheapRK2",
73+
"CheapRK2PreInit",
74+
"ConnectivityMap_computeConnectivity",
75+
"ConnectivityMap_patch",
76+
"CheapRK2EvalDerivs",
77+
"CheapRK2EndStep"]
78+
# Select which timers to compare (for CI)
79+
timers = ["sum#inclusive#sum#time.duration"] # Means the sum of the time from all ranks
80+
81+
# 3D convection test
82+
test_dir = os.path.join(SpheralConfigs.test_install_path(), "unit/Boundary")
83+
84+
group(name="3D Convection test")
85+
test_file = "testPeriodicBoundary-3d.py"
86+
test_path = os.path.join(test_dir, test_file)
87+
test_name = "3DCONV"
88+
89+
# Test with varying number of ranks
90+
ranks = [1, 2, 4]
91+
# We want 20 points per unit length
92+
ref_len = 1.
93+
sph_point_rho = 20. / ref_len
94+
sph_per_core = 300
95+
for i, n in enumerate(ranks):
96+
ncores = int(num_nodes*num_cores/n)
97+
total_sph_nodes = sph_per_core * ncores
98+
npd = int(np.cbrt(total_sph_nodes))
99+
new_len = npd * ref_len / sph_point_rho
100+
inps = f"--nx {npd} --ny {npd} --nz {npd} --x1 {new_len} --y1 {new_len} --z1 {new_len} --steps 100"
101+
t = spheral_setup_test(test_path, test_name, i, inps, ncores)
102+
endgroup()
103+
104+
# NOH tests
105+
test_dir = os.path.join(SpheralConfigs.test_install_path(), "functional/Hydro/Noh")
106+
107+
# General input for all Noh tests
108+
gen_noh_inps = "--crksph False --cfl 0.25 --Cl 1.0 --Cq 1.0 --xfilter 0.0 "+\
109+
"--nPerh 2.01 --graphics False --clearDirectories False --doCompare False "+\
110+
"--dataDir None --vizTime None --vizCycle None"
111+
112+
group(name="NOH 2D tests")
113+
test_file = "Noh-cylindrical-2d.py"
114+
nRadial = 100
115+
test_path = os.path.join(test_dir, test_file)
116+
test_name = "NC2D"
117+
118+
# Test with varying number of ranks
119+
ranks = [1, 2, 4]
120+
for i, n in enumerate(ranks):
121+
inps = f"{gen_noh_inps} --nRadial {nRadial} --steps 10"
122+
ncores = int(num_nodes*num_cores/n)
123+
t = spheral_setup_test(test_path, test_name, i, inps, ncores)
124+
125+
endgroup()
126+
127+
group(name="NOH 3D tests")
128+
test_file = "Noh-spherical-3d.py"
129+
test_path = os.path.join(test_dir, test_file)
130+
test_name = "NS3D"
131+
132+
# Test with varying number of SPH nodes per rank
133+
npcore = [100, 200, 300]
134+
for i, n in enumerate(npcore):
135+
ncores = int(num_nodes*num_cores)
136+
total_sph_nodes = n*ncores
137+
npd = int(np.cbrt(total_sph_nodes))
138+
node_inps = f"--nx {npd} --ny {npd} --nz {npd}"
139+
inps = f"{gen_noh_inps} {node_inps} --steps 10"
140+
t = spheral_setup_test(test_path, test_name, i, inps, ncores)
141+
# Add a wait to ensure all timer files are done
142+
wait()
143+
144+
if __name__=="__main__":
145+
main()

0 commit comments

Comments
 (0)