-
Notifications
You must be signed in to change notification settings - Fork 772
[SYCL][FPGA] Enable uses_global_work_offset attribute #1010
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
3 commits
Select commit
Hold shift + click to select a range
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
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
28 changes: 28 additions & 0 deletions
28
clang/test/CodeGenSYCL/intel-fpga-uses-global-work-offset.cpp
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,28 @@ | ||
// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -fsycl-is-device -emit-llvm -o - %s | FileCheck %s | ||
|
||
class Foo { | ||
public: | ||
[[intelfpga::uses_global_work_offset(0)]] void operator()() {} | ||
}; | ||
|
||
template <typename name, typename Func> | ||
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) { | ||
kernelFunc(); | ||
} | ||
|
||
void bar() { | ||
Foo boo; | ||
kernel<class kernel_name1>(boo); | ||
|
||
kernel<class kernel_name2>( | ||
[]() [[intelfpga::uses_global_work_offset(0)]]{}); | ||
|
||
kernel<class kernel_name3>( | ||
[]() [[intelfpga::uses_global_work_offset(1)]]{}); | ||
} | ||
|
||
// CHECK: define spir_kernel void @{{.*}}kernel_name1() {{.*}} !uses_global_work_offset ![[NUM5:[0-9]+]] | ||
// CHECK: define spir_kernel void @{{.*}}kernel_name2() {{.*}} !uses_global_work_offset ![[NUM5]] | ||
// CHECK: define spir_kernel void @{{.*}}kernel_name3() {{.*}} ![[NUM4:[0-9]+]] | ||
// CHECK-NOT: ![[NUM4]] = !{i32 1} | ||
// CHECK: ![[NUM5]] = !{i32 0} |
49 changes: 49 additions & 0 deletions
49
clang/test/SemaSYCL/intel-fpga-uses-global-work-offset.cpp
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,49 @@ | ||
// RUN: %clang_cc1 -Wno-return-type -fsycl-is-device -fcxx-exceptions -fsyntax-only -ast-dump -verify -pedantic %s | FileCheck %s | ||
vmaksimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
struct FuncObj { | ||
[[intelfpga::uses_global_work_offset(1)]] void operator()() {} | ||
}; | ||
|
||
template <typename name, typename Func> | ||
void kernel(Func kernelFunc) { | ||
kernelFunc(); | ||
} | ||
|
||
int main() { | ||
// CHECK: SYCLIntelUsesGlobalWorkOffsetAttr{{.*}}Enabled | ||
kernel<class test_kernel1>([]() { | ||
FuncObj(); | ||
}); | ||
|
||
// CHECK: SYCLIntelUsesGlobalWorkOffsetAttr | ||
// CHECK-NOT: Enabled | ||
kernel<class test_kernel2>( | ||
AGindinson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[]() [[intelfpga::uses_global_work_offset(0)]]{}); | ||
|
||
// CHECK: SYCLIntelUsesGlobalWorkOffsetAttr{{.*}}Enabled | ||
// expected-warning@+2{{'uses_global_work_offset' attribute should be 0 or 1. Adjusted to 1}} | ||
kernel<class test_kernel3>( | ||
[]() [[intelfpga::uses_global_work_offset(42)]]{}); | ||
|
||
// expected-error@+2{{'uses_global_work_offset' attribute requires a non-negative integral compile time constant expression}} | ||
kernel<class test_kernel4>( | ||
[]() [[intelfpga::uses_global_work_offset(-1)]]{}); | ||
|
||
// expected-error@+2{{'uses_global_work_offset' attribute requires parameter 0 to be an integer constant}} | ||
kernel<class test_kernel5>( | ||
[]() [[intelfpga::uses_global_work_offset("foo")]]{}); | ||
|
||
kernel<class test_kernel6>([]() { | ||
// expected-error@+1{{'uses_global_work_offset' attribute only applies to functions}} | ||
[[intelfpga::uses_global_work_offset(1)]] int a; | ||
}); | ||
|
||
// CHECK: SYCLIntelUsesGlobalWorkOffsetAttr{{.*}} | ||
// CHECK-NOT: Enabled | ||
// CHECK: SYCLIntelUsesGlobalWorkOffsetAttr{{.*}}Enabled | ||
// expected-warning@+2{{attribute 'uses_global_work_offset' is already applied}} | ||
kernel<class test_kernel7>( | ||
[]() [[intelfpga::uses_global_work_offset(0), intelfpga::uses_global_work_offset(1)]]{}); | ||
|
||
return 0; | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to reset Enabled to 1 if the warning is generated, or will that be handled in the generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need, as it is handled in code generation -
CodeGenFunction.cpp:674