Enhance benchmark CLI with GPU, HTJ2K, and compare-all modes#285
Merged
Conversation
Agent-Logs-Url: https://github.com/Raster-Lab/J2KSwift/sessions/92efab50-87fd-48f6-82f6-4a38a03184b9 Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Raster-Lab/J2KSwift/sessions/92efab50-87fd-48f6-82f6-4a38a03184b9 Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
…ps for topBitPlane Agent-Logs-Url: https://github.com/Raster-Lab/J2KSwift/sessions/92efab50-87fd-48f6-82f6-4a38a03184b9 Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Raster-Lab/J2KSwift/sessions/92efab50-87fd-48f6-82f6-4a38a03184b9 Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
…GPU fallback Agent-Logs-Url: https://github.com/Raster-Lab/J2KSwift/sessions/837df556-ae9d-48ce-a7a4-11fff5dfdceb Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
…me GPU detection Agent-Logs-Url: https://github.com/Raster-Lab/J2KSwift/sessions/837df556-ae9d-48ce-a7a4-11fff5dfdceb Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
SureshKViswanathan
April 11, 2026 01:03
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends the
j2k benchmarkCLI command with multi-backend benchmarking: CPU, GPU (Metal), and HTJ2K (Part 15 FBCOT). Adds--compare-allfor side-by-side comparison tables with speedup ratios. Handles no-GPU gracefully via transparent CPU fallback with explicit reporting.Also addresses code review feedback on HTJ2K block coder: deduplicates header parsing, removes force unwraps, uses idiomatic Swift for max computation.
Motivation
The existing benchmark command only measured CPU Part 1 encoding/decoding. No way to compare GPU-accelerated or HTJ2K pipelines, and no handling for systems without Metal (Linux, headless CI).
Changes
Benchmark CLI (
Sources/J2KCLI/Benchmark.swift)--gpu,--htj2k,--compare-allbenchmark modes viaBenchmarkModeenumMTLCreateSystemDefaultDevice()(not justcanImport(Metal)) to handle headless Macs⚠warning when GPU requested but unavailablegpu_availableandgpu_backendfields in JSON/CSV outputbenchmarkEncode/benchmarkDecodehelpers; fixed division-by-zero guard incomputeStatsHTJ2K block coder (
Sources/J2KCodec/J2KHTBlockCoder.swift)HTStreamHeaderstruct to deduplicate 6-byte header parsing betweendecodeCleanupanddecodeFromCodestreamEncoder pipeline (
Sources/J2KCodec/J2KEncoderPipeline.swift)absMags.reduce(0) { Swift.max($0, $1) }withabsMags.max() ?? 0Help text (
Sources/J2KCLI/main.swift)--gpu,--htj2k,--compare-allto BENCHMARK OPTIONSTesting
Documentation
Code Quality
Screenshots (if applicable)
N/A
Checklist
Related Issues