Skip to content

CADISHI style for CPU #22

Closed
Closed

Description

@jbphyswx

We are leveraging CADISHI-style (https://doi.org/10.1016/j.cpc.2018.10.018, https://github.com/bio-phys/cadishi) schemes on GPU but really we could probably leverage them on CPU to great gains. I belive we have good round robin threading and SIMD on the inner loop, but we should see if we can optimize using their style of calculation.

Activity

  1. self-assigned this
    on Jun 17, 2026
  2. jbphyswx commented on Sep 6, 2026

    @jbphyswx
    OwnerAuthor

    Implemented — and the premise needed checking first, because it is wrong single-threaded and right multi-threaded.

    Single-threaded, blocking wins almost nothing. Fixed-i-count probe, growing N so the working set crosses L2 (512 K/core) and L3 (32 M shared), AMD EPYC 7513:

    working set L2SF D=2 SP1D D=2
    0.10 MB → 74.4 MB (750× range) 4.31 → 4.49 ns/pair 5.31 → 5.67

    4–8 % from L1-resident to 2.3× past L3 — the inner loop is a unit-stride scan the prefetchers cover, so it is compute-bound. That looked like grounds to close this as not-applicable.

    The multi-core control reverses it. Same threads, same placement, same clocks; only the working set differs:

    working set 1 task 32 tasks scaling
    0.25 MB (fits L2) 232.0 6810.3 Mpairs/s 29.4×
    19.8 MB (past L2) 216.5 1165.9 Mpairs/s 5.4×

    So the loop is bandwidth-bound under multi-core load, which is the regime that matters.

    Implemented as a j-blocked sweep — i stays a single point in registers, so blocking j alone is what makes the block cache-resident. Tile chosen by measurement on dedicated cores (the shared login node swung 1.7× between runs; bandwidth must not be benchmarked there):

    tile N=400 K, k=32 N=1.5 M, k=32
    4096 3163.6 3902.6
    65536 3857.6 3865.2
    unblocked 2785.4 1807.6

    1.39× at N = 400 K and 2.14× at N = 1.5 M on 32 threads, the gain growing with working set. k = 1 is unchanged (229 vs 230 Mpairs/s), so blocking costs nothing single-threaded.

    All five flat CPU pair kernels take block pairs, sharing the enumeration abstraction with the culling in #31. The other two ingredients of that scheme — per-worker private histograms and a SIMD compute/scatter split — were already present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions