Skip to content

Commit dd02f93

Browse files
committed
Update impl
1 parent 3997ecc commit dd02f93

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ name = "escape"
1313
path = "examples/escape.rs"
1414

1515
[features]
16-
force_aarch64_generic = [] # Force use of generic implementation on aarch64
16+
force_aarch64_neon = [] # Force use of neon implementation on aarch64
1717

1818
[[bench]]
1919
name = "escape"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Optimized SIMD routines for escaping JSON strings. This repository contains the
1010
1111
> [!NOTE]
1212
>
13-
> The `force_aarch64_generic` feature flag can be used to force use of the generic fallback on aarch64. This is useful for testing the generic fallback on aarch64 devices with smaller register numbers.
13+
> The `force_aarch64_neon` feature flag can be used to force use of the neon implementation on aarch64. This is useful for the benchmark.
1414
1515
## Benchmarks
1616

src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(target_arch = "x86_64")]
22
mod x86;
33

4-
#[cfg(all(target_arch = "aarch64", not(feature = "force_aarch64_generic")))]
4+
#[cfg(target_arch = "aarch64")]
55
mod aarch64;
66

77
const BB: u8 = b'b'; // \x08
@@ -150,19 +150,17 @@ pub fn escape<S: AsRef<str>>(input: S) -> String {
150150

151151
#[cfg(target_arch = "aarch64")]
152152
{
153-
use std::arch::is_aarch64_feature_detected;
154-
155-
#[cfg(feature = "force_aarch64_generic")]
153+
#[cfg(feature = "force_aarch64_neon")]
156154
{
157-
return escape_generic(input);
155+
return aarch64::escape_neon(input);
158156
}
159-
#[cfg(not(feature = "force_aarch64_generic"))]
157+
#[cfg(not(feature = "force_aarch64_neon"))]
160158
{
161159
// on Apple M2 and later, the `bf16` feature is available
162160
// it means they have more registers and can significantly benefit from the SIMD path
163161
// TODO: add support for sve2 chips with wider registers
164162
// github actions ubuntu-24.04-arm runner has 128 bits sve2 registers, it's not enough for the SIMD path
165-
if cfg!(target_os = "macos") && is_aarch64_feature_detected!("bf16") {
163+
if cfg!(target_os = "macos") && std::arch::is_aarch64_feature_detected!("bf16") {
166164
return aarch64::escape_neon(input);
167165
} else {
168166
return escape_generic(input);

0 commit comments

Comments
 (0)