mpl going on good process
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>opengl32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -105,6 +106,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>opengl32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#ifndef SN_INTERNAL
|
||||
#define SN_INTERNAL
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_WARNINGS 1
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef uint64_t(SN_DECL *FACTORIALROC)(int n);
|
||||
|
||||
#pragma region matix function
|
||||
|
||||
INTERNAL void normalize(__m128 *source, __m128 *target);
|
||||
INTERNAL void f32_normalize(VEC(float) * source, VEC(float) * target);
|
||||
|
||||
INTERNAL void SN_DECL f32_add_sse(MAT_KERNEL(float) const *left, MAT_KERNEL(float) const *right,
|
||||
MAT_KERNEL(float) *restrict ans);
|
||||
|
||||
@@ -9,11 +9,26 @@
|
||||
#define ZMMCOUNT(T) sizeof(T) / 4
|
||||
|
||||
#define MAT_KERNEL(T) \
|
||||
union { \
|
||||
union mat_kernel_##T##{ \
|
||||
__m128 xmm[XMMCOUNT(T)]; \
|
||||
__m256 ymm[YMMCOUNT(T)]; \
|
||||
__m512 zmm[ZMMCOUNT(T)]; \
|
||||
T m[4][4]; \
|
||||
}
|
||||
|
||||
#define VEC(T) \
|
||||
union vec_##T##{ \
|
||||
__m128 xmm[XMMCOUNT(T) / 4]; \
|
||||
__m256 ymm[YMMCOUNT(T) / 4]; \
|
||||
__m512 zmm[ZMMCOUNT(T) / 4]; \
|
||||
T v[4]; \
|
||||
}
|
||||
|
||||
/*
|
||||
#undef ELEMENTSIZE
|
||||
#undef XMMCOUNT
|
||||
#undef YMMCOUNT
|
||||
#undef ZMMCOUNT
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "sn_intrinsic.h"
|
||||
|
||||
// ans = left * right(T) + ans
|
||||
// ans = left * right + ans
|
||||
INTERNAL void SN_DECL f32_fma_sse(MAT_KERNEL(float) const *restrict left,
|
||||
MAT_KERNEL(float) const *restrict right, MAT_KERNEL(float) *restrict ans)
|
||||
MAT_KERNEL(float) const *restrict right,
|
||||
MAT_KERNEL(float) *restrict ans)
|
||||
{
|
||||
register __m128 source0 = _mm_load_ps(&left->xmm[0]);
|
||||
register __m128 source1 = _mm_load_ps(&left->xmm[1]);
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
INTERNAL int SN_DECL index_pair_sse(short const *str, uint32_t target, int length)
|
||||
{
|
||||
int index = 0, result = 0, size = length, end = size - 8;
|
||||
__m128i s = {
|
||||
target,
|
||||
target,
|
||||
target,
|
||||
target,
|
||||
};
|
||||
__m128i s = _mm_set1_epi32(target);
|
||||
__m128i vec, com;
|
||||
|
||||
while (index < end) {
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
#include "StgSharpNative.h"
|
||||
#include "sn_intrinsic.h"
|
||||
#include "sn_internal.h"
|
||||
|
||||
SN_API void SN_DECL normalize(__m128 *restrict source, __m128 *restrict target)
|
||||
SN_API void SN_DECL normalize(VEC(float) *restrict source, VEC(float) *restrict target)
|
||||
{
|
||||
__m128 a_length_sq = _mm_mul_ps(*source, *source);
|
||||
register __m128 s = _mm_load_ps(&source->xmm);
|
||||
register __m128 a_length_sq = _mm_mul_ps(s, s);
|
||||
a_length_sq = _mm_add_ps(a_length_sq,
|
||||
_mm_shuffle_ps(a_length_sq, a_length_sq, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
a_length_sq = _mm_add_ss(a_length_sq,
|
||||
_mm_shuffle_ps(a_length_sq, a_length_sq, _MM_SHUFFLE(0, 0, 3, 2)));
|
||||
|
||||
__m128 a_inv_length = _mm_rsqrt_ps(a_length_sq);
|
||||
*source = _mm_mul_ps(*source, a_inv_length);
|
||||
s = _mm_mul_ps(s, a_inv_length);
|
||||
|
||||
__m128 dot_product = _mm_mul_ps(*target, *source);
|
||||
__m128 dot_product = _mm_mul_ps(target->xmm[0], s);
|
||||
dot_product = _mm_add_ps(dot_product,
|
||||
_mm_shuffle_ps(dot_product, dot_product, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
dot_product = _mm_add_ss(dot_product,
|
||||
_mm_shuffle_ps(dot_product, dot_product, _MM_SHUFFLE(0, 0, 3, 2)));
|
||||
|
||||
__m128 b_orthogonal = _mm_sub_ps(*target, _mm_mul_ps(*source, dot_product));
|
||||
__m128 b_orthogonal = _mm_sub_ps(target->xmm[0], _mm_mul_ps(s, dot_product));
|
||||
|
||||
__m128 b_length_sq = _mm_mul_ps(b_orthogonal, b_orthogonal);
|
||||
b_length_sq = _mm_add_ps(b_length_sq,
|
||||
@@ -27,5 +28,5 @@ SN_API void SN_DECL normalize(__m128 *restrict source, __m128 *restrict target)
|
||||
_mm_shuffle_ps(b_length_sq, b_length_sq, _MM_SHUFFLE(0, 0, 3, 2)));
|
||||
|
||||
__m128 b_inv_length = _mm_rsqrt_ps(b_length_sq);
|
||||
*target = _mm_mul_ps(b_orthogonal, b_inv_length);
|
||||
target->xmm[0] = _mm_mul_ps(b_orthogonal, b_inv_length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user