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
Segmentation fault and Assembler messages while compiling OpenCV with Branch rvv-intrinsic #701
Comments
For compiler issue, I am investigating now, thanks your report :) |
The error message is because you declare a The reason why we can't/don't support that is because the size of RVV vector type is unknown at compilation time, so compiler can't layout that at compilation time. |
@kito-cheng Hi Kito. Thanks lot for your reply. |
I have a roughly idea for solving that, but that might got very bad code gen for current GCC implementation: #include <riscv_vector.h>
#include <stdio.h>
class rvv_vector_type_wrapper32x4 {
public:
rvv_vector_type_wrapper32x4 () {
for (int i=0; i<4; i++){
data[i] = 0;
}
}
rvv_vector_type_wrapper32x4 (vint32m1_t val) {
vsetvl_e32m1 (4);
vse32_v_i32m1 (&data[0], val);
}
void load (int32_t *ptr) {
vsetvl_e32m1 (4);
vint32m1_t val = vle32_v_i32m1 (ptr);
vse32_v_i32m1 (&this->data[0], val);
}
void store (int32_t *ptr) const {
vsetvl_e32m1 (4);
vint32m1_t val = vle32_v_i32m1 (&this->data[0]);
vse32_v_i32m1 (ptr, val);
}
rvv_vector_type_wrapper32x4 operator+(
const rvv_vector_type_wrapper32x4 &rhs) const {
rvv_vector_type_wrapper32x4 rv;
vsetvl_e32m1 (4);
vint32m1_t vrhs = vle32_v_i32m1 (&rhs.data[0]);
vint32m1_t vlhs = vle32_v_i32m1 (&this->data[0]);
vint32m1_t val = vadd_vv_i32m1(vrhs, vlhs);
return rvv_vector_type_wrapper32x4(val);
}
int32_t operator[](size_t idx) const {
return data[idx];
}
int32_t data[4];
};
int x[4] = {1, 2, 3, 4};
int y[4] = {5, 6, 7, 8};
int z[4] = {0};
int main()
{
rvv_vector_type_wrapper32x4 a, b;
a.load (&x[0]);
b.load (&y[0]);
rvv_vector_type_wrapper32x4 c = a + b;
c.store (&z[0]);
printf ("result :");
for (int i=0; i<4; i++){
printf ("%d ", c[i]);
}
printf ("\n");
return 0;
} |
@kito-cheng Thanks a lot for the idea. I will use it temporarily. And we are discussing on making some changes on OpenCV universal intrinsic framework to fit scalable vector architecture. |
@kito-cheng , what are your thoughts on this approach for avoiding vector-member-in-class? It's a thin C++ wrapper that can use e.g. More info (slides). Would be happy to discuss. |
@jan-wassenberg I just spend some time more than I expect on investigate that since my C++ is little rusty, since GCC just stay at C++98 :P highways seems awesome to me, and basically RVV is very similar to the SVE, so if it work with SVE, it should work on RVV too, but I am curious about the empty And I also not saw the SVE support on github, does here any branch or repo for that? Thanks again for sharing your awesome work! |
@kito-cheng thanks!
Right, this is fine on x86 and NEON but will not work on SVE/RVV. That is why the Highway API is designed to work with builtin/non-class vector types such as vfloat32m1_t. Highway uses nonmember functions. The RVV backend would return vfloat32m1_t from functions instead of Vec128. The empty
I believe the N (some large constant) will be able to encode the mf8..m8.
It is not implemented yet. We are currently removing things that will not work in SVE, e.g.
Our work is automatically mirrored to https://github.com/google/highway so you can watch that repo :) |
I used some rvv intrinsics while developing in OpenCV. And I tried to use the branch
rvv-intrinsics
to compile OpenCV. Two errors have been encountered so far.First:
Second:
This seems to be problems with the toolchain itself, right?
Steps to compile OpenCV:
Suppose the toolchain with branch
rvv-intrinsic
is installed in/opt/RISCV
. If not, you may need editopencv/platforms/linux/riscv64-gcc.toolchain.cmake
.The text was updated successfully, but these errors were encountered: