Skip to content

Commit 43a2e03

Browse files
committed
fix: resolve test parameterization bugs in unified test runner
- Fix direction mapping in main.cpp: forward=-1 (FLAGFFT_FORWARD), inverse=1 - Fix default direction in TestParams: 0 means no filter (was -1) - Fix binary name construction in run_tests.py: - 2D tests use single binary test_2d_correctness - 1D tests use test_exec_{type}_{direction}_{algo}_{batch_mode} - All 22 operators now pass accuracy tests (CT: 8, BS: 8, 2D: 6)
1 parent 92c227f commit 43a2e03

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

ctest/flagfft_test.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ struct TestParams {
664664
int nx = 0; // 0 = use default size arrays
665665
int ny = 0; // 0 = use default size arrays
666666
int batch = 0; // 0 = use default batch arrays
667-
int direction = -1; // -1 = all directions, 0 = forward, 1 = inverse
667+
int direction = 0; // 0 = all directions (no filter), -1 = forward, 1 = inverse
668668
double scale = -1.0; // -1 = use default scales
669669
bool json_output = false;
670670
const char* json_file = nullptr;
@@ -711,8 +711,8 @@ inline std::vector<Test1DParam> override_params(std::vector<Test1DParam> default
711711
}
712712

713713
inline bool should_skip_direction(int direction_flag) {
714-
// direction_flag: FLAGFFT_FORWARD=0, FLAGFFT_INVERSE=1
715-
if (g_test_params.direction < 0) return false; // -1 = don't filter
714+
// direction_flag: FLAGFFT_FORWARD=-1, FLAGFFT_INVERSE=1
715+
if (g_test_params.direction == 0) return false; // 0 = no filter (unset)
716716
return g_test_params.direction != direction_flag;
717717
}
718718

ctest/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ int main(int argc, char** argv) {
2323
} else if (strncmp(argv[i], "--direction=", 12) == 0) {
2424
const char* dir = argv[i] + 12;
2525
if (strcmp(dir, "forward") == 0 || strcmp(dir, "fwd") == 0)
26-
g_test_params.direction = 0;
26+
g_test_params.direction = -1; // FLAGFFT_FORWARD
2727
else if (strcmp(dir, "inverse") == 0 || strcmp(dir, "inv") == 0)
28-
g_test_params.direction = 1;
28+
g_test_params.direction = 1; // FLAGFFT_INVERSE
2929
} else if (strncmp(argv[i], "--scale=", 8) == 0) {
3030
g_test_params.scale = atof(argv[i] + 8);
3131
} else if (strncmp(argv[i], "--json-file=", 12) == 0) {

tools/run_tests.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,37 @@ def parse_args() -> argparse.Namespace:
117117

118118
# Test execution functions
119119

120+
# Operators that include direction (fwd/inv) in their binary name
121+
_OPS_WITH_DIRECTION = {"c2c", "z2z"}
122+
120123

121124
def build_accuracy_cmd(case: dict, build_dir: Path) -> tuple[list[str], str]:
122-
binary = build_dir / "ctest" / case["ctest"]
125+
# Build binary name based on algorithm:
126+
# - 2D tests use a single binary: test_2d_correctness
127+
# - 1D tests: test_exec_{type}_{direction}_{algo}_{batch_mode}
128+
# For types with direction (c2c, z2z): include fwd/inv
129+
# For types without direction (r2c, c2r, d2z, z2d, r2c_c2r, d2z_z2d): no direction
130+
# batch_mode: batch=1 -> _s, batch>1 -> _b
131+
ctest_base = case["ctest"]
132+
algo = case["algo"]
133+
134+
if algo == "2d":
135+
# 2D tests use a single binary for all types
136+
binary_name = ctest_base
137+
else:
138+
batch_mode = "s" if case["batch"] == 1 else "b"
139+
# Check if this operator has direction in binary name
140+
# Extract the type prefix from op_id (e.g., "c2c_1d" -> "c2c")
141+
type_prefix = case["op_id"].split("_")[0]
142+
has_direction = type_prefix in _OPS_WITH_DIRECTION
143+
144+
if has_direction:
145+
dir_str = "fwd" if case["direction"] == "forward" else "inv"
146+
binary_name = f"{ctest_base}_{dir_str}_{algo}_{batch_mode}"
147+
else:
148+
binary_name = f"{ctest_base}_{algo}_{batch_mode}"
149+
150+
binary = build_dir / "ctest" / binary_name
123151
cmd = [str(binary), f"--nx={case['nx']}"]
124152
if case["rank"] == 2:
125153
cmd.append(f"--ny={case['ny']}")

0 commit comments

Comments
 (0)