Compare commits
4 Commits
b050361823
...
0c2af46a79
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c2af46a79 | |||
| 35c3e14586 | |||
| d60777002f | |||
| f7871915e9 |
@@ -84,9 +84,6 @@ check_cxx_source_compiles("int main(){}" HAS_VERSION_SCRIPT FAIL_REGEX
|
||||
"warning:")
|
||||
cmake_pop_check_state()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
add_compile_options(-mavx)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
add_link_options(LINKER:--gc-sections)
|
||||
endif()
|
||||
|
||||
@@ -396,27 +396,26 @@ inline PRESERVE_NONE WeaselJsonStatus n_string(Parser3 *self, char *buf,
|
||||
MUSTTAIL return Parser3::keepGoing(self, buf, bufEnd);
|
||||
}
|
||||
|
||||
inline PRESERVE_NONE WeaselJsonStatus n_string2(Parser3 *self, char *buf,
|
||||
char *bufEnd) {
|
||||
template <class V>
|
||||
PRESERVE_NONE WeaselJsonStatus n_string2_impl(Parser3 *self, char *buf,
|
||||
char *bufEnd) {
|
||||
const auto before = buf;
|
||||
|
||||
// Advance buf to the first "non-normal" character
|
||||
for (;;) {
|
||||
constexpr int kStride = 64;
|
||||
if (bufEnd - buf < kStride) [[unlikely]] {
|
||||
if (bufEnd - buf < V::lanes) [[unlikely]] {
|
||||
while (buf != bufEnd &&
|
||||
tables.stringByteMeaning[uint8_t(*buf)] == Tables::NORMAL) {
|
||||
++buf;
|
||||
}
|
||||
break;
|
||||
}
|
||||
using V = simd<int8_t, kStride>;
|
||||
auto v = V{(int8_t *)buf};
|
||||
int normal =
|
||||
(v != V::splat('"') & v != V::splat('\\') & v >= V::splat(0x20))
|
||||
.count_leading_nonzero_lanes();
|
||||
buf += normal;
|
||||
if (normal < kStride) {
|
||||
if (normal < V::lanes) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -485,6 +484,24 @@ inline PRESERVE_NONE WeaselJsonStatus n_string2(Parser3 *self, char *buf,
|
||||
}
|
||||
}
|
||||
|
||||
template WeaselJsonStatus
|
||||
n_string2_impl<simd<int8_t, 64, sse::Simd_x86_SSE>>(Parser3 *, char *, char *);
|
||||
|
||||
template __attribute__((target("avx2"))) WeaselJsonStatus
|
||||
n_string2_impl<simd<int8_t, 64, sse::Simd_x86_AVX2>>(Parser3 *, char *, char *);
|
||||
|
||||
__attribute__((target("default"))) inline PRESERVE_NONE WeaselJsonStatus
|
||||
n_string2(Parser3 *self, char *buf, char *bufEnd) {
|
||||
MUSTTAIL return n_string2_impl<simd<int8_t, 64, sse::Simd_x86_SSE>>(self, buf,
|
||||
bufEnd);
|
||||
}
|
||||
|
||||
__attribute__((target("avx2"))) inline PRESERVE_NONE WeaselJsonStatus
|
||||
n_string2(Parser3 *self, char *buf, char *bufEnd) {
|
||||
MUSTTAIL return n_string2_impl<simd<int8_t, 64, sse::Simd_x86_AVX2>>(
|
||||
self, buf, bufEnd);
|
||||
}
|
||||
|
||||
inline PRESERVE_NONE WeaselJsonStatus n_string_following_escape(Parser3 *self,
|
||||
char *buf,
|
||||
char *bufEnd) {
|
||||
|
||||
2748
src/simd.h
2748
src/simd.h
File diff suppressed because it is too large
Load Diff
@@ -262,7 +262,7 @@ TEST_CASE("bench3") {
|
||||
bench.batch(json.size());
|
||||
bench.unit("byte");
|
||||
auto *parser = WeaselJsonParser_create(1024, &c, nullptr);
|
||||
for (size_t stride = 1; stride <= json.size(); stride *= 2) {
|
||||
for (size_t stride = 128; stride <= json.size(); stride *= 2) {
|
||||
bench.run("parser3 (stride: " + std::to_string(stride) + ")", [&]() {
|
||||
auto copy = json;
|
||||
WeaselJsonParser_reset(parser);
|
||||
|
||||
Reference in New Issue
Block a user