mat kernel turns to be generic

This commit is contained in:
Youmu Liu
2025-09-19 20:38:44 +08:00
parent 8007eee846
commit 62cf2430f4
9 changed files with 111 additions and 178 deletions
+30 -20
View File
@@ -62,37 +62,37 @@ typedef uint64_t(SN_DECL *FACTORIALROC)(int n);
INTERNAL void normalize(__m128 *source, __m128 *target);
INTERNAL void SN_DECL f32_add_sse(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_add_avx(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_add_512(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_sub_sse(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_sub_avx(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_sub_512(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_transpose_sse(MAT_KERNEL(float) const *source,
MAT_KERNEL(float) * target);
MAT_KERNEL(float) *restrict target);
INTERNAL void SN_DECL f32_transpose_avx(MAT_KERNEL(float) const *source,
MAT_KERNEL(float) * target);
MAT_KERNEL(float) *restrict target);
INTERNAL void SN_DECL f32_transpose_512(MAT_KERNEL(float) const *source,
MAT_KERNEL(float) * target);
MAT_KERNEL(float) *restrict target);
INTERNAL void SN_DECL f32_scalar_mul_sse(MAT_KERNEL(float) const *matrix, float const scalar,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_scalar_mul_avx(MAT_KERNEL(float) const *matrix, float const scalar,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_scalar_mul_512(MAT_KERNEL(float) const *matrix, float const scalar,
MAT_KERNEL(float) * ans);
MAT_KERNEL(float) *restrict ans);
#pragma endregion
#pragma region fma
INTERNAL void SN_DECL kernel_fma_sse(MAT_KERNEL(float) const *restrict left,
MAT_KERNEL(float) const *restrict right,
MAT_KERNEL(float) *restrict ans);
INTERNAL void SN_DECL f32_fma_sse(MAT_KERNEL(float) const *restrict left,
MAT_KERNEL(float) const *restrict right,
MAT_KERNEL(float) *restrict ans);
#pragma endregion
@@ -100,6 +100,16 @@ INTERNAL void SN_DECL kernel_fma_sse(MAT_KERNEL(float) const *restrict left,
INTERNAL uint64_t SN_DECL factorial_simd_sse(int n);
#pragma endregion
#pragma region dot_product
INTERNAL void FORCEINLINE SN_DECL dot_41_sse(MAT_KERNEL(float) const *transpose,
__m128 const *vector, __m128 *ans);
INTERNAL void SN_DECL dot_41_avx(MAT_KERNEL(float) const *transpose, __m128 const *vector, __m128 *ans);
INTERNAL void SN_DECL dot_42_sse(MAT_KERNEL(float) const *transpose, __m128 const *vector, __m128 *ans);
INTERNAL void SN_DECL dot_42_avx(MAT_KERNEL(float) const *transpose, __m128 const *vector, __m128 *ans);
#pragma endregion
#pragma region string
INTERNAL int SN_DECL city_hash_simplify_sse(byte const *str, int length);
@@ -111,11 +121,11 @@ typedef struct sn_intrinsic {
int (*city_hash_simplify)(byte *str, int length);
FACTORIALROC factorial_simd;
int (*index_pair)(short const *str, uint32_t target, int length);
MATARITHMETIC kernel_add;
void (*kernel_fma)(void *left, void *right, void *ans);
SCALARMATARITHMETIC kernel_scalar_mul;
MATARITHMETIC kernel_sub;
MATTRANSPOSEPROC kernel_transpose;
MATARITHMETIC f32_add;
void (*f32_fma)(void *left, void *right, void *ans);
SCALARMATARITHMETIC f32_scalar_mul;
MATARITHMETIC f32_sub;
MATTRANSPOSEPROC f32_transpose;
VECTORNORMALIZEPROC normalize_3;
} sn_intrinsic;