Skip to content

Commit ee904b5

Browse files
cosmo0920edsiper
authored andcommitted
simd: Use __riscv_vsetvl_eXXm1 function to get the actual width of RVV instructions
This is because RVV instructions are truely hardware dependent. So, we need to obtain the actual width with the specific instriction of RVV extentions. Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 5dd2b0b commit ee904b5

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

include/fluent-bit/flb_simd.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,27 @@ typedef uint32x4_t flb_vector32;
7777
typedef vuint8m1_t flb_vector8;
7878
typedef vuint32m1_t flb_vector32;
7979

80-
#define RVV_VEC8_INST_LEN (128 / 8) /* 16 */
81-
#define RVV_VEC32_INST_LEN (128 / 8 / 4) /* 4 */
80+
static size_t vec8_vl_cached = 0;
81+
static size_t vec32_vl_cached = 0;
82+
83+
static inline size_t flb_rvv_get_vec8_vl()
84+
{
85+
if (vec8_vl_cached == 0) {
86+
vec8_vl_cached = __riscv_vsetvl_e8m1(16);
87+
}
88+
return vec8_vl_cached;
89+
}
90+
91+
static inline size_t flb_rvv_get_vec32_vl()
92+
{
93+
if (vec32_vl_cached == 0) {
94+
vec32_vl_cached = __riscv_vsetvl_e32m1(4);
95+
}
96+
return vec32_vl_cached;
97+
}
98+
99+
#define RVV_VEC8_INST_LEN flb_rvv_get_vec8_vl() /* 16 */
100+
#define RVV_VEC32_INST_LEN flb_rvv_get_vec32_vl() /* 4 */
82101

83102
#else
84103
/*

0 commit comments

Comments
 (0)