You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
True vectorized solutions for fixed grids on CPU and GPU #23
We finally obtained nearly optimal kernels for 2D slices on GPU, and added a followup for running the kernel on subsequent slices.
However, a very common pattern would be to have fixed observations (model grid, gridded observations, buoy data etc) and take the SF at many points in time. For these we have no optimal fast path. These would benefit (on both CPU and GPU) form a fast path that does the point loop once, and is vectorized along the trailing (time) dimension.
It may even be the case that even when the points are not constant, some gains can be had by leveraging massive vector ops on the gpu, and then doing the binning slice by slice (especially with our O(1) binning kernels
so baiscally you have some loop in theory that is like for i in 1:N_i, for j in 1:N_j < do all times> etc
we shoudl also suport things like <x,y,z,t> with a structuer fucntion in only <x,y> or only <x,y,z> etc.
Both halves are now done, and the first shipped a while ago.
The batching half was already delivered in the GPU rewrite and the CPU rework, after this issue was filed: the pair frame and the distance bin are computed once per (i,j) and reused across the field strip, with u staged batch-major on GPU so that loop is contiguous, and a batch-leading accumulator on CPU so the inner batch loop is unit-stride. Trailing auxiliary axes are a first-class part of the shape contract.
The grid-structure half is what this work added (#32): a lag schedule where the separation, direction and bin are properties of the lag rather than the pair, so the inner loop is a shifted-array reduction with one histogram write per lag. Plus the correlation-theorem transform, which gets every lag at once.
On "SF over a subset of axes" (<x,y,z,t> with the SF in <x,y>): for a natively gridded array this is expressible today by reshaping so the pair axes are leading and contiguous — (D, nx, ny, nz, nt) → (D, nx*ny, nz, nt). A non-contiguous choice such as <x,z> needs a permutedims first. So this part is an ergonomics gap rather than a missing capability, except for the lag schedule, where which axes the lags span is a genuine parameter.
The default is pair axes = all spatial axes of the grid, auxiliary = trailing axes, which reproduces the existing (n_dist, aux…) output shape exactly.
Activity
jbphyswx commentedon Sep 6, 2026
Both halves are now done, and the first shipped a while ago.
The batching half was already delivered in the GPU rewrite and the CPU rework, after this issue was filed: the pair frame and the distance bin are computed once per
(i,j)and reused across the field strip, withustaged batch-major on GPU so that loop is contiguous, and a batch-leading accumulator on CPU so the inner batch loop is unit-stride. Trailing auxiliary axes are a first-class part of the shape contract.The grid-structure half is what this work added (#32): a lag schedule where the separation, direction and bin are properties of the lag rather than the pair, so the inner loop is a shifted-array reduction with one histogram write per lag. Plus the correlation-theorem transform, which gets every lag at once.
On "SF over a subset of axes" (
<x,y,z,t>with the SF in<x,y>): for a natively gridded array this is expressible today by reshaping so the pair axes are leading and contiguous —(D, nx, ny, nz, nt)→(D, nx*ny, nz, nt). A non-contiguous choice such as<x,z>needs apermutedimsfirst. So this part is an ergonomics gap rather than a missing capability, except for the lag schedule, where which axes the lags span is a genuine parameter.The default is pair axes = all spatial axes of the grid, auxiliary = trailing axes, which reproduces the existing
(n_dist, aux…)output shape exactly.