1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
12 // <experimental/simd>
15 // template <class U, class Flags> void copy_from(const U* mem, Flags f);
17 #include <experimental/simd>
20 #include "test_macros.h"
22 namespace ex = std::experimental::parallelism_v2;
24 template <class T, class... Args>
25 auto not_supported_load(Args&&... args) -> decltype(
26 std::declval<ex::native_simd<T>>().copy_from(std::forward<Args>(args)...),
30 void not_supported_load(...) {}
32 template <class T, class... Args>
33 auto supported_load(Args&&... args) -> decltype(
34 std::declval<ex::native_simd<T>>().copy_from(std::forward<Args>(args)...),
38 void supported_load(...) = delete;
41 supported_load<int>((int*)nullptr, ex::element_aligned_tag());
42 supported_load<uint32_t>((int*)nullptr, ex::element_aligned_tag());
43 supported_load<double>((float*)nullptr, ex::element_aligned_tag());
44 supported_load<uint16_t>((unsigned int*)nullptr, ex::element_aligned_tag());
45 supported_load<uint32_t>((float*)nullptr, ex::element_aligned_tag());
47 not_supported_load<int>((int*)nullptr, int());
50 template <typename SimdType>
52 alignas(32) int32_t buffer[] = {4, 3, 2, 1};
55 a.copy_from(buffer, ex::element_aligned_tag());
63 a.copy_from(buffer, ex::vector_aligned_tag());
71 a.copy_from(buffer, ex::overaligned_tag<32>());
80 a.copy_from(buffer, ex::element_aligned);
88 a.copy_from(buffer, ex::vector_aligned);
96 a.copy_from(buffer, ex::overaligned<32>);
104 template <typename SimdType>
105 void test_converting_load() {
106 float buffer[] = {1., 2., 4., 8.};
108 a.copy_from(buffer, ex::element_aligned_tag());
116 // TODO: adjust the tests when this assertion fails.
117 assert(ex::native_simd<int32_t>::size() >= 4);
118 test_load<ex::native_simd<int32_t>>();
119 test_load<ex::fixed_size_simd<int32_t, 4>>();
120 test_converting_load<ex::native_simd<int32_t>>();
121 test_converting_load<ex::fixed_size_simd<int32_t, 4>>();