This commit is contained in:
Dmitrii Kovalkov 2020-05-21 10:11:48 +02:00
parent 8483dfa272
commit e317dfb6e4

View File

@ -102,44 +102,66 @@ struct BinaryOperationImplBase
static void vectorVector(const A * __restrict a, const B * __restrict b, ResultType * __restrict c, size_t size) static void vectorVector(const A * __restrict a, const B * __restrict b, ResultType * __restrict c, size_t size)
{ {
if (IsArchSupported(TargetArch::AVX512F)) if constexpr (UseMultitargetCode)
TargetSpecific::AVX512F::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size); {
else if (IsArchSupported(TargetArch::AVX2)) if (IsArchSupported(TargetArch::AVX512F))
TargetSpecific::AVX2::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size); TargetSpecific::AVX512F::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size);
else if (IsArchSupported(TargetArch::AVX)) else if (IsArchSupported(TargetArch::AVX2))
TargetSpecific::AVX::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size); TargetSpecific::AVX2::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size);
else if (IsArchSupported(TargetArch::SSE42)) else if (IsArchSupported(TargetArch::AVX))
TargetSpecific::SSE42::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size); TargetSpecific::AVX::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size);
else if (IsArchSupported(TargetArch::SSE42))
TargetSpecific::SSE42::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size);
else
TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size);
}
else else
{
TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size); TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::vectorVector(a, b, c, size);
}
} }
static void vectorConstant(const A * __restrict a, B b, ResultType * __restrict c, size_t size) static void vectorConstant(const A * __restrict a, B b, ResultType * __restrict c, size_t size)
{ {
if (IsArchSupported(TargetArch::AVX512F)) if constexpr (UseMultitargetCode)
TargetSpecific::AVX512F::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size); {
else if (IsArchSupported(TargetArch::AVX2)) if (IsArchSupported(TargetArch::AVX512F))
TargetSpecific::AVX2::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size); TargetSpecific::AVX512F::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size);
else if (IsArchSupported(TargetArch::AVX)) else if (IsArchSupported(TargetArch::AVX2))
TargetSpecific::AVX::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size); TargetSpecific::AVX2::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size);
else if (IsArchSupported(TargetArch::SSE42)) else if (IsArchSupported(TargetArch::AVX))
TargetSpecific::SSE42::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size); TargetSpecific::AVX::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size);
else if (IsArchSupported(TargetArch::SSE42))
TargetSpecific::SSE42::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size);
else
TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size);
}
else else
{
TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size); TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::vectorConstant(a, b, c, size);
}
} }
static void constantVector(A a, const B * __restrict b, ResultType * __restrict c, size_t size) static void constantVector(A a, const B * __restrict b, ResultType * __restrict c, size_t size)
{ {
if (IsArchSupported(TargetArch::AVX512F)) if constexpr (UseMultitargetCode)
TargetSpecific::AVX512F::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size); {
else if (IsArchSupported(TargetArch::AVX2)) if (IsArchSupported(TargetArch::AVX512F))
TargetSpecific::AVX2::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size); TargetSpecific::AVX512F::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size);
else if (IsArchSupported(TargetArch::AVX)) else if (IsArchSupported(TargetArch::AVX2))
TargetSpecific::AVX::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size); TargetSpecific::AVX2::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size);
else if (IsArchSupported(TargetArch::SSE42)) else if (IsArchSupported(TargetArch::AVX))
TargetSpecific::SSE42::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size); TargetSpecific::AVX::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size);
else if (IsArchSupported(TargetArch::SSE42))
TargetSpecific::SSE42::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size);
else
TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size);
}
else else
{
TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size); TargetSpecific::Default::BinaryOperationImplBase<A, B, Op, ResultType>::constantVector(a, b, c, size);
}
} }
static ResultType constantConstant(A a, B b) static ResultType constantConstant(A a, B b)