RISC-V: support RVV 0.7 in mainline RVV intrinsics#23246
RISC-V: support RVV 0.7 in mainline RVV intrinsics#23246opencv-pushbot merged 1 commit intoopencv:4.xfrom
Conversation
|
@mshabunin I added |
|
Which qemu do you use? Why is it I only tested core and imgproc in Xuantie qemu. I will run the whole testsuite and compare results with yours. |
|
Please merge build + test steps instructions for different scenarios. |
|
Updated the description, also filed an issue to the T-Head toolchain: XUANTIE-RV/xuantie-gnu-toolchain#5 - apparently toolchain built from sources can not compile OpenCV with RVV 0.7 support, but prebuilt one can. Also added my Docker-based testing environment: https://github.com/mshabunin/riscv-check |
| #ifdef __THEAD_VERSION__ | ||
| # if __riscv_v == 7000 // -march=rv64gcv0p7 | ||
| # include <fenv.h> | ||
| # define CV_RISCV_OLD |
There was a problem hiding this comment.
CV_RISCV_OLD
This name is unclear.
Please be more specific when and why we use it.
There was a problem hiding this comment.
Renamed to CV_RVV_THEAD_0_7 and added a comment
626c2f1 to
903ec0e
Compare
|
@Lzingnow , I didn't try to build with elf toolchain. Your issue is that you should build |
|
Hello, I have successfully installed the rvv-next branch of riscv-gnu-toolchain by following the above procedure. Then, I downloaded the source code for opencv4.8. Build with the following commands: At this point, it indicates that the installation was successful. Next, I want to write c++ code that calls the opencv library to generate an executable file that can run on a CPU that supports rvv1.0. Specifically, the PULP project's ara project. Here I test the resize function, c++ code is as follows: The specific compilation options are as follows: But I did not find the vector instruction after decompilation. May I ask why? The files resize.o and resize.dump are attached. |
|
Your |
|
@mshabunin Thank you very much. I got the executable file containing the vector instructions by setting up static compilation. But I also have a question about whether the opencv library for This is because I once tried to compile opencv libraries using the |
|
We do not build OpenCV for bare metal environments, it is not supported officially. In general OpenCV uses C/C++ libraries, some POSIX functions and a threading library (pthreads). If your toolchain can provide these interfaces, then perhaps it might work. |
|
Thank you for your reply. |
|
Hello, I would like to know if you have encountered such problems when testing with the rvv-next branch. After compiling the opencv library using the 1.Compile qemu: But there was an error: Then I found another
But there is still one mistake: In addition, I also tried I don't know how to solve this problem. |
|
I think I solved the problem, but instead of using qemu under the |

Recent T-Head GCC have ability to produce RVV 0.7.1 compatible machine code using mainline intrinsics syntax. It makes possible to have single intrinsics implementation for both 0.7 and 1.0 versions (
intrin_rvv.hpp, maybe scalable too).Build and test with RVV 1.0 (non-scalable)
Using one of the following toolchains:
Using one of the following qemu:
cmake \ -DCMAKE_TOOLCHAIN_FILE=/work/opencv/platforms/linux/riscv64-gcc.toolchain.cmake \ -DCPU_RVV_FLAGS_ON="-march=rv64gcv" \ -DRISCV_RVV_SCALABLE=OFF \ ../opencv # T-Head qemu /opt/xuantie-qemu-20221104/bin/qemu-riscv64 \ -L ${sysroot} \ -cpu c908v \ ./bin/opencv_test_core # Collab qemu /opt/bin/qemu-riscv64 \ -L ${sysroot} \ -cpu rv64,v=true,vext_spec=v1.0 \ ./bin/opencv_test_coreBuild and test with RVV 0.7.1 (non-scalable)
Using one of the following toolchains:
Build from sources(:exclamation:can not build OpenCV in this mode at this moment:exclamation:): https://github.com/T-head-Semi/xuantie-gnu-toolchainUsing qemu:
cmake \ -DCMAKE_TOOLCHAIN_FILE=/work/opencv/platforms/linux/riscv64-gcc.toolchain.cmake \ -DCPU_RVV_FLAGS_ON="-march=rv64gcv0p7" \ -DRISCV_RVV_SCALABLE=OFF \ ../opencv # T-Head qemu /opt/xuantie-qemu-20221104/bin/qemu-riscv64 \ -L ${sysroot} \ -cpu c906fdv \ ./bin/opencv_test_coreNotes:
v_truncimplementation have modified because there is no corresponding_rtz_intrinsics in 0.7v_absdiffhave been reimplemented to avoid using 64-bit types for 32-bit inputv_check_also updated to use 32-bit internallyCV_SIMD128_64Fguard was missing in some places