Repository navigation
AVX-512 register-permute gather in compute_ideal_weights_for_decimation - #683
Closed
karthick-mcw wants to merge 1 commit into
Closed
karthick-mcw wants to merge 1 commit into
karthick-mcw wants to merge 1 commit into
Conversation
…r_decimation For texel_count <= 48 (blocks up to 6x6), the ei.weights / ei.weight_error_scale / infilled_weights lookup tables are register resident in 3 zmm registers, so the per-texel gather in the initial average and refine loops can be done as an in-register permute (vpermt2ps + vpermps) instead of a hardware vgatherdps, which is microcoded and load-latency bound on Zen 5. Larger blocks fall back to the existing AVX2 gather path. Output is bit-identical. Adds a self-contained runtime AVX-512F check, since an AVX2 build of this library can still run on a host without AVX-512F.
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.
Summary
AVX-512 register-permute gather for
compute_ideal_weights_for_decimation.The initial-average and refine loops gather
ei.weights/ei.weight_error_scale/infilled_weightsper texel. The hardwarevgatherdpsused for this is microcoded and load-latency bound on Zen 5. Fortexel_count <= 48(blocks up to 6x6, the size this workload uses) the whole lookup table fits in 3 zmm registers, so the gather is done as an in-register permute (vpermt2ps+vpermps) instead, with no memory access. Larger blocks (e.g. 8x8 = 64 texels) exceed register residency and fall back to the existing AVX2 gather path, unchanged.The result is bit-identical: it's the same elements, fetched a different way. Adds a self-contained runtime AVX-512F check, since an AVX2 build of this library can still run on a host without AVX-512F — the new path is only taken when both the block is small enough and the host actually supports it.
Files:
Source/astcenc_ideal_endpoints_and_weights.cppMeasured
Asset compression workload, gain in % (positive means faster).
(Mac Air has no AVX-512, so this change is a no-op there, as expected — the 0%/0.2% is noise. Arrow Lake's AVX-512 was disabled by Intel on this generation, so it also falls back to the AVX2 path.)
Test plan
.astcoutput with and without the patch, on a host without AVX-512F (exercises the unchanged AVX2 fallback path).astcencC++ unit test suite (ctest,-DASTCENC_UNITTEST=ON), 223/223 tests pass on the patched build.Test/astc_test_functional.py --encoder avx2gives the identical result with and without the patch (38/93 pass; the remaining 55 error only on a missingImageMagickdependency in this test environment, not on the code — zero assertion failures either way).