回复:[RISC-V] [tech-vector-ext] RISC-V Vector Spec version 1.0-rc1-20210608
Linjie Yu
Hi, all I encountered a difficulty of applying "vrgather" instruction recently. The details are shown blow: The date from source should be duplicated as pair in a upsample application. Eg: src = [0, 1, 2, 3, 4, 5, 6, 7, 8] dst = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8] So, my relazation is: -------------------------------------------------------------------------------------------------- int inex[64] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 ........,31,31};// to be compatibled of all the VLEN(128 ~ 1024) vfloat32m2_t data = vundefined_f32m2();
vfloat32m1_t
zero = (
vfloat32m1_t )vmv_v_i_i32m1(0); while(length >0) { int gvl = vsetvl_e32m1(length); vuint32m2_t v_index = vle32_v_u32m2(index, gvl); vfloat32m1_t src_data = vle32_v_f32m1(src, gvl); data = vset_f32m2(data, src_data, 0); data = vset_f32m2(data, zero, 1);
vfloat32m2_t res = vrrgather_vv_f32m2(data, v_index, gvl);
length -=gvl; src += gvl; vse32_v_f32m2(out, res, gvl); dst +=gvl; } ----------------------------------------------------------------------------------------------- As shown before, the index data should be initialized as the max VLEN to make the code
compatibled. So do all the applications, that need a constant. I think it is contrary to the idea of RISC-V, that one code can run on all the RISC-V hardware. Does anyone have a better method ? Best Regards Damon Yu
|
|