Commit ee00ebe
Treat view slices as single points and vectorize unmasked point loops
Two launch-machinery fixes, verified locally with the device-free
compilation checker, DataLayouts and Fields unit tests (single- and
multi-threaded, bounds checks on), and interleaved benchmarks:
- num_slice_points(view, arg) = 1: a view slice contains one point by
definition, so no slice needs to be constructed at launch time. The
generic method throws for FusedMultiBroadcast launches (point-sliced
fused broadcasts mix 0-dimensional DataF dest slices with
dimension-preserving Broadcasted slices, so their inferred_size values
never agree), and it turned the slice size from a compile-time
constant into runtime slice construction executed several times per
GPU launch on the host and once per thread inside every kernel
(slice_subscope: 16.7-33.3 ns and 18 typed statements down to a
constant-folded 4.1 ns and 3 statements).
- Point loops with no mask now use @simd and inline f at the call site.
LLVM cannot vectorize across the carry branches of a flattened
CartesianIndices iteration, and the inliner gives up on point closures
over large broadcast expressions, materializing every argument slice
into a function call at each point; either alone leaves pointwise
loops scalar (0 vector instructions vs 512 for the equivalent plain
array broadcast). GPU subscopes iterate Generators, which do not
support @simd and keep a plain loop with the inlined call. Pointwise
broadcasts drop from 0.298 to 0.158 ns/point and fill! from 0.303 to
0.138 ns/point; baroclinic-wave step! recovers from 1.37x of main to
1.05x, and 100 bubble_2d steps from 1.73x to ~1.2x.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 8398477 commit ee00ebe
1 file changed
Lines changed: 48 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
83 | 102 | | |
84 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
85 | 121 | | |
86 | 122 | | |
87 | 123 | | |
| |||
0 commit comments