daily update on 20240206 by nitload youmu, token parser change to use regex generator
This commit is contained in:
@@ -36,6 +36,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define byte char
|
||||
#define cs_char uint16_t
|
||||
#define ssc_null_assert(ptr) assert(ptr != NULL)
|
||||
|
||||
#define ALIGN(simdVec) _mm_loadu_ps(&simdVec)
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
<ClCompile Include="stb_image.c" />
|
||||
<ClCompile Include="StgSharpC.c" />
|
||||
<ClCompile Include="hash.c" />
|
||||
<ClCompile Include="string.c" />
|
||||
<ClCompile Include="vector.c" />
|
||||
<ClCompile Include="vector_dot.c" />
|
||||
</ItemGroup>
|
||||
|
||||
+7
-12
@@ -1,9 +1,9 @@
|
||||
#include "ssc_intrinsic.h"
|
||||
#include "StgSharpC.h"
|
||||
|
||||
static inline uint32_t fmix32(uint32_t h);
|
||||
static inline uint32_t fmix32(uint32_t hash);
|
||||
|
||||
INTERNAL int SSCDECL city_hash_simplify(byte const *str, int const length)
|
||||
INTERNAL int SSCDECL city_hash_simplify_sse(byte const *str, int const length)
|
||||
{
|
||||
uint32_t hash = length, size = length << 1;
|
||||
byte *end = str + size, *ptr = str;
|
||||
@@ -37,15 +37,10 @@ INTERNAL int SSCDECL city_hash_simplify(byte const *str, int const length)
|
||||
hash = _mm_crc32_u8(hash,*ptr);
|
||||
}
|
||||
}
|
||||
hash ^= hash >> 16;
|
||||
hash *= 0x85ebca6b;
|
||||
hash ^= hash >> 13;
|
||||
hash *= 0xc2b2ae35;
|
||||
hash ^= hash >> 16;
|
||||
return fmix32(hash);
|
||||
}
|
||||
|
||||
INTERNAL inline uint32_t fmix32(uint32_t h)
|
||||
{
|
||||
h ^= h >> 16;
|
||||
h *= 0x85ebca6b;
|
||||
h ^= h >> 13;
|
||||
h *= 0xc2b2ae35;
|
||||
h ^= h >> 16;
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,8 @@ void load_intrinsic_sse(ssc_intrinsic *context)
|
||||
context->dot_41 = dot_41_sse;
|
||||
context->dot_42 = dot_42_sse;
|
||||
context->dot_43 = dot_43_sse;
|
||||
context->city_hash_simplify = city_hash_simplify;
|
||||
context->city_hash_simplify = city_hash_simplify_sse;
|
||||
context->index_pair = index_pair_sse;
|
||||
}
|
||||
|
||||
void load_intrinsic_avx(ssc_intrinsic *context)
|
||||
@@ -106,7 +107,8 @@ void load_intrinsic_avx(ssc_intrinsic *context)
|
||||
context->dot_41 = dot_41_avx;
|
||||
context->dot_42 = dot_42_avx;
|
||||
context->dot_43 = dot_43_avx;
|
||||
context->city_hash_simplify = city_hash_simplify;
|
||||
context->city_hash_simplify = city_hash_simplify_sse;
|
||||
context->index_pair = index_pair_sse;
|
||||
}
|
||||
|
||||
void load_intrinsic_512(ssc_intrinsic *context)
|
||||
@@ -130,5 +132,6 @@ void load_intrinsic_512(ssc_intrinsic *context)
|
||||
context->dot_41 = dot_41_avx;
|
||||
context->dot_42 = dot_42_avx;
|
||||
context->dot_43 = dot_43_avx;
|
||||
context->city_hash_simplify = city_hash_simplify;
|
||||
context->city_hash_simplify = city_hash_simplify_sse;
|
||||
context->index_pair = index_pair_sse;
|
||||
}
|
||||
|
||||
@@ -103,9 +103,10 @@ INTERNAL void SSCDECL dot_43_512(__4_columnset *transpose, __m128 *vector, __m12
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region quick_hash
|
||||
#pragma region string
|
||||
|
||||
INTERNAL int city_hash_simplify(byte const *str, int length);
|
||||
INTERNAL int SSCDECL city_hash_simplify_sse(byte const *str, int length);
|
||||
INTERNAL int SSCDECL index_pair_sse(byte const *str, uint32_t target, int length);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -121,6 +122,7 @@ typedef struct ssc_intrinsic {
|
||||
DOTPROC dot_41;
|
||||
DOTPROC dot_42;
|
||||
DOTPROC dot_43;
|
||||
int (*index_pair)(byte *str, byte *target, int length, int start);
|
||||
VECTORNORMALIZEPROC normalize_3;
|
||||
MATRIXTRANSPOSEPROC transpose_23;
|
||||
MATRIXTRANSPOSEPROC transpose_24;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "StgSharpC.h"
|
||||
#include "ssc_intrinsic.h"
|
||||
|
||||
int index_pair_sse(byte const *str, uint32_t target, int length)
|
||||
{
|
||||
int index = 0, result = 0, size = length << 1, end = size - 14;
|
||||
__m128i source = { .m128i_i32 = {
|
||||
target,
|
||||
target,
|
||||
target,
|
||||
target,
|
||||
} };
|
||||
for (; (index < end) && (!result); index += 14) { // move 7*2 bytes instead of 8*2
|
||||
__m128i vec = _mm_loadu_epi32(str + index);
|
||||
__m128i com = _mm_cmpeq_epi32(vec, source);
|
||||
result = _mm_movemask_epi8(com);
|
||||
}
|
||||
if (result) {
|
||||
for (; result; result >> 2) {
|
||||
index++;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
for (; (index < size - 2) && (!result); index += 2) {
|
||||
result = *(int *)(str + index) == target;
|
||||
}
|
||||
if (result) {
|
||||
return index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user