Skip to content

Commit

Permalink
fix: x86 uinttest failed
Browse files Browse the repository at this point in the history
  • Loading branch information
xiegx94 committed Oct 9, 2023
1 parent d233a2e commit 1fa4f8c
Show file tree
Hide file tree
Showing 23 changed files with 51,067 additions and 50,477 deletions.
560 changes: 355 additions & 205 deletions internal/native/avx/native_subr_amd64.go

Large diffs are not rendered by default.

30,182 changes: 14,130 additions & 16,052 deletions internal/native/avx/native_text_amd64.go

Large diffs are not rendered by default.

594 changes: 379 additions & 215 deletions internal/native/avx2/native_subr_amd64.go

Large diffs are not rendered by default.

32,253 changes: 14,509 additions & 17,744 deletions internal/native/avx2/native_text_amd64.go

Large diffs are not rendered by default.

558 changes: 354 additions & 204 deletions internal/native/sse/native_subr_amd64.go

Large diffs are not rendered by default.

30,055 changes: 14,037 additions & 16,018 deletions internal/native/sse/native_text_amd64.go

Large diffs are not rendered by default.

854 changes: 854 additions & 0 deletions native/atof_eisel_lemire.c

Large diffs are not rendered by default.

503 changes: 503 additions & 0 deletions native/atof_native.c

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions native/f32toa.c

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions native/fastbytes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "native.h"

size_t lspace(const char *sp, size_t nb, size_t p) {
const char * ss = sp;

/* seek to `p` */
sp += p;
nb -= p;

/* likely to run into non-spaces within a few characters, try scalar code first */
#if USE_AVX2
__m256i space_tab = _mm256_setr_epi8(
'\x20', 0, 0, 0, 0, 0, 0, 0,
0, '\x09', '\x0A', 0, 0, '\x0D', 0, 0,
'\x20', 0, 0, 0, 0, 0, 0, 0,
0, '\x09', '\x0A', 0, 0, '\x0D', 0, 0
);

/* 32-byte loop */
while (likely(nb >= 32)) {
__m256i input = _mm256_loadu_si256((__m256i*)sp);
__m256i shuffle = _mm256_shuffle_epi8(space_tab, input);
__m256i result = _mm256_cmpeq_epi8(input, shuffle);
int32_t mask = _mm256_movemask_epi8(result);
if (mask != -1) {
return sp - ss + __builtin_ctzll(~(uint64_t)mask);
}
sp += 32;
nb -= 32;
}
#endif

/* remaining bytes, do with scalar code */
while (nb-- > 0) {
switch (*sp++) {
case ' ' : break;
case '\r' : break;
case '\n' : break;
case '\t' : break;
default : return sp - ss - 1;
}
}

/* all the characters are spaces */
return sp - ss;
}
Loading

0 comments on commit 1fa4f8c

Please sign in to comment.