Skip to content
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

RISC-V: allow building scalable RVV support with GCC, LLVM 16 support #23383

Merged
merged 1 commit into from Apr 10, 2023

Conversation

mshabunin
Copy link
Contributor

@mshabunin mshabunin commented Mar 21, 2023

Related issue #22608

  • GCC does not support "overloaded RVV intrinsics", but we can add some of them in our code
  • LLVM since version 16 uses __riscv_<name> naming scheme (see related ticket), so we need to add compatibility headers to rename our 0.10 intinsics to the new scheme (also for some "overloaded intrinsics")

TODO:

  • check and fix compilation with GCC still does not work due to toolchain issue or limitation
  • extract overloaded intsinsics implementation to separate header
  • macros for overloaded intrinsics looks too broad, maybe convert them to function macros / inline functions / undef? used headers from RISC-V collab as is
  • clean-up the code - reduce modifications

Note: scalable RVV compilation using GCC still does not work (T-Head 2.6.1 and RISC-V Collab Toolchain@rvv_next) due to compiler issues or limitations. More analysis needed.

force_builders=Custom
build_image:Custom=riscv-clang-rvv
Xbuild_image:Custom=riscv-clang-rvv-128
Xbuild_image:Custom=riscv-gcc-rvv-07
test_modules:Custom=core,imgproc,dnn
buildworker:Custom=linux-4
test_timeout:Custom=600
build_contrib:Custom=OFF

@mshabunin mshabunin marked this pull request as ready for review April 5, 2023 11:19
@opencv-alalek opencv-alalek added this to the 4.8.0 milestone Apr 6, 2023
Copy link
Contributor

@opencv-alalek opencv-alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@opencv-alalek opencv-alalek self-assigned this Apr 6, 2023
@zhongjuzhe
Copy link

Can you use upstream GCC (GCC 13.0) test? We don't maintain rvv-next any more. All update upstream GCC directely.
https://github.com/gcc-mirror/gcc

@opencv-pushbot opencv-pushbot merged commit daf9de7 into opencv:4.x Apr 10, 2023
12 of 19 checks passed
@opencv-alalek
Copy link
Contributor

@zhongjuzhe Thank you for the information!
Is there some example how to build RISC-V GCC toolchain from upstream source code? (similar to https://github.com/riscv-collab/riscv-gnu-toolchain instructions)
CI logs? Or Dockerfile?

@zhongjuzhe
Copy link

It seems that RISC-V toolchain doesn't bump to latest upstream GCC. I think you can file an issue to @kito-cheng and ask him to update the toolchain.

Here is an simple example to verify that both GCC and LLVM are consisten each other with the same API doc:
https://godbolt.org/z/dz83ozbeb

compiler explorer has showed that both GCC and LLVM are recognizing same API RVV.

@mshabunin
Copy link
Contributor Author

I've been able to build riscv-collab toolchain with the latest GCC by updating gcc submodule to master manually. It can build OpenCV with scalable RVV support, but failed to build non-scalable (intrin_rvv.hpp) variant. I'm going to take a closer look. @zhongjuzhe , thank you for guidance!

@mshabunin mshabunin deleted the rvv-scalable-gcc branch April 17, 2023 10:21
@zhongjuzhe
Copy link

zhongjuzhe commented Apr 17, 2023 via email

@asmorkalov asmorkalov mentioned this pull request May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants