Skip to content

Commit 3b27412

Browse files
committed
avx512 specific tests
1 parent 528713a commit 3b27412

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/tests.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ mod public_imp {
6969
#[allow(unused_variables)] // nothing to do if not SIMD implementation is available
7070
pub(super) fn test_valid(input: &[u8]) {
7171
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
72+
#[cfg(all(
73+
avx512_stable,
74+
target_feature = "avx512f",
75+
target_feature = "avx512bw",
76+
target_feature = "avx512vbmi",
77+
target_feature = "avx512vbmi2"
78+
))]
79+
unsafe {
80+
assert!(simdutf8::basic::imp::x86::avx512::validate_utf8(input).is_ok());
81+
assert!(simdutf8::compat::imp::x86::avx512::validate_utf8(input).is_ok());
82+
83+
test_streaming::<simdutf8::basic::imp::x86::avx512::Utf8ValidatorImp>(input, true);
84+
test_chunked_streaming::<simdutf8::basic::imp::x86::avx512::ChunkedUtf8ValidatorImp>(
85+
input, true,
86+
);
87+
}
88+
7289
#[cfg(target_feature = "avx2")]
7390
unsafe {
7491
assert!(simdutf8::basic::imp::x86::avx2::validate_utf8(input).is_ok());
@@ -138,6 +155,24 @@ mod public_imp {
138155
#[allow(unused_variables)] // nothing to do if not SIMD implementation is available
139156
pub(super) fn test_invalid(input: &[u8], valid_up_to: usize, error_len: Option<usize>) {
140157
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
158+
#[cfg(all(
159+
avx512_stable,
160+
target_feature = "avx512f",
161+
target_feature = "avx512bw",
162+
target_feature = "avx512vbmi",
163+
target_feature = "avx512vbmi2"
164+
))]
165+
unsafe {
166+
assert!(simdutf8::basic::imp::x86::avx512::validate_utf8(input).is_err());
167+
let err = simdutf8::compat::imp::x86::avx512::validate_utf8(input).unwrap_err();
168+
assert_eq!(err.valid_up_to(), valid_up_to);
169+
assert_eq!(err.error_len(), error_len);
170+
171+
test_streaming::<simdutf8::basic::imp::x86::avx512::Utf8ValidatorImp>(input, false);
172+
test_chunked_streaming::<simdutf8::basic::imp::x86::avx512::ChunkedUtf8ValidatorImp>(
173+
input, false,
174+
);
175+
}
141176
#[cfg(target_feature = "avx2")]
142177
unsafe {
143178
assert!(simdutf8::basic::imp::x86::avx2::validate_utf8(input).is_err());
@@ -268,6 +303,24 @@ mod public_imp {
268303
}
269304
}
270305

306+
#[test]
307+
#[should_panic]
308+
#[cfg(all(
309+
any(target_arch = "x86", target_arch = "x86_64"),
310+
all(
311+
avx512_stable,
312+
target_feature = "avx512f",
313+
target_feature = "avx512bw",
314+
target_feature = "avx512vbmi",
315+
target_feature = "avx512vbmi2"
316+
)
317+
))]
318+
fn test_avx2_chunked_panic() {
319+
test_chunked_streaming_with_chunk_size::<
320+
simdutf8::basic::imp::x86::avx512::ChunkedUtf8ValidatorImp,
321+
>(b"abcd", 1, true);
322+
}
323+
271324
#[test]
272325
#[should_panic]
273326
#[cfg(all(

0 commit comments

Comments
 (0)