-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Headers][X86] Convert bf16 to f32 conversions to generic constexpr implementations #162927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
wubowski
wants to merge
2
commits into
llvm:main
Choose a base branch
from
wubowski:fix-issue-154911
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+10
−22
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -422,8 +422,7 @@ static __inline__ __bf16 __DEFAULT_FN_ATTRS128 _mm_cvtness_sbh(float __A) { | |||||
| /// A 128-bit vector of [4 x bfloat]. | ||||||
| /// \returns A 128-bit vector of [4 x float] come from conversion of __A | ||||||
| static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) { | ||||||
| return _mm_castsi128_ps( | ||||||
| (__m128i)_mm_slli_epi32((__m128i)_mm_cvtepi16_epi32((__m128i)__A), 16)); | ||||||
| return (__m128)__builtin_convertvector(__A, __v4sf); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're missing a shuffle vector to only access the bottom 4 elements of __A:
Suggested change
(will need clang-format) |
||||||
| } | ||||||
|
|
||||||
| /// Convert Packed BF16 Data to Packed float Data. | ||||||
|
|
@@ -434,8 +433,7 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) { | |||||
| /// A 128-bit vector of [8 x bfloat]. | ||||||
| /// \returns A 256-bit vector of [8 x float] come from conversion of __A | ||||||
| static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_cvtpbh_ps(__m128bh __A) { | ||||||
| return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32( | ||||||
| (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), 16)); | ||||||
| return (__m256)__builtin_convertvector(__A, __v8sf); | ||||||
| } | ||||||
|
|
||||||
| /// Convert Packed BF16 Data to Packed float Data using zeroing mask. | ||||||
|
|
@@ -450,8 +448,7 @@ static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_cvtpbh_ps(__m128bh __A) { | |||||
| /// \returns A 128-bit vector of [4 x float] come from conversion of __A | ||||||
| static __inline__ __m128 __DEFAULT_FN_ATTRS128 | ||||||
| _mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) { | ||||||
| return _mm_castsi128_ps((__m128i)_mm_slli_epi32( | ||||||
| (__m128i)_mm_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16)); | ||||||
| return _mm_maskz_mov_ps(__U, (__m128)__builtin_convertvector(__A, __v4sf)); | ||||||
| } | ||||||
|
|
||||||
| /// Convert Packed BF16 Data to Packed float Data using zeroing mask. | ||||||
|
|
@@ -466,8 +463,7 @@ _mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) { | |||||
| /// \returns A 256-bit vector of [8 x float] come from conversion of __A | ||||||
| static __inline__ __m256 __DEFAULT_FN_ATTRS256 | ||||||
| _mm256_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) { | ||||||
| return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32( | ||||||
| (__m256i)_mm256_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16)); | ||||||
| return _mm256_maskz_mov_ps(__U, (__m256)__builtin_convertvector(__A, __v8sf)); | ||||||
| } | ||||||
|
|
||||||
| /// Convert Packed BF16 Data to Packed float Data using merging mask. | ||||||
|
|
@@ -485,9 +481,7 @@ _mm256_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) { | |||||
| /// \returns A 128-bit vector of [4 x float] come from conversion of __A | ||||||
| static __inline__ __m128 __DEFAULT_FN_ATTRS128 | ||||||
| _mm_mask_cvtpbh_ps(__m128 __S, __mmask8 __U, __m128bh __A) { | ||||||
| return _mm_castsi128_ps((__m128i)_mm_mask_slli_epi32( | ||||||
| (__m128i)__S, (__mmask8)__U, (__m128i)_mm_cvtepi16_epi32((__m128i)__A), | ||||||
| 16)); | ||||||
| return _mm_mask_mov_ps(__S, __U, (__m128)__builtin_convertvector(__A, __v4sf)); | ||||||
| } | ||||||
|
|
||||||
| /// Convert Packed BF16 Data to Packed float Data using merging mask. | ||||||
|
|
@@ -505,9 +499,7 @@ _mm_mask_cvtpbh_ps(__m128 __S, __mmask8 __U, __m128bh __A) { | |||||
| /// \returns A 256-bit vector of [8 x float] come from conversion of __A | ||||||
| static __inline__ __m256 __DEFAULT_FN_ATTRS256 | ||||||
| _mm256_mask_cvtpbh_ps(__m256 __S, __mmask8 __U, __m128bh __A) { | ||||||
| return _mm256_castsi256_ps((__m256i)_mm256_mask_slli_epi32( | ||||||
| (__m256i)__S, (__mmask8)__U, (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), | ||||||
| 16)); | ||||||
| return _mm256_mask_mov_ps(__S, __U, (__m256)__builtin_convertvector(__A, __v8sf)); | ||||||
| } | ||||||
|
|
||||||
| #undef __DEFAULT_FN_ATTRS128 | ||||||
|
|
||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(style) - wrap _mm512_cvtpbh_ps instead of calling __builtin_convertvector directly - same for the other mask/maskz intrinsics