← Back to Pull requests

Tiling Work Update: `experiment/tiling-knobs` #43

Open
HamzaMateen opened this pull request with 561 lines diff across 6 files
View on GitHub
HamzaMateen HamzaMateen commented on Aug 24, 2026 20:24 UTC
Author

Summary


Tiling is implemented and results are numerically correct, but currently slower than untiled due to cursor overhead. Fixing requires restructuring the numeric pass' inner loop to make cursor work O(nnz(B)) instead of *O(strips rows(B))*.
I tested on Qemu for correctness, and the cache locality effects were tested on native x86_64 machine build.

Results


Cache Locality (Nonzeros-per-row pinned at 8)

| Columns | Accumulator | nnz(C) | GOP/s |
|---------|-------------|--------|-------|
| 4K | 52 KB | 263K | 0.119 |
| 16K | 208 KB | 1M | 0.115 |
| 65K | 832 KB | 4.2M | 0.082 |
| 262K | 3.3 MB | 16.8M | 0.047 |
| 1M | 13 MB | 67.1M | 0.037 |

3.27x loss top to bottom and bending knee is 208-832 KB.

Tiling Implementation


  • RVSP_TILE_COLS compile-time knob (0 means it's disabled and untiled path is taken)

  • Test suite passes under QEMU at tile sizes 1, 2, 3, 4, 16, 1024

  • Cross-build hashes: row_ptr/col_idx bit-identical across scalar/rvv/contig
  • Performance: Slower at Every Tile Size


    Interleaved repeats at N=65,536:
    tile=0        0.0830  0.0830  0.0749
    tile=32,768   0.0673  0.0742  0.0750
    tile=131,072  0.0560  0.0617  0.0576
    

    At tile=131,072 (single strip, identical arithmetic), ~27% slower because the cursor visits every row of B on every strip instead of just nnz(B):

    N=65K,   tile=2K      2.1M cursor vs 525K nnz(B)    4x overhead
    N=262K,  tile=2K      33.5M cursor vs 2.1M nnz(B)   16x overhead
    N=262K,  tile=32K     2.1M cursor vs 2.1M nnz(B)    1x overhead
    

    Next Steps


    1. Re-measure large-tile-only on F3 board
    2. Decide on O(nnz(B)) restructure based on results
    3. Symbolic-pass tiling still untouched (~2/3 remaining scattered traffic)

    Side Findings


  • genmat.c overshooting density 3.4-4.5x (C precedence bug, fixed). Gen_ rows before fix not comparable after.

  • bench.c --gen now exposes generator knobs (--gen-cv, --gen-min, --gen-band, --gen-sym).
  • Diff: 561 lines (+539 / -22) across 6 files Reviewer: ayokunle321 Review duration: 64791m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.60) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 561 lines diff across 6 files
    0.60
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 4 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    88%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    6 items
    ayokunle321 ayokunle321 commented on code on Aug 28, 2026 12:28 UTC
    Code Review
    bench/RESULTS.md:1
    @@ -0,0 +1,252 @@
    +# Baseline measurements

    This should not live in the bench folder. It's better for the results to be condensed and written in the paper if we are to talk about it.

    ayokunle321 ayokunle321 commented on code on Aug 28, 2026 12:42 UTC
    Code Review
    tools/src/genmat.c:1
    @@ -93,7 +93,7 @@ static int rand_count(double avg, double std, int min, int max, int curr_seed,
         curr_degree = (int)round(norm_box_muller(avg, std, curr_seed));
       } else {
         double avg_log_norm = log(avg * avg / sqrt(avg * avg + std * std));
    -    double std_log_norm = sqrt(log(1 + std * std / avg * avg));
    +    double std_log_norm = sqrt(log(1 + (std * std) / (avg * avg)));

    The fix looks right. I'd just put it in its own commit since it changes the generated matrices and is separate from the tiling work.

    ayokunle321 ayokunle321 commented on code on Aug 28, 2026 12:45 UTC
    Code Review
    src/kernels/spgemm/gustavson_core_f32.inc:1
    @@ -15,6 +15,131 @@
     #define RVSP_CAT(a, b) RVSP_CAT_(a, b)
     #define RVSP_NUMERIC_FN RVSP_CAT(RVSP_KERNEL_NAME, _numeric)
     
    +#if RVSP_TILE_COLS > 0

    The tiled function is called from RVSP_KERNEL_NAME, but bench goes through rvsp_spgemm_compute → numeric_for() → rvsp_spgemm_<name>_f32_numeric, which is still the untiled path.

    So the benchmark can run successfully and have no tiling arm. The tiled implementation needs to be hooked up as the numeric function for its own algorithm.

    Also, the mallocs are inside the numeric pass here. We moved those out of the timed region before, so this puts allocation back into what we're measuring.

    ayokunle321 ayokunle321 commented on code on Aug 28, 2026 12:48 UTC
    Code Review
    bench/run_bench.sh:1
    @@ -1414,8 +1457,8 @@ echo ">> experiment order per matrix: $(
     
     echo ">> matrix sweep (C = A*A)"
     
    -if [ -n "$ONLY_MTX" ]; then
    -    MATRIX_LIST=("$ONLY_MTX")
    +for case in "${GEN_CASES[@]}"; do
    +    read -r R C D S TAG EXTRA <<< "$case"
     

    This means the 19 SuiteSparse matrices aren't being benchmarked anymore.

    ayokunle321 ayokunle321 requested changes on Aug 28, 2026 12:52 UTC
    Changes Requested Reviewer

    If this is just experimental, it probably makes sense to keep it self-contained in its own experiments/ folder with its own benchmark and logic. If we want to evaluate it through the existing benchmark setup, though, it needs to be integrated with the current code path. I can take care of that integration if we decide to go that route.

    Reviewers
    Assignees
    HamzaMateen HamzaMateen
    Labels
    risk: low confidence: 88% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 60.2% (MEDIUM) · Higher = larger blast radius
    60.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88% · Lower = rushed or shallow review
    88%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.2% · Safe to merge
    7.2%