Skip to content

[SYCL][CUDA] Return invalid subgroup size warning #6183

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 6 commits into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3288,6 +3288,10 @@ def err_attribute_argument_is_zero : Error<
def warn_attribute_argument_n_negative : Warning<
"%0 attribute parameter %1 is negative and will be ignored">,
InGroup<CudaCompat>;
def warn_reqd_sub_group_attribute_cuda_n_32
: Warning<"attribute argument %0 is invalid and will be ignored; CUDA "
"requires sub_group size 32">,
InGroup<CudaCompat>;
def err_property_function_in_objc_container : Error<
"use of Objective-C property in function nested in Objective-C "
"container not supported, move function outside its container">;
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3886,6 +3886,10 @@ void Sema::AddIntelReqdSubGroupSize(Decl *D, const AttributeCommonInfo &CI,
<< CI << /*positive*/ 0;
return;
}
if (Context.getTargetInfo().getTriple().isNVPTX() && ArgVal != 32) {
Diag(E->getExprLoc(), diag::warn_reqd_sub_group_attribute_cuda_n_32)
<< ArgVal.getSExtValue();
}

// Check to see if there's a duplicate attribute with different values
// already applied to the declaration.
Expand Down
20 changes: 20 additions & 0 deletions clang/test/SemaSYCL/reqd-sub-group-size-cuda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %clang_cc1 -fsycl-is-device -triple nvptx -internal-isystem %S/Inputs -std=c++2b -verify %s
//
// This tests that a warning is returned when a sub group size other than 32 is
// requested in the CUDA backend via the reqd_sub_group_size() kernel attribute.
#include "sycl.hpp"

int main() {

sycl::queue Q;

Q.submit([&](sycl::handler &h) {
h.single_task<class invalid_kernel>([=] [[sycl::reqd_sub_group_size(8)]] {}); // expected-warning {{attribute argument 8 is invalid and will be ignored; CUDA requires sub_group size 32}}
});

Q.submit([&](sycl::handler &h) {
h.single_task<class valid_kernel>([=] [[sycl::reqd_sub_group_size(32)]] {});
});

return 0;
}