time service contains bug, it cannot stop after edge
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
#include "StgSharpNative.h"
|
||||
#include "sn_matkernel.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Define and initialize a global zero kernel aligned to 64 bytes for universal ISA usage */
|
||||
__declspec(align(64)) MAT_KERNEL(uint64_t) SN_ZERO_KERNEL;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
__declspec(align(64)) sn_zero_kernel_u64 SN_ZERO_KERNEL;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static void init_zero_kernel(void)
|
||||
{
|
||||
for (int c = 0; c < 4; ++c) {
|
||||
for (int r = 0; r < 4; ++r) {
|
||||
SN_ZERO_KERNEL.m[r][c] = 0.0;
|
||||
SN_ZERO_KERNEL.m[r][c] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#include "sn_matkernel.h"
|
||||
|
||||
DECLARE_BUILD_PANEL(AVX, float)
|
||||
{
|
||||
const int Q = 8; /* fixed for AVX float panel */
|
||||
|
||||
/* Neighbor kernels; substitute global zero kernel where out-of-bounds */
|
||||
const int has_right = (col_index + 1) < col_length;
|
||||
const int has_bottom = (row_index + 1) < row_length;
|
||||
|
||||
const MAT_KERNEL(float) *const k_lt = matrix + (col_index * row_length + row_index);
|
||||
const MAT_KERNEL(float) *const k_rt =
|
||||
has_right ? (matrix + ((col_index + 1) * row_length + row_index)) :
|
||||
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
|
||||
const MAT_KERNEL(float) *const k_lb =
|
||||
has_bottom ? (matrix + (col_index * row_length + (row_index + 1))) :
|
||||
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
|
||||
const MAT_KERNEL(float) *const k_rb =
|
||||
(has_right && has_bottom) ?
|
||||
(matrix + ((col_index + 1) * row_length + (row_index + 1))) :
|
||||
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
|
||||
|
||||
register __m128 top128, bot128;
|
||||
register __m256 col256;
|
||||
|
||||
for (int pc = 0; pc < Q; ++pc) {
|
||||
const int is_right_half = (pc >= 4);
|
||||
const int kc_col = pc & 3; /* column index inside 4x4 kernel */
|
||||
|
||||
const MAT_KERNEL(float) *src_top = is_right_half ? k_rt : k_lt;
|
||||
const MAT_KERNEL(float) *src_bot = is_right_half ? k_rb : k_lb;
|
||||
|
||||
/* Vector loads: each kernel column is a compact __m128 */
|
||||
top128 = src_top->xmm[kc_col];
|
||||
bot128 = src_bot->xmm[kc_col];
|
||||
|
||||
/* Combine into an AVX column: low 128 = top, high 128 = bottom */
|
||||
col256 = _mm256_set_m128(bot128, top128);
|
||||
|
||||
PANEL_COL_VEC((*panel), pc, 0) = col256;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "sn_matkernel.h"
|
||||
|
||||
DECLARE_BUILD_PANEL(AVX, float)
|
||||
{
|
||||
const int Q = 8; /* fixed for AVX float panel */
|
||||
|
||||
/* Neighbor kernels; substitute global zero kernel where out-of-bounds */
|
||||
const int has_right = (col_index + 1) < col_length;
|
||||
const int has_bottom = (row_index + 1) < row_length;
|
||||
|
||||
const MAT_KERNEL(float) *const k_lt = matrix + (col_index * row_length + row_index);
|
||||
const MAT_KERNEL(float) *const k_rt =
|
||||
has_right ? (matrix + ((col_index + 1) * row_length + row_index)) :
|
||||
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
|
||||
const MAT_KERNEL(float) *const k_lb =
|
||||
has_bottom ? (matrix + (col_index * row_length + (row_index + 1))) :
|
||||
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
|
||||
const MAT_KERNEL(float) *const k_rb =
|
||||
(has_right && has_bottom) ?
|
||||
(matrix + ((col_index + 1) * row_length + (row_index + 1))) :
|
||||
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
|
||||
|
||||
register __m128 top128, bot128;
|
||||
register __m256 col256;
|
||||
|
||||
for (int pc = 0; pc < Q; ++pc) {
|
||||
const int is_right_half = (pc >= 4);
|
||||
const int kc_col = pc & 3; /* column index inside 4x4 kernel */
|
||||
|
||||
const MAT_KERNEL(float) *src_top = is_right_half ? k_rt : k_lt;
|
||||
const MAT_KERNEL(float) *src_bot = is_right_half ? k_rb : k_lb;
|
||||
|
||||
/* Vector loads: each kernel column is a compact __m128 */
|
||||
top128 = src_top->xmm[kc_col];
|
||||
bot128 = src_bot->xmm[kc_col];
|
||||
|
||||
/* Combine into an AVX column: low 128 = top, high 128 = bottom */
|
||||
col256 = _mm256_set_m128(bot128, top128);
|
||||
|
||||
PANEL_COL_VEC((*panel), pc, 0) = col256;
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_STORE_PANEL(AVX, float)
|
||||
{
|
||||
const int Q = 8; /* fixed for AVX float panel */
|
||||
|
||||
/* Local dummy kernel to swallow out-of-bounds writes; no init needed */
|
||||
MAT_KERNEL(float) zero;
|
||||
|
||||
const int has_right = (col_index + 1) < col_length;
|
||||
const int has_bottom = (row_index + 1) < row_length;
|
||||
|
||||
MAT_KERNEL(float) *const k_lt = (col_index < col_length && row_index < row_length) ?
|
||||
(matrix + (col_index * row_length + row_index)) :
|
||||
&zero;
|
||||
MAT_KERNEL(float) *const k_rt =
|
||||
has_right && (row_index < row_length) ?
|
||||
(matrix + ((col_index + 1) * row_length + row_index)) :
|
||||
&zero;
|
||||
MAT_KERNEL(float) *const k_lb =
|
||||
has_bottom && (col_index < col_length) ?
|
||||
(matrix + (col_index * row_length + (row_index + 1))) :
|
||||
&zero;
|
||||
MAT_KERNEL(float) *const k_rb =
|
||||
(has_right && has_bottom) ?
|
||||
(matrix + ((col_index + 1) * row_length + (row_index + 1))) :
|
||||
&zero;
|
||||
|
||||
register __m128 top128, bot128;
|
||||
int i = 0;
|
||||
for (; i < Q / 2; i++) {
|
||||
const int kc_col = i; /* column index inside 4x4 kernel */
|
||||
|
||||
/* Load the panel column vector */
|
||||
const __m256 col256 = PANEL_COL_VEC((*panel), i, 0);
|
||||
/* Split into top/bottom halves */
|
||||
top128 = _mm256_castps256_ps128(col256); /* low 128 */
|
||||
bot128 = _mm256_extractf128_ps(col256, 1); /* high 128 */
|
||||
|
||||
/* Store back into kernels directly (out-of-bounds writes go to dummy) */
|
||||
k_rt->xmm[kc_col] = top128;
|
||||
k_rb->xmm[kc_col] = bot128;
|
||||
}
|
||||
for (; i < Q; i++) {
|
||||
const int kc_col = i - 4; /* column index inside 4x4 kernel */
|
||||
|
||||
/* Load the panel column vector */
|
||||
const __m256 col256 = PANEL_COL_VEC((*panel), i, 0);
|
||||
/* Split into top/bottom halves */
|
||||
top128 = _mm256_castps256_ps128(col256); /* low 128 */
|
||||
bot128 = _mm256_extractf128_ps(col256, 1); /* high 128 */
|
||||
|
||||
/* Store back into kernels directly (out-of-bounds writes go to dummy) */
|
||||
k_lt->xmm[kc_col] = top128;
|
||||
k_lb->xmm[kc_col] = bot128;
|
||||
}
|
||||
}
|
||||
@@ -68,9 +68,10 @@ void load_intrinsic_sse(sn_intrinsic *context)
|
||||
context->f32_buffer_add = BUF_PROC(float, sse, add);
|
||||
context->f32_panel_fma = KER_PROC(float, sse, fma);
|
||||
context->f32_buffer_fill = BUF_PROC(float, sse, fill);
|
||||
context->f32_kernel_scalar_mul = BUF_PROC(float, sse, scalar_mul);
|
||||
context->f32_kernel_sub = BUF_PROC(float, sse, sub);
|
||||
context->f32_kernel_transpose = KER_PROC(float, sse, transpose);
|
||||
context->variant = BUF_PROC(float, sse, scalar_mul);
|
||||
context->f32_buffer_sub = BUF_PROC(float, sse, sub);
|
||||
context->f32_buffer_transpose = KER_PROC(float, sse, transpose);
|
||||
context->f32_buffer_scalar_mul = BUF_PROC(float, sse, scalar_mul);
|
||||
context->f32_normalize_3 = f32_normalize;
|
||||
}
|
||||
|
||||
@@ -82,9 +83,10 @@ void load_intrinsic_avx(sn_intrinsic *context)
|
||||
context->f32_buffer_add = BUF_PROC(float, avx, add);
|
||||
context->f32_panel_fma = KER_PROC(float, sse, fma);
|
||||
context->f32_buffer_fill = BUF_PROC(float, avx, fill);
|
||||
context->f32_kernel_scalar_mul = BUF_PROC(float, avx, scalar_mul);
|
||||
context->f32_kernel_sub = BUF_PROC(float, avx, sub);
|
||||
context->f32_kernel_transpose = KER_PROC(float, avx, transpose);
|
||||
context->variant = BUF_PROC(float, avx, scalar_mul);
|
||||
context->f32_buffer_sub = BUF_PROC(float, avx, sub);
|
||||
context->f32_buffer_transpose = KER_PROC(float, avx, transpose);
|
||||
context->f32_buffer_scalar_mul = BUF_PROC(float, avx, scalar_mul);
|
||||
context->f32_normalize_3 = f32_normalize;
|
||||
}
|
||||
|
||||
@@ -96,8 +98,9 @@ void load_intrinsic_512(sn_intrinsic *context)
|
||||
context->f32_buffer_add = BUF_PROC(float, 512, add);
|
||||
context->f32_panel_fma = KER_PROC(float, sse, fma);
|
||||
context->f32_buffer_fill = BUF_PROC(float, 512, fill);
|
||||
context->f32_kernel_scalar_mul = BUF_PROC(float, 512, scalar_mul);
|
||||
context->f32_kernel_sub = BUF_PROC(float, 512, sub);
|
||||
context->f32_kernel_transpose = KER_PROC(float, 512, transpose);
|
||||
context->variant = BUF_PROC(float, 512, scalar_mul);
|
||||
context->f32_buffer_sub = BUF_PROC(float, 512, sub);
|
||||
context->f32_buffer_transpose = KER_PROC(float, 512, transpose);
|
||||
context->f32_buffer_scalar_mul = BUF_PROC(float, 512, scalar_mul);
|
||||
context->f32_normalize_3 = f32_normalize;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user