Skip to content

Improve h-sum in dot_avx calculation - #7002

Merged
timvisee merged 2 commits into
devfrom
improve_hsum_calculation
Aug 13, 2025
Merged

timvisee merged 2 commits into
devfrom
improve_hsum_calculation

Conversation

@JojiiOfficial

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as off-topic.

@JojiiOfficial JojiiOfficial changed the title Reduce usage of h-sum in dot_avx calculation Improve h-sum in dot_avx calculation Aug 8, 2025
let hsum = _mm_hadd_ps(lr_sum, lr_sum);
let p1 = _mm_extract_ps(hsum, 0);
let p2 = _mm_extract_ps(hsum, 1);
f32::from_bits(p1 as u32) + f32::from_bits(p2 as u32)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// Calculates the hsum (horizontal sum) of four 32 byte registers.
#[target_feature(enable = "avx")]
#[allow(clippy::missing_safety_doc)]
pub unsafe fn four_way_hsum(a: __m256, b: __m256, c: __m256, d: __m256) -> f32 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does adding #[inline] here make any difference? (I expect not)

@timvisee
timvisee merged commit 152bc5e into dev Aug 13, 2025
@timvisee
timvisee deleted the improve_hsum_calculation branch August 13, 2025 10:21
@coderabbitai coderabbitai Bot mentioned this pull request Aug 14, 2025
2 of 3 tasks
timvisee pushed a commit that referenced this pull request Aug 14, 2025
* Reduce amount of h-sum calculations in dot_avx

* Improve HSUM calculation and apply 4way-hsum to other places
@timvisee timvisee mentioned this pull request Aug 14, 2025
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.

3 participants