diff --git a/cmake/platform.cmake b/cmake/platform.cmake index f5de8521cd8..ca9da6c0d16 100644 --- a/cmake/platform.cmake +++ b/cmake/platform.cmake @@ -464,10 +464,17 @@ endif() if (DNNL_TARGET_ARCH STREQUAL "RV64") # Check if the RVV Intrinsics can be compiled with the current toolchain and flags include(CheckCXXSourceCompiles) - check_cxx_source_compiles("#include + check_cxx_source_compiles("#if !defined(__riscv) || !defined(__riscv_v) + #error \"RISC-V or vector extension(RVV) is not supported by the compiler\" + #endif + + #if defined(__riscv_v_intrinsic) && __riscv_v_intrinsic < 12000 + #error \"RISC-V intrinsics v0.12 or higher is required\" + #endif + + #include int main() { - size_t size = 64; - return vsetvl_e32m2(size); + return 0; };" CAN_COMPILE_RVV_INTRINSICS ) diff --git a/src/cpu/rv64/rvv_nchw_pooling.cpp b/src/cpu/rv64/rvv_nchw_pooling.cpp index 5ded8584251..e4a1b566c7f 100644 --- a/src/cpu/rv64/rvv_nchw_pooling.cpp +++ b/src/cpu/rv64/rvv_nchw_pooling.cpp @@ -57,9 +57,9 @@ void MaxPooling(const float *src, float *dst, const dim_t batch, int ow_offset = ow * strideW - padLeft; size_t size = std::min(ow_offset + kerW, inW) - std::max(ow_offset, 0); - size_t cycleLength = vsetvl_e32m8(size); - vfloat32m8_t vmax - = vle32_v_f32m8(&arr_flt_min[0], cycleLength); + size_t cycleLength = __riscv_vsetvl_e32m8(size); + vfloat32m8_t vmax = __riscv_vle32_v_f32m8( + &arr_flt_min[0], cycleLength); for (int id = std::max(od_offset, 0); id < std::min(od_offset + kerD, inD); id++) @@ -73,34 +73,35 @@ void MaxPooling(const float *src, float *dst, const dim_t batch, size_t iw = 0; for (; iw < size - cycleLength; iw += cycleLength) { - vfloat32m8_t vsrc = vle32_v_f32m8( + vfloat32m8_t vsrc = __riscv_vle32_v_f32m8( &local_src[local_src_offset + iw], cycleLength); - vmax = vfmax_vv_f32m8( + vmax = __riscv_vfmax_vv_f32m8( vsrc, vmax, cycleLength); } - size_t tailLength = vsetvl_e32m8(size - iw); + size_t tailLength + = __riscv_vsetvl_e32m8(size - iw); { - vfloat32m8_t vsrc = vle32_v_f32m8( + vfloat32m8_t vsrc = __riscv_vle32_v_f32m8( &local_src[local_src_offset + iw], tailLength); - vmax = vfmax_vv_f32m8( + vmax = __riscv_vfmax_vv_f32m8( vsrc, vmax, tailLength); } } vfloat32m1_t min_scalar; float min = -__FLT_MAX__; - min_scalar = vle32_v_f32m1(&min, 1); + min_scalar = __riscv_vle32_v_f32m1(&min, 1); - cycleLength = vsetvl_e32m8(size); + cycleLength = __riscv_vsetvl_e32m8(size); vfloat32m1_t vred_res; - vred_res = vfredmax_vs_f32m8_f32m1( - vred_res, vmax, min_scalar, cycleLength); + vred_res = __riscv_vfredmax_vs_f32m8_f32m1( + vmax, min_scalar, cycleLength); float red_res; - vse32_v_f32m1(&red_res, vred_res, 1); + __riscv_vse32_v_f32m1(&red_res, vred_res, 1); dst[dst_offset] = red_res; } }