@@ -3523,6 +3523,23 @@ static bool InvalidWorkGroupSizeAttrs(const Expr *MGValue, const Expr *XDim,
3523
3523
ZDimExpr->getResultAsAPSInt () != 1 ));
3524
3524
}
3525
3525
3526
+ // If the [[intel::max_work_group_size(X, Y, Z)]] attribute is specified on
3527
+ // a declaration along with [[sycl::reqd_work_group_size(X1, Y1, Z1)]]
3528
+ // attribute, check to see if values of reqd_work_group_size arguments are
3529
+ // equal or less than values of max_work_group_size attribute arguments.
3530
+ static bool checkWorkGroupSizeAttrValues (const Expr *LHS, const Expr *RHS) {
3531
+ // If any of the operand is still value dependent, we can't test anything.
3532
+ const auto *LHSCE = dyn_cast<ConstantExpr>(LHS);
3533
+ const auto *RHSCE = dyn_cast<ConstantExpr>(RHS);
3534
+
3535
+ if (!LHSCE || !RHSCE)
3536
+ return false ;
3537
+
3538
+ // Otherwise, check if value of reqd_work_group_size argument is
3539
+ // equal or less than value of max_work_group_size attribute argument.
3540
+ return !(LHSCE->getResultAsAPSInt () <= RHSCE->getResultAsAPSInt ());
3541
+ }
3542
+
3526
3543
void Sema::AddSYCLIntelMaxWorkGroupSizeAttr (Decl *D,
3527
3544
const AttributeCommonInfo &CI,
3528
3545
Expr *XDim, Expr *YDim,
@@ -3556,6 +3573,20 @@ void Sema::AddSYCLIntelMaxWorkGroupSizeAttr(Decl *D,
3556
3573
if (!XDim || !YDim || !ZDim)
3557
3574
return ;
3558
3575
3576
+ // If the [[intel::max_work_group_size(X, Y, Z)]] attribute is specified on
3577
+ // a declaration along with [[sycl::reqd_work_group_size(X1, Y1, Z1)]]
3578
+ // attribute, check to see if values of reqd_work_group_size arguments are
3579
+ // equal or less than values of max_work_group_size attribute arguments.
3580
+ if (const auto *DeclAttr = D->getAttr <ReqdWorkGroupSizeAttr>()) {
3581
+ if (checkWorkGroupSizeAttrValues (DeclAttr->getXDim (), XDim),
3582
+ checkWorkGroupSizeAttrValues (DeclAttr->getYDim (), YDim),
3583
+ checkWorkGroupSizeAttrValues (DeclAttr->getZDim (), ZDim)) {
3584
+ Diag (CI.getLoc (), diag::err_conflicting_sycl_function_attributes)
3585
+ << CI << DeclAttr->getSpelling ();
3586
+ return ;
3587
+ }
3588
+ }
3589
+
3559
3590
// If the declaration has a SYCLIntelMaxWorkGroupSizeAttr, check to see if
3560
3591
// the attribute holds equal values to (1, 1, 1) in case the value of
3561
3592
// SYCLIntelMaxGlobalWorkDimAttr equals to 0.
@@ -3616,6 +3647,20 @@ SYCLIntelMaxWorkGroupSizeAttr *Sema::MergeSYCLIntelMaxWorkGroupSizeAttr(
3616
3647
return nullptr ;
3617
3648
}
3618
3649
3650
+ // If the [[intel::max_work_group_size(X, Y, Z)]] attribute is specified on
3651
+ // a declaration along with [[sycl::reqd_work_group_size(X1, Y1, Z1)]]
3652
+ // attribute, check to see if values of reqd_work_group_size arguments are
3653
+ // equal or less than values of max_work_group_size attribute arguments.
3654
+ if (const auto *DeclAttr = D->getAttr <ReqdWorkGroupSizeAttr>()) {
3655
+ if (checkWorkGroupSizeAttrValues (DeclAttr->getXDim (), A.getXDim ()),
3656
+ checkWorkGroupSizeAttrValues (DeclAttr->getYDim (), A.getYDim ()),
3657
+ checkWorkGroupSizeAttrValues (DeclAttr->getZDim (), A.getZDim ())) {
3658
+ Diag (DeclAttr->getLoc (), diag::err_conflicting_sycl_function_attributes)
3659
+ << DeclAttr << A.getSpelling ();
3660
+ return nullptr ;
3661
+ }
3662
+ }
3663
+
3619
3664
// If the declaration has a SYCLIntelMaxWorkGroupSizeAttr,
3620
3665
// check to see if the attribute holds equal values to
3621
3666
// (1, 1, 1) in case the value of SYCLIntelMaxGlobalWorkDimAttr
0 commit comments