From 7898234bb3a384ac390ff39f642fb1ed45a6c356 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 29 Nov 2023 19:11:47 +0000 Subject: [PATCH 1/2] Make simdjson riscv64 aware --- .github/workflows/riscv64.yml | 29 +++++++++++++++++++++ include/simdjson/implementation_detection.h | 9 +++++++ include/simdjson/portability.h | 2 ++ 3 files changed, 40 insertions(+) create mode 100644 .github/workflows/riscv64.yml diff --git a/.github/workflows/riscv64.yml b/.github/workflows/riscv64.yml new file mode 100644 index 000000000..f37ea34d8 --- /dev/null +++ b/.github/workflows/riscv64.yml @@ -0,0 +1,29 @@ +name: Ubuntu riscv64 (GCC 11) + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: uraimo/run-on-arch-action@v2 + name: Test + id: runcmd + with: + arch: riscv64 + distro: ubuntu_latest + githubToken: ${{ github.token }} + install: | + apt-get update -q -y + apt-get install -y cmake make g++ + run: | + cmake -DCMAKE_BUILD_TYPE=Release -B build + cmake --build build -j=2 + ctest --output-on-failure --test-dir build diff --git a/include/simdjson/implementation_detection.h b/include/simdjson/implementation_detection.h index f66045ad1..ff8da8813 100644 --- a/include/simdjson/implementation_detection.h +++ b/include/simdjson/implementation_detection.h @@ -10,6 +10,7 @@ #define SIMDJSON_IMPLEMENTATION_ID_icelake 4 #define SIMDJSON_IMPLEMENTATION_ID_ppc64 5 #define SIMDJSON_IMPLEMENTATION_ID_westmere 6 +#define SIMDJSON_IMPLEMENTATION_ID_riscv64 7 #define SIMDJSON_IMPLEMENTATION_ID_FOR(IMPL) SIMDJSON_CAT(SIMDJSON_IMPLEMENTATION_ID_, IMPL) #define SIMDJSON_IMPLEMENTATION_ID SIMDJSON_IMPLEMENTATION_ID_FOR(SIMDJSON_IMPLEMENTATION) @@ -26,6 +27,12 @@ #endif #define SIMDJSON_CAN_ALWAYS_RUN_ARM64 SIMDJSON_IMPLEMENTATION_ARM64 && SIMDJSON_IS_ARM64 +#ifndef SIMDJSON_IMPLEMENTATION_RISCV64 +// riscv64 backend isn't implemented yet +#define SIMDJSON_IMPLEMENTATION_RISCV64 (0) +#endif +#define SIMDJSON_CAN_ALWAYS_RUN_RISCV64 SIMDJSON_IMPLEMENTATION_RISCV64 && SIMDJSON_IS_RISCV64 + // Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected // at runtime. #ifndef SIMDJSON_IMPLEMENTATION_ICELAKE @@ -98,6 +105,8 @@ #define SIMDJSON_BUILTIN_IMPLEMENTATION arm64 #elif SIMDJSON_CAN_ALWAYS_RUN_PPC64 #define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64 +#elif SIMDJSON_CAN_ALWAYS_RUN_RISCV64 +#define SIMDJSON_BUILTIN_IMPLEMENTATION riscv64 #elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK #define SIMDJSON_BUILTIN_IMPLEMENTATION fallback #else diff --git a/include/simdjson/portability.h b/include/simdjson/portability.h index b832b99ba..4034e1565 100644 --- a/include/simdjson/portability.h +++ b/include/simdjson/portability.h @@ -36,6 +36,8 @@ #define SIMDJSON_IS_X86_64 1 #elif defined(__aarch64__) || defined(_M_ARM64) #define SIMDJSON_IS_ARM64 1 +#elif defined(__riscv) && __riscv_xlen == 64 +#define SIMDJSON_IS_RISCV64 1 #elif defined(__PPC64__) || defined(_M_PPC64) #if defined(__ALTIVEC__) #define SIMDJSON_IS_PPC64_VMX 1 From b8a6b889c753cfc12fec2726bf21f66851f9633f Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 29 Nov 2023 22:09:25 +0000 Subject: [PATCH 2/2] review: Revert changes in include/simdjson/implementation_detection.h --- include/simdjson/implementation_detection.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/simdjson/implementation_detection.h b/include/simdjson/implementation_detection.h index ff8da8813..f66045ad1 100644 --- a/include/simdjson/implementation_detection.h +++ b/include/simdjson/implementation_detection.h @@ -10,7 +10,6 @@ #define SIMDJSON_IMPLEMENTATION_ID_icelake 4 #define SIMDJSON_IMPLEMENTATION_ID_ppc64 5 #define SIMDJSON_IMPLEMENTATION_ID_westmere 6 -#define SIMDJSON_IMPLEMENTATION_ID_riscv64 7 #define SIMDJSON_IMPLEMENTATION_ID_FOR(IMPL) SIMDJSON_CAT(SIMDJSON_IMPLEMENTATION_ID_, IMPL) #define SIMDJSON_IMPLEMENTATION_ID SIMDJSON_IMPLEMENTATION_ID_FOR(SIMDJSON_IMPLEMENTATION) @@ -27,12 +26,6 @@ #endif #define SIMDJSON_CAN_ALWAYS_RUN_ARM64 SIMDJSON_IMPLEMENTATION_ARM64 && SIMDJSON_IS_ARM64 -#ifndef SIMDJSON_IMPLEMENTATION_RISCV64 -// riscv64 backend isn't implemented yet -#define SIMDJSON_IMPLEMENTATION_RISCV64 (0) -#endif -#define SIMDJSON_CAN_ALWAYS_RUN_RISCV64 SIMDJSON_IMPLEMENTATION_RISCV64 && SIMDJSON_IS_RISCV64 - // Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected // at runtime. #ifndef SIMDJSON_IMPLEMENTATION_ICELAKE @@ -105,8 +98,6 @@ #define SIMDJSON_BUILTIN_IMPLEMENTATION arm64 #elif SIMDJSON_CAN_ALWAYS_RUN_PPC64 #define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64 -#elif SIMDJSON_CAN_ALWAYS_RUN_RISCV64 -#define SIMDJSON_BUILTIN_IMPLEMENTATION riscv64 #elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK #define SIMDJSON_BUILTIN_IMPLEMENTATION fallback #else