Skip to content

Commit dc704bf

Browse files
committed
[SYCL] reqd_work_group_size attribute is reversed (fix intel#14)
Signed-off-by: Aleksander Fadeev <aleksander.fadeev@intel.com>
1 parent 8696f6e commit dc704bf

File tree

2 files changed

+10
-44
lines changed

2 files changed

+10
-44
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,14 +2420,6 @@ def ReqdWorkGroupSize : InheritableAttr {
24202420
let Documentation = [Undocumented];
24212421
}
24222422

2423-
def SYCLIntelReqdWorkGroupSize : InheritableAttr {
2424-
let Spellings = [CXX11<"intel","reqd_work_group_size">];
2425-
let Args = [IntArgument<"XDim">, DefaultIntArgument<"YDim", 1>,
2426-
DefaultIntArgument<"ZDim", 1>];
2427-
let Subjects = SubjectList<[Function], ErrorDiag>;
2428-
let Documentation = [Undocumented];
2429-
}
2430-
24312423
def WorkGroupSizeHint : InheritableAttr {
24322424
// Does not have a [[]] spelling because it is an OpenCL-related attribute.
24332425
let Spellings = [GNU<"work_group_size_hint">];

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,32 +2898,15 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
28982898
/*ReverseAttrs=*/true);
28992899

29002900
if (const auto *A = D->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
2901-
if (S.getLangOpts().SYCLIsDevice &&
2902-
!(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
2903-
WGSize[0] <= A->getZDim())) {
2904-
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
2905-
<< Attr << A->getSpelling();
2906-
Result &= false;
2907-
}
2908-
if (!S.getLangOpts().SYCLIsDevice &&
2909-
!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
2901+
if (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
29102902
WGSize[2] <= A->getZDim())) {
29112903
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
29122904
<< Attr << A->getSpelling();
29132905
Result &= false;
29142906
}
29152907
}
29162908
if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
2917-
2918-
if (S.getLangOpts().SYCLIsDevice &&
2919-
!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
2920-
WGSize[0] >= A->getZDim())) {
2921-
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
2922-
<< Attr << A->getSpelling();
2923-
Result &= false;
2924-
}
2925-
if (!S.getLangOpts().SYCLIsDevice &&
2926-
!(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
2909+
if (!(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
29272910
WGSize[2] >= A->getZDim())) {
29282911
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
29292912
<< Attr << A->getSpelling();
@@ -2940,13 +2923,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29402923
return;
29412924

29422925
uint32_t WGSize[3];
2943-
if (const auto *A = D->getAttr<SYCLIntelReqdWorkGroupSizeAttr>()){
2944-
WGSize[1] = SYCLIntelReqdWorkGroupSizeAttr::DefaultYDim;
2945-
WGSize[2] = SYCLIntelReqdWorkGroupSizeAttr::DefaultZDim;
2946-
}
29472926
for (unsigned i = 0; i < 3; ++i) {
29482927
const Expr *E = AL.getArgAsExpr(i);
2949-
if (i < AL.getNumArgs() && !checkUInt32Argument(S, AL, E, WGSize[i], i,
2928+
if (!checkUInt32Argument(S, AL, E, WGSize[i], i,
29502929
/*StrictlyUnsigned=*/true))
29512930
return;
29522931
if (WGSize[i] == 0) {
@@ -2956,25 +2935,20 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29562935
}
29572936
}
29582937

2938+
// For a SYCLDevice WorkGroupAttr arguments are reversed
2939+
if (S.getLangOpts().SYCLIsDevice) {
2940+
std::swap(WGSize[0], WGSize[2]);
2941+
}
29592942
WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
2960-
if (S.getLangOpts().SYCLIsDevice && Existing &&
2961-
!(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] &&
2962-
Existing->getZDim() == WGSize[0]))
2963-
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
2964-
if (!S.getLangOpts().SYCLIsDevice && Existing &&
2943+
if (Existing &&
29652944
!(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] &&
29662945
Existing->getZDim() == WGSize[2]))
29672946
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
2968-
29692947
if (!checkWorkGroupSizeValues(S, D, AL, WGSize))
29702948
return;
29712949

2972-
if (S.getLangOpts().SYCLIsDevice)
2973-
D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[2],
2974-
WGSize[1], WGSize[0]));
2975-
else
2976-
D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[0],
2977-
WGSize[1], WGSize[2]));
2950+
D->addAttr(::new (S.Context)
2951+
WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2]));
29782952
}
29792953

29802954
// Handles intel_reqd_sub_group_size.

0 commit comments

Comments
 (0)