commit cabe53fbd452a08664ed160d007410df3f9a154b
parent 7866df07aa0d7c13b940fa81386086ca2d4dba45
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Thu, 30 Jun 2016 12:44:41 +0300
Various small fixes and improvements
Diffstat:
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/build.py b/build.py
@@ -42,13 +42,13 @@ print('ok')
if sys.platform.startswith('win32'):
generator = 'MinGW Makefiles'
-elif sys.platform.startswith('darwin'):
+else:
generator = 'Unix Makefiles'
options = [
'-DCMAKE_BUILD_TYPE=Release',
]
-subprocess.call(['cmake', '-G', generator, '..'] + options, cwd=build_dir)
-subprocess.call(['cmake', '--build', '.'], cwd=build_dir)
-subprocess.call(['ctest'], cwd=os.path.join(build_dir, 'tests'))
+if subprocess.call(['cmake', '-G', generator, '..'] + options, cwd=build_dir): raise Exception('Can\'t make project')
+if subprocess.call(['cmake', '--build', '.'], cwd=build_dir): raise Exception('Can\'t build project')
+if subprocess.call(['ctest'], cwd=os.path.join(build_dir, 'tests')): raise Exception('Can\'t test project')
diff --git a/include/kfr/base/min_max.hpp b/include/kfr/base/min_max.hpp
@@ -140,9 +140,14 @@ struct in_min_max<cpu_t::avx1> : in_min_max<cpu_t::sse41>
};
template <>
-struct in_min_max<cpu_t::avx2> : in_min_max<cpu_t::avx1>
+struct in_min_max<cpu_t::avx2> : in_min_max<cpu_t::avx1>, in_select<cpu_t::avx2>
{
constexpr static cpu_t cpu = cpu_t::avx2;
+
+private:
+ using in_select<cpu>::select;
+
+public:
using in_min_max<cpu_t::avx1>::min;
using in_min_max<cpu_t::avx1>::max;
@@ -160,6 +165,11 @@ struct in_min_max<cpu_t::avx2> : in_min_max<cpu_t::avx1>
KFR_CPU_INTRIN(avx2) i32avx max(i32avx x, i32avx y) { return _mm256_max_epi32(*x, *y); }
KFR_CPU_INTRIN(avx2) u32avx max(u32avx x, u32avx y) { return _mm256_max_epu32(*x, *y); }
+ KFR_CPU_INTRIN(avx2) i64avx min(i64avx x, i64avx y) { return select(x < y, x, y); }
+ KFR_CPU_INTRIN(avx2) u64avx min(u64avx x, u64avx y) { return select(x < y, x, y); }
+ KFR_CPU_INTRIN(avx2) i64avx max(i64avx x, i64avx y) { return select(x > y, x, y); }
+ KFR_CPU_INTRIN(avx2) u64avx max(u64avx x, u64avx y) { return select(x > y, x, y); }
+
KFR_HANDLE_ALL(min)
KFR_HANDLE_ALL(max)
KFR_SPEC_FN(in_min_max, min)
diff --git a/include/kfr/base/saturation.hpp b/include/kfr/base/saturation.hpp
@@ -115,8 +115,8 @@ template <cpu_t cc>
struct in_saturated<cpu_t::avx2, cc> : in_saturated<cpu_t::sse2, cc>
{
constexpr static cpu_t cpu = cpu_t::avx2;
- using in_saturated<cpu_t::sse41>::satadd;
- using in_saturated<cpu_t::sse41>::satsub;
+ using in_saturated<cpu_t::sse2, cc>::satadd;
+ using in_saturated<cpu_t::sse2, cc>::satsub;
KFR_SINTRIN u8avx satadd(u8avx x, u8avx y) { return _mm256_adds_epu8(*x, *y); }
KFR_SINTRIN i8avx satadd(i8avx x, i8avx y) { return _mm256_adds_epi8(*x, *y); }
@@ -138,9 +138,7 @@ namespace native
{
using fn_satadd = internal::in_saturated<>::fn_satadd;
template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)>
-KFR_INLINE ftype<common_type<T1, T2>>
-
-satadd(const T1& x, const T2& y)
+KFR_INLINE ftype<common_type<T1, T2>> satadd(const T1& x, const T2& y)
{
return internal::in_saturated<>::satadd(x, y);
}
@@ -152,9 +150,7 @@ KFR_INLINE expr_func<fn_satadd, E1, E2> satadd(E1&& x, E2&& y)
}
using fn_satsub = internal::in_saturated<>::fn_satsub;
template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)>
-KFR_INLINE ftype<common_type<T1, T2>>
-
-satsub(const T1& x, const T2& y)
+KFR_INLINE ftype<common_type<T1, T2>> satsub(const T1& x, const T2& y)
{
return internal::in_saturated<>::satsub(x, y);
}
@@ -162,9 +158,7 @@ satsub(const T1& x, const T2& y)
template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)>
KFR_INLINE expr_func<fn_satsub, E1, E2> satsub(E1&& x, E2&& y)
{
- return { fn_satsub(), std::forward<E1>(x), std::forward<E2>(y)
-
- };
+ return { fn_satsub(), std::forward<E1>(x), std::forward<E2>(y) };
}
}
}