Skip to content

Commit

Permalink
simd: utils: Encapsulate to calculate instruction length for RVV
Browse files Browse the repository at this point in the history
This is because RVV's instruction set is not having a fixed length.
Instead, RVV needs to specify the VLEN for the width of vectorized
calcucaltion.
In this case, we assumed as 128 for VLEN.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Jan 9, 2025
1 parent 2a8e1ae commit 788eaa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 9 additions & 0 deletions include/fluent-bit/flb_simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ typedef uint64_t flb_vector8;
typedef uint8_t flb_vector8;
#endif /* FLB_SIMD_DISABLED */

/* RVV's instruction length is flexible and not fixed width.
* We assumed that VLEN which is the fundamental intsruction length is 128.
*/
#if defined(FLB_SIMD_RVV)
#define FLB_SIMD_VEC8_INST_LEN RVV_VEC8_INST_LEN
#else
#define FLB_SIMD_VEC8_INST_LEN sizeof(flb_vector8)
#endif

/* element-wise comparisons to a scalar */
static inline bool flb_vector8_has(const flb_vector8 v, const uint8_t c);
static inline bool flb_vector8_has_zero(const flb_vector8 v);
Expand Down
6 changes: 1 addition & 5 deletions src/flb_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,7 @@ int flb_utils_write_str(char *buf, int *off, size_t size, const char *str, size_
off_t offset = 0;
char tmp[16];
char *p;
#if defined(FLB_SIMD_RVV)
const size_t inst_len = RVV_VEC8_INST_LEN;
#else
const size_t inst_len = sizeof(flb_vector8);
#endif
const size_t inst_len = FLB_SIMD_VEC8_INST_LEN;

/* to encode codepoints > 0xFFFF */
uint16_t high;
Expand Down

0 comments on commit 788eaa8

Please sign in to comment.