Repository navigation
[C++] Add RISC-V Vector (RVV) support and dynamic dispatch #51340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
74efff7
2490175
6dae1b4
4fffad3
1409867
1577b85
2a9a1ec
dc8c919
9ce230d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ python/doc/ | |
|
|
||
| .vscode | ||
| .idea/ | ||
| .icodemate/ | ||
| .pytest_cache/ | ||
| pkgs | ||
| docker_cache | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,6 +167,24 @@ elseif(ARROW_CPU_FLAG STREQUAL "aarch64") | |
| if(ARROW_SIMD_LEVEL STREQUAL "DEFAULT") | ||
| set(ARROW_SIMD_LEVEL "NEON") | ||
| endif() | ||
| elseif(ARROW_CPU_FLAG STREQUAL "riscv64") | ||
| set(ARROW_RVV_MARCH "rv64gcv") | ||
| check_cxx_compiler_flag("-march=${ARROW_RVV_MARCH}" CXX_SUPPORTS_RVV) | ||
| if(CXX_SUPPORTS_RVV AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(RVV128|RVV256|RVV512|MAX)$") | ||
| set(ARROW_HAVE_RUNTIME_RVV128 ON) | ||
| add_definitions(-DARROW_HAVE_RUNTIME_RVV128) | ||
| endif() | ||
| if(CXX_SUPPORTS_RVV AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(RVV256|RVV512|MAX)$") | ||
| set(ARROW_HAVE_RUNTIME_RVV256 ON) | ||
| add_definitions(-DARROW_HAVE_RUNTIME_RVV256) | ||
| endif() | ||
| if(CXX_SUPPORTS_RVV AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(RVV512|MAX)$") | ||
| set(ARROW_HAVE_RUNTIME_RVV512 ON) | ||
| add_definitions(-DARROW_HAVE_RUNTIME_RVV512) | ||
| endif() | ||
| if(ARROW_SIMD_LEVEL STREQUAL "DEFAULT") | ||
| set(ARROW_SIMD_LEVEL "NONE") | ||
| endif() | ||
| endif() | ||
|
|
||
| # Support C11 | ||
|
|
@@ -548,6 +566,25 @@ if(ARROW_CPU_FLAG STREQUAL "aarch64") | |
| endif() | ||
| endif() | ||
|
|
||
| if(ARROW_CPU_FLAG STREQUAL "riscv64") | ||
| if(ARROW_SIMD_LEVEL MATCHES "RVV") | ||
| if(NOT CXX_SUPPORTS_RVV) | ||
| message(FATAL_ERROR "RVV required but compiler doesn't support it.") | ||
| endif() | ||
| set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -march=${ARROW_RVV_MARCH}") | ||
| string(REGEX MATCH "[0-9]+" RVV_VECTOR_BITS ${ARROW_SIMD_LEVEL}) | ||
| if(RVV_VECTOR_BITS) | ||
| set(ARROW_HAVE_RVV${RVV_VECTOR_BITS} ON) | ||
| add_definitions(-DARROW_HAVE_RVV${RVV_VECTOR_BITS}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we also enable a compiler option for the given vector size, as in SVE above?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GCC documentation (https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html) shows -mrvv-vector-bits only accepts scalable/zvl (and pairs with a zvlXXXb march extension), unlike SVE's direct -msve-vector-bits=N.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it looks like xsimd itself uses something like I'm not sure how another approach would work. We need vectors to have a well-known length at compile-time. |
||
| else() | ||
| set(ARROW_HAVE_RVV_SIZELESS ON) | ||
| add_definitions(-DARROW_HAVE_RVV_SIZELESS) | ||
| endif() | ||
| elseif(NOT ARROW_SIMD_LEVEL STREQUAL "NONE") | ||
| message(WARNING "ARROW_SIMD_LEVEL=${ARROW_SIMD_LEVEL} not supported by riscv64.") | ||
| endif() | ||
| endif() | ||
|
|
||
| if(NOT WIN32 AND NOT APPLE) | ||
| if(ARROW_USE_MOLD) | ||
| find_program(LD_MOLD ld.mold) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add line break as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the missing blank line before if(ARROW_CPU_FLAG STREQUAL "riscv64"), as in the SVE/Arm block above.