-
Notifications
You must be signed in to change notification settings - Fork 788
[ESIMD] Add support for vectorizing scalar functions - FE part #3603
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
6 commits
Select commit
Hold shift + click to select a range
7f6d876
[ESIMD] Add support for widening SIMT functions - FE part
DenisBakhvalov 342f006
Addressed review comments
DenisBakhvalov c2b2f67
renamed sycl_esimd_widen into sycl_esimd_vectorize
DenisBakhvalov fa77646
Addressed review comments
DenisBakhvalov 44cc121
when merging, use the attribute from the declaration
DenisBakhvalov 708a011
Revert "when merging, use the attribute from the declaration"
DenisBakhvalov 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang_cc1 -disable-llvm-passes -triple spir64-unknown-unknown-sycldevice \ | ||
// RUN: -fsycl-is-device -S -emit-llvm %s -o - | FileCheck %s | ||
|
||
// This test checks the generation of CMGenxSIMT function attributes | ||
|
||
[[intel::sycl_esimd_vectorize(32)]] __attribute__((sycl_device)) void foo1() {} | ||
// CHECK: @_Z4foo1v() #[[ATTR1:[0-9]+]] | ||
|
||
[[intel::sycl_esimd_vectorize(8)]] [[intel::sycl_esimd_vectorize(16)]] __attribute__((sycl_device)) void foo2() {} | ||
// CHECK: @_Z4foo2v() #[[ATTR2:[0-9]+]] | ||
|
||
[[intel::sycl_esimd_vectorize(8)]] __attribute__((sycl_device)) void foo3(); | ||
[[intel::sycl_esimd_vectorize(16)]] __attribute__((sycl_device)) void foo3() {} | ||
// CHECK: @_Z4foo3v() #[[ATTR3:[0-9]+]] | ||
|
||
// CHECK: attributes #[[ATTR1]] = { {{.*}} "CMGenxSIMT"="32" {{.*}}} | ||
// CHECK: attributes #[[ATTR2]] = { {{.*}} "CMGenxSIMT"="8" {{.*}}} | ||
// CHECK: attributes #[[ATTR3]] = { {{.*}} "CMGenxSIMT"="16" {{.*}}} |
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,48 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s | ||
|
||
// This test check the semantics of sycl_esimd_vectorize attribute | ||
|
||
// expected-error@+1{{'sycl_esimd_vectorize' attribute argument must be 8, 16, or 32}} | ||
[[intel::sycl_esimd_vectorize(17)]] void foo1() {} | ||
// expected-error@+1{{integral constant expression must have integral or unscoped enumeration type, not 'float'}} | ||
[[intel::sycl_esimd_vectorize(3.f)]] void foo3() {} | ||
|
||
[[intel::sycl_esimd_vectorize(8)]] void foo4() {} | ||
[[intel::sycl_esimd_vectorize(16)]] void foo5() {} | ||
[[intel::sycl_esimd_vectorize(32)]] void foo6() {} | ||
|
||
// We explicitly do not support a GNU spelling for this attribute, which is why it is | ||
// treated as an unknown attribute. | ||
// expected-warning@+1{{unknown attribute 'sycl_esimd_vectorize' ignored}} | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
__attribute__((sycl_esimd_vectorize(8))) void foo7() {} | ||
|
||
// expected-note@+2{{previous attribute is here}} | ||
// expected-warning@+1{{attribute 'sycl_esimd_vectorize' is already applied with different arguments}} | ||
[[intel::sycl_esimd_vectorize(8)]] [[intel::sycl_esimd_vectorize(16)]] void foo8() {} | ||
|
||
// expected-note@+1{{previous attribute is here}} | ||
[[intel::sycl_esimd_vectorize(8)]] void foo9(); | ||
// expected-warning@+1{{attribute 'sycl_esimd_vectorize' is already applied with different arguments}} | ||
[[intel::sycl_esimd_vectorize(16)]] void foo9() {} | ||
|
||
// No diagnostic is emitted because the arguments match. | ||
[[intel::sycl_esimd_vectorize(16)]] void foo10(); | ||
[[intel::sycl_esimd_vectorize(16)]] void foo10() {} | ||
|
||
// expected-error@+1{{'sycl_esimd_vectorize' attribute only applies to functions}} | ||
[[intel::sycl_esimd_vectorize(8)]] int glob = 0; | ||
|
||
class A { | ||
[[intel::sycl_esimd_vectorize(8)]] void func2() {} | ||
}; | ||
|
||
struct Functor { | ||
[[intel::sycl_esimd_vectorize(8)]] void operator()(float) const {} | ||
}; | ||
|
||
void test() { | ||
auto f2 = []() [[intel::sycl_esimd_vectorize(8)]]{}; | ||
} | ||
|
||
template <int N> | ||
[[intel::sycl_esimd_vectorize(N)]] void templateFunc(); |
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,11 @@ | ||
// RUN: %clang_cc1 -fsycl-is-host -fsyntax-only -verify %s | ||
|
||
// This test check the semantics of sycl_esimd_vectorize attribute | ||
|
||
// expected-warning@+1{{'sycl_esimd_vectorize' attribute ignored}} | ||
[[intel::sycl_esimd_vectorize(17)]] void foo1() {} | ||
|
||
// We explicitly do not support a GNU spelling for this attribute, which is why it is | ||
// treated as an unknown attribute. | ||
// expected-warning@+1{{unknown attribute 'sycl_esimd_vectorize' ignored}} | ||
__attribute__((sycl_esimd_vectorize(8))) void foo2() {} |
95 changes: 95 additions & 0 deletions
95
clang/test/SemaSYCL/sycl-device-sycl_esimd_vectorize-template.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,95 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -ast-dump -verify -pedantic %s | FileCheck %s | ||
|
||
// Test that checks template parameter support for 'sycl_esimd_vectorize' attribute on sycl device. | ||
|
||
// Test wrong function template instantiation and ensure that the type | ||
// is checked properly when instantiating from the template definition. | ||
template <typename Ty> | ||
// expected-error@+3{{integral constant expression must have integral or unscoped enumeration type, not 'S'}} | ||
// expected-error@+2{{integral constant expression must have integral or unscoped enumeration type, not 'float'}} | ||
// expected-error@+1{{'sycl_esimd_vectorize' attribute argument must be 8, 16, or 32}} | ||
[[intel::sycl_esimd_vectorize(Ty{})]] void func() {} | ||
|
||
struct S {}; | ||
void test() { | ||
//expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}} | ||
func<S>(); | ||
//expected-note@+1{{in instantiation of function template specialization 'func<float>' requested here}} | ||
func<float>(); | ||
//expected-note@+1{{in instantiation of function template specialization 'func<int>' requested here}} | ||
func<int>(); | ||
} | ||
|
||
// Test a non-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::sycl_esimd_vectorize(foo() + 12)]] void func1(); | ||
|
||
// Test a constant expression. | ||
constexpr int bar() { return 0; } | ||
[[intel::sycl_esimd_vectorize(bar() + 16)]] void func2(); // OK | ||
|
||
// Test template parameter support on member function of class template. | ||
template <int SIZE> | ||
class KernelFunctor { | ||
public: | ||
// expected-error@+1{{'sycl_esimd_vectorize' attribute argument must be 8, 16, or 32}} | ||
[[intel::sycl_esimd_vectorize(SIZE)]] void operator()() {} | ||
}; | ||
|
||
int main() { | ||
//expected-note@+1{{in instantiation of template class 'KernelFunctor<-1>' requested here}} | ||
KernelFunctor<-1>(); | ||
// no error expected | ||
KernelFunctor<8>(); | ||
return 0; | ||
} | ||
|
||
// CHECK: ClassTemplateDecl {{.*}} {{.*}} KernelFunctor | ||
// CHECK: ClassTemplateSpecializationDecl {{.*}} {{.*}} class KernelFunctor definition | ||
// CHECK: CXXRecordDecl {{.*}} {{.*}} implicit class KernelFunctor | ||
// CHECK: SYCLIntelESimdVectorizeAttr {{.*}} | ||
// CHECK: SubstNonTypeTemplateParmExpr {{.*}} | ||
// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} | ||
// CHECK-NEXT: IntegerLiteral{{.*}}8{{$}} | ||
|
||
// Test template parameter support on function. | ||
template <int N> | ||
// expected-error@+1{{'sycl_esimd_vectorize' attribute argument must be 8, 16, or 32}} | ||
[[intel::sycl_esimd_vectorize(N)]] void func3() {} | ||
|
||
template <int N> | ||
[[intel::sycl_esimd_vectorize(32)]] void func4(); // expected-note {{previous attribute is here}} | ||
|
||
template <int N> | ||
[[intel::sycl_esimd_vectorize(N)]] void func4() {} // expected-warning {{attribute 'sycl_esimd_vectorize' is already applied with different arguments}} | ||
|
||
int check() { | ||
// no error expected. | ||
func3<8>(); | ||
//expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}} | ||
func3<-1>(); | ||
//expected-note@+1 {{in instantiation of function template specialization 'func4<16>' requested here}} | ||
func4<16>(); | ||
return 0; | ||
} | ||
|
||
// No diagnostic is emitted because the arguments match. Duplicate attribute is silently ignored. | ||
[[intel::sycl_esimd_vectorize(8)]] | ||
[[intel::sycl_esimd_vectorize(8)]] void func5() {} | ||
|
||
// CHECK: FunctionTemplateDecl {{.*}} {{.*}} func3 | ||
// CHECK: NonTypeTemplateParmDecl {{.*}} {{.*}} referenced 'int' depth 0 index 0 N | ||
// CHECK: FunctionDecl {{.*}} {{.*}} func3 'void ()' | ||
// CHECK: SYCLIntelESimdVectorizeAttr {{.*}} | ||
// CHECK: SubstNonTypeTemplateParmExpr {{.*}} | ||
// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} | ||
// CHECK-NEXT: IntegerLiteral{{.*}}8{{$}} | ||
|
||
// CHECK: FunctionDecl {{.*}} {{.*}} func5 'void ()' | ||
// CHECK: SYCLIntelESimdVectorizeAttr {{.*}} | ||
// CHECK-NEXT: ConstantExpr {{.*}} 'int' | ||
// CHECK-NEXT: value: Int 8 | ||
// CHECK-NEXT: IntegerLiteral{{.*}}8{{$}} |
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.