-
Notifications
You must be signed in to change notification settings - Fork 772
[SYCL] Support intel::reqd_work_group_size #1328
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
Changes from all commits
4555f44
c704d1a
d6e3575
18b0e94
6a313bf
995352e
421217a
f9c5822
eb5c797
9c1c130
a8b1121
93a022d
fb7e14e
8a3f1b8
dc0eaac
04a4c83
fc10805
971eaa4
65fc0ba
2776fe5
545cb9f
60541fd
50e397d
cf200c4
23e0bbb
6d2bce7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2922,14 +2922,22 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { | |
return; | ||
|
||
uint32_t WGSize[3]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Every comparison with this gives me a -Wsign-compare warning. XDim, YDim, and ZDim are all 'int' in type. This should be so as well likely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is TableGen has no unsigned type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okey, this problem I solved, it seems. |
||
if (AL.getKind() == ParsedAttr::AT_ReqdWorkGroupSize && | ||
AL.getAttributeSpellingListIndex() == | ||
ReqdWorkGroupSizeAttr::CXX11_intel_reqd_work_group_size) { | ||
WGSize[1] = ReqdWorkGroupSizeAttr::DefaultYDim; | ||
WGSize[2] = ReqdWorkGroupSizeAttr::DefaultZDim; | ||
} else if (!checkAttributeNumArgs(S, AL, 3)) | ||
return; | ||
|
||
for (unsigned i = 0; i < 3; ++i) { | ||
const Expr *E = AL.getArgAsExpr(i); | ||
if (!checkUInt32Argument(S, AL, E, WGSize[i], i, | ||
if (i < AL.getNumArgs() && | ||
!checkUInt32Argument(S, AL, AL.getArgAsExpr(i), WGSize[i], i, | ||
/*StrictlyUnsigned=*/true)) | ||
return; | ||
if (WGSize[i] == 0) { | ||
S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) | ||
<< AL << E->getSourceRange(); | ||
<< AL << AL.getArgAsExpr(i)->getSourceRange(); | ||
return; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify -DTRIGGER_ERROR %s | ||
// RUN: %clang_cc1 -fsycl -fsycl-is-device -ast-dump %s | FileCheck %s | ||
// RUN: %clang_cc1 -fsycl -fsycl-is-host -fsyntax-only -verify %s | ||
|
||
#ifndef __SYCL_DEVICE_ONLY__ | ||
// expected-no-diagnostics | ||
class Functor { | ||
public: | ||
[[intel::reqd_work_group_size(4)]] void operator()() {} | ||
}; | ||
|
||
template <typename name, typename Func> | ||
void kernel(Func kernelFunc) { | ||
kernelFunc(); | ||
} | ||
|
||
void bar() { | ||
Functor f; | ||
kernel<class kernel_name>(f); | ||
} | ||
#else | ||
[[intel::reqd_work_group_size(4)]] void f4x1x1() {} // expected-note {{conflicting attribute is here}} | ||
// expected-note@-1 {{conflicting attribute is here}} | ||
[[intel::reqd_work_group_size(32)]] void f32x1x1() {} // expected-note {{conflicting attribute is here}} | ||
|
||
[[intel::reqd_work_group_size(16)]] void f16x1x1() {} // expected-note {{conflicting attribute is here}} | ||
Fznamznon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[[intel::reqd_work_group_size(16, 16)]] void f16x16x1() {} // expected-note {{conflicting attribute is here}} | ||
|
||
[[intel::reqd_work_group_size(32, 32)]] void f32x32x1() {} // expected-note {{conflicting attribute is here}} | ||
[[intel::reqd_work_group_size(32, 32, 32)]] void f32x32x32() {} // expected-note {{conflicting attribute is here}} | ||
|
||
#ifdef TRIGGER_ERROR | ||
class Functor32 { | ||
public: | ||
[[cl::reqd_work_group_size(32)]] void operator()() {} // expected-error {{'reqd_work_group_size' attribute requires exactly 3 arguments}} | ||
}; | ||
class Functor33 { | ||
public: | ||
[[intel::reqd_work_group_size(32, -4)]] void operator()() {} // expected-error {{'reqd_work_group_size' attribute requires a non-negative integral compile time constant expression}} | ||
}; | ||
#endif // TRIGGER_ERROR | ||
|
||
class Functor16 { | ||
public: | ||
[[intel::reqd_work_group_size(16)]] void operator()() {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any examples with 2? What happens when I pass a negative to these? How about when things conflict with '1'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fadeeval please apply this. |
||
}; | ||
|
||
class Functor64 { | ||
public: | ||
[[intel::reqd_work_group_size(64, 64)]] void operator()() {} | ||
}; | ||
|
||
class Functor16x16x16 { | ||
public: | ||
[[intel::reqd_work_group_size(16, 16, 16)]] void operator()() {} | ||
}; | ||
|
||
class Functor8 { // expected-error {{conflicting attributes applied to a SYCL kernel}} | ||
public: | ||
[[intel::reqd_work_group_size(8)]] void operator()() { // expected-note {{conflicting attribute is here}} | ||
f4x1x1(); | ||
} | ||
}; | ||
|
||
class Functor { | ||
public: | ||
void operator()() { | ||
f4x1x1(); | ||
} | ||
}; | ||
|
||
class FunctorAttr { | ||
public: | ||
__attribute__((reqd_work_group_size(128, 128, 128))) void operator()() {} | ||
}; | ||
|
||
template <typename name, typename Func> | ||
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) { | ||
kernelFunc(); | ||
} | ||
|
||
void bar() { | ||
Functor16 f16; | ||
kernel<class kernel_name1>(f16); | ||
|
||
Functor f; | ||
kernel<class kernel_name2>(f); | ||
|
||
Functor16x16x16 f16x16x16; | ||
kernel<class kernel_name3>(f16x16x16); | ||
|
||
FunctorAttr fattr; | ||
kernel<class kernel_name4>(fattr); | ||
|
||
kernel<class kernel_name5>([]() [[intel::reqd_work_group_size(32, 32, 32)]] { | ||
f32x32x32(); | ||
}); | ||
|
||
#ifdef TRIGGER_ERROR | ||
Functor8 f8; | ||
kernel<class kernel_name6>(f8); | ||
|
||
kernel<class kernel_name7>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} | ||
f4x1x1(); | ||
f32x1x1(); | ||
}); | ||
|
||
kernel<class kernel_name8>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} | ||
f16x1x1(); | ||
f16x16x1(); | ||
}); | ||
|
||
kernel<class kernel_name9>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} | ||
f32x32x32(); | ||
f32x32x1(); | ||
}); | ||
|
||
// expected-error@+1 {{expected variable name or 'this' in lambda capture list}} | ||
kernel<class kernel_name10>([[intel::reqd_work_group_size(32, 32, 32)]][]() { | ||
f32x32x32(); | ||
}); | ||
|
||
#endif // TRIGGER_ERROR | ||
} | ||
|
||
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name1 | ||
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 16 | ||
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name2 | ||
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 4 | ||
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name3 | ||
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 16 16 | ||
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name4 | ||
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 128 128 128 | ||
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name5 | ||
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 32 32 32 | ||
#endif // __SYCL_DEVICE_ONLY__ |
Uh oh!
There was an error while loading. Please reload this page.