Skip to content

Commit 8d9154e

Browse files
committed
feat: add 2D FFT benchmark cases to all suites
- Smoke: +8 cases (16x16, 256x256 x c2c/z2z x fwd/inv) - Typical: +24 cases (6 2D sizes x c2c/z2z x fwd/inv) - Full: +72 cases (9 2D sizes incl Bluestein x c2c/z2z x fwd/inv x batch 1,4) - Update run_benchmark fixture to detect 2D sizes (string with 'x') and pass --rank 2 --shape NxM to CLI
1 parent a9bd32b commit 8d9154e

2 files changed

Lines changed: 50 additions & 12 deletions

File tree

benchmark/utils/pytest_plugin.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,29 @@ def invoke(*arguments: str, env: dict[str, str] | None = None, timeout: int = 24
127127
def run_benchmark(invoke_cli, bench_warmup, bench_iters):
128128
"""Invoke the bench subcommand with configured warmup/iters."""
129129

130-
def _run(size: int, api: str = "c2c", direction: str = "forward", batch: int = 1):
131-
return invoke_cli(
130+
def _run(size, api: str = "c2c", direction: str = "forward", batch: int = 1):
131+
is_2d = isinstance(size, str) and "x" in size
132+
cmd = [
132133
"bench",
133134
"--api",
134135
api,
135136
"--direction",
136137
direction,
137-
"--shape",
138-
str(size),
138+
]
139+
if is_2d:
140+
cmd += ["--rank", "2", "--shape", size]
141+
else:
142+
cmd += ["--shape", str(size)]
143+
cmd += [
139144
"--batch",
140145
str(batch),
141146
"--warmup",
142147
str(bench_warmup),
143148
"--iters",
144149
str(bench_iters),
145150
"--print-path",
146-
)
151+
]
152+
return invoke_cli(*cmd)
147153

148154
return _run
149155

benchmark/utils/suites.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# All APIs from ctest coverage
1010
ALL_APIS = ["c2c", "z2z", "r2c", "c2r", "d2z", "z2d"]
1111

12+
# 2D complex APIs only (rank 2 does not support real transforms yet)
13+
ALL_APIS_2D = ["c2c", "z2z"]
14+
1215
# Direction support per API
1316
API_DIRECTIONS = {
1417
"c2c": ["forward", "inverse"],
@@ -19,20 +22,36 @@
1922
"z2d": ["inverse"],
2023
}
2124

25+
# 2D sizes: smooth (CT path), non-square, Bluestein (prime dimensions)
26+
ALL_SIZES_2D = ["16x16", "64x64", "128x256", "256x128", "256x256", "512x512"]
27+
BLUESTEIN_SIZES_2D = ["23x23", "997x16", "16x997"]
28+
2229
# ── Suite definitions ──────────────────────────────────────────
2330

24-
# Smoke (24 cases): 3 key sizes x batch=1 x all API/direction combos
25-
SMOKE = {"sizes": [16, 256, 2048], "batches": [1]}
31+
# Smoke (24 1D cases + 4 2D cases): key sizes x batch=1 x all API/direction combos
32+
SMOKE = {
33+
"sizes": [16, 256, 2048],
34+
"batches": [1],
35+
"sizes_2d": ["16x16", "256x256"],
36+
"batches_2d": [1],
37+
}
2638

27-
# Typical (136 cases): all sizes x batch=1 + extra multi-batch on key sizes
39+
# Typical (136 1D + 24 2D cases)
2840
TYPICAL = {
2941
"sizes": ALL_SIZES,
3042
"batches": [1],
3143
"extra": [(256, 4), (256, 256), (2048, 4), (2048, 256)],
44+
"sizes_2d": ALL_SIZES_2D,
45+
"batches_2d": [1],
3246
}
3347

34-
# Full (312 cases): all sizes x all batches x all API/direction combos
35-
FULL = {"sizes": ALL_SIZES, "batches": ALL_BATCHES}
48+
# Full (312 1D + 48 2D cases)
49+
FULL = {
50+
"sizes": ALL_SIZES,
51+
"batches": ALL_BATCHES,
52+
"sizes_2d": ALL_SIZES_2D + BLUESTEIN_SIZES_2D,
53+
"batches_2d": [1, 4],
54+
}
3655

3756
SUITES = {"smoke": SMOKE, "typical": TYPICAL, "full": FULL}
3857

@@ -49,11 +68,14 @@ def expand_params(suite: dict):
4968
5069
Handles the 'extra' key for TYPICAL suite: additional (size, batch)
5170
pairs beyond the base sizes x batches cross product.
71+
72+
Also yields 2D entries from 'sizes_2d' x 'batches_2d' x ALL_APIS_2D.
73+
2D sizes are strings like "256x256" (detected by the caller to set rank=2).
5274
"""
5375
apis = ALL_APIS
5476
seen = set()
5577

56-
# Base: sizes x batches x apis
78+
# Base 1D: sizes x batches x apis
5779
for size in suite["sizes"]:
5880
for batch in suite["batches"]:
5981
for api in apis:
@@ -63,11 +85,21 @@ def expand_params(suite: dict):
6385
seen.add(key)
6486
yield key
6587

66-
# Extra (size, batch) pairs applied to all API/direction combos
88+
# Extra 1D (size, batch) pairs applied to all API/direction combos
6789
for size, batch in suite.get("extra", []):
6890
for api in apis:
6991
for direction in API_DIRECTIONS[api]:
7092
key = (size, batch, api, direction)
7193
if key not in seen:
7294
seen.add(key)
7395
yield key
96+
97+
# 2D: sizes_2d x batches_2d x ALL_APIS_2D (forward only)
98+
for size_2d in suite.get("sizes_2d", []):
99+
for batch in suite.get("batches_2d", [1]):
100+
for api in ALL_APIS_2D:
101+
for direction in API_DIRECTIONS[api]:
102+
key = (size_2d, batch, api, direction)
103+
if key not in seen:
104+
seen.add(key)
105+
yield key

0 commit comments

Comments
 (0)