|
1 | 1 | // RUN: %clangxx -fsycl %s -o %t
|
2 | 2 |
|
3 |
| -// Changing symbol size is a breaking change. If it happens, refer to the ABI |
4 |
| -// Policy Guide for further instructions on breaking ABI. |
| 3 | +// Changing symbol size or alignment is a breaking change. If it happens, refer |
| 4 | +// to the ABI Policy Guide for further instructions on breaking ABI. |
5 | 5 |
|
6 | 6 | #include <CL/sycl/accessor.hpp>
|
7 | 7 | #include <CL/sycl/buffer.hpp>
|
|
21 | 21 | #include <CL/sycl/queue.hpp>
|
22 | 22 | #include <CL/sycl/sampler.hpp>
|
23 | 23 | #include <CL/sycl/stream.hpp>
|
| 24 | +#include <CL/sycl/types.hpp> |
24 | 25 |
|
25 | 26 | using namespace cl::sycl;
|
26 | 27 |
|
27 |
| -template <int newSize, int oldSize> |
28 |
| -void check_size() { |
| 28 | +template <int newSize, int oldSize> void check_size() { |
29 | 29 | static_assert(newSize == oldSize, "Symbol size has changed.");
|
30 | 30 | }
|
31 | 31 |
|
32 |
| -template <typename T, size_t oldSize> |
33 |
| -void check_size() { |
| 32 | +template <int newAlignment, int oldAlignment> void check_alignment() { |
| 33 | + static_assert(newAlignment == oldAlignment, "Alignment has changed"); |
| 34 | +} |
| 35 | + |
| 36 | +template <typename T, size_t oldSize, size_t oldAlignment> void check() { |
34 | 37 | check_size<sizeof(T), oldSize>();
|
| 38 | + check_alignment<alignof(T), oldAlignment>(); |
35 | 39 | }
|
36 | 40 |
|
37 | 41 | int main() {
|
38 | 42 | using accessor_t = accessor<int, 1, access::mode::read,
|
39 | 43 | access::target::global_buffer,
|
40 | 44 | access::placeholder::true_t>;
|
41 |
| - check_size<accessor_t, 32>(); |
42 |
| - check_size<detail::AccessorImplDevice<1>, 24>(); |
43 |
| - check_size<detail::LocalAccessorBaseDevice<1>, 24>(); |
44 |
| - check_size<detail::AccessorImplHost, 128>(); |
45 |
| - check_size<detail::AccessorBaseHost, 16>(); |
46 |
| - check_size<detail::LocalAccessorImplHost, 56>(); |
47 |
| - check_size<buffer<int>, 40>(); |
48 |
| - check_size<context, 16>(); |
49 |
| - check_size<cpu_selector, 8>(); |
50 |
| - check_size<device, 16>(); |
51 |
| - check_size<device_event, 8>(); |
52 |
| - check_size<device_selector, 8>(); |
53 |
| - check_size<event, 16>(); |
54 |
| - check_size<gpu_selector, 8>(); |
| 45 | + check<accessor_t, 32, 8>(); |
| 46 | + check<detail::AccessorImplDevice<1>, 24, 8>(); |
| 47 | + check<detail::LocalAccessorBaseDevice<1>, 24, 8>(); |
| 48 | + check<detail::AccessorImplHost, 128, 8>(); |
| 49 | + check<detail::AccessorBaseHost, 16, 8>(); |
| 50 | + check<detail::LocalAccessorImplHost, 56, 8>(); |
| 51 | + check<buffer<int>, 40, 8>(); |
| 52 | + check<context, 16, 8>(); |
| 53 | + check<cpu_selector, 8, 8>(); |
| 54 | + check<device, 16, 8>(); |
| 55 | + check<device_event, 8, 8>(); |
| 56 | + check<device_selector, 8, 8>(); |
| 57 | + check<event, 16, 8>(); |
| 58 | + check<gpu_selector, 8, 8>(); |
55 | 59 | #ifdef _MSC_VER
|
56 |
| - check_size<handler, 552>(); |
57 |
| - check_size<detail::buffer_impl, 216>(); |
58 |
| - check_size<detail::image_impl<1>, 272>(); |
| 60 | + check<handler, 552, 8>(); |
| 61 | + check<detail::buffer_impl, 216, 8>(); |
| 62 | + check<detail::image_impl<1>, 272, 8>(); |
59 | 63 | #else
|
60 |
| - check_size<handler, 560>(); |
61 |
| - check_size<detail::buffer_impl, 184>(); |
62 |
| - check_size<detail::image_impl<1>, 240>(); |
| 64 | + check<handler, 560, 8>(); |
| 65 | + check<detail::buffer_impl, 184, 8>(); |
| 66 | + check<detail::image_impl<1>, 240, 8>(); |
63 | 67 | #endif
|
64 |
| - check_size<image<1>, 16>(); |
65 |
| - check_size<kernel, 16>(); |
66 |
| - check_size<platform, 16>(); |
| 68 | + check<image<1>, 16, 8>(); |
| 69 | + check<kernel, 16, 8>(); |
| 70 | + check<platform, 16, 8>(); |
67 | 71 | #ifdef __SYCL_DEVICE_ONLY__
|
68 |
| - check_size<private_memory<int, 1>, 4>(); |
69 |
| - check_size<detail::sampler_impl, 8>(); |
| 72 | + check<private_memory<int, 1>, 4, 4>(); |
| 73 | + check<detail::sampler_impl, 8, 8>(); |
70 | 74 | #endif
|
71 |
| - check_size<program, 16>(); |
72 |
| - check_size<range<1>, 8>(); |
73 |
| - check_size<sampler, 16>(); |
74 |
| - check_size<stream, 144>(); |
75 |
| - check_size<queue, 16>(); |
| 75 | + check<program, 16, 8>(); |
| 76 | + check<range<1>, 8, 8>(); |
| 77 | + check<sampler, 16, 8>(); |
| 78 | + check<stream, 144, 8>(); |
| 79 | + check<queue, 16, 8>(); |
| 80 | + check<vec<float, 1>, 4, 4>(); |
| 81 | + check<vec<float, 2>, 8, 8>(); |
| 82 | + check<vec<float, 4>, 16, 16>(); |
| 83 | + check<vec<float, 8>, 32, 32>(); |
| 84 | + check<vec<float, 16>, 64, 64>(); |
| 85 | + check<vec<double, 1>, 8, 8>(); |
| 86 | + check<vec<double, 2>, 16, 16>(); |
| 87 | + check<vec<double, 4>, 32, 32>(); |
| 88 | + check<vec<double, 8>, 64, 64>(); |
76 | 89 |
|
77 | 90 | return 0;
|
78 | 91 | }
|
0 commit comments