-
Notifications
You must be signed in to change notification settings - Fork 294
Restore cross checks, part 2: fix the Rust runtime and unit tests #1578
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
base: master
Are you sure you want to change the base?
Changes from all commits
3f1b2ed
4fdf3d9
9da5091
ba4fd5d
185abbc
5328e6f
e4cda87
332ba16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,11 +24,10 @@ impl Hasher for Djb2Hasher { | |
| self.0.into() | ||
| } | ||
|
|
||
| #[cfg(feature = "djb2-ssse3")] | ||
| #[cfg(target_feature = "ssse3")] | ||
| #[inline] | ||
| fn write(&mut self, bytes: &[u8]) { | ||
| use simd::u32x4; | ||
| use simd::x86::ssse3::Ssse3U32x4; | ||
| use core::simd::u32x4; | ||
|
|
||
| let mut u32_chunks = bytes.chunks(4); | ||
| let last_chunk = if bytes.len() % 4 != 0 { | ||
|
|
@@ -37,14 +36,15 @@ impl Hasher for Djb2Hasher { | |
| None | ||
| }; | ||
| self.0 = u32_chunks.fold(self.0, |h, cb| { | ||
| let cvec = u32x4::new(cb[0] as u32, cb[1] as u32, cb[2] as u32, cb[3] as u32); | ||
| let cvec = u32x4::from_array([cb[0] as u32, cb[1] as u32, cb[2] as u32, cb[3] as u32]); | ||
| // The djb2 factors: powers of 33 from 33^3 to 33^0 | ||
| const DJB2_FACTORS: u32x4 = u32x4::new(35937, 1089, 33, 1); | ||
| const DJB2_FACTORS: u32x4 = u32x4::from_array([35937, 1089, 33, 1]); | ||
| let cmul = cvec * DJB2_FACTORS; | ||
| let ch1 = Ssse3U32x4::hadd(cmul, cmul); | ||
| let ch2 = Ssse3U32x4::hadd(ch1, ch1); | ||
| let ch1 = unsafe { core::arch::x86_64::_mm_hadd_epi32(cmul.into(), cmul.into()) }; | ||
| let ch2 = unsafe { core::arch::x86_64::_mm_hadd_epi32(ch1, ch1) }; | ||
| let cval = unsafe { core::arch::x86_64::_mm_extract_epi32(ch2, 0) }; | ||
|
Comment on lines
+43
to
+45
Contributor
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. Do we need to worry about aarch64 portability here, or is this gated to x86[_64] only at a higher level?
Contributor
Author
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. This specific function is gated on the
Contributor
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. I don't think it's critical, was just curious what scaffolding we had in place here.
Contributor
Author
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. I switched to a |
||
| // h = h * 33^4 + ch2[0] | ||
| h.wrapping_mul(1185921u32).wrapping_add(ch2.extract(0)) | ||
| h.wrapping_mul(1185921u32).wrapping_add(cval as u32) | ||
| }); | ||
| // Add in the last 1-3 bytes manually | ||
| if let Some(last_bytes) = last_chunk { | ||
|
|
@@ -54,7 +54,7 @@ impl Hasher for Djb2Hasher { | |
| } | ||
| } | ||
|
|
||
| #[cfg(not(feature = "djb2-ssse3"))] | ||
| #[cfg(not(target_feature = "ssse3"))] | ||
| #[inline] | ||
| fn write(&mut self, bytes: &[u8]) { | ||
| self.0 = bytes | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.