Use reinterpret instead of c-style casting for GCC#22938
Conversation
| { | ||
| uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A}; | ||
| return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)vint8m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); | ||
| return v_int8x16(vreinterpret_v_u8m1_i8m1(vrgather_vv_u8m1(vreinterpret_v_i8m1_u8m1(vint8m1_t(vec)), vreinterpret_v_u64m1_u8m1(vle64_v_u64m1(ptr, 2)), 16))); |
There was a problem hiding this comment.
Which compiler are you using?
/build/precommit_custom_linux/4.x/opencv/modules/core/include/opencv2/core/hal/intrin_rvv.hpp: In function 'cv::hal_baseline::v_int16x8 cv::hal_baseline::v_pack_triplets(const v_int16x8&)':
/build/precommit_custom_linux/4.x/opencv/modules/core/include/opencv2/core/hal/intrin_rvv.hpp:2833:65: error: 'vreinterpret_v_i16m1_u8m1' was not declared in this scope; did you mean 'vreinterpret_v_u16m1_u8m1'?
2833 | return v_int16x8(vreinterpret_v_u8m1_i16m1(vrgather_vv_u8m1(vreinterpret_v_i16m1_u8m1(vint16m1_t(vec)), vreinterpret_v_u64m1_u8m1(vle64_v_u64m1(ptr, 2)), 16)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| vreinterpret_v_u16m1_u8m1
/build/precommit_custom_linux/4.x/opencv/modules/core/include/opencv2/core/hal/intrin_rvv.hpp:2833:22: error: 'vreinterpret_v_u8m1_i16m1' was not declared in this scope; did you mean 'vreinterpret_v_u8m1_u16m1'?
2833 | return v_int16x8(vreinterpret_v_u8m1_i16m1(vrgather_vv_u8m1(vreinterpret_v_i16m1_u8m1(vint16m1_t(vec)), vreinterpret_v_u64m1_u8m1(vle64_v_u64m1(ptr, 2)), 16)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| vreinterpret_v_u8m1_u16m1
Compiler: https://github.com/riscv-collab/riscv-gnu-toolchain/tree/rvv-next
There was a problem hiding this comment.
It seems that this patch fixes compilation with T-Head toolchain 2.6.1 (https://occ.t-head.cn/community/download?id=4090445921563774976). I've tested it (ported to 4.x) and it works now:
PATH=/opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1/bin:${PATH} \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/opencv/platforms/linux/riscv64-gcc.toolchain.cmake \
-DRISCV_RVV_SCALABLE=OFF \
-DCPU_BASELINE=RVV \
-DCPU_RVV_FLAGS_ON=-march=rv64gcv1p0 \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_OPENCL=OFF \
/opencv
Tested with T-Head qemu (https://occ.t-head.cn/community/download?id=4108987827910414336), it seems that the c908v core supports RVV 1.0 unlike c906 and c910v:
OPENCV_TEST_DATA_PATH=/opencv_extra/testdata \
/opt/qemu/bin/qemu-riscv64 \
-cpu c908v \
-L /opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1/sysroot/ \
./bin/opencv_test_core --gtest_filter=*HAL*:*intrin*
There was a problem hiding this comment.
I can see that T-Head compiler defines #define __THEAD_VERSION__ "2.6.1" macro, perhaps we could modify the patch so that it would work with both mainline and T-Head toolchains.
There was a problem hiding this comment.
@Xxfore Ping
Please dump riscv64-unknown-linux-gnu-g++ -march=rv64gcv -dM -E - < /dev/null output from your compiler.
alalek
left a comment
There was a problem hiding this comment.
- Confirmed compilation with GCC from
rvv-nextandRISCV_RVV_SCALABLE=OFF
Use reinterpret instead of c-style casting for GCC Co-authored-by: Xu Zhang <xu.zhang@hexintek.com> Co-authored-by: Maksim Shabunin <maksim.shabunin@gmail.com>
Use reinterpret instead of c-style casting for GCC Co-authored-by: Xu Zhang <xu.zhang@hexintek.com> Co-authored-by: Maksim Shabunin <maksim.shabunin@gmail.com>
Adjust for GCC about type cast.
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.