Commit f440c69
Fix 2D ||b||_2 indexing: read from k=Ng plane, not k=0
For 2D grids with ghost cells, the memory layout uses Sz = 1 + 2*Ng
planes, with actual data stored at plane k=Ng (the middle plane).
Ghost planes k=0 and k=2 contain boundary data.
The GPU reduction for ||b||_2 was using `idx = j*stride + i` which
reads from k=0 (ghost plane, contains zeros/garbage). This caused
the adaptive mode to compute wrong relative residuals and exit early.
Fixed by adding `k_plane_offset = Ng * plane_stride` to the 2D index
calculation, matching how the original CPU code and 3D code work.
Bug introduced: de074c0 (GPU reduction for ||b||_2)
Root cause: 2D memory layout wasn't accounted for in GPU reduction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent d4eb9dd commit f440c69
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1891 | 1891 | | |
1892 | 1892 | | |
1893 | 1893 | | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
1894 | 1897 | | |
1895 | 1898 | | |
1896 | 1899 | | |
1897 | 1900 | | |
1898 | | - | |
| 1901 | + | |
1899 | 1902 | | |
1900 | 1903 | | |
1901 | 1904 | | |
| |||
2027 | 2030 | | |
2028 | 2031 | | |
2029 | 2032 | | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
2030 | 2036 | | |
2031 | 2037 | | |
2032 | 2038 | | |
2033 | 2039 | | |
2034 | | - | |
| 2040 | + | |
2035 | 2041 | | |
2036 | 2042 | | |
2037 | 2043 | | |
| |||
0 commit comments