23
23
# Current install configuration from Spack
24
24
spheral_install_config = SpheralConfigs .config ()
25
25
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
+
26
29
# Consolidate Caliper files after run
27
30
def gather_files (manager ):
28
31
filtered = [test for test in manager .testlist if test .status is PASSED ]
@@ -34,120 +37,109 @@ def gather_files(manager):
34
37
outdir = os .path .join (output_loc , spheral_install_config , test_name )
35
38
if (not os .path .exists (outdir )):
36
39
log (f"Creating { outdir } " )
37
- os .mkdir (outdir )
40
+ os .makedirs (outdir )
38
41
outfile = os .path .join (outdir , cali_filename )
39
42
log (f"Copying { cali_filename } to { outdir } " )
40
43
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"
142
49
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 ,
146
52
label = test_name ,
147
53
np = ncores ,
54
+ nt = threads ,
148
55
caliper_filename = caliper_filename ,
149
56
regions = regions ,
150
57
timers = timers ,
151
58
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