Skip to content

Astc compute_ideal_weights_for_decimation: drop redundant gather via pre-subtracted infill - #682

Closed
karthick-mcw wants to merge 1 commit into
ARM-software:mainfrom
karthick-mcw:perf/decimation-gather-optimizations-v2
Closed

karthick-mcw wants to merge 1 commit into
ARM-software:mainfrom
karthick-mcw:perf/decimation-gather-optimizations-v2

Conversation

@karthick-mcw

Copy link
Copy Markdown

Summary

Drop a redundant gather in the refine loop of compute_ideal_weights_for_decimation.

compute_ideal_weights_for_decimation's refine loop gathered both infilled_weights and ei.weights per texel and subtracted them (old_weight - ideal_weight). This pre-subtracts ei.weights from the infilled weight at store time instead, so the refine loop only needs a single gather (weight_diff) for the same result — one fewer gather per texel on the hot path.

The result is bit-identical. The subtraction is reassociated to happen once at infill-store time instead of once per use in the refine loop, so the arithmetic — and therefore the output — doesn't change.

Files: Source/astcenc_ideal_endpoints_and_weights.cpp

Measured

Asset compression workload, gain in % (positive means faster).

Vendor CPU OS Compiler Single thread All threads
AMD Granite 9600 Windows clang-cl -0.93 2.2
Intel Arrow Lake Windows clang-cl 0.2 2.31
Apple Mac Air macOS AppleClang 0.58 0.07

Test plan

  • Bit-identical output: 6 representative LDR/HDR textures x 6 block sizes (4x4-12x12) x 4 quality presets (144 runs), byte-identical .astc output with and without the patch.
  • Unit test: astcenc C++ unit test suite (ctest, -DASTCENC_UNITTEST=ON), 223/223 tests pass on the patched build.
  • Functional tests: Test/astc_test_functional.py --encoder avx2 gives the identical result with and without the patch (38/93 pass; the remaining 55 error only on a missing ImageMagick dependency in this test environment, not on the code — zero assertion failures either way).
  • Timing: single core and all cores on all three machines (table above).

…n refine loop

The refine loop gathered both infilled_weights and ei.weights per
texel and subtracted them (old_weight - ideal_weight). Pre-subtract
ei.weights from the infilled weight at store time instead, so the
refine loop only needs a single gather (weight_diff) for the same
result. Fewer gather ops on the hot refine loop. Output is
bit-identical.
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.

1 participant