#ifndef CPU_RV64_GEMM_RVV_GEMM_UTILS_F32_HPP
#define CPU_RV64_GEMM_RVV_GEMM_UTILS_F32_HPP
#include "common/c_types_map.hpp"
#include <cstddef>
#include "xbyak_riscv/xbyak_riscv_util.hpp"
namespace dnnl {
namespace impl {
namespace cpu {
namespace rv64 {
namespace gemm_utils {
template <typename T, bool isTransA, bool isTransB>
struct gemm_traits_t {};
template <bool isTransA, bool isTransB>
struct gemm_traits_t<float, isTransA, isTransB> {
static constexpr dim_t BM = 4032;
static constexpr dim_t BN = isTransA ? 96 : 256;
static constexpr dim_t BK = isTransB ? 96 : 256;
};
template <typename T>
struct gemm_utils_traits;
template <>
struct gemm_utils_traits<float> {
static dim_t get_m_unroll_factor() {
static const dim_t m = []() -> dim_t {
const uint32_t vlen = Xbyak_riscv::CPU::getInstance().getVlen();
return static_cast<dim_t>(vlen / 32 * 4);
}();
return m;
}
static constexpr dim_t get_n_unroll_factor() { return 7; }
};
template <typename data_t>
void sum_two_matrices(dim_t m, dim_t n, data_t *__restrict p_src, dim_t ld_src,
data_t *__restrict p_dst, dim_t ld_dst) {
for (dim_t j = 0; j < n; j++) {
for (dim_t i = 0; i < m; i++) {
p_dst[i + j * ld_dst] += p_src[i + j * ld_src];
}
}
}
void calc_nthr_nocopy_rvv(dim_t m, dim_t n, dim_t k, int nthrs, int *nthrs_m,
int *nthrs_n, int *nthrs_k, dim_t *BM, dim_t *BN, dim_t *BK);
void partition_unit_diff(
int ithr, int nthr, dim_t n, dim_t *t_offset, dim_t *t_block);
void jit_rvv_gemm_kernel(const float *A, const float *B, float *C, dim_t lda,
dim_t ldb, dim_t ldc, dim_t K, float alpha, float beta, dim_t m,
dim_t n_cols, bool isTransA, bool isTransB);
} } } } } #endif