Skip to content

Commit 80e818c

Browse files
committed
format, lint, spelling, and final touchups
1 parent 5202494 commit 80e818c

File tree

8 files changed

+79
-106
lines changed

8 files changed

+79
-106
lines changed

examples/scaling/FRONTIER_BENCH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The code for the benchmarks is built with the following command
3333

3434
The benchmarks can be run in their default configuration with the following
3535
```
36-
./examples/scaling/submit_all.sh --account <acount_name>
36+
./examples/scaling/submit_all.sh --account <account_name>
3737
```
3838
By default this will submit the following jobs for benchmarking
3939

examples/scaling/analyze.py

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pandas as pd
33
from io import StringIO
44

5+
56
def parse_time_avg(path):
67
last_val = None
78
pattern = re.compile(r"Time Avg =\s*([0-9.E+-]+)")
@@ -12,6 +13,7 @@ def parse_time_avg(path):
1213
last_val = float(match.group(1))
1314
return last_val
1415

16+
1517
def parse_grind_time(path):
1618
last_val = None
1719
pattern = re.compile(r"Performance: \s*([0-9.E+-]+)")
@@ -22,6 +24,7 @@ def parse_grind_time(path):
2224
last_val = float(match.group(1))
2325
return last_val
2426

27+
2528
def parse_reference_file(filename):
2629
with open(filename) as f:
2730
content = f.read()
@@ -44,15 +47,7 @@ def parse_reference_file(filename):
4447
rdma = rdma_match.group(1) if rdma_match else None
4548

4649
for _, row in df.iterrows():
47-
records.append({
48-
"scaling": "weak",
49-
"nodes": int(row["nodes"]),
50-
"memory": memory,
51-
"rdma": rdma,
52-
"phase": "sim",
53-
"time_avg": row["time_avg"],
54-
"efficiency": row["efficiency"]
55-
})
50+
records.append({"scaling": "weak", "nodes": int(row["nodes"]), "memory": memory, "rdma": rdma, "phase": "sim", "time_avg": row["time_avg"], "efficiency": row["efficiency"]})
5651

5752
elif header.startswith("Strong Scaling"):
5853
mem_match = re.search(r"Memory: ~(\d+)GB", header)
@@ -61,27 +56,26 @@ def parse_reference_file(filename):
6156
rdma = rdma_match.group(1) if rdma_match else None
6257

6358
for _, row in df.iterrows():
64-
records.append({
65-
"scaling": "strong",
66-
"nodes": int(row["nodes"]),
67-
"memory": memory,
68-
"rdma": rdma,
69-
"phase": "sim",
70-
"time_avg": row["time_avg"],
71-
"speedup": row["speedup"],
72-
"efficiency": row["efficiency"]
73-
})
59+
records.append(
60+
{
61+
"scaling": "strong",
62+
"nodes": int(row["nodes"]),
63+
"memory": memory,
64+
"rdma": rdma,
65+
"phase": "sim",
66+
"time_avg": row["time_avg"],
67+
"speedup": row["speedup"],
68+
"efficiency": row["efficiency"],
69+
}
70+
)
7471

7572
elif header.startswith("Grind Time"):
7673
for _, row in df.iterrows():
77-
records.append({
78-
"scaling": "grind",
79-
"memory": int(row["memory"]),
80-
"grind_time": row["grind_time"]
81-
})
74+
records.append({"scaling": "grind", "memory": int(row["memory"]), "grind_time": row["grind_time"]})
8275

8376
return pd.DataFrame(records)
8477

78+
8579
# Get log files and filter for simulation logs
8680
files = os.listdir("examples/scaling/logs/")
8781
files = [f for f in files if "sim" in f]
@@ -91,14 +85,7 @@ def parse_reference_file(filename):
9185
# Remove extension
9286
parts = fname.replace(".out", "").split("-")
9387
scaling, nodes, memory, rdma, phase = parts
94-
records.append({
95-
"scaling": scaling,
96-
"nodes": int(nodes),
97-
"memory": int(memory),
98-
"rdma": rdma,
99-
"phase": phase,
100-
"file": fname
101-
})
88+
records.append({"scaling": scaling, "nodes": int(nodes), "memory": int(memory), "rdma": rdma, "phase": phase, "file": fname})
10289

10390
df = pd.DataFrame(records)
10491

@@ -119,12 +106,9 @@ def parse_reference_file(filename):
119106

120107
for mem in weak_scaling_mem:
121108
for rdma in weak_scaling_rdma:
122-
subset = weak_df[(weak_df["memory"] == mem) &
123-
(weak_df["rdma"] == rdma)]
109+
subset = weak_df[(weak_df["memory"] == mem) & (weak_df["rdma"] == rdma)]
124110
subset = subset.sort_values(by="nodes")
125-
ref = weak_ref_df[(weak_ref_df["memory"] == mem) &
126-
(weak_ref_df["rdma"] == rdma) &
127-
(weak_ref_df["nodes"].isin(subset["nodes"]))]
111+
ref = weak_ref_df[(weak_ref_df["memory"] == mem) & (weak_ref_df["rdma"] == rdma) & (weak_ref_df["nodes"].isin(subset["nodes"]))]
128112
ref = ref.sort_values(by="nodes")
129113

130114
times = []
@@ -148,13 +132,10 @@ def parse_reference_file(filename):
148132

149133
for mem in strong_scaling_mem:
150134
for rdma in strong_scaling_rdma:
151-
subset = strong_df[(strong_df["memory"] == mem) &
152-
(strong_df["rdma"] == rdma)]
135+
subset = strong_df[(strong_df["memory"] == mem) & (strong_df["rdma"] == rdma)]
153136
subset = subset.sort_values(by="nodes")
154137

155-
ref = strong_ref_df[(strong_ref_df["memory"] == mem) &
156-
(strong_ref_df["rdma"] == rdma) &
157-
(strong_ref_df["nodes"].isin(subset["nodes"]))]
138+
ref = strong_ref_df[(strong_ref_df["memory"] == mem) & (strong_ref_df["rdma"] == rdma) & (strong_ref_df["nodes"].isin(subset["nodes"]))]
158139
ref = ref.sort_values(by="nodes")
159140

160141
times = []
@@ -194,4 +175,3 @@ def parse_reference_file(filename):
194175
print(subset[["memory", "grind_time", "rel_perf"]].to_string(index=False))
195176

196177
print()
197-

examples/scaling/case.py

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,9 @@
2828
metavar="MEMORY",
2929
help="Weak scaling: memory per rank in GB. Strong scaling: global memory in GB. Used to determine cell count.",
3030
)
31-
parser.add_argument(
32-
"--rdma_mpi",
33-
metavar="RDMA",
34-
type=str,
35-
choices=["T", "F"],
36-
default="F",
37-
help="Enable RDMA-aware MPI optimizations.")
38-
parser.add_argument(
39-
"--n-steps",
40-
metavar="N",
41-
type=int,
42-
default=20,
43-
help="Number of time steps to simulate.")
44-
parser.add_argument(
45-
"--n-save",
46-
metavar="NS",
47-
type=int,
48-
default=20,
49-
help="Number of time steps between saves.")
31+
parser.add_argument("--rdma_mpi", metavar="RDMA", type=str, choices=["T", "F"], default="F", help="Enable RDMA-aware MPI optimizations.")
32+
parser.add_argument("--n-steps", metavar="N", type=int, default=20, help="Number of time steps to simulate.")
33+
parser.add_argument("--n-save", metavar="NS", type=int, default=20, help="Number of time steps between saves.")
5034
args = parser.parse_args()
5135

5236
if args.scaling is None:
@@ -59,28 +43,30 @@
5943
# Number of ranks.
6044
nranks = args.mfc["nodes"] * args.mfc["tasks_per_node"]
6145

46+
6247
# This subroutine finds three factors of n that are as close to each other as possible.
6348
def closest_three_factors(n):
6449
best_triplet = None
65-
min_range = float('inf')
50+
min_range = float("inf")
6651

6752
# Iterate over possible first factor a
68-
for a in range(1, int(n ** (1/3)) + 2): # a should be around the cube root of n
69-
if n % a == 0:
70-
n1 = n // a # Remaining part
53+
for factor_one in range(1, int(n ** (1 / 3)) + 2): # factor_one should be around the cube root of n
54+
if n % factor_one == 0:
55+
n1 = n // factor_one # Remaining part
7156

7257
# Iterate over possible second factor b
73-
for b in range(a, int(math.sqrt(n1)) + 2): # b should be around sqrt of n1
74-
if n1 % b == 0:
75-
c = n1 // b # Third factor
58+
for factor_two in range(factor_one, int(math.sqrt(n1)) + 2): # factor_two should be around sqrt of n1
59+
if n1 % factor_two == 0:
60+
factor_three = n1 // factor_two # Third factor
7661

77-
triplet_range = c - a # Spread of the numbers
62+
triplet_range = factor_three - factor_one # Spread of the numbers
7863
if triplet_range < min_range:
7964
min_range = triplet_range
80-
best_triplet = (a, b, c)
65+
best_triplet = (factor_one, factor_two, factor_three)
8166

8267
return best_triplet
8368

69+
8470
def nxyz_from_ncells_weak(ncells: float) -> typing.Tuple[int, int, int]:
8571
s = math.floor(ncells ** (1 / 3))
8672
ND = closest_three_factors(nranks)
@@ -89,17 +75,19 @@ def nxyz_from_ncells_weak(ncells: float) -> typing.Tuple[int, int, int]:
8975
N1 = ND[0] * s - 1
9076
N2 = ND[1] * s - 1
9177
N3 = ND[2] * s - 1
92-
Lx = ND[0]
93-
Ly = ND[1]
94-
Lz = ND[2]
95-
return N1, N2, N3, Lx, Ly, Lz
78+
L1 = ND[0]
79+
L2 = ND[1]
80+
L3 = ND[2]
81+
return N1, N2, N3, L1, L2, L3
82+
9683

9784
def nxyz_from_ncells_strong(ncells: float) -> typing.Tuple[int, int, int]:
9885
s = round(ncells ** (1 / 3))
99-
Lx = 4
100-
Ly = 4
101-
Lz = 4
102-
return s, s, s, Lx, Ly, Lz
86+
L1 = 4
87+
L2 = 4
88+
L3 = 4
89+
return s, s, s, L1, L2, L3
90+
10391

10492
if args.scaling == "weak":
10593
Nx, Ny, Nz, Lx, Ly, Lz = nxyz_from_ncells_weak(cpg * args.memory)
@@ -117,32 +105,32 @@ def nxyz_from_ncells_strong(ncells: float) -> typing.Tuple[int, int, int]:
117105
ISD = 5.0 / 8 * D0
118106

119107
## pre-shock properties - AIR
120-
p0a = patm # pressure - Pa
121-
rho0a = 1.204 # density - kg/m3
122-
gama = 1.40 # gamma
123-
pia = 0 # pi infinity - Pa
124-
c_a = math.sqrt(gama * (p0a + pia) / rho0a) # speed of sound - M/s
108+
p0a = patm # pressure - Pa
109+
rho0a = 1.204 # density - kg/m3
110+
gama = 1.40 # gamma
111+
pia = 0 # pi infinity - Pa
112+
c_a = math.sqrt(gama * (p0a + pia) / rho0a) # speed of sound - M/s
125113

126114
## Droplet - WATER
127115
rho0w = 1000 # density - kg/m3
128-
p0w = patm # pressure - Pa
129-
gamw = 6.12 # gamma
130-
piw = 3.43e08 # pi infty - Pa
131-
c_w = math.sqrt(gamw * (p0w + piw) / rho0w) # speed of sound - m/s
116+
p0w = patm # pressure - Pa
117+
gamw = 6.12 # gamma
118+
piw = 3.43e08 # pi infty - Pa
119+
c_w = math.sqrt(gamw * (p0w + piw) / rho0w) # speed of sound - m/s
132120

133121
# Shock Mach number of interest
134122
Min = 2.4
135123

136124
# Pos to pre shock ratios - AIR
137-
psOp0a = (Min**2 - 1) * 2 * gama / (gama + 1) + 1 # pressure
138-
rhosOrho0a = (1 + (gama + 1) / (gama - 1) * psOp0a) / ((gama + 1) / (gama - 1) + psOp0a) # density
139-
ss = Min * c_a # shock speed of sound - m/s
125+
psOp0a = (Min**2 - 1) * 2 * gama / (gama + 1) + 1 # pressure
126+
rhosOrho0a = (1 + (gama + 1) / (gama - 1) * psOp0a) / ((gama + 1) / (gama - 1) + psOp0a) # density
127+
ss = Min * c_a # shock speed of sound - m/s
140128

141129
# post-shock conditions - AIR
142-
ps = psOp0a * p0a # pressure - Pa
143-
rhos = rhosOrho0a * rho0a # density - kg / m3
144-
c_s = math.sqrt(gama * (ps + pia) / rhos) # post shock speed of sound - m/s
145-
vel = c_a / gama * (psOp0a - 1.0) * p0a / (p0a + pia) / Min # velocity at the post shock - m/s
130+
ps = psOp0a * p0a # pressure - Pa
131+
rhos = rhosOrho0a * rho0a # density - kg / m3
132+
c_s = math.sqrt(gama * (ps + pia) / rhos) # post shock speed of sound - m/s
133+
vel = c_a / gama * (psOp0a - 1.0) * p0a / (p0a + pia) / Min # velocity at the post shock - m/s
146134

147135
# Domain extents
148136
xb = -Lx * D0 / 2

examples/scaling/export.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,33 @@
44
CDIR = os.path.abspath(os.path.join("examples", "scaling"))
55
LDIR = os.path.join(CDIR, "logs")
66

7+
78
def get_num(s: str) -> float:
89
try:
910
return float(re.findall(r"[0-9]+\.[0-9]+(?:E[-+][0-9]+)?", s, re.MULTILINE)[0])
1011
except:
1112
return None
1213

14+
1315
def get_nums(arr):
1416
return {get_num(_) for _ in arr if get_num(_)}
1517

18+
1619
@dataclass(frozen=True, order=True)
1720
class Configuration:
1821
nodes: int
1922
mem: int
2023
rdma_mpi: bool
2124

25+
2226
@dataclass
2327
class Result:
2428
ts_avg: float
2529
mpi_avg: float
2630
init_t: float
2731
sim_t: float
2832

33+
2934
runs = {}
3035

3136
for logpath in glob.glob(os.path.join(LDIR, "run-*-sim*")):

examples/scaling/submit_all.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if [[ -z "$ACCOUNT" ]]; then
2121
exit 1
2222
fi
2323

24-
#./examples/scaling/submit_weak.sh --account $ACCOUNT
25-
#./examples/scaling/submit_strong.sh --account $ACCOUNT
26-
./examples/scaling/submit_grind.sh --account $ACCOUNT --mem "8"
24+
./examples/scaling/submit_weak.sh --account $ACCOUNT
25+
./examples/scaling/submit_strong.sh --account $ACCOUNT
26+
./examples/scaling/submit_grind.sh --account $ACCOUNT
2727

examples/scaling/submit_grind.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ if [ ! -d \$case_dir/restart_data ]; then
7676
7777
# Note: `time` is not used for performance measurement, only for monitoring
7878
# the job's progress.
79-
time ./mfc.sh run \$case_dir/case.py -c frontier -n 1 -N 1 --clean \
80-
-t pre_process -# grind-\$slug-pre -- --scaling weak\
79+
time ./mfc.sh run \$case_dir/case.py -c frontier -n 1 -N 1 --clean \
80+
-t pre_process -# grind-\$slug-pre -- --scaling weak \
8181
--memory $M \
8282
> examples/scaling/logs/grind-\$slug-pre.out 2>&1
8383
fi
@@ -88,7 +88,7 @@ echo "Running \$slug"
8888
# Note: `time` is not used for performance measurement, only for monitoring
8989
# the job's progress.
9090
time ./mfc.sh run \$case_dir/case.py -c frontier -n 1 -N 1 -t simulation \
91-
--case-optimization -# grind-\$slug-sim -- --scaling weak\
91+
--case-optimization -# grind-\$slug-sim -- --scaling weak \
9292
--memory $M --n-steps 100 --n-save 20 \
9393
> examples/scaling/logs/grind-\$slug-sim.out 2>&1
9494

examples/scaling/submit_strong.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ if [ ! -d \$case_dir/restart_data ]; then
8585
8686
# Note: `time` is not used for performance measurement, only for monitoring
8787
# the job's progress.
88-
time ./mfc.sh run \$case_dir/case.py -c frontier -n 8 -N $N --clean \
88+
time ./mfc.sh run \$case_dir/case.py -c frontier -n 8 -N $N --clean \
8989
-t pre_process -# strong-\$slug-pre -- --scaling strong \
9090
--memory $M \
9191
> examples/scaling/logs/strong-\$slug-pre.out 2>&1

examples/scaling/submit_weak.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ if [ ! -d \$case_dir/restart_data ]; then
8585
8686
# Note: `time` is not used for performance measurement, only for monitoring
8787
# the job's progress.
88-
time ./mfc.sh run \$case_dir/case.py -c frontier -n 8 -N $N --clean \
89-
-t pre_process -# weak-\$slug-pre -- --scaling weak\
88+
time ./mfc.sh run \$case_dir/case.py -c frontier -n 8 -N $N --clean \
89+
-t pre_process -# weak-\$slug-pre -- --scaling weak \
9090
--memory $M \
9191
> examples/scaling/logs/weak-\$slug-pre.out 2>&1
9292
fi
@@ -99,7 +99,7 @@ for rdma_mpi in F T; do
9999
# Note: `time` is not used for performance measurement, only for monitoring
100100
# the job's progress.
101101
time ./mfc.sh run \$case_dir/case.py -c frontier -n 8 -N $N -t simulation \
102-
--case-optimization -# weak-\$slug-sim -- --scaling weak\
102+
--case-optimization -# weak-\$slug-sim -- --scaling weak \
103103
--memory $M --rdma_mpi \$rdma_mpi --n-steps 20 \
104104
> examples/scaling/logs/weak-\$slug-sim.out 2>&1
105105

0 commit comments

Comments
 (0)