Commit 9258b5d9 authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: strip TEMP migration probes + proactive side-effect-parity sweep

Migration validated (JNA CUAS targets match JCuda). Cleanup:
- Removed all TEMP debug probes (-Dtp.dbg.corrpair, probeClt, saveTDRender,
  the one-shot DBG/PROBE blocks in GpuQuadJna + CuasMotion). Real fixes kept
  (rectilinear port, num_pairs=3, setCorrIndicesTdData, imclt ref_scene,
  num_corr_tiles propagation f6dcc90f).
- Proactive sweep for the f6dcc90f bug-class (JNA override drops a base
  side-effect field write): getCorrComboIndices/getCorr2DCombo propagate
  num_corr_combo_tiles, setCorrIndicesTdData propagates num_corr_tiles,
  getTextureIndices propagates num_texture_tiles; those fields made protected.
  These four are LATENT (no live consumer on the validated CUAS path) and are
  marked NOT-YET-TESTED inline.

Java-only. mvn compile clean.
Co-Authored-By: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
parent f6dcc90f
...@@ -275,7 +275,6 @@ public class CuasMotion { ...@@ -275,7 +275,6 @@ public class CuasMotion {
private double [] noise_map8 = null; private double [] noise_map8 = null;
private int [] noise_neibs = null; private int [] noise_neibs = null;
private int debugLevel = 0; private int debugLevel = 0;
private boolean corrpair_dbg_done = false; // TEMP post-mortem one-shot flag (By Claude 06/26/2026), remove with the -Dtp.dbg.corrpair probe
private GpuQuad gpuQuad = null; private GpuQuad gpuQuad = null;
private ImageDtt image_dtt = null; private ImageDtt image_dtt = null;
private int gpu_max_width; private int gpu_max_width;
...@@ -2905,50 +2904,9 @@ public class CuasMotion { ...@@ -2905,50 +2904,9 @@ public class CuasMotion {
renderFromTD(false, "img"+dbg_suffix); renderFromTD(false, "img"+dbg_suffix);
} }
TDCorrTile [] tdCorrTiles = TDCorrTile.getFromGpu(gpuQuad); TDCorrTile [] tdCorrTiles = TDCorrTile.getFromGpu(gpuQuad);
// TEMP post-mortem (By Claude 06/26/2026): one-shot SAVE of reference + scene CLT renders (GPU->back)
// to localize the CORR2D-all-NaN divergence — is gpu_clt_ref actually populated? Both buffers are
// current here (ref from setRectilinearReferenceTD, scene from interRectilinearCorrTD). Saved (not
// shown) so they persist post-mortem; one-shot so no flood. Gate: -Dtp.dbg.corrpair=1. REMOVE after fix.
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)
}
return tdCorrTiles; return tdCorrTiles;
} }
// TEMP post-mortem helper (By Claude 06/26/2026): imclt the selected CLT buffer (ref/scene) back to an
// image and SAVE it to the model directory (persists after the run). REMOVE with the probe above.
private void saveTDRender(boolean use_reference, String title) {
gpuQuad.execImcltRbgAll(gpuQuad.getNumColors() <= 1, use_reference, null);
float [][] rbg = gpuQuad.getRBG(0); // single-camera rectilinear
String [] titles = new String [rbg.length]; // makeArrays derefs titles[i] -> must be non-null
for (int i = 0; i < titles.length; i++) titles[i] = title + "-" + i;
ImagePlus imp = ShowDoubleFloatArrays.makeArrays(
rbg, gpuQuad.getImageWidth(), gpuQuad.getImageHeight(), title, titles);
if (imp != null) {
parentCLT.saveImagePlusInModelDirectory(imp);
System.out.println("saveTDRender(): saved post-mortem render '"+title+"' (use_reference="+use_reference+")");
}
}
public float [][] shiftAndRenderAccumulate( public float [][] shiftAndRenderAccumulate(
CLTParameters clt_parameters, CLTParameters clt_parameters,
final boolean center, final boolean center,
......
...@@ -143,8 +143,8 @@ public class GpuQuad{ // quad camera description ...@@ -143,8 +143,8 @@ public class GpuQuad{ // quad camera description
public int num_task_tiles; public int num_task_tiles;
protected int num_corr_tiles; // protected so the JNA backend can propagate the native count (getFromGpu/getCorrTilesTd read it). By Claude 06/26/2026. protected int num_corr_tiles; // protected so the JNA backend can propagate the native count (getFromGpu/getCorrTilesTd read it). By Claude 06/26/2026.
private final int num_all_pairs; // = 6; // number of correlation pairs per tile (should match tasks) private final int num_all_pairs; // = 6; // number of correlation pairs per tile (should match tasks)
private int num_corr_combo_tiles; protected int num_corr_combo_tiles; // protected so JNA backend can propagate native count (side-effect parity). By Claude 06/27/2026.
private int num_texture_tiles; protected int num_texture_tiles; // protected so JNA backend can propagate native count (side-effect parity). By Claude 06/27/2026.
private boolean geometry_correction_set = false; private boolean geometry_correction_set = false;
private boolean geometry_correction_vector_set = false; private boolean geometry_correction_vector_set = false;
......
...@@ -249,30 +249,11 @@ public class GpuQuadJna extends GpuQuad { ...@@ -249,30 +249,11 @@ public class GpuQuadJna extends GpuQuad {
} }
// ---- direct CLT conversion (+ the fragile no_kernels / use_center_image / erase_clt / ref_scene paths) ---- // ---- direct CLT conversion (+ the fragile no_kernels / use_center_image / erase_clt / ref_scene paths) ----
// 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) { @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; boolean skip_kernels = rectilinear || no_kernels;
if (!skip_kernels) setConvolutionKernels(false); if (!skip_kernels) setConvolutionKernels(false);
if (!rectilinear) setBayerImages(false, use_center_image); if (!rectilinear) setBayerImages(false, use_center_image);
lib.tp_proc_exec_convert_direct(proc, ref_scene ? 1 : 0, erase_clt, no_kernels ? 1 : 0); lib.tp_proc_exec_convert_direct(proc, ref_scene ? 1 : 0, erase_clt, no_kernels ? 1 : 0);
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 ---- // ---- inverse CLT -> RBG ----
...@@ -309,18 +290,10 @@ public class GpuQuadJna extends GpuQuad { ...@@ -309,18 +290,10 @@ public class GpuQuadJna extends GpuQuad {
float[] s = scaleTriplet(scales); float[] s = scaleTriplet(scales);
lib.tp_proc_exec_corr2d_td(proc, sel_pairs_in[0], sel_pairs_in[1], sel_pairs_in[2], sel_pairs_in[3], s[0], s[1], s[2]); lib.tp_proc_exec_corr2d_td(proc, sel_pairs_in[0], sel_pairs_in[1], sel_pairs_in[2], sel_pairs_in[3], s[0], s[1], s[2]);
} }
private boolean inter_td_probed = false; // TEMP probe one-shot (By Claude 06/26/2026), remove after fix
@Override public void execCorr2D_inter_TD(double[] scales) { @Override public void execCorr2D_inter_TD(double[] scales) {
ensureRbgCorr(); ensureRbgCorr();
float[] s = scaleTriplet(scales); float[] s = scaleTriplet(scales);
int sel = getSensorMaskInter(); lib.tp_proc_exec_corr2d_inter_td(proc, getSensorMaskInter(), s[0], s[1], s[2]);
int n = lib.tp_proc_exec_corr2d_inter_td(proc, sel, s[0], s[1], s[2]); // returns last_num_corr_tiles
if (!inter_td_probed) { // TEMP PROBE — remove after fix
inter_td_probed = true;
System.out.println(String.format(
"PROBE inter_corr: sel_sensors=%d (popc=%d) num_cams=%d num_colors=%d scales[%.3f,%.3f,%.3f] -> num_corr_tiles=%d",
sel, Integer.bitCount(sel), num_cams, num_colors, s[0], s[1], s[2], n));
}
} }
@Override public void execCorr2D_combine(boolean init_corr, int num_pairs_in, int pairs_mask, boolean no_transpose_vertical) { @Override public void execCorr2D_combine(boolean init_corr, int num_pairs_in, int pairs_mask, boolean no_transpose_vertical) {
int num_pairs = getNumUsedPairs(); int num_pairs = getNumUsedPairs();
...@@ -343,6 +316,7 @@ public class GpuQuadJna extends GpuQuad { ...@@ -343,6 +316,7 @@ public class GpuQuadJna extends GpuQuad {
@Override public float[][] getCorr2DCombo(int corr_rad) { @Override public float[][] getCorr2DCombo(int corr_rad) {
int corr_size = (2 * corr_rad + 1) * (2 * corr_rad + 1); int corr_size = (2 * corr_rad + 1) * (2 * corr_rad + 1);
int n = lib.tp_proc_num_corr_combo(proc); int n = lib.tp_proc_num_corr_combo(proc);
num_corr_combo_tiles = n; // NOT YET TESTED (latent: no live consumer on validated path) — side-effect parity w/ base, cf. f6dcc90f. By Claude 06/27/2026.
float[] flat = new float[n * corr_size]; float[] flat = new float[n * corr_size];
lib.tp_proc_get_corr2d_combo(proc, flat); lib.tp_proc_get_corr2d_combo(proc, flat);
float[][] corrs = new float[n][corr_size]; float[][] corrs = new float[n][corr_size];
...@@ -376,10 +350,12 @@ public class GpuQuadJna extends GpuQuad { ...@@ -376,10 +350,12 @@ public class GpuQuadJna extends GpuQuad {
// ensureRbgCorr() guarantees the native corr buffers exist (idempotent). By Claude on 06/26/2026. // ensureRbgCorr() guarantees the native corr buffers exist (idempotent). By Claude on 06/26/2026.
@Override public void setCorrIndicesTdData(int num_tiles, int[] corr_indices, float[] fdata) { @Override public void setCorrIndicesTdData(int num_tiles, int[] corr_indices, float[] fdata) {
ensureRbgCorr(); ensureRbgCorr();
num_corr_tiles = num_tiles; // NOT YET TESTED on this path — base setCorrIndicesTdData sets this; readers (getFromGpu) rely on it. By Claude 06/27/2026.
lib.tp_proc_set_corr_indices_td(proc, corr_indices, fdata, num_tiles); lib.tp_proc_set_corr_indices_td(proc, corr_indices, fdata, num_tiles);
} }
@Override public int[] getCorrComboIndices() { @Override public int[] getCorrComboIndices() {
int n = lib.tp_proc_num_corr_combo(proc); int n = lib.tp_proc_num_corr_combo(proc);
num_corr_combo_tiles = n; // NOT YET TESTED (latent: no live consumer on validated path) — side-effect parity w/ base, cf. f6dcc90f. By Claude 06/27/2026.
int[] out = new int[n]; int[] out = new int[n];
lib.tp_proc_get_corr_combo_indices(proc, out, n); lib.tp_proc_get_corr_combo_indices(proc, out, n);
return out; return out;
...@@ -428,6 +404,7 @@ public class GpuQuadJna extends GpuQuad { ...@@ -428,6 +404,7 @@ public class GpuQuadJna extends GpuQuad {
int [] tmp = new int [tilesX * tilesY]; int [] tmp = new int [tilesX * tilesY];
int cnt = lib.tp_proc_get_texture_indices(proc, tmp, tmp.length); int cnt = lib.tp_proc_get_texture_indices(proc, tmp, tmp.length);
if (cnt < 0) cnt = 0; if (cnt < 0) cnt = 0;
num_texture_tiles = cnt; // NOT YET TESTED (texture path off validated CUAS path) — side-effect parity w/ base. By Claude 06/27/2026.
int [] out = new int [cnt]; int [] out = new int [cnt];
System.arraycopy(tmp, 0, out, 0, cnt); System.arraycopy(tmp, 0, out, 0, cnt);
return out; return out;
......
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