Compare commits

...

3 commits

Author SHA1 Message Date
bab2min
8bfdda93ae Fix typo 2024-06-01 16:04:17 +09:00
bab2min
86a684de7d Update BitUtils.h and search.cpp for Windows ARM64 support (#168) 2024-06-01 00:57:53 +09:00
bab2min
33953f867e Update vcxproj config for ARM64 2024-06-01 00:56:41 +09:00
4 changed files with 42 additions and 6 deletions

View file

@ -118,6 +118,10 @@ namespace kiwi
{
#if defined(__GNUC__)
return __builtin_popcount(v);
#elif defined(_MSC_VER) && defined(KIWI_ARCH_ARM64)
uint64x1_t w = { v };
w = neon_cnt(w);
return w.n64_u64[0];
#elif defined(_MSC_VER)
return __popcnt(v);
#else
@ -129,6 +133,10 @@ namespace kiwi
{
#if defined(__GNUC__)
return __builtin_popcountll(v);
#elif defined(_MSC_VER) && defined(KIWI_ARCH_ARM64)
uint64x1_t w = { v };
w = neon_cnt(w);
return w.n64_u64[0];
#elif defined(_MSC_VER) && defined(_M_X64)
return __popcnt64(v);
#else

View file

@ -893,6 +893,28 @@ namespace kiwi
#endif
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 || KIWI_ARCH_ARM64
#if defined(_MSC_VER)
#define ALIGNED_(x) __declspec(align(x))
#define _MERGE_U8x8(a, b, c, d, e, f, g, h) (uint64_t(a) | (uint64_t(b) << 8) | (uint64_t(c) << 16) | (uint64_t(d) << 24) | (uint64_t(e) << 32) | (uint64_t(f) << 40) | (uint64_t(g) << 48) | (uint64_t(h) << 56))
#define _MERGE_U16x4(a, b, c, d) (uint64_t(a) | (uint64_t(b) << 16) | (uint64_t(c) << 32) | (uint64_t(d) << 48))
#define _MERGE_U32x2(a, b) (uint64_t(a) | (uint64_t(b) << 32))
#define INIT_U8x16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) (_MERGE_U8x8(a, b, c, d, e, f, g, h)), (_MERGE_U8x8(i, j, k, l, m, n, o, p))
#define INIT_U16x8(a, b, c, d, e, f, g, h) (_MERGE_U16x4(a, b, c, d), _MERGE_U16x4(e, f, g, h))
#define INIT_U32x4(a, b, c, d) (_MERGE_U32x2(a, b), _MERGE_U32x2(c, d))
#else
#if defined(__GNUC__)
#define ALIGNED_(x) __attribute__ ((aligned(x)))
#define INIT_U8x16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p
#define INIT_U16x8(a, b, c, d, e, f, g, h) a, b, c, d, e, f, g, h
#define INIT_U32x4(a, b, c, d) a, b, c, d
#endif
#endif
namespace kiwi
{
namespace nst
@ -905,7 +927,7 @@ namespace kiwi
int8x16_t ptarget = vdupq_n_s8(target), pkey;
uint8x16_t peq, pgt, pmasked;
static const uint8x16_t __attribute__((aligned(16))) mask = { 1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128 };
static const uint8x16_t ALIGNED_(16) mask = { INIT_U8x16(1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128) };
while (i < size)
{
@ -938,7 +960,7 @@ namespace kiwi
int16x8_t ptarget = vdupq_n_s16(target), pkey;
uint16x8_t peq, pgt;
static const uint16x8_t __attribute__((aligned(16))) mask = { 1, 2, 4, 8, 16, 32, 64, 128 };
static const uint16x8_t ALIGNED_(16) mask = { INIT_U16x8(1, 2, 4, 8, 16, 32, 64, 128) };
while (i < size)
{
@ -968,7 +990,7 @@ namespace kiwi
int32x4_t ptarget = vdupq_n_s32(target), pkey;
uint32x4_t peq, pgt;
static const uint32x4_t __attribute__((aligned(16))) mask = { 1, 2, 4, 8 };
static const uint32x4_t ALIGNED_(16) mask = { INIT_U32x4(1, 2, 4, 8) };
while (i < size)
{
@ -998,7 +1020,7 @@ namespace kiwi
int64x2_t ptarget = vdupq_n_s64(target), pkey;
uint64x2_t peq, pgt;
static const uint64x2_t __attribute__((aligned(16))) mask = { 1, 2 };
static const uint64x2_t ALIGNED_(16) mask = { 1, 2 };
while (i < size)
{

View file

@ -31,7 +31,6 @@
<ProjectGuid>{F91F4D06-6485-4FF0-AB01-C07E9E58A80E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>kiwi_c</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>kiwi_c</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -70,7 +69,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View file

@ -90,10 +90,14 @@
<ClCompile Include="..\src\archImpl\avx2.cpp">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\src\archImpl\avx512bw.cpp">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AdvancedVectorExtensions512</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AdvancedVectorExtensions512</EnableEnhancedInstructionSet>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\src\archImpl\neon.cpp">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotSet</EnableEnhancedInstructionSet>
@ -108,10 +112,14 @@
<ClCompile Include="..\src\archImpl\sse2.cpp">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\src\ArchImpl\sse4_1.cpp">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\src\ArchUtils.cpp" />
<ClCompile Include="..\src\Combiner.cpp" />