new mat proc std
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#define SSC_INTRIN_HEAD
|
||||
|
||||
#include "StgSharpNative.h"
|
||||
#include "sn_matkernel.h"
|
||||
#include "sn_intrinsic.matkernel.h"
|
||||
#include <immintrin.h>
|
||||
#include <smmintrin.h>
|
||||
#include <stdint.h>
|
||||
@@ -47,18 +47,6 @@ typedef union scalar_pack {
|
||||
uint64_t data[8];
|
||||
} scalar_pack;
|
||||
|
||||
// define operation style:
|
||||
|
||||
#define PANEL_OP 1
|
||||
#define BUFFER_OP 2
|
||||
#define KERNEL_OP 3
|
||||
|
||||
#define RIGHT_ANS_PARAM 1
|
||||
#define LEFT_RIGHT_ANS_PARAM 2
|
||||
#define RIGHT_ANS_SCALAR_PARAM 3
|
||||
#define LEFT_RIGHT_ANS_SCALAR_PARAM 4
|
||||
#define ANS_SCALAR_PARAM 5
|
||||
|
||||
/* Mirrors StgSharp.Mathematics.Numeric.MatrixParallelTaskPackage<T> (128 bytes). */
|
||||
#define MAT_TASK(T) \
|
||||
struct { \
|
||||
@@ -84,140 +72,7 @@ static_assert(sizeof(matrix_task) == 128, "matrix_parallel_task_package size mis
|
||||
static_assert(sizeof(MAT_TASK(float)) == 128, "matrix_parallel_task_package size mismatch");
|
||||
#endif
|
||||
|
||||
typedef void(SN_DECL *UNIFIKERNELPROC)(matrix_task *task);
|
||||
#define UNIFIKERNRLPROC(T_arch, T_feature, T_op) mat_proc_##T_op##_##T_arch##_##T_feature
|
||||
|
||||
#pragma region matrix buffer operation function type
|
||||
|
||||
typedef void(SN_DECL *BUF_PROC_AS)(mat_kernel *ans, scalar_pack *scalar, int count);
|
||||
typedef void(SN_DECL *BUF_PROC_RAS)(mat_kernel *right, mat_kernel *ans, scalar_pack *scalar,
|
||||
int count);
|
||||
typedef void(SN_DECL *BUF_PROC_LRAS)(mat_kernel *left, mat_kernel *right, mat_kernel *ans,
|
||||
scalar_pack *scalar, int count);
|
||||
typedef void(SN_DECL *BUF_PROC_RA)(mat_kernel *right, mat_kernel *ans, int count);
|
||||
typedef void(SN_DECL *BUF_PROC_LRA)(mat_kernel *left, mat_kernel *right, mat_kernel *ans,
|
||||
int count);
|
||||
|
||||
#define BUF_PROC(T_type, T_arch, T_feature, T_op_name) \
|
||||
T_type##_buf_##T_op_name##_##T_arch##T_feature
|
||||
|
||||
#define DECLARE_BUF_PROC_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL BUF_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) *restrict ans, scalar_pack const *scalar, size_t count)
|
||||
#define DECLARE_BUF_PROC_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL BUF_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *right, MAT_KERNEL(T_type) *restrict ans, \
|
||||
scalar_pack const *scalar, size_t count)
|
||||
#define DECLARE_BUF_PROC_LEFT_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL BUF_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
|
||||
MAT_KERNEL(T_type) *restrict ans, scalar_pack const *scalar, size_t count)
|
||||
#define DECLARE_BUF_PROC_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL BUF_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *right, MAT_KERNEL(T_type) *restrict ans, size_t count)
|
||||
#define DECLARE_BUF_PROC_LEFT_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL BUF_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
|
||||
MAT_KERNEL(T_type) *restrict ans, size_t count)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region matrix panel function type
|
||||
|
||||
typedef void(SN_DECL *PANEL_PROC)(mat_panel *panel, mat_kernel *kernel, int col_length,
|
||||
int row_length, int col_index, int row_index);
|
||||
typedef void(SN_DECL *PNL_PROC_LRA)(mat_panel *left, mat_panel *right, mat_panel *ans);
|
||||
typedef void(SN_DECL *PNL_PROC_RA)(mat_panel *right, mat_panel *ans);
|
||||
typedef void(SN_DECL *PNL_PROC_LRAS)(mat_panel *left, mat_panel *right, mat_panel *ans,
|
||||
scalar_pack *scalar);
|
||||
typedef void(SN_DECL *PNL_PROC_RAS)(mat_panel *right, mat_panel *ans, scalar_pack *scalar);
|
||||
|
||||
#define PNL_PROC(T_type, T_arch, T_feature, T_op_name) \
|
||||
T_type##_pnl_##T_op_name##_##T_arch##T_feature
|
||||
#define DECLARE_PNL_PROC_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL PNL_PROC(T_type, T_arch, T_feature, \
|
||||
T_op_name)(MAT_PANEL_##T_arch##(T_type) *restrict ans)
|
||||
#define DECLARE_PNL_PROC_LEFT_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL PNL_PROC(T_type, T_arch, T_feature, \
|
||||
T_op_name)(MAT_PANEL_##T_arch##(T_type) const *left, \
|
||||
MAT_PANEL_##T_arch##(T_type) const *right, \
|
||||
MAT_PANEL_##T_arch##(T_type) *restrict ans)
|
||||
#define DECLARE_PNL_PROC_LEFT_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL PNL_PROC(T_type, T_arch, T_op_name)( \
|
||||
MAT_PANEL_##T_arch##(T_type) const *left, \
|
||||
MAT_PANEL_##T_arch##(T_type) const *right, \
|
||||
MAT_PANEL_##T_arch##(T_type) *restrict ans, scalar_pack const *scalar)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region matrix kernel function type
|
||||
|
||||
typedef void(SN_DECL *KER_PROC_AS)(mat_kernel *ans, scalar_pack *scalar);
|
||||
typedef void(SN_DECL *KER_PROC_RA)(mat_kernel *left, mat_kernel *ans);
|
||||
typedef void(SN_DECL *KER_PROC_LRA)(mat_kernel *left, mat_kernel *right, mat_kernel *ans);
|
||||
typedef void(SN_DECL *KER_PROC_LAS)(mat_kernel *matrix, mat_kernel *ans, scalar_pack *scalar);
|
||||
|
||||
#define KER_PROC(T_type, T_arch, T_feature, T_op_name) \
|
||||
T_type##_kernel_##T_op_name##_##T_arch##T_feature
|
||||
|
||||
#define DECLARE_KER_PROC_LEFT_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KER_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
|
||||
MAT_KERNEL(T_type) *restrict ans, scalar_pack const *scalar)
|
||||
#define DECLARE_KER_PROC_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KER_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *right, MAT_KERNEL(T_type) *restrict ans, \
|
||||
scalar_pack const *scalar)
|
||||
#define DECLARE_KER_PROC_LEFT_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KER_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
|
||||
MAT_KERNEL(T_type) *restrict ans)
|
||||
#define DECLARE_KER_PROC_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KER_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *right, MAT_KERNEL(T_type) *restrict ans)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region matrix kernel tile function type
|
||||
|
||||
typedef void(SN_DECL *KERTILE_PROC_AS)(mat_kernel *ans, scalar_pack *scalar, __m128 *enumeration);
|
||||
typedef void(SN_DECL *KERTILE_PROC_RA)(mat_kernel *left, mat_kernel *ans, __m128 *enumeration);
|
||||
typedef void(SN_DECL *KERTILE_PROC_LRA)(mat_kernel *left, mat_kernel *right, mat_kernel *ans,
|
||||
__m128 *enumeration);
|
||||
typedef void(SN_DECL *KERTILE_PROC_LAS)(mat_kernel *matrix, mat_kernel *ans, scalar_pack *scalar,
|
||||
__m128 *enumeration);
|
||||
|
||||
#define KERTILE_PROC(T_type, T_arch, T_feature, T_op_name) \
|
||||
T_type##_kernel_tile_##T_op_name##_##T_arch##T_feature
|
||||
|
||||
#define DECLARE_KERTILE_PROC_LEFT_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KERTILE_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
|
||||
MAT_KERNEL(T_type) *restrict ans, scalar_pack const *scalar, \
|
||||
__m128 const *enumeration)
|
||||
#define DECLARE_KERTILE_PROC_RIGHT_ANS_SCALAR(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KERTILE_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *right, MAT_KERNEL(T_type) *restrict ans, \
|
||||
scalar_pack const *scalar, __m128 const *enumeration)
|
||||
#define DECLARE_KERTILE_PROC_LEFT_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KERTILE_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
|
||||
MAT_KERNEL(T_type) *restrict ans, __m128 const *enumeration)
|
||||
#define DECLARE_KERTILE_PROC_RIGHT_ANS(T_type, T_arch, T_feature, T_op_name) \
|
||||
INTERNAL void SN_DECL KERTILE_PROC(T_type, T_arch, T_feature, T_op_name)( \
|
||||
MAT_KERNEL(T_type) const *right, MAT_KERNEL(T_type) *restrict ans, \
|
||||
__m128 const *enumeration)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region special matrix kernel operation
|
||||
|
||||
typedef void(SN_DECL *PIVOTPROC)(mat_kernel const *source, size_t col_begin, size_t col_length,
|
||||
size_t *restrict ans);
|
||||
INTERNAL void SN_DECL pivot_float(MAT_KERNEL(float) const *source, size_t col_begin,
|
||||
size_t col_length, size_t *restrict ans);
|
||||
|
||||
#pragma endregion
|
||||
typedef void(SN_DECL *UNI_MK_PROC)(matrix_task *task);
|
||||
|
||||
typedef void(SN_DECL *VECTORNORMALIZEPROC)(__m128 *source, __m128 *target);
|
||||
typedef void(SN_DECL *DOTPROC)(void *transpose, __m128 *vector, __m128 *ans);
|
||||
@@ -231,15 +86,15 @@ typedef int(SN_DECL *INDEX_PAIR)(short const *stram, uint32_t target, int length
|
||||
#pragma endregion
|
||||
|
||||
typedef struct mat_intrinsic {
|
||||
UNIFIKERNELPROC buffer_add;
|
||||
UNIFIKERNELPROC buffer_fill;
|
||||
UNIFIKERNELPROC buffer_scalar_mul;
|
||||
UNIFIKERNELPROC buffer_sub;
|
||||
UNIFIKERNELPROC buffer_transpose;
|
||||
UNIFIKERNELPROC clear_panel;
|
||||
UNIFIKERNELPROC ker_fma;
|
||||
UNIFIKERNELPROC ker_tile_fma;
|
||||
UNIFIKERNELPROC pivot;
|
||||
UNI_MK_PROC buffer_add;
|
||||
UNI_MK_PROC buffer_fill;
|
||||
UNI_MK_PROC buffer_scalar_mul;
|
||||
UNI_MK_PROC buffer_sub;
|
||||
UNI_MK_PROC buffer_transpose;
|
||||
UNI_MK_PROC clear_panel;
|
||||
UNI_MK_PROC ker_fma;
|
||||
UNI_MK_PROC ker_tile_fma;
|
||||
UNI_MK_PROC pivot;
|
||||
|
||||
} mat_intrinsic;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user