Skip to content

Commit

Permalink
128 only
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Feb 3, 2024
1 parent e205c6e commit 379e796
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 33 deletions.
21 changes: 6 additions & 15 deletions src/serialize/writer/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,21 +603,12 @@ where
let num_reserved_bytes = value.len() * 8 + 32 + 3;
writer.reserve(num_reserved_bytes);

if std::is_x86_feature_detected!("avx2") {
let written = crate::serialize::writer::simd::format_escaped_str_impl_256(
writer.as_mut_buffer_ptr(),
value.as_bytes().as_ptr(),
value.len(),
);
writer.set_written(written);
} else {
let written = crate::serialize::writer::simd::format_escaped_str_impl_128(
writer.as_mut_buffer_ptr(),
value.as_bytes().as_ptr(),
value.len(),
);
writer.set_written(written);
}
let written = crate::serialize::writer::simd::format_escaped_str_impl_128(
writer.as_mut_buffer_ptr(),
value.as_bytes().as_ptr(),
value.len(),
);
writer.set_written(written);
}
Ok(())
}
Expand Down
18 changes: 0 additions & 18 deletions src/serialize/writer/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ macro_rules! impl_format_simd {
}

#[inline(never)]
#[cfg(not(target_feature = "avx2"))]
#[cfg_attr(target_arch = "x86_64", cold)]
pub unsafe fn format_escaped_str_impl_128(
odptr: *mut u8,
value_ptr: *const u8,
Expand All @@ -131,19 +129,3 @@ pub unsafe fn format_escaped_str_impl_128(

impl_format_simd!(odptr, value_ptr, value_len);
}

#[cfg(target_arch = "x86_64")]
#[inline(never)]
#[cfg_attr(not(target_feature = "avx2"), target_feature(enable = "avx2"))]
#[cfg_attr(not(target_feature = "avx2"), target_feature(enable = "bmi2"))]
pub unsafe fn format_escaped_str_impl_256(
odptr: *mut u8,
value_ptr: *const u8,
value_len: usize,
) -> usize {
const STRIDE: usize = 32;
const STRIDE_SATURATION: u32 = u32::MAX;
type StrVector = std::simd::u8x32;

impl_format_simd!(odptr, value_ptr, value_len);
}

0 comments on commit 379e796

Please sign in to comment.