mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e777c1759 | |||
| a410c723c8 | |||
| f91a1ae07e |
+1
-1
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
|
|||||||
project(
|
project(
|
||||||
simdjson
|
simdjson
|
||||||
# The version number is modified by tools/release.py
|
# The version number is modified by tools/release.py
|
||||||
VERSION 2.0.0
|
VERSION 2.0.2
|
||||||
DESCRIPTION "Parsing gigabytes of JSON per second"
|
DESCRIPTION "Parsing gigabytes of JSON per second"
|
||||||
HOMEPAGE_URL "https://simdjson.org/"
|
HOMEPAGE_URL "https://simdjson.org/"
|
||||||
LANGUAGES CXX C
|
LANGUAGES CXX C
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ PROJECT_NAME = simdjson
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = "2.0.0"
|
PROJECT_NUMBER = "2.0.2"
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define __BENCHMARKER_H
|
#define __BENCHMARKER_H
|
||||||
|
|
||||||
#include "event_counter.h"
|
#include "event_counter.h"
|
||||||
#include "simdjson.h" // For SIMDJSON_DISABLE_DEPRECATED_WARNINGS
|
#include "simdjson.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
|
|
||||||
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
||||||
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
||||||
|
// We do it separately for clang since it has different warnings.
|
||||||
|
#ifdef __clang__
|
||||||
|
// clang is missing -Wmaybe-uninitialized.
|
||||||
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
@@ -134,6 +137,22 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
||||||
|
#else // __clang__
|
||||||
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wconversion) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wmaybe-uninitialized)
|
||||||
|
#endif // __clang__
|
||||||
|
|
||||||
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
||||||
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
||||||
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
||||||
|
|||||||
@@ -3,6 +3,32 @@
|
|||||||
|
|
||||||
#include "simdjson/internal/simdprune_tables.h"
|
#include "simdjson/internal/simdprune_tables.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#if __GNUC__ == 8
|
||||||
|
#define SIMDJSON_GCC8 1
|
||||||
|
#endif // __GNUC__ == 8
|
||||||
|
#endif // defined(__GNUC__) && !defined(__clang__)
|
||||||
|
|
||||||
|
#if SIMDJSON_GCC8
|
||||||
|
/**
|
||||||
|
* GCC 8 fails to provide _mm512_set_epi8. We roll our own.
|
||||||
|
*/
|
||||||
|
inline __m512i _mm512_set_epi8(uint8_t a0, uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6, uint8_t a7, uint8_t a8, uint8_t a9, uint8_t a10, uint8_t a11, uint8_t a12, uint8_t a13, uint8_t a14, uint8_t a15, uint8_t a16, uint8_t a17, uint8_t a18, uint8_t a19, uint8_t a20, uint8_t a21, uint8_t a22, uint8_t a23, uint8_t a24, uint8_t a25, uint8_t a26, uint8_t a27, uint8_t a28, uint8_t a29, uint8_t a30, uint8_t a31, uint8_t a32, uint8_t a33, uint8_t a34, uint8_t a35, uint8_t a36, uint8_t a37, uint8_t a38, uint8_t a39, uint8_t a40, uint8_t a41, uint8_t a42, uint8_t a43, uint8_t a44, uint8_t a45, uint8_t a46, uint8_t a47, uint8_t a48, uint8_t a49, uint8_t a50, uint8_t a51, uint8_t a52, uint8_t a53, uint8_t a54, uint8_t a55, uint8_t a56, uint8_t a57, uint8_t a58, uint8_t a59, uint8_t a60, uint8_t a61, uint8_t a62, uint8_t a63) {
|
||||||
|
return _mm512_set_epi64(uint64_t(a7) + (uint64_t(a6) << 8) + (uint64_t(a5) << 16) + (uint64_t(a4) << 24) + (uint64_t(a3) << 32) + (uint64_t(a2) << 40) + (uint64_t(a1) << 48) + (uint64_t(a0) << 56),
|
||||||
|
uint64_t(a15) + (uint64_t(a14) << 8) + (uint64_t(a13) << 16) + (uint64_t(a12) << 24) + (uint64_t(a11) << 32) + (uint64_t(a10) << 40) + (uint64_t(a9) << 48) + (uint64_t(a8) << 56),
|
||||||
|
uint64_t(a23) + (uint64_t(a22) << 8) + (uint64_t(a21) << 16) + (uint64_t(a20) << 24) + (uint64_t(a19) << 32) + (uint64_t(a18) << 40) + (uint64_t(a17) << 48) + (uint64_t(a16) << 56),
|
||||||
|
uint64_t(a31) + (uint64_t(a30) << 8) + (uint64_t(a29) << 16) + (uint64_t(a28) << 24) + (uint64_t(a27) << 32) + (uint64_t(a26) << 40) + (uint64_t(a25) << 48) + (uint64_t(a24) << 56),
|
||||||
|
uint64_t(a39) + (uint64_t(a38) << 8) + (uint64_t(a37) << 16) + (uint64_t(a36) << 24) + (uint64_t(a35) << 32) + (uint64_t(a34) << 40) + (uint64_t(a33) << 48) + (uint64_t(a32) << 56),
|
||||||
|
uint64_t(a47) + (uint64_t(a46) << 8) + (uint64_t(a45) << 16) + (uint64_t(a44) << 24) + (uint64_t(a43) << 32) + (uint64_t(a42) << 40) + (uint64_t(a41) << 48) + (uint64_t(a40) << 56),
|
||||||
|
uint64_t(a55) + (uint64_t(a54) << 8) + (uint64_t(a53) << 16) + (uint64_t(a52) << 24) + (uint64_t(a51) << 32) + (uint64_t(a50) << 40) + (uint64_t(a49) << 48) + (uint64_t(a48) << 56),
|
||||||
|
uint64_t(a63) + (uint64_t(a62) << 8) + (uint64_t(a61) << 16) + (uint64_t(a60) << 24) + (uint64_t(a59) << 32) + (uint64_t(a58) << 40) + (uint64_t(a57) << 48) + (uint64_t(a56) << 56));
|
||||||
|
}
|
||||||
|
#endif // SIMDJSON_GCC8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
namespace SIMDJSON_IMPLEMENTATION {
|
namespace SIMDJSON_IMPLEMENTATION {
|
||||||
namespace {
|
namespace {
|
||||||
@@ -51,7 +77,13 @@ namespace simd {
|
|||||||
|
|
||||||
template<int N=1>
|
template<int N=1>
|
||||||
simdjson_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
|
simdjson_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
|
||||||
|
#if SIMDJSON_GCC8
|
||||||
|
// workaround for compilers unable to figure out that 16 - N is a constant (GCC 8)
|
||||||
|
constexpr int shift = 16 - N;
|
||||||
|
return _mm512_alignr_epi8(*this, _mm512_permutex2var_epi64(prev_chunk, _mm512_set_epi64(13, 12, 11, 10, 9, 8, 7, 6), *this), shift);
|
||||||
|
#else
|
||||||
return _mm512_alignr_epi8(*this, _mm512_permutex2var_epi64(prev_chunk, _mm512_set_epi64(13, 12, 11, 10, 9, 8, 7, 6), *this), 16 - N);
|
return _mm512_alignr_epi8(*this, _mm512_permutex2var_epi64(prev_chunk, _mm512_set_epi64(13, 12, 11, 10, 9, 8, 7, 6), *this), 16 - N);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// By default, we allow AVX512.
|
||||||
|
#ifndef SIMDJSON_AVX512_ALLOWED
|
||||||
|
#define SIMDJSON_AVX512_ALLOWED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
||||||
// at runtime.
|
// at runtime.
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||||
|
|
||||||
/** The version of simdjson being used (major.minor.revision) */
|
/** The version of simdjson being used (major.minor.revision) */
|
||||||
#define SIMDJSON_VERSION 2.0.0
|
#define SIMDJSON_VERSION 2.0.2
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
enum {
|
enum {
|
||||||
@@ -19,7 +19,7 @@ enum {
|
|||||||
/**
|
/**
|
||||||
* The revision (major.minor.REVISION) of simdjson being used.
|
* The revision (major.minor.REVISION) of simdjson being used.
|
||||||
*/
|
*/
|
||||||
SIMDJSON_VERSION_REVISION = 0
|
SIMDJSON_VERSION_REVISION = 2
|
||||||
};
|
};
|
||||||
} // namespace simdjson
|
} // namespace simdjson
|
||||||
|
|
||||||
|
|||||||
@@ -81,8 +81,10 @@ def dofile(fid, prepath, filename):
|
|||||||
# print(f"// dofile: invoked with prepath={prepath}, filename={filename}",file=fid)
|
# print(f"// dofile: invoked with prepath={prepath}, filename={filename}",file=fid)
|
||||||
file = os.path.join(prepath, filename)
|
file = os.path.join(prepath, filename)
|
||||||
RELFILE = os.path.relpath(file, PROJECTPATH)
|
RELFILE = os.path.relpath(file, PROJECTPATH)
|
||||||
|
# Windows use \ as a directory separator, but we do not want that:
|
||||||
|
OSRELFILE = RELFILE.replace('\\','/')
|
||||||
# Last lines are always ignored. Files should end by an empty lines.
|
# Last lines are always ignored. Files should end by an empty lines.
|
||||||
print(f"/* begin file {RELFILE} */", file=fid)
|
print(f"/* begin file {OSRELFILE} */", file=fid)
|
||||||
includepattern = re.compile('^#include "(.*)"')
|
includepattern = re.compile('^#include "(.*)"')
|
||||||
redefines_simdjson_implementation = re.compile('^#define\s+SIMDJSON_IMPLEMENTATION\s+(.*)')
|
redefines_simdjson_implementation = re.compile('^#define\s+SIMDJSON_IMPLEMENTATION\s+(.*)')
|
||||||
undefines_simdjson_implementation = re.compile('^#undef\s+SIMDJSON_IMPLEMENTATION\s*$')
|
undefines_simdjson_implementation = re.compile('^#undef\s+SIMDJSON_IMPLEMENTATION\s*$')
|
||||||
@@ -114,7 +116,7 @@ def dofile(fid, prepath, filename):
|
|||||||
else:
|
else:
|
||||||
# copy the line, with SIMDJSON_IMPLEMENTATION replace to what it is currently defined to
|
# copy the line, with SIMDJSON_IMPLEMENTATION replace to what it is currently defined to
|
||||||
print(uses_simdjson_implementation.sub(current_implementation+"\\1",line), file=fid)
|
print(uses_simdjson_implementation.sub(current_implementation+"\\1",line), file=fid)
|
||||||
print(f"/* end file {RELFILE} */", file=fid)
|
print(f"/* end file {OSRELFILE} */", file=fid)
|
||||||
|
|
||||||
|
|
||||||
# Get the generation date from git, so the output is reproducible.
|
# Get the generation date from git, so the output is reproducible.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* auto-generated on 2022-05-25 11:24:40 -0400. Do not edit! */
|
/* auto-generated on 2022-06-01 16:39:41 -0400. Do not edit! */
|
||||||
/* begin file src/simdjson.cpp */
|
/* begin file src/simdjson.cpp */
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
|
|
||||||
@@ -7589,6 +7589,9 @@ simdjson_really_inline error_code json_structural_indexer::finish(dom_parser_imp
|
|||||||
* naked intrinsics.
|
* naked intrinsics.
|
||||||
* TODO: make this code more elegant.
|
* TODO: make this code more elegant.
|
||||||
*/
|
*/
|
||||||
|
// Under GCC 12, the intrinsic _mm512_extracti32x4_epi32 may generate 'maybe uninitialized'.
|
||||||
|
// as a workaround, we disable warnings within the following function.
|
||||||
|
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||||
namespace simdjson { namespace icelake { namespace { namespace stage1 {
|
namespace simdjson { namespace icelake { namespace { namespace stage1 {
|
||||||
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
||||||
// In some instances, the next branch is expensive because it is mispredicted.
|
// In some instances, the next branch is expensive because it is mispredicted.
|
||||||
@@ -7623,6 +7626,7 @@ simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
|||||||
this->tail += count;
|
this->tail += count;
|
||||||
}
|
}
|
||||||
}}}}
|
}}}}
|
||||||
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
/* begin file src/generic/stage1/utf8_validator.h */
|
/* begin file src/generic/stage1/utf8_validator.h */
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
|
|||||||
+59
-3
@@ -1,4 +1,4 @@
|
|||||||
/* auto-generated on 2022-05-25 11:24:40 -0400. Do not edit! */
|
/* auto-generated on 2022-06-01 16:39:41 -0400. Do not edit! */
|
||||||
/* begin file include/simdjson.h */
|
/* begin file include/simdjson.h */
|
||||||
#ifndef SIMDJSON_H
|
#ifndef SIMDJSON_H
|
||||||
#define SIMDJSON_H
|
#define SIMDJSON_H
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||||
|
|
||||||
/** The version of simdjson being used (major.minor.revision) */
|
/** The version of simdjson being used (major.minor.revision) */
|
||||||
#define SIMDJSON_VERSION 2.0.0
|
#define SIMDJSON_VERSION 2.0.2
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
enum {
|
enum {
|
||||||
@@ -58,7 +58,7 @@ enum {
|
|||||||
/**
|
/**
|
||||||
* The revision (major.minor.REVISION) of simdjson being used.
|
* The revision (major.minor.REVISION) of simdjson being used.
|
||||||
*/
|
*/
|
||||||
SIMDJSON_VERSION_REVISION = 0
|
SIMDJSON_VERSION_REVISION = 2
|
||||||
};
|
};
|
||||||
} // namespace simdjson
|
} // namespace simdjson
|
||||||
|
|
||||||
@@ -414,6 +414,9 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
|
|
||||||
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
||||||
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
||||||
|
// We do it separately for clang since it has different warnings.
|
||||||
|
#ifdef __clang__
|
||||||
|
// clang is missing -Wmaybe-uninitialized.
|
||||||
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
@@ -426,6 +429,22 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
||||||
|
#else // __clang__
|
||||||
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wconversion) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wmaybe-uninitialized)
|
||||||
|
#endif // __clang__
|
||||||
|
|
||||||
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
||||||
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
||||||
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
||||||
@@ -9482,6 +9501,11 @@ extern SIMDJSON_DLLIMPORTEXPORT const uint64_t thintable_epi8[256];
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// By default, we allow AVX512.
|
||||||
|
#ifndef SIMDJSON_AVX512_ALLOWED
|
||||||
|
#define SIMDJSON_AVX512_ALLOWED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
||||||
// at runtime.
|
// at runtime.
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
||||||
@@ -14146,6 +14170,32 @@ simdjson_really_inline uint64_t prefix_xor(const uint64_t bitmask) {
|
|||||||
#define SIMDJSON_ICELAKE_SIMD_H
|
#define SIMDJSON_ICELAKE_SIMD_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#if __GNUC__ == 8
|
||||||
|
#define SIMDJSON_GCC8 1
|
||||||
|
#endif // __GNUC__ == 8
|
||||||
|
#endif // defined(__GNUC__) && !defined(__clang__)
|
||||||
|
|
||||||
|
#if SIMDJSON_GCC8
|
||||||
|
/**
|
||||||
|
* GCC 8 fails to provide _mm512_set_epi8. We roll our own.
|
||||||
|
*/
|
||||||
|
inline __m512i _mm512_set_epi8(uint8_t a0, uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6, uint8_t a7, uint8_t a8, uint8_t a9, uint8_t a10, uint8_t a11, uint8_t a12, uint8_t a13, uint8_t a14, uint8_t a15, uint8_t a16, uint8_t a17, uint8_t a18, uint8_t a19, uint8_t a20, uint8_t a21, uint8_t a22, uint8_t a23, uint8_t a24, uint8_t a25, uint8_t a26, uint8_t a27, uint8_t a28, uint8_t a29, uint8_t a30, uint8_t a31, uint8_t a32, uint8_t a33, uint8_t a34, uint8_t a35, uint8_t a36, uint8_t a37, uint8_t a38, uint8_t a39, uint8_t a40, uint8_t a41, uint8_t a42, uint8_t a43, uint8_t a44, uint8_t a45, uint8_t a46, uint8_t a47, uint8_t a48, uint8_t a49, uint8_t a50, uint8_t a51, uint8_t a52, uint8_t a53, uint8_t a54, uint8_t a55, uint8_t a56, uint8_t a57, uint8_t a58, uint8_t a59, uint8_t a60, uint8_t a61, uint8_t a62, uint8_t a63) {
|
||||||
|
return _mm512_set_epi64(uint64_t(a7) + (uint64_t(a6) << 8) + (uint64_t(a5) << 16) + (uint64_t(a4) << 24) + (uint64_t(a3) << 32) + (uint64_t(a2) << 40) + (uint64_t(a1) << 48) + (uint64_t(a0) << 56),
|
||||||
|
uint64_t(a15) + (uint64_t(a14) << 8) + (uint64_t(a13) << 16) + (uint64_t(a12) << 24) + (uint64_t(a11) << 32) + (uint64_t(a10) << 40) + (uint64_t(a9) << 48) + (uint64_t(a8) << 56),
|
||||||
|
uint64_t(a23) + (uint64_t(a22) << 8) + (uint64_t(a21) << 16) + (uint64_t(a20) << 24) + (uint64_t(a19) << 32) + (uint64_t(a18) << 40) + (uint64_t(a17) << 48) + (uint64_t(a16) << 56),
|
||||||
|
uint64_t(a31) + (uint64_t(a30) << 8) + (uint64_t(a29) << 16) + (uint64_t(a28) << 24) + (uint64_t(a27) << 32) + (uint64_t(a26) << 40) + (uint64_t(a25) << 48) + (uint64_t(a24) << 56),
|
||||||
|
uint64_t(a39) + (uint64_t(a38) << 8) + (uint64_t(a37) << 16) + (uint64_t(a36) << 24) + (uint64_t(a35) << 32) + (uint64_t(a34) << 40) + (uint64_t(a33) << 48) + (uint64_t(a32) << 56),
|
||||||
|
uint64_t(a47) + (uint64_t(a46) << 8) + (uint64_t(a45) << 16) + (uint64_t(a44) << 24) + (uint64_t(a43) << 32) + (uint64_t(a42) << 40) + (uint64_t(a41) << 48) + (uint64_t(a40) << 56),
|
||||||
|
uint64_t(a55) + (uint64_t(a54) << 8) + (uint64_t(a53) << 16) + (uint64_t(a52) << 24) + (uint64_t(a51) << 32) + (uint64_t(a50) << 40) + (uint64_t(a49) << 48) + (uint64_t(a48) << 56),
|
||||||
|
uint64_t(a63) + (uint64_t(a62) << 8) + (uint64_t(a61) << 16) + (uint64_t(a60) << 24) + (uint64_t(a59) << 32) + (uint64_t(a58) << 40) + (uint64_t(a57) << 48) + (uint64_t(a56) << 56));
|
||||||
|
}
|
||||||
|
#endif // SIMDJSON_GCC8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
namespace icelake {
|
namespace icelake {
|
||||||
namespace {
|
namespace {
|
||||||
@@ -14194,7 +14244,13 @@ namespace simd {
|
|||||||
|
|
||||||
template<int N=1>
|
template<int N=1>
|
||||||
simdjson_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
|
simdjson_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
|
||||||
|
#if SIMDJSON_GCC8
|
||||||
|
// workaround for compilers unable to figure out that 16 - N is a constant (GCC 8)
|
||||||
|
constexpr int shift = 16 - N;
|
||||||
|
return _mm512_alignr_epi8(*this, _mm512_permutex2var_epi64(prev_chunk, _mm512_set_epi64(13, 12, 11, 10, 9, 8, 7, 6), *this), shift);
|
||||||
|
#else
|
||||||
return _mm512_alignr_epi8(*this, _mm512_permutex2var_epi64(prev_chunk, _mm512_set_epi64(13, 12, 11, 10, 9, 8, 7, 6), *this), 16 - N);
|
return _mm512_alignr_epi8(*this, _mm512_permutex2var_epi64(prev_chunk, _mm512_set_epi64(13, 12, 11, 10, 9, 8, 7, 6), *this), 16 - N);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ simdjson_really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t>
|
|||||||
* naked intrinsics.
|
* naked intrinsics.
|
||||||
* TODO: make this code more elegant.
|
* TODO: make this code more elegant.
|
||||||
*/
|
*/
|
||||||
|
// Under GCC 12, the intrinsic _mm512_extracti32x4_epi32 may generate 'maybe uninitialized'.
|
||||||
|
// as a workaround, we disable warnings within the following function.
|
||||||
|
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||||
namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { namespace { namespace stage1 {
|
namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { namespace { namespace stage1 {
|
||||||
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
||||||
// In some instances, the next branch is expensive because it is mispredicted.
|
// In some instances, the next branch is expensive because it is mispredicted.
|
||||||
@@ -148,6 +151,7 @@ simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
|||||||
this->tail += count;
|
this->tail += count;
|
||||||
}
|
}
|
||||||
}}}}
|
}}}}
|
||||||
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
#include "generic/stage1/utf8_validator.h"
|
#include "generic/stage1/utf8_validator.h"
|
||||||
|
|
||||||
|
|||||||
+30
-1
@@ -1,3 +1,4 @@
|
|||||||
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
|
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -38,6 +39,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
}
|
}
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("a,arch", ss.str(), cxxopts::value<std::string>())
|
("a,arch", ss.str(), cxxopts::value<std::string>())
|
||||||
|
("t,timing", "Report only timing.")
|
||||||
("f,file", "File name.", cxxopts::value<std::string>())
|
("f,file", "File name.", cxxopts::value<std::string>())
|
||||||
("h,help", "Print usage.")
|
("h,help", "Print usage.")
|
||||||
;
|
;
|
||||||
@@ -79,7 +81,34 @@ int main(int argc, const char *argv[]) {
|
|||||||
size_t copy_len;
|
size_t copy_len;
|
||||||
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
||||||
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
||||||
printf("%s", copy.data());
|
/**
|
||||||
|
* If a user only wants to time the required time, we do not output
|
||||||
|
* the result and we simply do the processing in a tight loop.
|
||||||
|
* At this point in time, we can assume that the processing will
|
||||||
|
* succeed.
|
||||||
|
*/
|
||||||
|
if(result.count("timing")) {
|
||||||
|
uint64_t beforens = std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
|
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
||||||
|
uint64_t afterns = std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
|
size_t times = 1;
|
||||||
|
while(afterns - beforens < 1000000000) {
|
||||||
|
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
||||||
|
afterns = std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
|
times += 1;
|
||||||
|
}
|
||||||
|
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
||||||
|
printf("%.3f GB/s\n", double(p.length() * times) / double(afterns - beforens));
|
||||||
|
} else {
|
||||||
|
// This is the expected path:
|
||||||
|
printf("%s", copy.data());
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
#ifdef __cpp_exceptions
|
#ifdef __cpp_exceptions
|
||||||
} catch (const cxxopts::OptionException& e) {
|
} catch (const cxxopts::OptionException& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user