Skip to content

Commit dae2768

Browse files
committed
fix comments
1 parent 7361874 commit dae2768

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7536,18 +7536,32 @@ def CUDAClusterDimsAttrDoc : Documentation {
75367536
let Category = DocCatDecl;
75377537
let Content = [{
75387538
In CUDA/HIP programming, the ``__cluster_dims__`` attribute can be applied to a kernel function
7539-
to set the dimensions of a thread block cluster. This allows to group multiple thread blocks into
7540-
a larger unit called a "cluster". `__cluster_dims__` defines the cluster size as ``(X, Y, Z)``,
7541-
where each value is the number of thread blocks in that dimension.
7539+
to set the dimensions of a thread block cluster. ``__cluster_dims__`` defines the cluster size
7540+
as ``(X, Y, Z)``, where each value is the number of thread blocks in that dimension.
7541+
The ``__cluster_dims__`` and `__no_cluster__`` attributes are mutually exclusive.
7542+
7543+
.. code::
7544+
7545+
__global__ __cluster_dims__(2, 1, 1) void kernel(...) {
7546+
...
7547+
}
7548+
75427549
}];
75437550
}
75447551

75457552
def CUDANoClusterAttrDoc : Documentation {
75467553
let Category = DocCatDecl;
75477554
let Content = [{
7548-
In CUDA/HIP programming, the ``__no_cluster__`` attribute can be applied to a kernel function to
7549-
indicate that the thread block cluster feature will not be enabled at both compile time and kernel
7550-
launch time. Note: this is a LLVM/Clang only attribute.
7555+
In CUDA/HIP programming, the LLVM/Clang-exclusive ``__no_cluster__`` attribute can be applied to
7556+
a kernel function to indicate that the thread block cluster feature will not be enabled at both
7557+
compile time and kernel launch time. The ``__cluster_dims__`` and `__no_cluster__`` attributes
7558+
are mutually exclusive.
7559+
7560+
.. code::
7561+
7562+
__global__ __no_cluster__ void kernel(...) {
7563+
...
7564+
}
75517565
}];
75527566
}
75537567

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13028,7 +13028,7 @@ def warn_cuda_maxclusterrank_sm_90 : Warning<
1302813028
"%1 attribute">, InGroup<IgnoredAttributes>;
1302913029

1303013030
def err_cuda_cluster_attr_not_supported : Error<
13031-
"%select{__cluster_dims__|__no_cluster__}0 is not supported for this GPU architecture"
13031+
"%0 is not supported for this GPU architecture"
1303213032
>;
1303313033

1303413034
def err_cuda_cluster_dims_too_large : Error<

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5686,11 +5686,11 @@ makeClusterDimsArgExpr(Sema &S, Expr *E, const CUDAClusterDimsAttr &AL,
56865686

56875687
// Accept template arguments for now as they depend on something else.
56885688
// We'll get to check them when they eventually get instantiated.
5689-
if (E->isValueDependent())
5689+
if (E->isInstantiationDependent())
56905690
return {E, 1};
56915691

5692-
std::optional<llvm::APSInt> I = llvm::APSInt(64);
5693-
if (!(I = E->getIntegerConstantExpr(S.Context))) {
5692+
std::optional<llvm::APSInt> I = E->getIntegerConstantExpr(S.Context);
5693+
if (!I) {
56945694
S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
56955695
<< &AL << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
56965696
return {nullptr, 0};
@@ -5758,7 +5758,7 @@ CUDAClusterDimsAttr *Sema::createClusterDimsAttr(const AttributeCommonInfo &CI,
57585758
return nullptr;
57595759
}
57605760

5761-
return ::new (Context) CUDAClusterDimsAttr(Context, CI, X, Y, Z);
5761+
return CUDAClusterDimsAttr::Create(Context, X, Y, Z, CI);
57625762
}
57635763

57645764
void Sema::addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
@@ -5768,16 +5768,16 @@ void Sema::addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
57685768
}
57695769

57705770
void Sema::addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI) {
5771-
if (CUDANoClusterAttr *Attr = ::new (Context) CUDANoClusterAttr(Context, CI))
5772-
D->addAttr(Attr);
5771+
D->addAttr(CUDANoClusterAttr::Create(Context, CI));
57735772
}
57745773

57755774
static void handleClusterDimsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57765775
auto &TTI = S.Context.getTargetInfo();
57775776
auto Arch = StringToOffloadArch(TTI.getTargetOpts().CPU);
57785777
if ((TTI.getTriple().isNVPTX() && Arch < clang::OffloadArch::SM_90) ||
57795778
(TTI.getTriple().isAMDGPU() && Arch < clang::OffloadArch::GFX1250)) {
5780-
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported) << 0;
5779+
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported)
5780+
<< "__cluster_dims__";
57815781
return;
57825782
}
57835783

@@ -5795,7 +5795,8 @@ static void handleNoClusterAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57955795
auto Arch = StringToOffloadArch(TTI.getTargetOpts().CPU);
57965796
if ((TTI.getTriple().isNVPTX() && Arch < clang::OffloadArch::SM_90) ||
57975797
(TTI.getTriple().isAMDGPU() && Arch < clang::OffloadArch::GFX1250)) {
5798-
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported) << 1;
5798+
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported)
5799+
<< "__no_cluster__";
57995800
return;
58005801
}
58015802

0 commit comments

Comments
 (0)