diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-08-25 00:33:09 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-08-25 00:33:09 +0200 |
commit | 9799ae3f29197eb65508e398d59591c238e59d6b (patch) | |
tree | d94c825a416d2d03ba85ee545e3e74187bbca1f3 /c/simd-isascii | |
parent | e6d02a085533134ee6bf1bca862b03968a83b591 (diff) |
Use _mm512_set1_epi8()
Diffstat (limited to 'c/simd-isascii')
-rw-r--r-- | c/simd-isascii/isascii.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/c/simd-isascii/isascii.c b/c/simd-isascii/isascii.c index 612aa49..299894f 100644 --- a/c/simd-isascii/isascii.c +++ b/c/simd-isascii/isascii.c @@ -16,21 +16,10 @@ static const unsigned char *readfile(const char *, size_t *); -static const uint8_t charmsk[64] = { - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, -}; - bool strisascii(const unsigned char *s, size_t n) { - __m512i msk = _mm512_loadu_epi8(charmsk); + __m512i msk = _mm512_set1_epi8((char)(1 << 7)); while (n >= VECWDTH) { if (_mm512_test_epi8_mask(_mm512_loadu_epi8(s), msk) != 0) return false; @@ -69,12 +58,12 @@ main(int argc, char **argv) clock_t tmbeg = clock(); if (!strisascii(beg, len)) puts("Non-ASCII"); - printf("Elapsed time: %.3fs\n", (double)(clock() - tmbeg) / CLOCKS_PER_SEC); + printf("Elapsed time (AVX-512): %.3fs\n", (double)(clock() - tmbeg) / CLOCKS_PER_SEC); tmbeg = clock(); if (!strisascii_dumb((const unsigned char *)beg, len)) puts("Non-ASCII"); - printf("Elapsed time: %.3fs\n", (double)(clock() - tmbeg) / CLOCKS_PER_SEC); + printf("Elapsed time (Generic): %.3fs\n", (double)(clock() - tmbeg) / CLOCKS_PER_SEC); munmap((void *)beg, len); return rv; |