Skip to content

Commit 4005b2b

Browse files
author
Alexander Batashev
committed
React to comments
Signed-off-by: Alexander Batashev <[email protected]>
1 parent 371a715 commit 4005b2b

File tree

2 files changed

+53
-35
lines changed

2 files changed

+53
-35
lines changed

sycl/test/abi/layout_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clangxx -fsycl -c -fno-color-diagnostics -Xclang -ast-dump %s | FileCheck %s
22
// REQUIRES: linux
33

4-
#include <CL/sycl.hpp>
4+
#include <CL/sycl/handler.hpp>
55

66
// The order of field declarations and their types are important.
77

sycl/test/abi/symbol_size.cpp

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,62 @@
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>
521

622
using namespace cl::sycl;
723

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+
}
1628

17-
bool HasChanged = false;
29+
template <typename T, size_t oldSize>
30+
void check_size() {
31+
check_size<sizeof(T), oldSize>();
32+
}
1833

34+
int main() {
1935
using accessor_t = accessor<int, 1, access::mode::read,
2036
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>();
4260

4361
return 0;
4462
}

0 commit comments

Comments
 (0)