Add fallback implementation to CI
- Also add SIMDJSON_IMPLEMENTATION_HASWELL/WESTMERE/ARM64/FALLBACK=1/0 to enable/disable various implemnentations
This commit is contained in:
parent
af203aaf86
commit
7cf3a7511b
|
@ -511,7 +511,7 @@ steps:
|
|||
environment:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_DISABLE_AVX=ON
|
||||
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION_HASWELL=OFF
|
||||
commands:
|
||||
- apt-get update -qq
|
||||
- apt-get install -y clang make cmake
|
||||
|
@ -534,7 +534,7 @@ steps:
|
|||
environment:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_DISABLE_AVX=ON
|
||||
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION_HASWELL=OFF
|
||||
commands:
|
||||
- apt-get update -qq
|
||||
- apt-get install -y cmake
|
||||
|
|
|
@ -77,7 +77,8 @@ objs
|
|||
/get_corpus_benchmark
|
||||
/json2json
|
||||
/jsoncheck
|
||||
/jsoncheck_noavx
|
||||
/jsoncheck_westmere
|
||||
/jsoncheck_fallback
|
||||
/jsonpointer
|
||||
/jsonstats
|
||||
/integer_tests
|
||||
|
|
|
@ -31,7 +31,10 @@ set(PROJECT_VERSION_PATCH 1)
|
|||
set(SIMDJSON_LIB_VERSION "0.2.1" CACHE STRING "simdjson library version")
|
||||
set(SIMDJSON_LIB_SOVERSION "0" CACHE STRING "simdjson library soversion")
|
||||
|
||||
option(SIMDJSON_DISABLE_AVX "Forcefully disable AVX even if hardware supports it" OFF)
|
||||
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
|
||||
option(SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON)
|
||||
option(SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON)
|
||||
option(SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON)
|
||||
if(NOT MSVC)
|
||||
option(SIMDJSON_BUILD_STATIC "Build a static library" OFF) # turning it on disables the production of a dynamic library
|
||||
else()
|
||||
|
|
24
Makefile
24
Makefile
|
@ -61,7 +61,7 @@ endif # ifeq ($(MEMSANITIZE),1)
|
|||
SRCHEADERS_GENERIC=src/generic/atomparsing.h src/generic/numberparsing.h src/generic/stage1_find_marks.h src/generic/stage2_build_tape.h src/generic/stringparsing.h src/generic/stage2_streaming_build_tape.h src/generic/utf8_fastvalidate_algorithm.h src/generic/utf8_lookup_algorithm.h src/generic/utf8_lookup2_algorithm.h src/generic/utf8_range_algorithm.h src/generic/utf8_zwegner_algorithm.h
|
||||
SRCHEADERS_ARM64= src/arm64/bitmanipulation.h src/arm64/bitmask.h src/arm64/intrinsics.h src/arm64/numberparsing.h src/arm64/simd.h src/arm64/stage1_find_marks.h src/arm64/stage2_build_tape.h src/arm64/stringparsing.h
|
||||
SRCHEADERS_HASWELL= src/haswell/bitmanipulation.h src/haswell/bitmask.h src/haswell/intrinsics.h src/haswell/numberparsing.h src/haswell/simd.h src/haswell/stage1_find_marks.h src/haswell/stage2_build_tape.h src/haswell/stringparsing.h
|
||||
SRCHEADERS_FALLBACK= src/fallback/implementation.h src/fallback/stage1_find_marks.h src/fallback/stage2_build_tape.h
|
||||
SRCHEADERS_FALLBACK= src/fallback/bitmanipulation.h src/fallback/implementation.h src/fallback/numberparsing.h src/fallback/stage1_find_marks.h src/fallback/stage2_build_tape.h src/fallback/stringparsing.h
|
||||
SRCHEADERS_WESTMERE=src/westmere/bitmanipulation.h src/westmere/bitmask.h src/westmere/intrinsics.h src/westmere/numberparsing.h src/westmere/simd.h src/westmere/stage1_find_marks.h src/westmere/stage2_build_tape.h src/westmere/stringparsing.h
|
||||
SRCHEADERS_SRC=src/isadetection.h src/jsoncharutils.h src/simdprune_tables.h src/implementation.cpp src/stage1_find_marks.cpp src/stage2_build_tape.cpp src/document_parser_callbacks.h
|
||||
SRCHEADERS=$(SRCHEADERS_SRC) $(SRCHEADERS_GENERIC) $(SRCHEADERS_ARM64) $(SRCHEADERS_HASWELL) $(SRCHEADERS_WESTMERE) $(SRCHEADERS_FALLBACK)
|
||||
|
@ -96,7 +96,7 @@ JSON_INCLUDE:=dependencies/json/single_include/nlohmann/json.hpp
|
|||
EXTRAOBJECTS=ujdecode.o
|
||||
|
||||
MAINEXECUTABLES=parse minify json2json jsonstats statisticalmodel jsonpointer get_corpus_benchmark
|
||||
TESTEXECUTABLES=jsoncheck jsoncheck_noavx integer_tests numberparsingcheck stringparsingcheck pointercheck parse_many_test basictests errortests readme_examples
|
||||
TESTEXECUTABLES=jsoncheck jsoncheck_westmere jsoncheck_fallback integer_tests numberparsingcheck stringparsingcheck pointercheck parse_many_test basictests errortests readme_examples
|
||||
COMPARISONEXECUTABLES=minifiercompetition parsingcompetition parseandstatcompetition distinctuseridcompetition allparserscheckfile allparsingcompetition
|
||||
SUPPLEMENTARYEXECUTABLES=parse_noutf8validation parse_nonumberparsing parse_nostringparsing
|
||||
|
||||
|
@ -134,8 +134,11 @@ run_jsoncheck: jsoncheck
|
|||
run_parse_many_test: parse_many_test
|
||||
./parse_many_test
|
||||
|
||||
run_jsoncheck_noavx: jsoncheck_noavx
|
||||
./jsoncheck_noavx
|
||||
run_jsoncheck_westmere: jsoncheck_westmere
|
||||
./jsoncheck_westmere
|
||||
|
||||
run_jsoncheck_fallback: jsoncheck_fallback
|
||||
./jsoncheck_fallback
|
||||
|
||||
run_pointercheck: pointercheck
|
||||
./pointercheck
|
||||
|
@ -152,12 +155,12 @@ $(FEATURE_JSON_FILES): benchmark/genfeaturejson.rb
|
|||
run_benchfeatures: benchfeatures $(FEATURE_JSON_FILES)
|
||||
./benchfeatures -n 1000
|
||||
|
||||
test: run_basictests run_readme_examples run_jsoncheck run_numberparsingcheck run_integer_tests run_stringparsingcheck run_parse_many_test run_pointercheck run_testjson2json_sh run_issue150_sh run_jsoncheck_noavx
|
||||
test: run_basictests run_readme_examples run_jsoncheck run_numberparsingcheck run_integer_tests run_stringparsingcheck run_parse_many_test run_pointercheck run_testjson2json_sh run_issue150_sh run_jsoncheck_westmere run_jsoncheck_fallback
|
||||
@echo "It looks like the code is good!"
|
||||
|
||||
quiettest: run_basictests run_readme_examples run_jsoncheck run_numberparsingcheck run_integer_tests run_stringparsingcheck run_jsoncheck run_parse_many_test run_pointercheck run_testjson2json_sh run_issue150_sh run_jsoncheck_noavx
|
||||
quiettest: run_basictests run_readme_examples run_jsoncheck run_numberparsingcheck run_integer_tests run_stringparsingcheck run_jsoncheck run_parse_many_test run_pointercheck run_testjson2json_sh run_issue150_sh run_jsoncheck_westmere run_jsoncheck_fallback
|
||||
|
||||
quicktests: run_basictests run_readme_examples run_jsoncheck run_numberparsingcheck run_integer_tests run_stringparsingcheck run_jsoncheck run_parse_many_test run_pointercheck run_jsoncheck_noavx
|
||||
quicktests: run_basictests run_readme_examples run_jsoncheck run_numberparsingcheck run_integer_tests run_stringparsingcheck run_jsoncheck run_parse_many_test run_pointercheck run_jsoncheck_westmere run_jsoncheck_fallback
|
||||
|
||||
slowtests: run_testjson2json_sh run_issue150_sh
|
||||
|
||||
|
@ -215,8 +218,11 @@ parse_many_test:tests/parse_many_test.cpp $(HEADERS) $(LIBFILES)
|
|||
$(CXX) $(CXXFLAGS) -o parse_many_test tests/parse_many_test.cpp -I. $(LIBFILES) $(LIBFLAGS)
|
||||
|
||||
|
||||
jsoncheck_noavx:tests/jsoncheck.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o jsoncheck_noavx tests/jsoncheck.cpp -I. $(LIBFILES) $(LIBFLAGS) -DSIMDJSON_DISABLE_AVX2_DETECTION
|
||||
jsoncheck_westmere:tests/jsoncheck.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o jsoncheck_westmere tests/jsoncheck.cpp -I. $(LIBFILES) $(LIBFLAGS) -DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
||||
|
||||
jsoncheck_fallback:tests/jsoncheck.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o jsoncheck_fallback tests/jsoncheck.cpp -I. $(LIBFILES) $(LIBFLAGS) -DSIMDJSON_IMPLEMENTATION_HASWELL=0 -DSIMDJSON_IMPLEMENTATION_WESTMERE=0 -DSIMDJSON_IMPLEMENTATION_ARM64=0
|
||||
|
||||
basictests:tests/basictests.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o basictests tests/basictests.cpp -I. $(LIBFILES) $(LIBFLAGS)
|
||||
|
|
|
@ -25,7 +25,7 @@ if [ ! -d build-$variant ] ; then
|
|||
-DSIMDJSON_BUILD_STATIC=On \
|
||||
-DENABLE_FUZZING=On \
|
||||
-DSIMDJSON_FUZZ_LINKMAIN=On \
|
||||
-DSIMDJSON_DISABLE_AVX=On
|
||||
-DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
||||
|
||||
ninja
|
||||
cd ..
|
||||
|
@ -69,7 +69,7 @@ if [ ! -d build-$variant ] ; then
|
|||
-DENABLE_FUZZING=On \
|
||||
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
||||
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE \
|
||||
-DSIMDJSON_DISABLE_AVX=On
|
||||
-DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
||||
|
||||
ninja
|
||||
cd ..
|
||||
|
@ -97,7 +97,7 @@ if which clang++-8 >/dev/null 2>&1 ; then
|
|||
-DENABLE_FUZZING=On \
|
||||
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
||||
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE \
|
||||
-DSIMDJSON_DISABLE_AVX=On
|
||||
-DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
||||
|
||||
ninja
|
||||
cd ..
|
||||
|
|
|
@ -21,6 +21,28 @@
|
|||
#define STRINGIFY_IMPLEMENTATION_(a) #a
|
||||
#define STRINGIFY(a) STRINGIFY_IMPLEMENTATION_(a)
|
||||
|
||||
#ifndef SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||
#define SIMDJSON_IMPLEMENTATION_FALLBACK 1
|
||||
#endif
|
||||
|
||||
#if IS_ARM64
|
||||
#ifndef SIMDJSON_IMPLEMENTATION_ARM64
|
||||
#define SIMDJSON_IMPLEMENTATION_ARM64 1
|
||||
#endif
|
||||
#define SIMDJSON_IMPLEMENTATION_HASWELL 0
|
||||
#define SIMDJSON_IMPLEMENTATION_WESTMERE 0
|
||||
#endif // IS_ARM64
|
||||
|
||||
#if IS_X86_64
|
||||
#ifndef SIMDJSON_IMPLEMENTATION_HASWELL
|
||||
#define SIMDJSON_IMPLEMENTATION_HASWELL 1
|
||||
#endif
|
||||
#ifndef SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||
#define SIMDJSON_IMPLEMENTATION_WESTMERE 1
|
||||
#endif
|
||||
#define SIMDJSON_IMPLEMENTATION_ARM64 0
|
||||
#endif // IS_X86_64
|
||||
|
||||
// we are going to use runtime dispatch
|
||||
#ifdef IS_X86_64
|
||||
#ifdef __clang__
|
||||
|
|
|
@ -191,11 +191,9 @@ static inline uint32_t detect_supported_architectures() {
|
|||
eax = 0x7;
|
||||
ecx = 0x0;
|
||||
cpuid(&eax, &ebx, &ecx, &edx);
|
||||
#ifndef SIMDJSON_DISABLE_AVX2_DETECTION
|
||||
if (ebx & cpuid_avx2_bit) {
|
||||
host_isa |= instruction_set::AVX2;
|
||||
}
|
||||
#endif
|
||||
if (ebx & cpuid_bmi1_bit) {
|
||||
host_isa |= instruction_set::BMI1;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_BITMANIPULATION_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "arm64/intrinsics.h"
|
||||
|
||||
namespace simdjson::arm64 {
|
||||
|
@ -83,6 +80,4 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
|
|||
|
||||
} // namespace simdjson::arm64
|
||||
|
||||
#endif // IS_ARM64
|
||||
|
||||
#endif // SIMDJSON_ARM64_BITMANIPULATION_H
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "arm64/intrinsics.h"
|
||||
|
||||
namespace simdjson::arm64 {
|
||||
|
@ -40,5 +38,4 @@ really_inline uint64_t prefix_xor(uint64_t bitmask) {
|
|||
} // namespace simdjson::arm64
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_ARM64
|
||||
#endif
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_IMPLEMENTATION_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "isadetection.h"
|
||||
|
||||
namespace simdjson::arm64 {
|
||||
|
@ -20,6 +17,4 @@ public:
|
|||
|
||||
} // namespace simdjson::arm64
|
||||
|
||||
#endif // IS_ARM64
|
||||
|
||||
#endif // SIMDJSON_ARM64_IMPLEMENTATION_H
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
// This should be the correct header whether
|
||||
// you use visual studio or other compilers.
|
||||
#include <arm_neon.h>
|
||||
|
||||
#endif // IS_ARM64
|
||||
#endif // SIMDJSON_ARM64_INTRINSICS_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_NUMBERPARSING_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "jsoncharutils.h"
|
||||
#include "arm64/intrinsics.h"
|
||||
#include "arm64/bitmanipulation.h"
|
||||
|
@ -35,9 +32,6 @@ static inline uint32_t parse_eight_digits_unrolled(const char *chars) {
|
|||
|
||||
#include "generic/numberparsing.h"
|
||||
|
||||
} // namespace simdjson::arm64
|
||||
|
||||
}// namespace simdjson::arm64
|
||||
|
||||
|
||||
#endif // IS_ARM64
|
||||
#endif // SIMDJSON_ARM64_NUMBERPARSING_H
|
||||
#endif // SIMDJSON_ARM64_NUMBERPARSING_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_SIMD_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "arm64/intrinsics.h"
|
||||
|
||||
namespace simdjson::arm64::simd {
|
||||
|
@ -347,5 +344,4 @@ namespace simdjson::arm64::simd {
|
|||
|
||||
} // namespace simdjson::arm64::simd
|
||||
|
||||
#endif // IS_ARM64
|
||||
#endif // SIMDJSON_ARM64_SIMD_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_STAGE1_FIND_MARKS_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "arm64/bitmask.h"
|
||||
#include "arm64/simd.h"
|
||||
#include "arm64/bitmanipulation.h"
|
||||
|
@ -56,6 +53,4 @@ WARN_UNUSED error_code implementation::stage1(const uint8_t *buf, size_t len, do
|
|||
|
||||
} // namespace simdjson::arm64
|
||||
|
||||
#endif // IS_ARM64
|
||||
|
||||
#endif // SIMDJSON_ARM64_STAGE1_FIND_MARKS_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_STAGE2_BUILD_TAPE_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "arm64/implementation.h"
|
||||
#include "arm64/stringparsing.h"
|
||||
#include "arm64/numberparsing.h"
|
||||
|
@ -17,6 +14,4 @@ namespace simdjson::arm64 {
|
|||
|
||||
} // namespace simdjson::arm64
|
||||
|
||||
#endif // IS_ARM64
|
||||
|
||||
#endif // SIMDJSON_ARM64_STAGE2_BUILD_TAPE_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_ARM64_STRINGPARSING_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_ARM64
|
||||
|
||||
#include "jsoncharutils.h"
|
||||
#include "arm64/simd.h"
|
||||
#include "arm64/intrinsics.h"
|
||||
|
@ -52,6 +49,4 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
|
|||
}
|
||||
// namespace simdjson::amd64
|
||||
|
||||
#endif // IS_ARM64
|
||||
|
||||
#endif // SIMDJSON_ARM64_STRINGPARSING_H
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "haswell/intrinsics.h"
|
||||
|
||||
TARGET_HASWELL
|
||||
|
@ -76,6 +74,4 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
|
|||
}// namespace simdjson::haswell
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_BITMANIPULATION_H
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "haswell/intrinsics.h"
|
||||
|
||||
TARGET_HASWELL
|
||||
|
@ -26,6 +24,4 @@ really_inline uint64_t prefix_xor(const uint64_t bitmask) {
|
|||
} // namespace simdjson::haswell
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_BITMASK_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_HASWELL_IMPLEMENTATION_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "isadetection.h"
|
||||
|
||||
namespace simdjson::haswell {
|
||||
|
@ -24,6 +21,4 @@ public:
|
|||
|
||||
} // namespace simdjson::haswell
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_IMPLEMENTATION_H
|
|
@ -3,14 +3,10 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h> // visual studio
|
||||
#else
|
||||
#include <x86intrin.h> // elsewhere
|
||||
#endif // _MSC_VER
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_INTRINSICS_H
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "jsoncharutils.h"
|
||||
#include "haswell/intrinsics.h"
|
||||
#include "haswell/bitmanipulation.h"
|
||||
|
@ -45,6 +43,4 @@ static inline uint32_t parse_eight_digits_unrolled(const char *chars) {
|
|||
} // namespace simdjson::haswell
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_NUMBERPARSING_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_HASWELL_SIMD_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "haswell/intrinsics.h"
|
||||
|
||||
TARGET_HASWELL
|
||||
|
@ -311,6 +308,4 @@ namespace simdjson::haswell::simd {
|
|||
} // namespace simdjson::haswell::simd
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_SIMD_H
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "haswell/bitmask.h"
|
||||
#include "haswell/simd.h"
|
||||
#include "haswell/bitmanipulation.h"
|
||||
|
@ -55,6 +53,4 @@ WARN_UNUSED error_code implementation::stage1(const uint8_t *buf, size_t len, do
|
|||
} // namespace simdjson::haswell
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_STAGE1_FIND_MARKS_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_HASWELL_STAGE2_BUILD_TAPE_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "haswell/implementation.h"
|
||||
#include "haswell/stringparsing.h"
|
||||
#include "haswell/numberparsing.h"
|
||||
|
@ -19,6 +16,4 @@ namespace simdjson::haswell {
|
|||
} // namespace simdjson
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_STAGE2_BUILD_TAPE_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_HASWELL_STRINGPARSING_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "jsoncharutils.h"
|
||||
#include "haswell/simd.h"
|
||||
#include "haswell/intrinsics.h"
|
||||
|
@ -48,6 +45,4 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
|
|||
} // namespace simdjson::haswell
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_HASWELL_STRINGPARSING_H
|
||||
|
|
|
@ -1,39 +1,46 @@
|
|||
#include "simdjson.h"
|
||||
#include "isadetection.h"
|
||||
#include <initializer_list>
|
||||
|
||||
// Static array of known implementations. We're hoping these get baked into the executable
|
||||
// without requiring a static initializer.
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#if SIMDJSON_IMPLEMENTATION_HASWELL
|
||||
#include "haswell/implementation.h"
|
||||
namespace simdjson::internal { const haswell::implementation haswell_singleton{}; }
|
||||
#endif // SIMDJSON_IMPLEMENTATION_HASWELL
|
||||
|
||||
#if SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||
#include "westmere/implementation.h"
|
||||
#include "fallback/implementation.h"
|
||||
|
||||
namespace simdjson::internal {
|
||||
const fallback::implementation fallback_singleton{};
|
||||
const haswell::implementation haswell_singleton{};
|
||||
const westmere::implementation westmere_singleton{};
|
||||
constexpr const std::initializer_list<const implementation *> available_implementation_pointers { &haswell_singleton, &westmere_singleton, &fallback_singleton };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IS_ARM64
|
||||
namespace simdjson::internal { const westmere::implementation westmere_singleton{}; }
|
||||
#endif // SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||
|
||||
#if SIMDJSON_IMPLEMENTATION_ARM64
|
||||
#include "arm64/implementation.h"
|
||||
namespace simdjson::internal { const arm64::implementation arm64_singleton{}; }
|
||||
#endif // SIMDJSON_IMPLEMENTATION_ARM64
|
||||
|
||||
#if SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||
#include "fallback/implementation.h"
|
||||
namespace simdjson::internal { const fallback::implementation fallback_singleton{}; }
|
||||
#endif // SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||
|
||||
namespace simdjson::internal {
|
||||
const fallback::implementation fallback_singleton{};
|
||||
const arm64::implementation arm64_singleton{};
|
||||
constexpr const std::initializer_list<const implementation *> available_implementation_pointers { &arm64_singleton, &fallback_singleton };
|
||||
}
|
||||
|
||||
constexpr const std::initializer_list<const implementation *> available_implementation_pointers {
|
||||
#if SIMDJSON_IMPLEMENTATION_HASWELL
|
||||
&haswell_singleton,
|
||||
#endif
|
||||
|
||||
|
||||
namespace simdjson::internal {
|
||||
#if SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||
&westmere_singleton,
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_ARM64
|
||||
&arm64_singleton,
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||
&fallback_singleton,
|
||||
#endif
|
||||
}; // available_implementation_pointers
|
||||
|
||||
// So we can return UNSUPPORTED_ARCHITECTURE from the parser when there is no support
|
||||
class unsupported_implementation final : public implementation {
|
||||
|
@ -79,4 +86,4 @@ const implementation *detect_best_supported_implementation_on_first_use::set_bes
|
|||
return active_implementation = available_implementations.detect_best_supported();
|
||||
}
|
||||
|
||||
} // namespace simdjson
|
||||
} // namespace simdjson::internal
|
||||
|
|
|
@ -120,11 +120,9 @@ static inline uint32_t detect_supported_architectures() {
|
|||
eax = 0x7;
|
||||
ecx = 0x0;
|
||||
cpuid(&eax, &ebx, &ecx, &edx);
|
||||
#ifndef SIMDJSON_DISABLE_AVX2_DETECTION
|
||||
if (ebx & cpuid_avx2_bit) {
|
||||
host_isa |= instruction_set::AVX2;
|
||||
}
|
||||
#endif
|
||||
if (ebx & cpuid_bmi1_bit) {
|
||||
host_isa |= instruction_set::BMI1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
#if SIMDJSON_IMPLEMENTATION_ARM64
|
||||
#include "arm64/stage1_find_marks.h"
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||
#include "fallback/stage1_find_marks.h"
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_HASWELL
|
||||
#include "haswell/stage1_find_marks.h"
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||
#include "westmere/stage1_find_marks.h"
|
||||
#endif
|
||||
|
|
|
@ -12,7 +12,15 @@ void found_string(const uint8_t *buf, const uint8_t *parsed_begin,
|
|||
void found_bad_string(const uint8_t *buf);
|
||||
#endif
|
||||
|
||||
#if SIMDJSON_IMPLEMENTATION_ARM64
|
||||
#include "arm64/stage2_build_tape.h"
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||
#include "fallback/stage2_build_tape.h"
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_HASWELL
|
||||
#include "haswell/stage2_build_tape.h"
|
||||
#endif
|
||||
#if SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||
#include "westmere/stage2_build_tape.h"
|
||||
#endif
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_BITMANIPULATION_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "westmere/intrinsics.h"
|
||||
|
||||
TARGET_WESTMERE
|
||||
|
@ -84,9 +81,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
|
|||
#endif
|
||||
}
|
||||
|
||||
}// namespace simdjson::westmere
|
||||
} // namespace simdjson::westmere
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_BITMANIPULATION_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_BITMASK_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "westmere/intrinsics.h"
|
||||
|
||||
TARGET_WESTMERE
|
||||
|
@ -26,6 +23,4 @@ really_inline uint64_t prefix_xor(const uint64_t bitmask) {
|
|||
} // namespace simdjson::westmere
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_BITMASK_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_IMPLEMENTATION_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "simdjson/implementation.h"
|
||||
#include "isadetection.h"
|
||||
|
||||
|
@ -21,6 +18,4 @@ public:
|
|||
|
||||
} // namespace simdjson::westmere
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_IMPLEMENTATION_H
|
|
@ -1,12 +1,10 @@
|
|||
#ifndef SIMDJSON_WESTMERE_INTRINSICS_H
|
||||
#define SIMDJSON_WESTMERE_INTRINSICS_H
|
||||
|
||||
#ifdef IS_X86_64
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h> // visual studio
|
||||
#else
|
||||
#include <x86intrin.h> // elsewhere
|
||||
#endif // _MSC_VER
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_INTRINSICS_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_NUMBERPARSING_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "jsoncharutils.h"
|
||||
#include "westmere/intrinsics.h"
|
||||
#include "westmere/bitmanipulation.h"
|
||||
|
@ -47,7 +44,4 @@ static inline uint32_t parse_eight_digits_unrolled(const char *chars) {
|
|||
} // namespace simdjson::westmere
|
||||
UNTARGET_REGION
|
||||
|
||||
|
||||
|
||||
#endif // IS_X86_64
|
||||
#endif // SIMDJSON_WESTMERE_NUMBERPARSING_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_SIMD_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "westmere/intrinsics.h"
|
||||
|
||||
TARGET_WESTMERE
|
||||
|
@ -311,5 +308,4 @@ namespace simdjson::westmere::simd {
|
|||
} // namespace simdjson::westmere::simd
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
#endif // SIMDJSON_WESTMERE_SIMD_INPUT_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_STAGE1_FIND_MARKS_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "westmere/bitmask.h"
|
||||
#include "westmere/simd.h"
|
||||
#include "westmere/bitmanipulation.h"
|
||||
|
@ -57,5 +54,4 @@ WARN_UNUSED error_code implementation::stage1(const uint8_t *buf, size_t len, do
|
|||
} // namespace simdjson::westmere
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
#endif // SIMDJSON_WESTMERE_STAGE1_FIND_MARKS_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_STAGE2_BUILD_TAPE_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "westmere/implementation.h"
|
||||
#include "westmere/stringparsing.h"
|
||||
#include "westmere/numberparsing.h"
|
||||
|
@ -18,7 +15,4 @@ namespace simdjson::westmere {
|
|||
|
||||
} // namespace simdjson::westmere
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_STAGE2_BUILD_TAPE_H
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define SIMDJSON_WESTMERE_STRINGPARSING_H
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
#ifdef IS_X86_64
|
||||
|
||||
#include "jsoncharutils.h"
|
||||
#include "westmere/simd.h"
|
||||
#include "westmere/intrinsics.h"
|
||||
|
@ -50,6 +47,4 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
|
|||
} // namespace simdjson::westmere
|
||||
UNTARGET_REGION
|
||||
|
||||
#endif // IS_X86_64
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_STRINGPARSING_H
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
#include <string_view>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
|
@ -1459,7 +1461,8 @@ bool lots_of_brackets() {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::cout << std::unitbuf;
|
||||
char c;
|
||||
#ifndef _MSC_VER
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "a:")) != -1) {
|
||||
switch (c) {
|
||||
case 'a': {
|
||||
|
@ -1476,6 +1479,9 @@ int main(int argc, char *argv[]) {
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int optind = 1;
|
||||
#endif
|
||||
|
||||
// this is put here deliberately to check that the documentation is correct (README),
|
||||
// should this fail to compile, you should update the documentation:
|
||||
|
|
|
@ -112,7 +112,28 @@ bool validate(const char *dirname) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc != 2) {
|
||||
#ifndef _MSC_VER
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "a:")) != -1) {
|
||||
switch (c) {
|
||||
case 'a': {
|
||||
const simdjson::implementation *impl = simdjson::available_implementations[optarg];
|
||||
if (!impl) {
|
||||
fprintf(stderr, "Unsupported architecture value -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "Unexpected argument %c\n", c);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int optind = 1;
|
||||
#endif
|
||||
if ((argc - optind) != 1) {
|
||||
std::cerr << "Usage: " << argv[0] << " <directorywithjsonfiles>"
|
||||
<< std::endl;
|
||||
#ifndef SIMDJSON_TEST_DATA_DIR
|
||||
|
@ -126,5 +147,5 @@ int main(int argc, char *argv[]) {
|
|||
return validate(SIMDJSON_TEST_DATA_DIR) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
return validate(argv[1]) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
return validate(argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -18,23 +18,6 @@ else ()
|
|||
set (X64 FALSE)
|
||||
endif ()
|
||||
|
||||
if(X64)
|
||||
message(STATUS "Detected x64 processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
if(SIMDJSON_DISABLE_AVX)
|
||||
message(STATUS "Disabling AVX. No runtime dispatch.")
|
||||
if(NOT MSVC)
|
||||
set (OPT_FLAGS "${OPT_FLAGS} -mno-avx -mno-bmi -mpclmul -msse4.2") #westmere
|
||||
else()
|
||||
set (OPT_FLAGS "${OPT_FLAGS}")
|
||||
endif()
|
||||
else()
|
||||
if(NOT MSVC)
|
||||
message(STATUS "Assuming Westmere or better")
|
||||
set (OPT_FLAGS "${OPT_FLAGS} -mpclmul -msse4.2")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SIMDJSON_EXCEPTIONS)
|
||||
set(OPT_FLAGS "${OPT_FLAGS} -DSIMDJSON_EXCEPTIONS=1")
|
||||
else()
|
||||
|
|
Loading…
Reference in New Issue