Skip to content

Commit 89525ac

Browse files
committed
fix comments
1 parent 182dab2 commit 89525ac

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
@@ -7549,18 +7549,32 @@ def CUDAClusterDimsAttrDoc : Documentation {
75497549
let Category = DocCatDecl;
75507550
let Content = [{
75517551
In CUDA/HIP programming, the ``__cluster_dims__`` attribute can be applied to a kernel function
7552-
to set the dimensions of a thread block cluster. This allows to group multiple thread blocks into
7553-
a larger unit called a "cluster". `__cluster_dims__` defines the cluster size as ``(X, Y, Z)``,
7554-
where each value is the number of thread blocks in that dimension.
7552+
to set the dimensions of a thread block cluster. ``__cluster_dims__`` defines the cluster size
7553+
as ``(X, Y, Z)``, where each value is the number of thread blocks in that dimension.
7554+
The ``__cluster_dims__`` and `__no_cluster__`` attributes are mutually exclusive.
7555+
7556+
.. code::
7557+
7558+
__global__ __cluster_dims__(2, 1, 1) void kernel(...) {
7559+
...
7560+
}
7561+
75557562
}];
75567563
}
75577564

75587565
def CUDANoClusterAttrDoc : Documentation {
75597566
let Category = DocCatDecl;
75607567
let Content = [{
7561-
In CUDA/HIP programming, the ``__no_cluster__`` attribute can be applied to a kernel function to
7562-
indicate that the thread block cluster feature will not be enabled at both compile time and kernel
7563-
launch time. Note: this is a LLVM/Clang only attribute.
7568+
In CUDA/HIP programming, the LLVM/Clang-exclusive ``__no_cluster__`` attribute can be applied to
7569+
a kernel function to indicate that the thread block cluster feature will not be enabled at both
7570+
compile time and kernel launch time. The ``__cluster_dims__`` and `__no_cluster__`` attributes
7571+
are mutually exclusive.
7572+
7573+
.. code::
7574+
7575+
__global__ __no_cluster__ void kernel(...) {
7576+
...
7577+
}
75647578
}];
75657579
}
75667580

clang/include/clang/Basic/DiagnosticSemaKinds.td

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

1307313073
def err_cuda_cluster_attr_not_supported : Error<
13074-
"%select{__cluster_dims__|__no_cluster__}0 is not supported for this GPU architecture"
13074+
"%0 is not supported for this GPU architecture"
1307513075
>;
1307613076

1307713077
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
@@ -5682,11 +5682,11 @@ makeClusterDimsArgExpr(Sema &S, Expr *E, const CUDAClusterDimsAttr &AL,
56825682

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

5688-
std::optional<llvm::APSInt> I = llvm::APSInt(64);
5689-
if (!(I = E->getIntegerConstantExpr(S.Context))) {
5688+
std::optional<llvm::APSInt> I = E->getIntegerConstantExpr(S.Context);
5689+
if (!I) {
56905690
S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
56915691
<< &AL << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
56925692
return {nullptr, 0};
@@ -5754,7 +5754,7 @@ CUDAClusterDimsAttr *Sema::createClusterDimsAttr(const AttributeCommonInfo &CI,
57545754
return nullptr;
57555755
}
57565756

5757-
return ::new (Context) CUDAClusterDimsAttr(Context, CI, X, Y, Z);
5757+
return CUDAClusterDimsAttr::Create(Context, X, Y, Z, CI);
57585758
}
57595759

57605760
void Sema::addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
@@ -5764,16 +5764,16 @@ void Sema::addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
57645764
}
57655765

57665766
void Sema::addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI) {
5767-
if (CUDANoClusterAttr *Attr = ::new (Context) CUDANoClusterAttr(Context, CI))
5768-
D->addAttr(Attr);
5767+
D->addAttr(CUDANoClusterAttr::Create(Context, CI));
57695768
}
57705769

57715770
static void handleClusterDimsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57725771
auto &TTI = S.Context.getTargetInfo();
57735772
auto Arch = StringToOffloadArch(TTI.getTargetOpts().CPU);
57745773
if ((TTI.getTriple().isNVPTX() && Arch < clang::OffloadArch::SM_90) ||
57755774
(TTI.getTriple().isAMDGPU() && Arch < clang::OffloadArch::GFX1250)) {
5776-
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported) << 0;
5775+
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported)
5776+
<< "__cluster_dims__";
57775777
return;
57785778
}
57795779

@@ -5791,7 +5791,8 @@ static void handleNoClusterAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57915791
auto Arch = StringToOffloadArch(TTI.getTargetOpts().CPU);
57925792
if ((TTI.getTriple().isNVPTX() && Arch < clang::OffloadArch::SM_90) ||
57935793
(TTI.getTriple().isAMDGPU() && Arch < clang::OffloadArch::GFX1250)) {
5794-
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported) << 1;
5794+
S.Diag(AL.getLoc(), diag::err_cuda_cluster_attr_not_supported)
5795+
<< "__no_cluster__";
57955796
return;
57965797
}
57975798

0 commit comments

Comments
 (0)