|
1 |
| -// RUN: %clangxx -fsycl %s -o %t && %t |
2 |
| - |
3 |
| -#include <CL/sycl.hpp> |
4 |
| -#include <cassert> |
| 1 | +// RUN: %clangxx -fsycl %s -o %t |
| 2 | + |
| 3 | +// Changing symbol size is a breaking change. If it happens, refer to the ABI |
| 4 | +// Policy Guide for further insrtuctions on breaking ABI. |
| 5 | + |
| 6 | +#include <CL/sycl/accessor.hpp> |
| 7 | +#include <CL/sycl/buffer.hpp> |
| 8 | +#include <CL/sycl/device.hpp> |
| 9 | +#include <CL/sycl/device_event.hpp> |
| 10 | +#include <CL/sycl/device_selector.hpp> |
| 11 | +#include <CL/sycl/event.hpp> |
| 12 | +#include <CL/sycl/handler.hpp> |
| 13 | +#include <CL/sycl/image.hpp> |
| 14 | +#include <CL/sycl/kernel.hpp> |
| 15 | +#include <CL/sycl/multi_ptr.hpp> |
| 16 | +#include <CL/sycl/platform.hpp> |
| 17 | +#include <CL/sycl/program.hpp> |
| 18 | +#include <CL/sycl/queue.hpp> |
| 19 | +#include <CL/sycl/sampler.hpp> |
| 20 | +#include <CL/sycl/stream.hpp> |
5 | 21 |
|
6 | 22 | using namespace cl::sycl;
|
7 | 23 |
|
8 |
| -#define CHECK_LAYOUT(class_name, size) \ |
9 |
| - if (sizeof(class_name) != size) { \ |
10 |
| - std::cout << "Size of class " << #class_name << " has changed. Was: " \ |
11 |
| - << #size << ". Now: " << sizeof(class_name) << std::endl; \ |
12 |
| - HasChanged = true; \ |
13 |
| - } |
14 |
| - |
15 |
| -int main() { |
| 24 | +template <int newSize, int oldSize> |
| 25 | +void check_size() { |
| 26 | + static_assert(newSize == oldSize, "Symbol size has changed."); |
| 27 | +} |
16 | 28 |
|
17 |
| - bool HasChanged = false; |
| 29 | +template <typename T, size_t oldSize> |
| 30 | +void check_size() { |
| 31 | + check_size<sizeof(T), oldSize>(); |
| 32 | +} |
18 | 33 |
|
| 34 | +int main() { |
19 | 35 | using accessor_t = accessor<int, 1, access::mode::read,
|
20 | 36 | access::target::global_buffer, access::placeholder::true_t>;
|
21 |
| - CHECK_LAYOUT(accessor_t, 32) |
22 |
| - CHECK_LAYOUT(buffer<int>, 40) |
23 |
| - CHECK_LAYOUT(context, 16) |
24 |
| - CHECK_LAYOUT(cpu_selector, 8) |
25 |
| - CHECK_LAYOUT(device, 16) |
26 |
| - CHECK_LAYOUT(device_event, 8) |
27 |
| - CHECK_LAYOUT(device_selector, 8) |
28 |
| - CHECK_LAYOUT(event, 16) |
29 |
| - CHECK_LAYOUT(gpu_selector, 8) |
30 |
| - CHECK_LAYOUT(handler, 472) |
31 |
| - CHECK_LAYOUT(image<1>, 16) |
32 |
| - CHECK_LAYOUT(kernel, 16) |
33 |
| - CHECK_LAYOUT(platform, 16) |
34 |
| - CHECK_LAYOUT(private_memory<int>, 8) |
35 |
| - CHECK_LAYOUT(program, 16) |
36 |
| - CHECK_LAYOUT(range<1>, 8) |
37 |
| - CHECK_LAYOUT(sampler, 16) |
38 |
| - CHECK_LAYOUT(stream, 208) |
39 |
| - CHECK_LAYOUT(queue, 16) |
40 |
| - |
41 |
| - assert(!HasChanged && "Some symbols changed their sizes!"); |
| 37 | + check_size<accessor_t, 32>(); |
| 38 | + check_size<buffer<int>, 40>(); |
| 39 | + check_size<context, 16>(); |
| 40 | + check_size<cpu_selector, 8>(); |
| 41 | + check_size<device, 16>(); |
| 42 | + check_size<device_event, 8>(); |
| 43 | + check_size<device_selector, 8>(); |
| 44 | + check_size<event, 16>(); |
| 45 | + check_size<gpu_selector, 8>(); |
| 46 | + check_size<handler, 472>(); |
| 47 | + check_size<image<1>, 16>(); |
| 48 | + check_size<kernel, 16>(); |
| 49 | + check_size<platform, 16>(); |
| 50 | +#ifdef __SYCL_DEVICE_ONLY__ |
| 51 | + check_size<private_memory<int, 1>, 4>(); |
| 52 | +#else |
| 53 | + check_size<private_memory<int, 1>, 8>(); |
| 54 | +#endif |
| 55 | + check_size<program, 16>(); |
| 56 | + check_size<range<1>, 8>(); |
| 57 | + check_size<sampler, 16>(); |
| 58 | + check_size<stream, 208>(); |
| 59 | + check_size<queue, 16>(); |
42 | 60 |
|
43 | 61 | return 0;
|
44 | 62 | }
|
0 commit comments