add simd id and cpu id
This commit is contained in:
@@ -13,10 +13,9 @@
|
||||
#include <cpuid.h>
|
||||
#endif // _MSC_VER
|
||||
|
||||
PRIVATE void load_intrinsic_sse(sn_intrinsic *context);
|
||||
PRIVATE void load_intrinsic_avx(sn_intrinsic *context);
|
||||
PRIVATE void load_intrinsic_avx_fma(sn_intrinsic *context);
|
||||
PRIVATE void load_intrinsic_512(sn_intrinsic *context, SIMDID simdid);
|
||||
PRIVATE void load_intrinsic_sse(sn_intrinsic *context, SIMDID id);
|
||||
PRIVATE void load_intrinsic_avx(sn_intrinsic *context, SIMDID id);
|
||||
PRIVATE void load_intrinsic_512(sn_intrinsic *context, SIMDID id);
|
||||
|
||||
SN_API SIMDID load_intrinsic_function(void *intrinsic_context)
|
||||
{
|
||||
@@ -26,18 +25,21 @@ SN_API SIMDID load_intrinsic_function(void *intrinsic_context)
|
||||
|
||||
sn_intrinsic *context = (sn_intrinsic *)intrinsic_context;
|
||||
|
||||
if (check_isa(AVX512)) {
|
||||
switch (simdid.make_byte[1]) {
|
||||
case SIMDID_MAIN_LVL_SSE:
|
||||
load_intrinsic_sse(context, simdid);
|
||||
break;
|
||||
case SIMDID_MAIN_LVL_AVX2:
|
||||
load_intrinsic_avx(context, simdid);
|
||||
break;
|
||||
case SIMDID_MAIN_LVL_AVX512:
|
||||
load_intrinsic_512(context, simdid);
|
||||
} else if (check_isa(AVX256)) {
|
||||
load_intrinsic_avx(context);
|
||||
} else if (check_isa(SSE)) {
|
||||
load_intrinsic_sse(context);
|
||||
break;
|
||||
}
|
||||
|
||||
return simdid;
|
||||
}
|
||||
|
||||
void load_intrinsic_sse(sn_intrinsic *context)
|
||||
void load_intrinsic_sse(sn_intrinsic *context, SIMDID id)
|
||||
{
|
||||
context->city_hash_simplify = city_hash_simplify_sse;
|
||||
context->factorial_simd = factorial_simd_sse;
|
||||
@@ -47,10 +49,10 @@ void load_intrinsic_sse(sn_intrinsic *context)
|
||||
context->mat[F32].buffer_fill = BUF_PROC(float, sse, , fill);
|
||||
context->mat[F32].buffer_scalar_mul = BUF_PROC(float, sse, , scalar_mul);
|
||||
context->mat[F32].buffer_sub = BUF_PROC(float, sse, , sub);
|
||||
context->mat[F32].buffer_transpose = KER_PROC(float, sse, transpose);
|
||||
context->mat[F32].buffer_transpose = KER_PROC(float, sse, , transpose);
|
||||
context->mat[F32].build_panel = NULL;
|
||||
context->mat[F32].clear_panel = PNL_PROC(float, sse, , clear);
|
||||
context->mat[F32].panel_fma = PNL_PROC(float, sse, , fma);
|
||||
context->mat[F32].panel_fma = KER_PROC(float, sse, , fma);
|
||||
context->mat[F32].pivot = pivot_float;
|
||||
context->mat[F32].store_panel = NULL;
|
||||
|
||||
@@ -68,8 +70,12 @@ void load_intrinsic_sse(sn_intrinsic *context)
|
||||
context->vec_f32_normalize_3 = f32_normalize;
|
||||
}
|
||||
|
||||
void load_intrinsic_avx(sn_intrinsic *context)
|
||||
void load_intrinsic_avx(sn_intrinsic *context, SIMDID id)
|
||||
{
|
||||
char avx_seg = id.make_byte[5];
|
||||
char is_fma = (avx_seg & 1 << 3) != 0;
|
||||
char is_f16c = (avx_seg & 1 << 4) != 0;
|
||||
|
||||
context->city_hash_simplify = city_hash_simplify_sse;
|
||||
context->factorial_simd = factorial_simd_sse;
|
||||
context->index_pair = index_pair_sse;
|
||||
@@ -78,10 +84,11 @@ void load_intrinsic_avx(sn_intrinsic *context)
|
||||
context->mat[F32].buffer_fill = BUF_PROC(float, avx, , fill);
|
||||
context->mat[F32].buffer_scalar_mul = BUF_PROC(float, avx, , scalar_mul);
|
||||
context->mat[F32].buffer_sub = BUF_PROC(float, avx, , sub);
|
||||
context->mat[F32].buffer_transpose = KER_PROC(float, avx, transpose);
|
||||
context->mat[F32].buffer_transpose = KER_PROC(float, avx, , transpose);
|
||||
context->mat[F32].build_panel = BUILD_PANEL(avx, float);
|
||||
context->mat[F32].clear_panel = PNL_PROC(float, avx, , clear);
|
||||
context->mat[F32].panel_fma = PNL_PROC(float, avx, , fma);
|
||||
context->mat[F32].panel_fma = is_fma ? KER_PROC(float, avx, , fma) :
|
||||
KER_PROC(float, avx, _fma, fma);
|
||||
context->mat[F32].pivot = pivot_float;
|
||||
context->mat[F32].store_panel = STORE_PANEL(avx, float);
|
||||
|
||||
@@ -92,7 +99,8 @@ void load_intrinsic_avx(sn_intrinsic *context)
|
||||
context->mat[F64].buffer_transpose = NULL;
|
||||
context->mat[F64].build_panel = NULL;
|
||||
context->mat[F64].clear_panel = PNL_PROC(double, avx, , clear);
|
||||
context->mat[F64].panel_fma = PNL_PROC(double, avx, , fma);
|
||||
context->mat[F64].panel_fma = is_fma ? PNL_PROC(double, avx, , fma) :
|
||||
PNL_PROC(double, avx, _fma, fma);
|
||||
context->mat[F64].pivot = NULL;
|
||||
context->mat[F64].store_panel = NULL;
|
||||
|
||||
@@ -109,10 +117,10 @@ void load_intrinsic_512(sn_intrinsic *context, SIMDID id)
|
||||
context->mat[F32].buffer_fill = BUF_PROC(float, 512, , fill);
|
||||
context->mat[F32].buffer_scalar_mul = BUF_PROC(float, 512, , scalar_mul);
|
||||
context->mat[F32].buffer_sub = BUF_PROC(float, 512, , sub);
|
||||
context->mat[F32].buffer_transpose = KER_PROC(float, 512, transpose);
|
||||
context->mat[F32].buffer_transpose = KER_PROC(float, 512, , transpose);
|
||||
context->mat[F32].build_panel = BUILD_PANEL(512, float);
|
||||
context->mat[F32].clear_panel = PNL_PROC(float, 512, , clear);
|
||||
context->mat[F32].panel_fma = PNL_PROC(float, 512, , fma);
|
||||
context->mat[F32].panel_fma = KER_PROC(float, 512, , fma);
|
||||
context->mat[F32].pivot = pivot_float;
|
||||
context->mat[F32].store_panel = STORE_PANEL(512, float);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user