commit 7a121a55a3969cb549a2c418e9944e344a105f6b
parent 91ad4cd4bb526797d8e3c47a9559974511405339
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Fri, 22 Jul 2016 15:43:03 +0300
generic cpu support
Diffstat:
11 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/include/kfr/base/abs.hpp b/include/kfr/base/abs.hpp
@@ -69,6 +69,8 @@ public:
KFR_SPEC_FN(in_abs, abs)
};
+#ifdef CID_ARCH_X86
+
template <cpu_t cc>
struct in_abs<cpu_t::ssse3, cc> : in_select<cc>
{
@@ -113,6 +115,7 @@ struct in_abs<cpu_t::avx2, cc> : in_abs<cpu_t::ssse3, cc>
KFR_HANDLE_SCALAR(abs)
KFR_SPEC_FN(in_abs, abs)
};
+#endif
}
namespace native
diff --git a/include/kfr/base/intrinsics.h b/include/kfr/base/intrinsics.h
@@ -103,10 +103,14 @@
#endif
+#ifdef CID_ARCH_X86
#include <immintrin.h>
#ifdef KFR_OS_WIN
#include <intrin.h>
#endif
+#else
+#include <arm_neon.h>
+#endif
#ifndef KFR_AVX2_DEFINED
#undef __AVX2__
diff --git a/include/kfr/base/logical.hpp b/include/kfr/base/logical.hpp
@@ -110,6 +110,8 @@ struct in_bittest<cpu_t::common>
KFR_SPEC_FN(in_bittest, bittestall)
};
+#ifdef CID_ARCH_X86
+
template <>
struct in_bittest<cpu_t::sse2>
{
@@ -313,6 +315,7 @@ struct in_bittest<cpu_t::avx2> : in_bittest<cpu_t::avx1>
KFR_SPEC_FN(in_bittest, bittestnone)
KFR_SPEC_FN(in_bittest, bittestall)
};
+#endif
}
namespace native
diff --git a/include/kfr/base/min_max.hpp b/include/kfr/base/min_max.hpp
@@ -86,6 +86,8 @@ public:
KFR_SPEC_FN(in_min_max, max)
};
+#ifdef CID_ARCH_X86
+
template <cpu_t cc>
struct in_min_max<cpu_t::sse2, cc> : in_select<cc>
{
@@ -220,6 +222,8 @@ public:
KFR_SPEC_FN(in_min_max, max)
};
+#endif
+
template <cpu_t cpu = cpu_t::native>
struct in_minabs_maxabs
{
diff --git a/include/kfr/base/round.hpp b/include/kfr/base/round.hpp
@@ -169,6 +169,8 @@ struct in_round<cpu_t::common>
KFR_SPEC_FN(in_round, fract)
};
+#ifdef CID_ARCH_X86
+
template <>
struct in_round<cpu_t::sse41> : in_round<cpu_t::common>
{
@@ -256,6 +258,8 @@ struct in_round<cpu_t::avx1> : in_round<cpu_t::sse41>
#undef KFR_mm256_roundnearest_ps
#undef KFR_mm256_trunc_pd
#undef KFR_mm256_roundnearest_pd
+
+#endif
}
namespace native
diff --git a/include/kfr/base/saturation.hpp b/include/kfr/base/saturation.hpp
@@ -108,6 +108,8 @@ protected:
}
};
+#ifdef CID_ARCH_X86
+
template <cpu_t cc>
struct in_saturated<cpu_t::sse2, cc> : in_saturated<cpu_t::common>, in_select<cc>
{
@@ -169,6 +171,7 @@ struct in_saturated<cpu_t::avx2, cc> : in_saturated<cpu_t::sse2, cc>
KFR_SPEC_FN(in_saturated, satadd)
KFR_SPEC_FN(in_saturated, satsub)
};
+#endif
}
namespace native
{
diff --git a/include/kfr/base/select.hpp b/include/kfr/base/select.hpp
@@ -50,6 +50,8 @@ struct in_select_impl<cpu_t::common>
KFR_SPEC_FN(in_select_impl, select)
};
+#ifdef CID_ARCH_X86
+
template <>
struct in_select_impl<cpu_t::sse41> : in_select_impl<cpu_t::common>
{
@@ -120,6 +122,8 @@ struct in_select_impl<cpu_t::avx2> : in_select_impl<cpu_t::avx1>
KFR_SPEC_FN(in_select_impl, select)
};
+#endif
+
template <cpu_t c = cpu_t::native>
struct in_select : in_select_impl<c>
{
diff --git a/include/kfr/base/sqrt.hpp b/include/kfr/base/sqrt.hpp
@@ -58,6 +58,8 @@ struct in_sqrt<cpu_t::common>
KFR_SPEC_FN(in_sqrt, sqrt)
};
+#ifdef CID_ARCH_X86
+
template <>
struct in_sqrt<cpu_t::sse2>
{
@@ -84,6 +86,7 @@ struct in_sqrt<cpu_t::avx1> : in_sqrt<cpu_t::sse2>
KFR_HANDLE_SCALAR(sqrt)
KFR_SPEC_FN(in_sqrt, sqrt)
};
+#endif
}
namespace native
{
diff --git a/include/kfr/base/vec.hpp b/include/kfr/base/vec.hpp
@@ -1149,8 +1149,11 @@ KFR_INLINE vec<T, N> tovec(simd<T, N> x)
{
return x;
}
+
+#ifdef CID_ARCH_SSE2
KFR_INLINE f32x4 tovec(__m128 x) { return f32x4(x); }
KFR_INLINE f64x2 tovec(__m128d x) { return f64x2(x); }
+#endif
template <typename T, typename... Args, size_t Nout = (sizeof...(Args) + 1)>
constexpr KFR_INLINE mask<T, Nout> make_mask(bool arg, Args... args)
diff --git a/include/kfr/cident.h b/include/kfr/cident.h
@@ -2,6 +2,8 @@
#if defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__)
#define CID_ARCH_X86 1
+#elif defined (__arm__) || defined(__arm64__) || defined(_M_ARM)
+#define CID_ARCH_ARM 1
#endif
#ifdef CID_ARCH_X86
@@ -112,12 +114,22 @@
#define CID_ARCH_NAME sse2
#elif defined CID_ARCH_SSE
#define CID_ARCH_NAME sse
+#endif
+
+#elif defined(CID_ARCH_ARM)
+
+#if defined(__arm64__)
+#define CID_ARCH_X64 1
#else
-#define CID_ARCH_NAME common
+#define CID_ARCH_X32 1
#endif
#endif
+#ifndef CID_ARCH_NAME
+#define CID_ARCH_NAME common
+#endif
+
#define CID_STRINGIFY2(x) #x
#define CID_STRINGIFY(x) CID_STRINGIFY2(x)
@@ -316,13 +328,20 @@
#define CID_HAS_EXCEPTIONS 1
#endif
+#if __has_include(<assert.h>)
#include <assert.h>
+#define CID_HAS_ASSERT_H 1
+#endif
#ifndef CID_THROW
#if CID_HAS_EXCEPTIONS
#define CID_THROW(x) throw x
#else
+#ifdef CID_HAS_ASSERT_H
#define CID_THROW(x) assert(false)
+#else
+#define CID_THROW(x) abort()
+#endif
#endif
#endif
diff --git a/include/kfr/math.hpp b/include/kfr/math.hpp
@@ -31,6 +31,7 @@
#include "base/constants.hpp"
#include "base/digitreverse.hpp"
#include "base/gamma.hpp"
+#include "base/hyperbolic.hpp"
#include "base/log_exp.hpp"
#include "base/logical.hpp"
#include "base/min_max.hpp"
@@ -43,7 +44,6 @@
#include "base/sin_cos.hpp"
#include "base/sqrt.hpp"
#include "base/tan.hpp"
-#include "kfr/base/hyperbolic.hpp"
namespace kfr
{