Skip to content

Commit 0aa2e04

Browse files
committed
test: thread-sweep retrofit (partial-warp widths, 238 new cases) + host-helper pins + glass-dispatch.cuh in conftest hash
1 parent 83ac701 commit 0aa2e04

9 files changed

Lines changed: 6081 additions & 4397 deletions

File tree

‎test/conftest.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def _hash_sources(cu_path: pathlib.Path) -> str:
151151
# any single-driver edit.
152152
paths = [cu_path, CUDA_DIR / "helpers.cuh",
153153
GLASS_DIR / "glass.cuh", GLASS_DIR / "glass-cgrps.cuh",
154-
GLASS_DIR / "glass-defaults.cuh", GLASS_DIR / "glass-nvidia.cuh"]
154+
GLASS_DIR / "glass-defaults.cuh", GLASS_DIR / "glass-dispatch.cuh",
155+
GLASS_DIR / "glass-nvidia.cuh"]
155156
paths += sorted((GLASS_DIR / "src").rglob("*.cuh"))
156157
paths += [
157158
CUDA_DIR / "test_iamax.cu",

‎test/cuda/test_defaults.cu‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,21 @@ static_assert(glass::suggested_block_threads<op::gemm, 32, float>() == 256u, "ge
143143
static_assert(glass::suggested_warps_per_block<op::dot>() == 8u, "dot WPB=8");
144144
static_assert(glass::suggested_warps_per_block<op::chol>() == 2u, "chol WPB=2");
145145

146+
// ── host-side query/size helpers: constexpr, so the asserts ARE the test.
147+
// Property-based (positive, monotone in threads/size) rather than exact —
148+
// the formulas are the implementation's business, launchability is ours. ──
149+
static_assert(glass::dot_fast_scratch_bytes<float>(64) == 8, "2 warps -> 2 floats");
150+
static_assert(glass::dot_fast_scratch_bytes<double>(256) >= glass::dot_fast_scratch_bytes<double>(32), "monotone in threads");
151+
static_assert(glass::iamax_scratch_bytes<float>(64) > 0 && glass::iamax_fast_scratch_bytes<float>(64) > 0, "iamax scratch positive");
152+
static_assert(glass::argreduce_scratch_bytes<float>(64) > 0 && glass::argreduce_fast_scratch_bytes<float>(64) > 0, "argreduce scratch positive");
153+
static_assert(glass::congruence_scratch_bytes<float, 12, 4>() > 0, "congruence scratch positive");
154+
static_assert(glass::gn_step_scratch_bytes<float, 7>() > 0, "gn_step scratch positive");
155+
static_assert(glass::inv_dense_scratch_bytes<float>(8) >= glass::inv_dense_scratch_bytes<float>(4), "inv_dense monotone in dim");
156+
static_assert(glass::trmv_scratch_bytes<double>(6) == 6 * sizeof(double), "trmv scratch = n*T");
157+
constexpr uint32_t k_inv_dims[] = {4u, 6u};
158+
static_assert(glass::inv_fused_scratch_bytes<float>(2, k_inv_dims) > 0, "K-way fused inv scratch positive");
159+
static_assert(glass::eigh_sweeps<double>() > glass::eigh_sweeps<float>(), "f64 needs more Jacobi sweeps");
160+
static_assert(glass::syev_eps<float>() > 0 && glass::syev_eps<double>() < glass::syev_eps<float>(), "syev eps ordered by precision");
161+
static_assert(!glass::suggested_use_reduced<4, 8, 128>(), "reduced corner empty on sm_120 (REDUCED_SWEEP_RESULTS)");
162+
146163
int main() { printf("ok\n"); return 0; }

‎test/gpu-proof.json‎

Lines changed: 6053 additions & 4387 deletions
Large diffs are not rendered by default.

‎test/test_banded.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Validates the single + dual-output bdmv against a dense block-tridiagonal
44
reference. Uses ASYMMETRIC L/R off-diagonal blocks so an L/R swap is caught,
55
exercises the edge block-rows (row 0 with a zero L-pad, row N-1 with a zero
6-
R-pad), and checks thread-count invariance (1 / 32 / 256 threads).
6+
R-pad), and checks thread-count invariance (1 / 7 / 33 / 256 threads — incl. partial warps).
77
"""
88
import numpy as np
99
import pytest
@@ -33,7 +33,7 @@ def reference(mat, vec, BS, NBR):
3333

3434

3535
@pytest.mark.parametrize("BS,NBR", [(2, 3), (6, 4)])
36-
@pytest.mark.parametrize("threads", [1, 32, 256])
36+
@pytest.mark.parametrize("threads", [1, 7, 33, 256]) # THREAD_SWEEP_CORE
3737
def test_bdmv(bins, BS, NBR, threads):
3838
mat, vec = make_banded(BS, NBR, seed=BS * 100 + NBR)
3939
ref = reference(mat, vec, BS, NBR)

‎test/test_factor_check.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _spd(n):
6161

6262

6363
@pytest.mark.parametrize("n", CHOL_N)
64-
@pytest.mark.parametrize("surf,th", [("block", 128), ("cgrps", 96), ("warp", 32)])
64+
@pytest.mark.parametrize("surf,th", [("block", 128), ("block", 33), ("block", 7), ("cgrps", 96), ("warp", 32)])
6565
def test_chol_check_pd(bins, n, surf, th):
6666
P = _spd(n)
6767
fail, L = _cholchk(bins["factor_check"], surf, th, n, P.copy())
@@ -71,7 +71,7 @@ def test_chol_check_pd(bins, n, surf, th):
7171

7272

7373
@pytest.mark.parametrize("n", CHOL_N)
74-
@pytest.mark.parametrize("surf,th", [("block", 128), ("cgrps", 96), ("warp", 32)])
74+
@pytest.mark.parametrize("surf,th", [("block", 128), ("block", 33), ("block", 7), ("cgrps", 96), ("warp", 32)])
7575
def test_chol_check_non_pd(bins, n, surf, th):
7676
ND = (-_spd(n)).astype(np.float32) # negative-definite => first pivot <= 0
7777
fail, _ = _cholchk(bins["factor_check"], surf, th, n, ND.copy())

‎test/test_pcg.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def from_padded(p, SS, KP):
4949

5050

5151
@pytest.mark.parametrize("SS,KP", [(2, 3), (6, 4)])
52-
@pytest.mark.parametrize("threads", [32, 128, 256])
52+
@pytest.mark.parametrize("threads", [1, 7, 33, 128, 256]) # incl. partial warps
5353
def test_pcg_solve(bins, SS, KP, threads):
5454
Sd, band, pinv = make_spd_banded(SS, KP, seed=SS * 10 + KP)
5555
n = SS * KP

‎test/test_qp.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# Thread counts swept for the invariance test: 1, one warp, two warps, the
2222
# production count, and a deliberate non-multiple of 32 (trailing partial warp).
23-
THREAD_COUNTS = [1, 32, 64, 256, 96]
23+
THREAD_COUNTS = [1, 7, 32, 33, 64, 96, 256] # incl. partial warps (7, 33)
2424

2525

2626
# --- harness ----------------------------------------------------------------

‎test/test_trsv.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88
import pytest
99
import scipy.linalg
10-
from conftest import run_op
10+
from conftest import run_op, THREAD_SWEEP_CORE
1111

1212
RNG = np.random.default_rng(7)
1313

@@ -103,7 +103,7 @@ def test_thread_invariance(bins, op, lower, unit, trans):
103103
else:
104104
expected = _oracle_trmv(A, v, lower, unit, trans).astype(np.float32)
105105
ref = None
106-
for threads in (1, 7, 33, 256):
106+
for threads in THREAD_SWEEP_CORE:
107107
result = _run(bins, op, threads, n, lower, unit, trans, A, v)
108108
assert np.allclose(result, expected, rtol=RTOL, atol=ATOL), \
109109
f"{op} threads={threads} lower={lower} unit={unit} trans={trans}: oracle mismatch"

‎test/test_warp.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ATOL = 1e-3
2121

2222
SIZES = [5, 7, 16, 33, 40, 64]
23-
WARP_COUNTS = [1, 2, 4]
23+
WARP_COUNTS = [1, 2, 3, 4, 8] # odd + large; partial warps are FORBIDDEN by the warp contract
2424

2525

2626
def _per_warp(arr, W, n):

0 commit comments

Comments
 (0)