Upgrade RISC-V Vector intrinsic and cleanup the obsolete RVV backend.#25883
Upgrade RISC-V Vector intrinsic and cleanup the obsolete RVV backend.#25883asmorkalov merged 6 commits intoopencv:4.xfrom
Conversation
|
RISC-V config in CI failed: |
clang 16 work with RVV intrinsic
Maybe we need upgrade LLVM version on the CI server |
|
@mshabunin could you take a look? |
|
Updated workflow (use clang-17 in precommit): opencv/ci-gha-workflow#176 |
|
@mshabunin I merged CI patch and re-triggered RISC-V jobs. |
|
Restarting pipelines didn't help. Perhaps we need to update PR itself. |
|
Should I push an empty commit or do something else? |
|
@hanliutong , yes, please push a new commit or rebase the whole branch. |
c0974f5 to
c750f57
Compare
|
@mshabunin rebased, please re-trigger the CI |
|
There is another issue with T-Head compiler - now it can not compile dnn inline kernels, because they use new intrinsics version: It seems that now both CV_RVV and CV_RVV071 are defined in
Let's try to combine both pieces into one, so that inline snippets in dnn wouldn't be compiled. Something like this: #ifdef CV_CPU_COMPILE_RVV
# ifdef __riscv_vector_071
# define CV_RVV071 1
# else
# define CV_RVV 1
# endif
#include <riscv_vector.h>
#endif |
|
There are some issues left with XuanTie toolchain (https://github.com/XUANTIE-RV/xuantie-gnu-toolchain/, I used prebuilt 2.10.0 - https://www.xrvm.cn/community/download?id=4333581795569242112) Command line: $ PATH=/work/chains/xuantie-toolchain-2.10.0/bin:${PATH} \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/opencv/platforms/linux/riscv64-071-gcc.toolchain.cmake -DBUILD_SHARED_LIBS=OFF -DWITH_OPENCL=OFF -DCORE=C908V -DCMAKE_BUILD_TYPE=Release ../opencv
$ ninjaLinker errors: It seems that optimized functions are declared/called but not defined with current preprocessor macros state. |
|
Fixed by using macro --- #if CV_TRY_RVV
+++ #if CV_TRY_RVV && CV_RVVthen the in-place optimizing function only called with the upsteam toolchain which using new RVV intrinsic. #if CV_TRY_RVV && CV_RVV
if(useRVV)
opt_RVV::fastConv(wptr, wstep, biasptr, rowbuf0, data_out0 + ofs0,
outShape, bsz, vsz, vsz_a, outZp, multptr, cn0 == 0, cn1 == inpCn);
else
#endifNote: macro state:
|
|
@hanliutong @mshabunin DO we need the table above somewhere in code as comment? |
|
added on cv_cpu_dispatch.h |
Upgrade RISC-V Vector intrinsic and cleanup the obsolete RVV backend. opencv#25883 This patch upgrade RISC-V Vector intrinsic from `v0.10` to `v0.12`/`v1.0`: - Update cmake check and options; - Upgrade RVV implement for Universal Intrinsic; - Upgrade RVV optimized DNN kernel. - Cleanup the obsolete RVV backend (`intrin_rvv.hpp`) and compatable header file. With this patch, RVV backend require Clang 17+ or GCC 14+ (which means `__riscv_v_intrinsic >= 12000`, see https://godbolt.org/z/es7ncETE3) This patch is test with Clang 17.0.6 (require extra `-DWITH_PNG=OFF` due to ICE), Clang 18.1.8 and GCC 14.1.0 on QEMU and k230 (with `--gtest_filter="*hal_*"`). ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This patch upgrade RISC-V Vector intrinsic from
v0.10tov0.12/v1.0:intrin_rvv.hpp) and compatable header file.With this patch, RVV backend require Clang 17+ or GCC 14+ (which means
__riscv_v_intrinsic >= 12000, see https://godbolt.org/z/es7ncETE3)This patch is test with Clang 17.0.6 (require extra
-DWITH_PNG=OFFdue to ICE), Clang 18.1.8 and GCC 14.1.0 on QEMU and k230 (with--gtest_filter="*hal_*").Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.