Commit b6a986ac authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: fix rectilinear inter-scene corr buffer sizing (JNA) — num_pairs=3

Second JNA-mode failure after the Phase-1 NPE fix: cudaErrorIllegalAddress at
tp_utils.cu:142 (image upload), actually a DEFERRED fault from the inter-scene
correlate2D_inter kernel writing out of bounds.

Root cause: GpuQuadJna.ensureRbgCorr sized the native correlation buffers via
Correlation2d.getNumPairs(num_cams). For the rectilinear single-camera config
num_cams=1 -> getNumPairs(1)=0 -> tp_proc_setup_rbg_corr allocates zero-size
gpu_corrs_td / gpu_corrs / gpu_corr_indices, so the inter-scene correlation
wrote past them -> illegal address, surfacing (sticky) at the next CUDA call.

Fix: mirror the JCuda oracle, whose rectilinear ctor hardcodes num_pairs=3
(GpuQuad.java:732) for exactly the inter-scene case ->
  int num_pairs = rectilinear ? 3 : Correlation2d.getNumPairs(num_cams);

Java-only; libtileproc.so untouched. mvn compile clean.
Co-Authored-By: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
parent b65ee10d
...@@ -126,7 +126,12 @@ public class GpuQuadJna extends GpuQuad { ...@@ -126,7 +126,12 @@ public class GpuQuadJna extends GpuQuad {
if (jna_rbg_corr_ready) return; if (jna_rbg_corr_ready) return;
int corr_out_rad = 7; // CORR_OUT_RAD -> 15x15 int corr_out_rad = 7; // CORR_OUT_RAD -> 15x15
float[] cw = (num_colors == 1) ? new float[]{1f,1f,1f} : new float[]{0.25f,0.25f,0.5f}; float[] cw = (num_colors == 1) ? new float[]{1f,1f,1f} : new float[]{0.25f,0.25f,0.5f};
lib.tp_proc_setup_rbg_corr(proc, Correlation2d.getNumPairs(num_cams), 0,0,0,0, cw[0],cw[1],cw[2], corr_out_rad); // Correlation buffers are sized by num_pairs. The rectilinear single-camera config does INTER-scene
// correlation, for which getNumPairs(num_cams=1)=0 -> zero-size buffers -> correlate2D_inter writes
// OOB -> cudaErrorIllegalAddress (deferred to the next CUDA call). The JCuda oracle's rectilinear ctor
// hardcodes num_pairs=3 for exactly this (GpuQuad.java:732); mirror it. By Claude on 06/26/2026.
int num_pairs = rectilinear ? 3 : Correlation2d.getNumPairs(num_cams);
lib.tp_proc_setup_rbg_corr(proc, num_pairs, 0,0,0,0, cw[0],cw[1],cw[2], corr_out_rad);
jna_rbg_corr_ready = true; jna_rbg_corr_ready = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment