-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Initial ABI checks implementation #1528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bader
merged 24 commits into
intel:sycl
from
alexbatashev:private/abatashe/basic_abi_checks
Apr 23, 2020
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3deffec
[SYCL] Add basic ABI checks
189b639
Basic layout test
ad5e3b6
Make tests more universal
407341e
A more robust symbols checker
a5f4978
Add vtable checks
3f9f6d8
Merge remote-tracking branch 'origin/sycl' into private/abatashe/basi…
c748c91
React to some comments
961afa4
Merge remote-tracking branch 'origin/sycl' into private/abatashe/basi…
23ca0ec
React to comments
3ccb3aa
Add some Windows support
a9a8f0f
React to comments
c3838e1
Fix more comments
07e1b93
Merge remote-tracking branch 'origin/sycl' into private/abatashe/basi…
eb108bb
Update tests
3e2c8e3
React to comments
371a715
Apply clang-format
4005b2b
React to comments
ecc3771
Update sycl/test/abi/symbol_size.cpp
alexbatashev 82b9ee4
Update sycl/doc/ABIPolicyGuide.md
alexbatashev bf41e70
React to comments
e93a28e
React to comments
7a24da3
Merge remote-tracking branch 'origin/sycl' into private/abatashe/basi…
ad7489b
React to comments
cfb822d
Add test for abi_check.py
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# ABI Policy Guide | ||
|
||
## Intro | ||
|
||
Application Binary Interface is a contract between binary modules, that defines | ||
how structures and routines are accessed in machine code. Changing the ABI may | ||
break backwards compatibility of user application with the DPC++ runtime library | ||
for user-developed applications, resulting in need to rebuild such applications. | ||
The goal of this document is to provide guidelines for maintaining the current | ||
ABI of the DPC++ runtime library and mechanisms of notifying users about ABI | ||
changes. | ||
|
||
All ABI changes can be divided into two large groups: breaking and non-breaking. | ||
A breaking change means that the new binary is incompatible with the previous | ||
version (i.e. it can not be used as a drop-in replacement). A non-breaking | ||
change means that the forward compatibility is broken (i.e. the old library | ||
can be replaced with newer version, but not vice versa). | ||
|
||
The following non-exhaustive list contains changes that are considered to be | ||
breaking: | ||
|
||
1. Changing the size of exported symbol (for example, adding new member field | ||
to the exported class). | ||
1. Removing the exported symbol (that includes both changing the signature of | ||
exported routine and removing it). | ||
1. Changing the alignment of exported symbol. | ||
1. Changing the layout of exported symbol (for example, reordering class field | ||
members). | ||
1. Adding or removing base classes. | ||
|
||
Adding a new exported symbol is considered to be non-breaking change. | ||
|
||
## ABI Versioning Policy | ||
|
||
TBD | ||
|
||
## `__SYCL_EXPORT` Macro | ||
|
||
The `__SYCL_EXPORT` provides facilities for fine-grained control over exported | ||
symbols. Mark symbols that are supposed to be accessible by the user and that | ||
are implemented in the SYCL Runtime library with this macro. Template | ||
specializations also must be explicitly marked with `__SYCL_EXPORT` macro. | ||
Symbols not marked `__SYCL_EXPORT` have internal linkage. | ||
|
||
A few examples of when it is necessary to mark symbols with the macro: | ||
|
||
* The `device` class: | ||
- It is defined as API by the SYCL spec. | ||
- It is implemented in `device.cpp` file. | ||
* The `SYCLMemObjT` class: | ||
- It is not defined in the SYCL spec, but it is an implementation detail that | ||
is accessible by the user (buffer and image inherit from this class). | ||
- It has symbols that are implemented in the Runtime library. | ||
|
||
When it is not necessary to mark symbols with `__SYCL_EXPORT`: | ||
* The `buffer` class: | ||
- It is defined by the SYCL spec, but it is fully implemented in the headers. | ||
* The `ProgramManager` class: | ||
- It is an implementation detail. | ||
- It is not accessed from the header files that are available to users. | ||
|
||
## Automated ABI Changes Testing | ||
|
||
> The automated tests deal with the most commonly occurring problems, but they | ||
> may not catch some corner cases. If you believe your PR breaks ABI, but the | ||
> test does not indicate that, please, notify the reviewers. | ||
|
||
There is a set of tests to help identifying ABI changes: | ||
|
||
* `test/abi/sycl_symbols_*.dump` contains dump of publicly available symbols. | ||
If you add a new symbol, it is considered non-breaking change. When the test | ||
reports missing symbols, it means you have either changed or remove some of | ||
existing API methods. In both cases you need to adjust the dump file. You | ||
can do it either manually, or by invoking the following command: | ||
```shell | ||
python3 sycl/tools/abi_check.py --mode dump_symbols --output path/to/output.dump path/to/sycl.so(.dll) | ||
``` | ||
* `test/abi/layout*` and `test/abi/symbol_size*` are a group of tests to check | ||
the internal layout of some classes. The layout tests check Clang AST for | ||
changes, while symbol_size check `sizeof` for objects. Changing the class | ||
layout is a breaking change. | ||
|
||
## Breaking ABI | ||
|
||
Whenever you need to change the existing ABI, please, follow these steps: | ||
|
||
1. Adjust you PR description to reflect (non-)breaking ABI changes. Make sure | ||
it is clear, why breaking ABI is necessary. | ||
2. Fix failing ABI tests in your Pull Request. Use aforementioned techniques to | ||
update test files. | ||
3. Update the library version according to the policies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ Developing oneAPI DPC++ Compiler | |
CompilerAndRuntimeDesign | ||
EnvironmentVariables | ||
PluginInterface | ||
|
||
ABIPolicyGuide |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// RUN: %clangxx -fsycl -c -fno-color-diagnostics -Xclang -ast-dump %s | FileCheck %s | ||
// REQUIRES: linux | ||
|
||
#include <CL/sycl/handler.hpp> | ||
|
||
// The order of field declarations and their types are important. | ||
|
||
// CHECK: CXXRecordDecl {{.*}} class handler definition | ||
// CHECK: FieldDecl {{.*}} MQueue 'shared_ptr_class<detail::queue_impl>':'std::shared_ptr<cl::sycl::detail::queue_impl>' | ||
// CHECK-NEXT: FieldDecl {{.*}} MArgsStorage 'vector_class<vector_class<char> >':'std::vector<std::vector<char, std::allocator<char> >, std::allocator<std::vector<char, std::allocator<char> > > >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MAccStorage 'vector_class<detail::AccessorImplPtr>':'std::vector<std::shared_ptr<cl::sycl::detail::AccessorImplHost>, std::allocator<std::shared_ptr<cl::sycl::detail::AccessorImplHost> > >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MLocalAccStorage 'vector_class<detail::LocalAccessorImplPtr>':'std::vector<std::shared_ptr<cl::sycl::detail::LocalAccessorImplHost>, std::allocator<std::shared_ptr<cl::sycl::detail::LocalAccessorImplHost> > >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MStreamStorage 'vector_class<shared_ptr_class<detail::stream_impl> >':'std::vector<std::shared_ptr<cl::sycl::detail::stream_impl>, std::allocator<std::shared_ptr<cl::sycl::detail::stream_impl> > >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MSharedPtrStorage 'vector_class<shared_ptr_class<const void> >':'std::vector<std::shared_ptr<const void>, std::allocator<std::shared_ptr<const void> > >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MArgs 'vector_class<detail::ArgDesc>':'std::vector<cl::sycl::detail::ArgDesc, std::allocator<cl::sycl::detail::ArgDesc> >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MAssociatedAccesors 'vector_class<detail::ArgDesc>':'std::vector<cl::sycl::detail::ArgDesc, std::allocator<cl::sycl::detail::ArgDesc> >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MRequirements 'vector_class<detail::Requirement *>':'std::vector<cl::sycl::detail::AccessorImplHost *, std::allocator<cl::sycl::detail::AccessorImplHost *> >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MNDRDesc 'detail::NDRDescT':'cl::sycl::detail::NDRDescT' | ||
// CHECK-NEXT: FieldDecl {{.*}} MKernelName 'cl::sycl::string_class':'std::__cxx11::basic_string<char>' | ||
// CHECK-NEXT: FieldDecl {{.*}} MKernel 'shared_ptr_class<detail::kernel_impl>':'std::shared_ptr<cl::sycl::detail::kernel_impl>' | ||
// CHECK-NEXT: FieldDecl {{.*}} MCGType 'detail::CG::CGTYPE':'cl::sycl::detail::CG::CGTYPE' | ||
// CHECK-NEXT: DeclRefExpr {{.*}} 'cl::sycl::detail::CG::CGTYPE' EnumConstant {{.*}} 'NONE' 'cl::sycl::detail::CG::CGTYPE' | ||
// CHECK-NEXT: FieldDecl {{.*}} MSrcPtr 'void *' | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} <NullToPointer> | ||
// CHECK-NEXT: CXXNullPtrLiteralExpr {{.*}} 'nullptr_t' | ||
// CHECK-NEXT: FieldDecl {{.*}} MDstPtr 'void *' | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void *' <NullToPointer> | ||
// CHECK-NEXT: CXXNullPtrLiteralExpr {{.*}} 'nullptr_t' | ||
// CHECK-NEXT: FieldDecl {{.*}} MLength 'size_t':'unsigned long' | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'size_t':'unsigned long' <IntegralCast> | ||
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0 | ||
// CHECK-NEXT: FieldDecl {{.*}} MPattern 'vector_class<char>':'std::vector<char, std::allocator<char> >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MHostKernel 'unique_ptr_class<detail::HostKernelBase>':'std::unique_ptr<cl::sycl::detail::HostKernelBase, std::default_delete<cl::sycl::detail::HostKernelBase> >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MOSModuleHandle 'detail::OSModuleHandle':'long' | ||
// CHECK-NEXT: FieldDecl {{.*}} MInteropTask 'std::unique_ptr<detail::InteropTask>':'std::unique_ptr<cl::sycl::detail::InteropTask, std::default_delete<cl::sycl::detail::InteropTask> >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MEvents 'vector_class<detail::EventImplPtr>':'std::vector<std::shared_ptr<cl::sycl::detail::event_impl>, std::allocator<std::shared_ptr<cl::sycl::detail::event_impl> > >' | ||
// CHECK-NEXT: FieldDecl {{.*}} MIsHost 'bool' | ||
// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.