-
Notifications
You must be signed in to change notification settings - Fork 788
[FPGA][NFC] improves tests for [[intel::no_global_work_offset]] attribute #6184
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
4 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
118 changes: 118 additions & 0 deletions
118
clang/test/SemaSYCL/intel-fpga-no-global-work-offset-ast.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,118 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -Wno-sycl-2017-compat -ast-dump %s | FileCheck %s | ||
|
||
// Tests for AST of Intel FPGA no_global_work_offset function attribute. | ||
|
||
#include "sycl.hpp" | ||
|
||
using namespace cl::sycl; | ||
queue q; | ||
|
||
struct FuncObj { | ||
[[intel::no_global_work_offset]] void operator()() const {} | ||
}; | ||
|
||
// CHECK: FunctionDecl {{.*}} func 'void ()' | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK-NEXT: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr{{.*}}'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 | ||
[[intel::no_global_work_offset(1)]] void func() {} | ||
|
||
class KernelFunctor { | ||
public: | ||
void operator()() const { | ||
func(); | ||
} | ||
}; | ||
|
||
// CHECK: FunctionTemplateDecl {{.*}} func1 | ||
// CHECK: FunctionDecl {{.*}} func1 'void ()' | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK_NEXT: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK_NEXT: DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'N' 'int' | ||
// CHECK: FunctionDecl {{.*}} func1 'void ()' | ||
// CHECK-NEXT: TemplateArgument integral 1 | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK-NEXT: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr{{.*}}'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: SubstNonTypeTemplateParmExpr | ||
// CHECK-NEXT: NonTypeTemplateParmDecl | ||
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 | ||
|
||
// Test that checks template parameter support on function. | ||
template <int N> | ||
[[intel::no_global_work_offset(N)]] void func1() {} | ||
|
||
// Test that checks template parameter support on member function of class template. | ||
template <int SIZE> | ||
class KernelFunctor2 { | ||
public: | ||
[[intel::no_global_work_offset(SIZE)]] void operator()() const {} | ||
}; | ||
|
||
int main() { | ||
q.submit([&](handler &h) { | ||
// CHECK: FunctionDecl {{.*}}test_kernel1 | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}1{{$}} | ||
h.single_task<class test_kernel1>(FuncObj()); | ||
|
||
// CHECK: FunctionDecl {{.*}}test_kernel2 | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 0 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}0{{$}} | ||
h.single_task<class test_kernel2>( | ||
[]() [[intel::no_global_work_offset(0)]] {}); | ||
|
||
// CHECK: FunctionDecl {{.*}}test_kernel3 | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 42 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}42{{$}} | ||
h.single_task<class test_kernel3>( | ||
[]() [[intel::no_global_work_offset(42)]] {}); | ||
|
||
// CHECK: FunctionDecl {{.*}}test_kernel4 | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int -1 | ||
// CHECK-NEXT: UnaryOperator{{.*}} 'int' prefix '-' | ||
// CHECK-NEXT-NEXT: IntegerLiteral{{.*}}1{{$}} | ||
h.single_task<class test_kernel4>( | ||
[]() [[intel::no_global_work_offset(-1)]] {}); | ||
|
||
// Ignore duplicate attribute. | ||
h.single_task<class test_kernel5>( | ||
// CHECK: FunctionDecl {{.*}}test_kernel5 | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}1{{$}} | ||
// CHECK-NOT: SYCLIntelNoGlobalWorkOffsetAttr | ||
[]() [[intel::no_global_work_offset, | ||
intel::no_global_work_offset]] {}); // OK | ||
|
||
// Test attribute does not get propagated. | ||
// CHECK: FunctionDecl {{.*}}test_kernel6 | ||
// CHECK-NOT: SYCLIntelLoopFuseAttr | ||
KernelFunctor f1; | ||
h.single_task<class test_kernel6>(f1); | ||
|
||
// CHECK: FunctionDecl {{.*}}test_kernel7 | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr | ||
// CHECK-NEXT: ConstantExpr{{.*}}'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: SubstNonTypeTemplateParmExpr | ||
// CHECK-NEXT: NonTypeTemplateParmDecl | ||
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 | ||
KernelFunctor2<1> f2; | ||
h.single_task<class test_kernel7>(f2); | ||
}); | ||
func1<1>(); | ||
return 0; | ||
} |
101 changes: 47 additions & 54 deletions
101
clang/test/SemaSYCL/intel-fpga-no-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 |
---|---|---|
@@ -1,68 +1,61 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -Wno-return-type -sycl-std=2017 -Wno-sycl-2017-compat -fcxx-exceptions -fsyntax-only -ast-dump -verify -pedantic %s | FileCheck %s | ||
// RUN: %clang_cc1 -fsycl-is-device -verify %s | ||
|
||
#include "sycl.hpp" | ||
// Test that checks 'no_global_work_offset' attribute support on function. | ||
|
||
using namespace cl::sycl; | ||
queue q; | ||
// Tests for incorrect argument values for Intel FPGA 'no_global_work_offset' function attribute. | ||
[[intel::no_global_work_offset(1)]] int a; // expected-error{{'no_global_work_offset' attribute only applies to functions}} | ||
|
||
//expected-warning@+1 {{unknown attribute 'no_global_work_offset' ignored}} | ||
[[intelfpga::no_global_work_offset]] void RemovedSpell(); | ||
[[intel::no_global_work_offset("foo")]] void test() {} // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const char[4]'}} | ||
|
||
struct FuncObj { | ||
[[intel::no_global_work_offset]] void operator()() const {} | ||
}; | ||
[[intel::no_global_work_offset(0, 1)]] void test1() {} // expected-error{{'no_global_work_offset' attribute takes no more than 1 argument}} | ||
|
||
int main() { | ||
q.submit([&](handler &h) { | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr {{.*}} | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}1{{$}} | ||
h.single_task<class test_kernel1>(FuncObj()); | ||
[[intelfpga::no_global_work_offset]] void RemovedSpell(); // expected-warning {{unknown attribute 'no_global_work_offset' ignored}} | ||
|
||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr {{.*}} | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 0 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}0{{$}} | ||
h.single_task<class test_kernel2>( | ||
[]() [[intel::no_global_work_offset(0)]]{}); | ||
// Test that checks wrong function template instantiation and ensures that the type | ||
// is checked properly when instantiating from the template definition. | ||
template <typename Ty> | ||
// expected-error@+1{{integral constant expression must have integral or unscoped enumeration type, not 'S'}} | ||
[[intel::no_global_work_offset(Ty{})]] void func() {} | ||
|
||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr{{.*}} | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 42 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}42{{$}} | ||
h.single_task<class test_kernel3>( | ||
[]() [[intel::no_global_work_offset(42)]]{}); | ||
struct S {}; | ||
void var() { | ||
// expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}} | ||
func<S>(); | ||
} | ||
|
||
// Test that checks expression is not a constant expression. | ||
// expected-note@+1{{declared here}} | ||
int foo(); | ||
// expected-error@+2{{expression is not an integral constant expression}} | ||
// expected-note@+1{{non-constexpr function 'foo' cannot be used in a constant expression}} | ||
[[intel::no_global_work_offset(foo() + 12)]] void func1(); | ||
|
||
// Test that checks expression is a constant expression. | ||
constexpr int bar() { return 0; } | ||
[[intel::no_global_work_offset(bar() + 12)]] void func2(); // OK | ||
|
||
// No diagnostic is thrown since arguments match. Silently ignore duplicate attribute. | ||
[[intel::no_global_work_offset]] void func3(); | ||
[[intel::no_global_work_offset(1)]] void func3() {} // OK | ||
|
||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr{{.*}} | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int -1 | ||
// CHECK-NEXT: UnaryOperator{{.*}} 'int' prefix '-' | ||
// CHECK-NEXT-NEXT: IntegerLiteral{{.*}}1{{$}} | ||
h.single_task<class test_kernel4>( | ||
[]() [[intel::no_global_work_offset(-1)]]{}); | ||
[[intel::no_global_work_offset(0)]] void func4(); // expected-note {{previous attribute is here}} | ||
[[intel::no_global_work_offset]] void func4(); // expected-warning{{attribute 'no_global_work_offset' is already applied with different arguments}} | ||
|
||
// Ignore duplicate attribute. | ||
h.single_task<class test_kernel5>( | ||
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr {{.*}} | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 1 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}1{{$}} | ||
[]() [[intel::no_global_work_offset, | ||
intel::no_global_work_offset]]{}); // OK | ||
// No diagnostic is emitted because the arguments match. | ||
[[intel::no_global_work_offset(1)]] void func5(); | ||
[[intel::no_global_work_offset(1)]] void func5() {} // OK | ||
|
||
// expected-error@+2{{integral constant expression must have integral or unscoped enumeration type, not 'const char[4]'}} | ||
h.single_task<class test_kernel6>( | ||
[]() [[intel::no_global_work_offset("foo")]]{}); | ||
// Diagnostic is emitted because the arguments mismatch. | ||
[[intel::no_global_work_offset(0)]] void func6(); // expected-note {{previous attribute is here}} | ||
[[intel::no_global_work_offset(1)]] void func6(); // expected-warning{{attribute 'no_global_work_offset' is already applied with different arguments}} | ||
|
||
h.single_task<class test_kernel7>([]() { | ||
// expected-error@+1{{'no_global_work_offset' attribute only applies to functions}} | ||
[[intel::no_global_work_offset(1)]] int a; | ||
}); | ||
// Test that checks template parameter support on function. | ||
template <int N> | ||
[[intel::no_global_work_offset(0)]] void func7(); // expected-note {{previous attribute is here}} | ||
template <int N> | ||
[[intel::no_global_work_offset(N)]] void func7() {} // expected-warning {{attribute 'no_global_work_offset' is already applied with different arguments}} | ||
|
||
h.single_task<class test_kernel8>( | ||
[]() [[intel::no_global_work_offset(0), // expected-note {{previous attribute is here}} | ||
intel::no_global_work_offset(1)]]{}); // expected-warning{{attribute 'no_global_work_offset' is already applied with different arguments}} | ||
}); | ||
int check() { | ||
func7<1>(); // expected-note {{in instantiation of function template specialization 'func7<1>' requested here}} | ||
return 0; | ||
} |
96 changes: 0 additions & 96 deletions
96
clang/test/SemaSYCL/sycl-device-intel-fpga-no-global-work-offset.cpp
This file was deleted.
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.