Skip to content

Compiler optimizations - #84

Merged
pgbrodrick merged 3 commits into
emit-sds:devfrom
pgbrodrick:compiler_optimizations
Jul 30, 2026
Merged

Compiler optimizations#84
pgbrodrick merged 3 commits into
emit-sds:devfrom
pgbrodrick:compiler_optimizations

Conversation

@pgbrodrick

Copy link
Copy Markdown
Member

Leverage views and strategic function definition for fully type-specific compilation.

In practice, this reduces runtime by about 35% (EMIT style runs) with identical results. This PR uses more sophisticated views and TLS, but no increased performance was found, and there is notably more complexity, so keeping this implementation. The solver Levenberg-Marquardt solver referenced in the above is perhaps worth considering, however.

Note that the above PR also identifies a small algorithm bug in the BVLS solver, which I chose not to address here. Presently, we modify all bounds simultaneously, instead of one at a time. Technically, I believe this is incorrect, but in practice I found minuscule differences from the unmixing problem. For the sake of numerical consistency, I've allowed it to persist, though this could be reconsidered.

@vatsal-j vatsal-j left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgbrodrick The code itself looks good as far as I can tell (and you've already tested it). The doc building test failed because the new functions:

│     SpectralUnmixing._unmix_pixel_kernel :: Tuple{SpectralLibrary, Matrix{Float64}, Union{Nothing, Matrix{Float64}}, Any, Any, String, Int64, Vector{Int64}, String, String, Int64, String}
│     SpectralUnmixing.ensure_2d :: Tuple{AbstractVector{Float64}}
│     SpectralUnmixing.ensure_2d :: Tuple{AbstractMatrix{Float64}}

need to be added to docs/src/api.md

@pgbrodrick
pgbrodrick requested review from vatsal-j and removed request for vatsal-j July 30, 2026 20:46
@pgbrodrick

Copy link
Copy Markdown
Member Author

Merging now that the above request on documentation has been cleared.

@pgbrodrick
pgbrodrick merged commit 8ebc278 into emit-sds:dev Jul 30, 2026
3 checks passed
@pgbrodrick pgbrodrick mentioned this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants