Commit f163b14a authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: more one-shot post-mortem diagnostics (TEMP, Java-only)

Single sacrificial run -> generous logging without spam:
- GpuQuadJna: probe BOTH first ref convert (gpu_clt_ref) AND first scene convert
  (gpu_clt) — NaN%/nonzero/range each (probeClt helper).
- CuasMotion.correlatePair one-shot: log targets_mv / tp_ref,tp_img counts /
  erase_cltr,erase_clt / fpixels null-ness, plus TD-correlation read-back stats
  (tile count + NaN% of TD values) alongside the DBG-REF/DBG-IMG renders.

All gated/one-shot; no native change (reads via existing tp_proc_get_clt).
TEMP — remove with the rest of the -Dtp.dbg.corrpair probe.
Co-Authored-By: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
parent 6da17148
......@@ -2912,6 +2912,22 @@ public class CuasMotion {
if (!corrpair_dbg_done && "1".equals(System.getProperty("tp.dbg.corrpair"))) {
corrpair_dbg_done = true;
String sfx = (dbg_suffix == null) ? "" : dbg_suffix;
// context: how the two converts were set up
System.out.println("DBG corrpair: targets_mv="+(targets_mv!=null)+
" tp_ref="+((tp_ref==null)?"null":tp_ref.length)+" tp_img="+((tp_img==null)?"null":tp_img.length)+
" erase_cltr="+erase_cltr+" erase_clt="+erase_clt+
" fpixels_ref="+(fpixels_ref!=null)+" fpixels_img="+(fpixels_img!=null));
// TD correlation read back from GPU (host-side): how many tiles + NaN fraction of one tile's data
int n_tiles = 0, n_nan_data = 0; long n_vals = 0, n_nan_vals = 0;
if (tdCorrTiles != null) {
for (TDCorrTile t : tdCorrTiles) if (t != null) {
n_tiles++;
float [] d = t.getFloatData();
if (d != null) { for (float v : d) { n_vals++; if (Float.isNaN(v)) n_nan_vals++; } if (n_nan_vals == n_vals && n_vals>0) n_nan_data++; }
}
}
System.out.println(String.format("DBG corrpair: TD tiles=%d, TD values NaN=%.1f%% (of %d)",
n_tiles, 100.0 * n_nan_vals / Math.max(n_vals,1), n_vals));
saveTDRender(true, "DBG-REF"+sfx); // gpu_clt_ref render — blank/NaN => reference not loaded
saveTDRender(false, "DBG-IMG"+sfx); // gpu_clt render (scene) — expected OK (matches SOURCE)
}
......
......@@ -249,26 +249,30 @@ public class GpuQuadJna extends GpuQuad {
}
// ---- direct CLT conversion (+ the fragile no_kernels / use_center_image / erase_clt / ref_scene paths) ----
// TEMP PROBE flag (By Claude 06/26/2026): print gpu_clt_ref stats once after the first ref_scene convert,
// to confirm whether the reference convert actually populates gpu_clt_ref (CORR2D-all-NaN divergence).
// REMOVE after the reference-CLT divergence is fixed.
// TEMP PROBE flags (By Claude 06/26/2026): print CLT-buffer stats once after the first ref convert and
// once after the first scene convert, to localize the CORR2D-all-NaN divergence (inter corr needs BOTH
// gpu_clt + gpu_clt_ref). REMOVE after the reference-CLT divergence is fixed.
private boolean clt_ref_probed = false;
private boolean clt_scene_probed = false;
@Override public void execConvertDirect(boolean ref_scene, int[] wh, int erase_clt, boolean no_kernels, boolean use_center_image) {
boolean skip_kernels = rectilinear || no_kernels;
if (!skip_kernels) setConvolutionKernels(false);
if (!rectilinear) setBayerImages(false, use_center_image);
lib.tp_proc_exec_convert_direct(proc, ref_scene ? 1 : 0, erase_clt, no_kernels ? 1 : 0);
if (ref_scene && !clt_ref_probed) { // TEMP PROBE — remove after fix
clt_ref_probed = true;
int sz = getCltSize(true);
float[] clt = new float[sz];
lib.tp_proc_get_clt(proc, 0, 1, clt);
int nan = 0, nz = 0; float mn = Float.POSITIVE_INFINITY, mx = Float.NEGATIVE_INFINITY;
for (float v : clt) { if (Float.isNaN(v)) nan++; else { if (v != 0f) nz++; if (v < mn) mn = v; if (v > mx) mx = v; } }
System.out.println(String.format(
"PROBE gpu_clt_ref[cam0]: size=%d NaN=%.1f%% nonzero=%d finite[min=%g max=%g] (erase_clt=%d)",
sz, 100.0 * nan / Math.max(sz, 1), nz, (nz > 0 ? mn : 0f), (nz > 0 ? mx : 0f), erase_clt));
}
if (ref_scene && !clt_ref_probed) { clt_ref_probed = true; probeClt(true, erase_clt); } // TEMP — remove after fix
if (!ref_scene && !clt_scene_probed){ clt_scene_probed = true; probeClt(false, erase_clt); } // TEMP — remove after fix
}
// TEMP probe helper (By Claude 06/26/2026): read back gpu_clt[_ref] and print NaN%/nonzero/range. REMOVE after fix.
private void probeClt(boolean use_ref, int erase_clt) {
int sz = getCltSize(use_ref);
float[] clt = new float[sz];
lib.tp_proc_get_clt(proc, 0, use_ref ? 1 : 0, clt);
int nan = 0, nz = 0; float mn = Float.POSITIVE_INFINITY, mx = Float.NEGATIVE_INFINITY;
for (float v : clt) { if (Float.isNaN(v)) nan++; else { if (v != 0f) nz++; if (v < mn) mn = v; if (v > mx) mx = v; } }
System.out.println(String.format(
"PROBE %s[cam0]: size=%d NaN=%.1f%% nonzero=%d finite[min=%g max=%g] (erase_clt=%d)",
use_ref ? "gpu_clt_ref" : "gpu_clt ", sz, 100.0 * nan / Math.max(sz, 1), nz,
(nz > 0 ? mn : 0f), (nz > 0 ? mx : 0f), erase_clt));
}
// ---- inverse CLT -> RBG ----
......
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