-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Remove need to mark free functions with SYCL_EXTERNAL attribute #14170
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
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
efb93a5
Support for free function traits.
rdeodhar 2cd0d1a
Updated tests.
rdeodhar 9003bf0
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar c5c2540
Updated a test.
rdeodhar 318c528
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar c091fca
Added header file for clang testing.
rdeodhar d78a903
Deferred HIP support to a future PR.
rdeodhar a0ed967
Correction to test.
rdeodhar 26b7b09
Experimental test change.
rdeodhar fae8dd3
Enable HIP.
rdeodhar 44ef070
Add debug print.
rdeodhar 51f7072
Adjusted a test to add USM requirement.
rdeodhar 89ef3dc
Removed need for SYCL_EXTERNAL on free functions.
rdeodhar 9c0b8f0
Simplifications mostly, and support for extern "C".
rdeodhar 42478c8
Remove debug code.
rdeodhar a926383
Changes to namespaces.
rdeodhar be9c177
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar e9f50cc
Removed some unneeded code and unneeded namespace qualifiers.
rdeodhar 2dc28f7
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar 1e1aa2c
Fixes for templated free functions.
rdeodhar 0a5569b
Removed debug code.
rdeodhar 07ebf0d
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar be6c168
Removed unneeded code.
rdeodhar ef8b031
Merge branch 'freefunc_traits' of https://github.com/rdeodhar/llvm in…
rdeodhar 40fb924
Removed need to specify SYCL_EXTERNAL.
rdeodhar bbdf983
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar 38ad179
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar 85fe22a
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar 46d3e5d
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar 66665af
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar 9f4eded
Changed templated forward declaration for shim.
rdeodhar b8e1665
Correction to forward declaration of templated free functions.
rdeodhar 670cc61
Merge branch 'freefunc_traits' of https://github.com/rdeodhar/llvm in…
rdeodhar f753c37
Changed the way non-templated functions are forward declared.
rdeodhar 36ba16a
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar 7e6aacf
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar c57f9cd
Corrected a test.
rdeodhar 7b0dcf9
Minor change to API test.
rdeodhar a0f4ddc
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc_tr…
rdeodhar 06f91cf
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar b83a080
Merge branch 'freefunc_traits' of https://github.com/rdeodhar/llvm in…
rdeodhar cbb3f23
Correction to where free functions are placed.
rdeodhar db857f2
Removed "device" marking from test.
rdeodhar 0475c35
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar e39f44a
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar 2a90137
Simplified checking of free function attributes.
rdeodhar 74b5d82
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar 6d7a31a
Added test for free function parameter errors.
rdeodhar e5edf4c
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar e0f5b82
Added test to ensure missing SYCL_EXTERN on free function does not ge…
rdeodhar 5603aef
Fixed comment.
rdeodhar d803209
Exclude member functions as free function candidates and add a test.
rdeodhar 3b71b2c
Added add_ir_atribute_check test.
rdeodhar af52693
Comment correction.
rdeodhar 9d1a87e
Merge branch 'sycl' of https://github.com/intel/llvm into freefunc3
rdeodhar 2d2ef56
Simplification.
rdeodhar 7189420
Updated a comment.
rdeodhar 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
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
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,58 @@ | ||
//==---- free_function_implicit_sycl_extern.cpp ----------------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// RUN: %clang_cc1 -fsycl-is-device -triple -spir64-unknown-unknown -verify %s | ||
|
||
// expected-no-diagnostics | ||
|
||
// This test confirms that functions or methods with add_ir_attributes_function | ||
// attribute values in dependent contexts can be handled without assertions when | ||
// checking for the presence of free function properties. | ||
|
||
template <typename T> constexpr int value() { return 5; } | ||
|
||
// In this struct the function the add_ir_attributes_function values for "S()" | ||
// are as follows. Note that the "value" is represented as a CallExpr. | ||
// `-SYCLAddIRAttributesFunctionAttr 0x562ec6c13390 < col:5, col : 67 > | ||
// | -ConstantExpr 0x562ec6c13440 < col:49 > 'const char[5]' lvalue | ||
// | |-value: LValue <todo> | ||
// | `-StringLiteral 0x562ec6c13160 < col:49 > 'const char[5]' lvalue "name" | ||
// `-CallExpr 0x562ec6c13220 < col:57, col : 66 > '<dependent type>' | ||
// `-UnresolvedLookupExpr 0x562ec6c131a8 < col:57, col : 64 > '<dependent type>' lvalue(ADL) = 'value' 0x562ec6bea700 | ||
// `-TemplateArgument type 'T':'type-parameter-0-0' | ||
// `-TemplateTypeParmType 0x562ec6bea8b0 'T' dependent depth 0 index 0 | ||
// `-TemplateTypeParm 0x562ec6bea860 'T' | ||
|
||
template <typename T> struct S { | ||
#if defined(__SYCL_DEVICE_ONLY__) | ||
[[__sycl_detail__::add_ir_attributes_function("name", value<T>())]] | ||
#endif | ||
S() { | ||
} | ||
}; | ||
|
||
// For the free function "f" the add_ir_attributes_function values are: | ||
// | -SYCLAddIRAttributesFunctionAttr 0x56361c3c3ea8 < line:37 : 32, line : 39 : 15 > | ||
// | |-ConstantExpr 0x56361c3c3f00 < line:38 : 5 > 'const char[5]' lvalue | ||
// | | |-value: LValue <todo> | ||
// | | `-StringLiteral 0x56361c398cf0 < col:5 > 'const char[5]' lvalue "name" | ||
// | `-ConstantExpr 0x56361c3c3f60 < line:39 : 5, col : 14 > 'int' | ||
// | |-value: Int 5 | ||
// | `-CallExpr 0x56361c3c3e88 < col:5, col : 14 > 'int' | ||
// | `-ImplicitCastExpr 0x56361c3c3e70 < col:5, col : 12 > 'int (*)()' < FunctionToPointerDecay > | ||
// | `-DeclRefExpr 0x56361c3c3dc0 < col:5, col : 12 > 'int ()' lvalue Function 0x56361c3c3cc8 'value' 'int ()' (FunctionTemplate 0x56361c398a90 'value') | ||
|
||
template <typename T> | ||
__attribute__((sycl_device)) [[__sycl_detail__::add_ir_attributes_function( | ||
"name", | ||
value<T>())]] [[__sycl_detail__:: | ||
add_ir_attributes_function("sycl-single-task-kernel", | ||
0)]] void | ||
f(T i) {} | ||
|
||
template void f(int i); |
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
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,51 @@ | ||
//==---- free_function_errors.cpp --------------------------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// RUN: %clangxx -fsyntax-only -fsycl-device-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s | ||
|
||
#include <array> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
|
||
struct S { | ||
int i; | ||
float f; | ||
}; | ||
|
||
union U { | ||
int i; | ||
float f; | ||
}; | ||
|
||
using accType = accessor<int, 1, access::mode::read_write>; | ||
|
||
// expected-error@+3 {{'struct S' cannot be used as the type of a kernel parameter}} | ||
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY( | ||
(ext::oneapi::experimental::single_task_kernel)) | ||
void ff(struct S s) {} | ||
|
||
// expected-error@+3 {{'union U' cannot be used as the type of a kernel parameter}} | ||
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY( | ||
(ext::oneapi::experimental::single_task_kernel)) | ||
void ff(union U u) {} | ||
|
||
// expected-error@+3 {{'accType' (aka 'accessor<int, 1, access::mode::read_write>') cannot be used as the type of a kernel parameter}} | ||
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY( | ||
(ext::oneapi::experimental::single_task_kernel)) | ||
void ff(accType acc) {} | ||
|
||
// expected-error@+3 {{'std::array<int, 10>' cannot be used as the type of a kernel parameter}} | ||
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY( | ||
(ext::oneapi::experimental::single_task_kernel)) | ||
void ff(std::array<int, 10> a) {} | ||
|
||
// expected-error@+3 {{'int &' cannot be used as the type of a kernel parameter}} | ||
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY( | ||
(ext::oneapi::experimental::single_task_kernel)) | ||
void ff(int &ip) {} |
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.