Skip to content
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

inflate more SIMD #11

Closed
wants to merge 1 commit into from
Closed

inflate more SIMD #11

wants to merge 1 commit into from

Conversation

folkertdev
Copy link
Collaborator

needs refinement, and just hardcodes x86 + AVX2.

The general gist here is that we get fewer instructions, but the same number of cycles as a safer version without this much SIMD. But that can be very instruction-set dependent. So we should have more instruction sets before we can really make this decision.

@folkertdev
Copy link
Collaborator Author

folkertdev commented Feb 13, 2024

I tried to improve the offset_from_end == 1 case, but it is only faster in the micro benchmark, and actually slower in the inflate of silesia-small.tar.gz

            if offset_from_end == 1 {
                use std::arch::x86_64::{_mm256_set1_epi8, _mm256_storeu_si256};

                // this will just repeat this value many times
                let element = self.buf[current - 1];
                let b = unsafe { element.assume_init() };

                if false && safe_to_chunk {
                    let chunk = unsafe { std::arch::x86_64::_mm256_set1_epi8(b as i8) };
                    for d in self.buf[current..][..length].chunks_mut(32) {
                        unsafe {
                            _mm256_storeu_si256(d.as_mut_ptr().cast(), chunk);
                        }
                    }
                } else {
                    self.buf[current..][..length].fill(element);
                }
            } else {
                for i in 0..length {
                    self.buf[current + i] = self.buf[start + i];
                }
            }

@folkertdev folkertdev closed this Oct 9, 2024
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