mat kernel turns to be generic
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
#ifndef SSC_INTRIN
|
||||
#define SSC_INTRIN
|
||||
|
||||
#define SSC_INTRIN_HEAD
|
||||
|
||||
#include "StgSharpNative.h"
|
||||
#include "sn_matkernel.h"
|
||||
#include <immintrin.h>
|
||||
#include <smmintrin.h>
|
||||
|
||||
@@ -39,25 +42,6 @@ typedef union mat_kernel {
|
||||
float m[4][4];
|
||||
} mat_kernel;
|
||||
|
||||
typedef union column_2 {
|
||||
__m256 stream;
|
||||
__m128 column[2];
|
||||
float m[4][2];
|
||||
} __2_columnset;
|
||||
|
||||
typedef union column_3 {
|
||||
__m256 part;
|
||||
__m128 column[3];
|
||||
float m[4][3];
|
||||
} __3_columnset;
|
||||
|
||||
typedef union column_4 {
|
||||
__m512 stream;
|
||||
__m256 half[2];
|
||||
__m128 column[4];
|
||||
float m[4][4];
|
||||
} __4_columnset;
|
||||
|
||||
typedef union scalar_pack {
|
||||
uint64_t data[8];
|
||||
} scalar_pack;
|
||||
@@ -77,34 +61,38 @@ typedef uint64_t(SN_DECL *FACTORIALROC)(int n);
|
||||
|
||||
INTERNAL void normalize(__m128 *source, __m128 *target);
|
||||
|
||||
INTERNAL void SN_DECL kernel_add_sse(mat_kernel const *left, mat_kernel const *right,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_add_avx(mat_kernel const *left, mat_kernel const *right,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_add_512(mat_kernel const *left, mat_kernel const *right,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_sub_sse(mat_kernel const *left, mat_kernel const *right,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_sub_avx(mat_kernel const *left, mat_kernel const *right,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_sub_512(mat_kernel const *left, mat_kernel const *right,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_transpose_sse(mat_kernel const *source, mat_kernel *target);
|
||||
INTERNAL void SN_DECL kernel_transpose_avx(mat_kernel const *source, mat_kernel *target);
|
||||
INTERNAL void SN_DECL kernel_transpose_512(mat_kernel const *source, mat_kernel *target);
|
||||
INTERNAL void SN_DECL kernel_scalar_mul_sse(mat_kernel const *matrix, float const scalar,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_scalar_mul_avx(mat_kernel const *matrix, float const scalar,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL kernel_scalar_mul_512(mat_kernel const *matrix, float const scalar,
|
||||
mat_kernel *ans);
|
||||
INTERNAL void SN_DECL f32_add_sse(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_add_avx(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_add_512(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_sub_sse(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_sub_avx(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_sub_512(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_transpose_sse(MAT_KERNEL(float) const *source,
|
||||
MAT_KERNEL(float) * target);
|
||||
INTERNAL void SN_DECL f32_transpose_avx(MAT_KERNEL(float) const *source,
|
||||
MAT_KERNEL(float) * target);
|
||||
INTERNAL void SN_DECL f32_transpose_512(MAT_KERNEL(float) const *source,
|
||||
MAT_KERNEL(float) * target);
|
||||
INTERNAL void SN_DECL f32_scalar_mul_sse(MAT_KERNEL(float) const *matrix, float const scalar,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_scalar_mul_avx(MAT_KERNEL(float) const *matrix, float const scalar,
|
||||
MAT_KERNEL(float) * ans);
|
||||
INTERNAL void SN_DECL f32_scalar_mul_512(MAT_KERNEL(float) const *matrix, float const scalar,
|
||||
MAT_KERNEL(float) * ans);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region fma
|
||||
|
||||
INTERNAL void SN_DECL kernel_fma_sse(mat_kernel const *restrict left,
|
||||
mat_kernel const *restrict right, mat_kernel *restrict ans);
|
||||
INTERNAL void SN_DECL kernel_fma_sse(MAT_KERNEL(float) const *restrict left,
|
||||
MAT_KERNEL(float) const *restrict right,
|
||||
MAT_KERNEL(float) *restrict ans);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SN_MATKERNEL
|
||||
#define SN_MATKERNEL
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
#define ELEMENTSIZE(T) sizeof(T)
|
||||
#define XMMCOUNT(T) sizeof(T) / 16
|
||||
#define YMMCOUNT(T) sizeof(T) / 32
|
||||
#define ZMMCOUNT(T) sizeof(T) / 64
|
||||
|
||||
#define MAT_KERNEL(T) \
|
||||
union { \
|
||||
__m128 xmm[XMMCOUNT(T)]; \
|
||||
__m256 ymm[YMMCOUNT(T)]; \
|
||||
__m512 zmm[ZMMCOUNT(T)]; \
|
||||
T m[16]; \
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user