adjust for clang-gcc

This commit is contained in:
Youmu Liu
2026-04-03 18:40:11 +08:00
parent 2f74e5e8a9
commit d702b3224c
19 changed files with 217 additions and 126 deletions
+3 -3
View File
@@ -13,7 +13,6 @@
#include "gl.h"
#include "wgl.h"
#define GLFWAPI INTERNAL
#include "glfw\glfw3.h"
#include <immintrin.h>
#include <assert.h>
@@ -71,11 +70,12 @@ SN_API void SN_DECL load_intrinsic_function(void *intrinsic_context, uint64_t id
SN_API SIMDID SN_DECL sn_get_unite_simd(SIMDID left, SIMDID right);
SN_API int SN_DECL sn_compare_simd(SIMDID left, SIMDID right);
SN_API void SN_DECL sn_set_thread_affinity(int core_id);
SN_API void SN_DECL sn_get_numa_overall(int *out_numa_count, int *count_of_each_numa);
SN_API void SN_DECL sn_get_numa_each(int numa_id, uint64_t *in_numa_cpuid, uint64_t *global_cpuid);
SN_API int SN_DECL sn_get_numa_overall(int *out_numa_count, int *count_of_each_numa);
SN_API int SN_DECL sn_get_numa_each(int numa_id, uint64_t *in_numa_cpuid, uint64_t *global_cpuid);
/* Per-core variant: always re-executes CPUID, never caches.
* Must be called on the target core (after affinity is set). */
SN_API SIMDID SN_DECL sn_get_simd_level_local();
SN_API SIMDID SN_DECL sn_get_simd_level_global();
#pragma endregion
#ifdef __cplusplus
+6 -1
View File
@@ -2,7 +2,7 @@
#ifndef SN_INTERNAL
#define SN_INTERNAL
#include <xmmintrin.h>
#include <immintrin.h>
#define UNSAFE_AS(type, expr) *(type *)&(expr)
@@ -37,4 +37,9 @@
#define PRIVATE static
#define INTERNAL extern
#define SN_PTR_CAST(type, expr) ((type *)(void *)(expr))
#define SN_CONST_PTR_CAST(type, expr) ((type const *)(void const *)(expr))
#define SN_REF_CAST(type, expr) ((type *)(void *)&(expr))
#define SN_CONST_REF_CAST(type, expr) ((type const *)(void const *)&(expr))
#endif //
@@ -239,8 +239,8 @@ INTERNAL uint64_t SN_DECL factorial_simd_sse(int n);
#pragma region dot_product
INTERNAL void FORCEINLINE SN_DECL dot_41_sse(MAT_KERNEL(float) const *transpose,
__m128 const *vector, __m128 *ans);
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,
+9 -3
View File
@@ -39,6 +39,11 @@ typedef union uint64_u {
uint32_t u32[2];
} uint64_u;
/* Opaque placeholder used by generic single-kernel dispatch.
* It preserves pointer semantics without pretending every branch shares the
* same concrete MAT_KERNEL(T) type. */
typedef struct sn_mat_kernel_opaque sn_mat_kernel_opaque;
typedef struct mat_kernel mat_kernel;
typedef struct mat_panel mat_panel;
@@ -71,9 +76,10 @@ static_assert(sizeof(matrix_task) == 128, "matrix_parallel_task_package size mis
static_assert(sizeof(matrix_task) == 128, "matrix_parallel_task_package size mismatch");
#endif
typedef void(SN_DECL *UNI_MK_PROC)(matrix_task *task);
typedef void(SN_DECL *UNI_SK_PROC)(mat_kernel const *left, mat_kernel const *right,
mat_kernel *restrict ans, uint64_t scalar);
typedef void(SN_DECL *UNI_MK_PROC)(matrix_task const *task);
typedef void(SN_DECL *UNI_SK_PROC)(sn_mat_kernel_opaque const *left,
sn_mat_kernel_opaque const *right,
sn_mat_kernel_opaque *restrict ans, uint64_t scalar);
typedef void(SN_DECL *VECTORNORMALIZEPROC)(sn_vec_f32 *source, sn_vec_f32 *target);
typedef void(SN_DECL *DOTPROC)(void *transpose, __m128 *vector, __m128 *ans);
@@ -138,7 +138,7 @@ extern __declspec(align(64)) sn_zero_kernel_u64 SN_ZERO_KERNEL;
int col_length, int row_length, \
int col_index, int row_index)
/* Declarations for AVX float variant
#if 0
DECLARE_BUILD_PANEL(avx, float);
DECLARE_BUILD_PANEL(512, float);
@@ -149,6 +149,6 @@ DECLARE_STORE_PANEL(512, float);
DECLARE_BUILD_PANEL(512, double);
DECLARE_STORE_PANEL(512, double);
/**/
#endif
#endif /* SN_MATKERNEL */
#endif /* SN_MATKERNEL */
+20 -9
View File
@@ -11,19 +11,21 @@
#define MK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op) \
T_type##_multi_kernel_proc_##T_op##_##T_arch##_##T_feature
#define GET_MK_PROC_STD(T_type, T_arch, T_feature, T_op) \
((UNI_MK_PROC)MK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op))
MK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op)
#define SN_MK_PROC_DECL(T_type, P_name) INTERNAL void SN_DECL P_name(MAT_TASK(T_type) const *task)
#define SN_MK_PROC_DECL_STD(T_type, T_arch, T_feature, T_op) \
INTERNAL FORCEINLINE void SN_DECL MK_PROC_NAME_STD(T_type, T_arch, T_feature, \
T_op)(MAT_TASK(T_type) const *task)
#define SN_MK_PROC_DECL_STD(T_type, T_arch, T_feature, T_op) \
INTERNAL void SN_DECL MK_PROC_NAME_STD(T_type, T_arch, T_feature, \
T_op)(MAT_TASK(T_type) const *task)
#define SK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op) \
T_type##_single_kernel_proc_##T_op##_##T_arch##_##T_feature
#define GET_SK_PROC_STD(T_type, T_arch, T_feature, T_op) \
((UNI_SK_PROC)SK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op))
#define SN_SK_PROC_DECL_STD(T_type, T_arch, T_feature, T_op) \
INTERNAL FORCEINLINE void SN_DECL SK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op)( \
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
MAT_KERNEL(T_type) *restrict ans, uint64_t scalar)
SK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op)
#define SN_SK_PROC_DECL_STD(T_type, T_arch, T_feature, T_op) \
INTERNAL void SN_DECL SK_PROC_NAME_STD(T_type, T_arch, T_feature, \
T_op)(sn_mat_kernel_opaque const *left_ptr, \
sn_mat_kernel_opaque const *right_ptr, \
sn_mat_kernel_opaque *restrict ans_ptr, \
uint64_t scalar)
#define _SN_STD__PROBE_0 0
#define _SN_STD__PROBE_1 1
@@ -100,4 +102,13 @@
matrix_task const *_ = (_SN_PARAM_STYLE(param), (_SN_MEM_LAYOUT(mem)), task); \
_SN_MK_EXPAND_PARAM(param); \
_SN_MK_EXPAND_MEM(mem)
#define __sk_param_std(T) \
typedef MAT_KERNEL(T) SN_MAT_KERNEL_LOCAL; \
SN_MAT_KERNEL_LOCAL const *left = \
(SN_MAT_KERNEL_LOCAL const *)(left_ptr); \
SN_MAT_KERNEL_LOCAL const *right = \
(SN_MAT_KERNEL_LOCAL const *)(right_ptr); \
SN_MAT_KERNEL_LOCAL *restrict ans = \
(SN_MAT_KERNEL_LOCAL *)(ans_ptr)
#endif // !SN_INTRINSIC_PARAM_EXPAND