Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
f7939cc0
Commit
f7939cc0
authored
Jul 16, 2026
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CODEX: Compare resident pose candidate RMS
Co-authored-by:
Codex
<
codex@elphel.com
>
parent
9bdef093
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
10 deletions
+59
-10
CuasPoseRT.java
src/main/java/com/elphel/imagej/cuas/rt/CuasPoseRT.java
+2
-3
GpuQuadJna.java
src/main/java/com/elphel/imagej/gpu/jna/GpuQuadJna.java
+5
-1
Stage0.java
src/main/java/com/elphel/imagej/gpu/jna/Stage0.java
+1
-1
TpJna.java
src/main/java/com/elphel/imagej/gpu/jna/TpJna.java
+3
-3
IntersceneLma.java
...n/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
+32
-0
IntersceneLmaFloat.java
...a/com/elphel/imagej/tileprocessor/IntersceneLmaFloat.java
+16
-2
No files found.
src/main/java/com/elphel/imagej/cuas/rt/CuasPoseRT.java
View file @
f7939cc0
...
...
@@ -1042,9 +1042,8 @@ public class CuasPoseRT {
numTiles
,
capturePrepared
);
if
((
result
!=
null
)
&&
!
pose_lma_step_path_reported
)
{
pose_lma_step_path_reported
=
true
;
System
.
out
.
println
(
"CuasPoseRT: resident CUDA float LMA candidate active "
+
"(raw fx/J reused; Java-double candidate is debug/fallback only; "
+
"Java RMS/acceptance retained)"
);
System
.
out
.
println
(
"CuasPoseRT: resident CUDA float LMA candidate/RMS oracle active "
+
"(separate candidate fx/J buffers; Java acceptance authoritative)"
);
}
return
result
;
});
// production candidate: resident raw fx/J -> parallel prepare/reduce -> fixed 3x3 tail // By Codex on 07/15/2026
...
...
src/main/java/com/elphel/imagej/gpu/jna/GpuQuadJna.java
View file @
f7939cc0
...
...
@@ -592,7 +592,11 @@ public class GpuQuadJna extends GpuQuad {
packed
[
IntersceneLmaFloat
.
LMA_RESULT_FLOATS
],
packed
[
IntersceneLmaFloat
.
LMA_RESULT_FLOATS
+
1
])
:
null
;
return
new
IntersceneLmaFloat
.
ResidentLmaStepResult
(
unpackPoseLmaStep
(
packed
),
prepared
);
unpackPoseLmaStep
(
packed
),
prepared
,
packed
[
IntersceneLmaFloat
.
LMA_RESULT_FLOATS
],
packed
[
IntersceneLmaFloat
.
LMA_RESULT_FLOATS
+
1
],
packed
[
IntersceneLmaFloat
.
LMA_RESULT_FLOATS
+
2
],
packed
[
IntersceneLmaFloat
.
LMA_RESULT_FLOATS
+
3
]);
}
private
static
IntersceneLmaFloat
.
LmaStepResult
unpackPoseLmaStep
(
final
float
[]
packed
)
{
...
...
src/main/java/com/elphel/imagej/gpu/jna/Stage0.java
View file @
f7939cc0
...
...
@@ -10,7 +10,7 @@ import com.sun.jna.Pointer;
* com.elphel.imagej.gpu.jna.Stage0 [kernel_src_dir] [libcudadevrt.a]
*/
public
class
Stage0
{
private
static
final
int
EXPECTED_KERNELS
=
3
2
;
// 19 base + 2 conditioning + 4 consolidate + 2 peak + pose fx/J + 3
pose LMA + products
private
static
final
int
EXPECTED_KERNELS
=
3
3
;
// 19 base + 2 conditioning + 4 consolidate + 2 peak + pose fx/J + 4
pose LMA + products
public
static
void
main
(
String
[]
args
)
{
String
srcdir
=
(
args
.
length
>
0
)
?
args
[
0
]
:
"/home/elphel/git/tile_processor_gpu/src"
;
String
devrt
=
(
args
.
length
>
1
)
?
args
[
1
]
:
"/usr/local/cuda/targets/x86_64-linux/lib/libcudadevrt.a"
;
...
...
src/main/java/com/elphel/imagej/gpu/jna/TpJna.java
View file @
f7939cc0
...
...
@@ -12,8 +12,8 @@ public interface TpJna extends Library {
/** NVRTC-compile the kernels in srcdir (+ getTpDefines), cuLink(libcudadevrt), load the module.
* Returns an opaque module handle, or null on failure (see tp_last_error()). */
Pointer
tp_create_module
(
String
srcdir
,
String
libcudadevrt
);
/** Number of kernel functions resolved in the module (3
2
expected:
* 19 base + 2 conditioning + 4 consolidation + 2 peak + pose-fx/J +
3
pose-LMA + LMA-products),
/** Number of kernel functions resolved in the module (3
3
expected:
* 19 base + 2 conditioning + 4 consolidation + 2 peak + pose-fx/J +
4
pose-LMA + LMA-products),
* or -1 if handle is null. */
int
tp_module_num_functions
(
Pointer
module
);
/** Last error message (NVRTC/CUDA log), empty if none. */
...
...
@@ -155,7 +155,7 @@ public interface TpJna extends Library {
float
[]
ymfxWeighted
,
float
[]
vector
,
int
numValues
,
float
[]
result
);
/** Continue from raw fx/J left by the most recent pose kernel. Result has
* the 19 candidate floats followed by current full/pure RMS. Prepared
* the 19 candidate floats followed by current
and candidate
full/pure RMS. Prepared
* arrays are nullable unless capturePrepared is nonzero. */
int
tp_proc_exec_pose_lma_resident_step
(
Pointer
proc
,
float
lambda
,
float
[]
weights
,
float
[]
y
,
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
View file @
f7939cc0
...
...
@@ -126,6 +126,7 @@ public class IntersceneLma {
}
private
PoseLmaResidentStepProvider
poseLmaResidentStepProvider
=
null
;
private
static
boolean
poseLmaStepOracleReported
=
false
;
private
static
boolean
poseLmaAcceptanceOracleReported
=
false
;
private
IntersceneLmaFloat
.
Camera
poseFloatReference
=
null
;
private
IntersceneLmaFloat
.
Camera
poseFloatScene
=
null
;
private
float
[]
poseFloatCenters
=
null
;
...
...
@@ -1046,6 +1047,11 @@ public class IntersceneLma {
if
(
last_ymfx
==
null
)
{
return
null
;
// need to re-init/restart LMA
}
if
(
residentCandidateValid
&&
(
residentResult
!=
null
)
&&
(
debug_level
>=
1
)
&&
!
poseLmaAcceptanceOracleReported
)
{
reportPoseRmsDecision
(
residentResult
,
this
.
last_rms
,
rms
,
rms_diff
);
poseLmaAcceptanceOracleReported
=
true
;
}
this
.
good_or_bad_rms
=
rms
.
clone
();
if
(
rms
[
0
]
<
this
.
last_rms
[
0
])
{
// improved
...
...
@@ -1928,6 +1934,32 @@ public class IntersceneLma {
label
,
poseStep
.
valid
,
maxProducts
,
maxDelta
,
maxCandidate
));
}
private
static
void
reportPoseRmsDecision
(
final
IntersceneLmaFloat
.
ResidentLmaStepResult
resident
,
final
double
[]
javaCurrent
,
final
double
[]
javaCandidate
,
final
double
rmsDiff
)
{
final
boolean
finite
=
Float
.
isFinite
(
resident
.
currentRms
)
&&
Float
.
isFinite
(
resident
.
currentPureRms
)
&&
Float
.
isFinite
(
resident
.
candidateRms
)
&&
Float
.
isFinite
(
resident
.
candidatePureRms
);
final
boolean
floatImproved
=
finite
&&
(
resident
.
candidateRms
<
resident
.
currentRms
);
final
boolean
doubleImproved
=
javaCandidate
[
0
]
<
javaCurrent
[
0
];
final
boolean
floatStop
=
floatImproved
&&
(
resident
.
candidateRms
>=
resident
.
currentRms
*
(
1.0f
-
(
float
)
rmsDiff
));
final
boolean
doubleStop
=
doubleImproved
&&
(
javaCandidate
[
0
]
>=
javaCurrent
[
0
]
*
(
1.0
-
rmsDiff
));
System
.
out
.
println
(
String
.
format
(
"IntersceneLma resident CUDA-float vs Java-double RMS/decision: finite=%s, |current RMS|=%g, |current pure RMS|=%g, |candidate RMS|=%g, |candidate pure RMS|=%g, improved-match=%s, stop-match=%s"
,
finite
,
Math
.
abs
(
resident
.
currentRms
-
javaCurrent
[
0
]),
Math
.
abs
(
resident
.
currentPureRms
-
javaCurrent
[
1
]),
Math
.
abs
(
resident
.
candidateRms
-
javaCandidate
[
0
]),
Math
.
abs
(
resident
.
candidatePureRms
-
javaCandidate
[
1
]),
floatImproved
==
doubleImproved
,
floatStop
==
doubleStop
));
}
private
static
final
class
DoubleLmaStepResult
{
final
double
[]
products
;
final
double
[]
delta
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneLmaFloat.java
View file @
f7939cc0
...
...
@@ -42,7 +42,7 @@ public final class IntersceneLmaFloat {
public
static
final
int
NUM_COMPONENTS
=
2
;
public
static
final
int
LMA_PRODUCTS
=
NUM_PARAMS
*
NUM_PARAMS
+
NUM_PARAMS
;
public
static
final
int
LMA_RESULT_FLOATS
=
1
+
LMA_PRODUCTS
+
2
*
NUM_PARAMS
;
public
static
final
int
LMA_RESIDENT_RESULT_FLOATS
=
LMA_RESULT_FLOATS
+
2
;
public
static
final
int
LMA_RESIDENT_RESULT_FLOATS
=
LMA_RESULT_FLOATS
+
4
;
public
static
final
float
INFINITY_DISPARITY
=
0.01f
;
static
final
int
ERS_XYZ
=
0
;
...
...
@@ -216,10 +216,24 @@ public final class IntersceneLmaFloat {
public
static
final
class
ResidentLmaStepResult
{
public
final
LmaStepResult
step
;
public
final
PreparedLma
prepared
;
public
final
float
currentRms
;
public
final
float
currentPureRms
;
public
final
float
candidateRms
;
public
final
float
candidatePureRms
;
public
ResidentLmaStepResult
(
final
LmaStepResult
step
,
final
PreparedLma
prepared
)
{
public
ResidentLmaStepResult
(
final
LmaStepResult
step
,
final
PreparedLma
prepared
,
final
float
currentRms
,
final
float
currentPureRms
,
final
float
candidateRms
,
final
float
candidatePureRms
)
{
this
.
step
=
step
;
this
.
prepared
=
prepared
;
this
.
currentRms
=
currentRms
;
this
.
currentPureRms
=
currentPureRms
;
this
.
candidateRms
=
candidateRms
;
this
.
candidatePureRms
=
candidatePureRms
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment