//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 // // // [simd.traits] //template > struct simd_size; //template > //inline constexpr std::size_t ex::simd_size_v = ex::simd_size::value; #include "../test_utils.h" namespace ex = std::experimental::parallelism_v2; struct CheckSimdSizeFixedDeduce { template void check() { static_assert(ex::simd_size_v> == N, "Simd size mismatch with abi fixed_size"); static_assert(ex::simd_size>::value == N, "Simd size mismatch with abi fixed_size"); static_assert(ex::simd_size_v> == N, "Simd size mismatch with abi deduce"); static_assert(ex::simd_size>::value == N, "Simd size mismatch with abi deduce"); } template void performChecks(std::index_sequence) { (check(), ...); } template void operator()() { performChecks(std::make_index_sequence{}); } }; struct CheckSimdSizeScalarNativeCompatible { template void operator()() { static_assert(ex::simd_size_v == 1); static_assert(ex::simd_size::value == 1); LIBCPP_STATIC_ASSERT(ex::simd_size>::value == 16 / sizeof(T)); LIBCPP_STATIC_ASSERT(ex::simd_size_v> == 16 / sizeof(T)); LIBCPP_STATIC_ASSERT( ex::simd_size>::value == _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(T)); LIBCPP_STATIC_ASSERT(ex::simd_size_v> == _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(T)); } }; template , class = void> struct has_simd_size : std::false_type {}; template struct has_simd_size::value)>> : std::true_type {}; struct CheckSimdSizeTraits { template void operator()() { static_assert(has_simd_size::value); static_assert(!has_simd_size>::value); static_assert(has_simd_size::value); static_assert(has_simd_size>::value); static_assert(has_simd_size>::value); static_assert(has_simd_size>::value); static_assert(!has_simd_size, ex::simd_abi::native>::value); static_assert(!has_simd_size, ex::simd_abi::native>::value); static_assert(!has_simd_size, ex::simd_abi::native>::value); static_assert(!has_simd_size, ex::simd_abi::native>::value); static_assert(!has_simd_size::value); static_assert(!has_simd_size>::value); static_assert(!has_simd_size>::value); static_assert(!has_simd_size>::value); } }; int main(int, char**) { types::for_each(arithmetic_no_bool_types(), CheckSimdSizeFixedDeduce()); types::for_each(arithmetic_no_bool_types(), CheckSimdSizeScalarNativeCompatible()); types::for_each(arithmetic_no_bool_types(), CheckSimdSizeTraits()); return 0; }