Avoid use of _mm512_set_epi16 for reversing 16-bit vectors#198
Merged
r-devulap merged 1 commit intonumpy:mainfrom Apr 22, 2025
Merged
Avoid use of _mm512_set_epi16 for reversing 16-bit vectors#198r-devulap merged 1 commit intonumpy:mainfrom
r-devulap merged 1 commit intonumpy:mainfrom
Conversation
r-devulap
approved these changes
Apr 22, 2025
Member
r-devulap
left a comment
There was a problem hiding this comment.
LGTM. Thanks @sterrettm2 for fixing it!
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the usage of _mm512_set_epi16 with a constexpr array and _mm512_loadu_si512 to reverse 16‐bit vectors, addressing build issues on older GCC versions. Key changes include updating the NETWORK_REVERSE_32LANES macro to list indices in reversed order and modifying the vector reversal functions in both avx512fp16-16bit-qsort.hpp and avx512-16bit-qsort.hpp.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/xss-common-includes.h | Updated NETWORK_REVERSE_32LANES macro to emit reversed index order for vector reversal. |
| src/avx512fp16-16bit-qsort.hpp | Replaced _mm512_set_epi16 with loading a constexpr array for reversing vectors. |
| src/avx512-16bit-qsort.hpp | Similarly replaced _mm512_set_epi16 with a constexpr array load to reverse vectors. |
Comments suppressed due to low confidence (3)
src/xss-common-includes.h:82
- Ensure that the revised ordering in the NETWORK_REVERSE_32LANES macro correctly matches the intended reversal behavior for all consumers of this macro.
31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
src/avx512fp16-16bit-qsort.hpp:142
- Verify that using _mm512_loadu_si512 on the static array 'arr' preserves the correct vector reversal behavior and that the array size exactly meets the requirements of the intrinsic.
constexpr static uint16_t arr[] = {NETWORK_REVERSE_32LANES};
src/avx512-16bit-qsort.hpp:178
- Confirm that replacing _mm512_set_epi16 with a constexpr array and _mm512_loadu_si512 in the reverse functions maintains the intended reversal logic, particularly regarding the reversed index order.
constexpr static uint16_t arr[] = {NETWORK_REVERSE_32LANES};
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.
To help with older GCC versions we should avoid using _mm512_set_epi16, and currently some are used for reversing vectors. Hopefully this fixes GCC 8 builds and thus #196.
There is no meaningful performance change from this patch; here are benchmarks to show the lack of regression
Benchmarks