[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-28 Thread Sam McCall via cfe-commits
@@ -10,6 +10,7 @@ // //===--===// +#include "../Basic/Targets/NVPTX.h" sam-mccall wrote: @jchlanda ah, that's simpler than I expected! Wish I'd found that before reverting... That looks go

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-28 Thread Jakub Chlanda via cfe-commits
@@ -10,6 +10,7 @@ // //===--===// +#include "../Basic/Targets/NVPTX.h" jchlanda wrote: @sam-mccall, apologies for introducing the bug and thank you for drawing my attention to it. I've got

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-27 Thread Sam McCall via cfe-commits
@@ -10,6 +10,7 @@ // //===--===// +#include "../Basic/Targets/NVPTX.h" sam-mccall wrote: This header is not part of `clangBasic`'s interface, but rather its implementation (`lib/Basic` rath

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-26 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda closed https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-26 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 437c41f418be8a812229acc3573ebba688832ad5 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH] [NVPTX] Add support for maxclusterrank in launch_bounds Since S

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-25 Thread Artem Belevich via cfe-commits
https://github.com/Artem-B approved this pull request. https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-25 Thread Jakub Chlanda via cfe-commits
@@ -537,59 +537,46 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-25 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 9c8caed3c8def15ccdbfdf831f36d0befed1fc84 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH 1/7] [NVPTX] Add support for maxclusterrank in launch_bounds Sin

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-25 Thread Jakub Chlanda via cfe-commits
@@ -5607,6 +5607,21 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) { return false; } +// Helper to get CudaArch. +static CudaArch getCudaArch(const TargetInfo &TI) { jchlanda wrote: Done in: 3c17966b26a613f3b1a117f992d45b751cbff4

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-25 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 9c8caed3c8def15ccdbfdf831f36d0befed1fc84 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH 1/6] [NVPTX] Add support for maxclusterrank in launch_bounds Sin

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Artem Belevich via cfe-commits
@@ -537,59 +537,46 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Artem Belevich via cfe-commits
@@ -537,59 +537,46 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Artem Belevich via cfe-commits
@@ -5607,6 +5607,21 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) { return false; } +// Helper to get CudaArch. +static CudaArch getCudaArch(const TargetInfo &TI) { Artem-B wrote: You may need to verify that `TI->getTriple()->is

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Artem Belevich via cfe-commits
https://github.com/Artem-B resolved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Artem Belevich via cfe-commits
https://github.com/Artem-B resolved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
@@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -triple nvptx-unknown-unknown -target-cpu sm_90 -verify %s + +#include "Inputs/cuda.h" + +__launch_bounds__(128, 7) void Test2Args(void); +__launch_bounds__(128) void Test1Arg(void); + +__launch_bounds__(0x) v

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
@@ -12,7 +12,7 @@ __launch_bounds__(0x1) void TestWayTooBigArg(void); // expected- __launch_bounds__(-128, 7) void TestNegArg1(void); // expected-warning {{'launch_bounds' attribute parameter 0 is negative and will be ignored}} __launch_bounds__(128, -7) void T

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 9c8caed3c8def15ccdbfdf831f36d0befed1fc84 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH 1/5] [NVPTX] Add support for maxclusterrank in launch_bounds Sin

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
@@ -537,59 +537,46 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
@@ -11836,6 +11836,10 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +def warn_cuda_maxclusterrank_sm_90 : Warning< + "maxclusterrank requires sm_90 or higher, CUDA

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
@@ -5607,6 +5607,21 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) { return false; } +// Helper to get CudaArch. +static CudaArch getCudaArch(const TargetInfo &TI) { jchlanda wrote: Is that the kind of thing you had in mind: ```d

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 9c8caed3c8def15ccdbfdf831f36d0befed1fc84 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH 1/4] [NVPTX] Add support for maxclusterrank in launch_bounds Sin

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-22 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda resolved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Artem Belevich via cfe-commits
@@ -537,59 +537,46 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Artem Belevich via cfe-commits
@@ -12,7 +12,7 @@ __launch_bounds__(0x1) void TestWayTooBigArg(void); // expected- __launch_bounds__(-128, 7) void TestNegArg1(void); // expected-warning {{'launch_bounds' attribute parameter 0 is negative and will be ignored}} __launch_bounds__(128, -7) void T

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Artem Belevich via cfe-commits
@@ -5607,6 +5607,21 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) { return false; } +// Helper to get CudaArch. +static CudaArch getCudaArch(const TargetInfo &TI) { Artem-B wrote: Considering that we do have TargetInfo pointer h

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Artem Belevich via cfe-commits
@@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -triple nvptx-unknown-unknown -target-cpu sm_90 -verify %s + +#include "Inputs/cuda.h" + +__launch_bounds__(128, 7) void Test2Args(void); +__launch_bounds__(128) void Test1Arg(void); + +__launch_bounds__(0x) v

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Artem Belevich via cfe-commits
@@ -5650,34 +5665,51 @@ static Expr *makeLaunchBoundsArgExpr(Sema &S, Expr *E, CUDALaunchBoundsAttr * Sema::CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, - Expr *MinBlocks) { - CUDALaunchBoundsAttr TmpAttr(Context, CI, Max

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Artem Belevich via cfe-commits
@@ -11836,6 +11836,10 @@ def err_sycl_special_type_num_init_method : Error< "types with 'sycl_special_class' attribute must have one and only one '__init' " "method defined">; +def warn_cuda_maxclusterrank_sm_90 : Warning< + "maxclusterrank requires sm_90 or higher, CUDA

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda resolved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda resolved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 9c8caed3c8def15ccdbfdf831f36d0befed1fc84 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH 1/3] [NVPTX] Add support for maxclusterrank in launch_bounds Sin

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
@@ -537,59 +537,52 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda resolved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda updated https://github.com/llvm/llvm-project/pull/66496 >From 9c8caed3c8def15ccdbfdf831f36d0befed1fc84 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 15 Sep 2023 12:08:04 +0100 Subject: [PATCH 1/2] [NVPTX] Add support for maxclusterrank in launch_bounds Sin

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
@@ -5662,22 +5677,39 @@ Sema::CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, return nullptr; } + if (MaxBlocks) { +// Feature '.maxclusterrank' requires .target sm_90 or higher. +auto SM = getCudaArch(Context.getTargetInfo()); +if

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
@@ -307,6 +307,14 @@ void CodeGenModule::handleCUDALaunchBoundsAttr( NVPTXTargetCodeGenInfo::addNVVMMetadata(F, "minctasm", MinBlocks.getExtValue()); } + if (Attr->getMaxBlocks()) { +llvm::APSInt MaxBlocks(32); +Max

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
ldrumm wrote: including Artem as NVPTX is involved https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
https://github.com/ldrumm edited https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
@@ -537,59 +537,52 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
https://github.com/ldrumm edited https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
@@ -537,59 +537,52 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, raw_ostream &O) const { // If the NVVM IR has some of reqntid* specified, then output // the reqntid directive, and set the unspec

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
https://github.com/ldrumm approved this pull request. lovely tests. Looks good module nits https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
@@ -5662,22 +5677,39 @@ Sema::CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, return nullptr; } + if (MaxBlocks) { +// Feature '.maxclusterrank' requires .target sm_90 or higher. +auto SM = getCudaArch(Context.getTargetInfo()); +if

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
@@ -307,6 +307,14 @@ void CodeGenModule::handleCUDALaunchBoundsAttr( NVPTXTargetCodeGenInfo::addNVVMMetadata(F, "minctasm", MinBlocks.getExtValue()); } + if (Attr->getMaxBlocks()) { +llvm::APSInt MaxBlocks(32); +Max

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread via cfe-commits
https://github.com/ldrumm edited https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-21 Thread Jakub Chlanda via cfe-commits
jchlanda wrote: A friendly ping. https://github.com/llvm/llvm-project/pull/66496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-15 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Changes Since SM_90 CUDA supports specifying additional argument to the launch_bounds attribute: maxBlocksPerCluster, to express the maximum number of CTAs that can be part of the cluster. See: https://docs.nvidia.com/cuda/parallel-thr

[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-15 Thread Jakub Chlanda via cfe-commits
https://github.com/jchlanda created https://github.com/llvm/llvm-project/pull/66496 Since SM_90 CUDA supports specifying additional argument to the launch_bounds attribute: maxBlocksPerCluster, to express the maximum number of CTAs that can be part of the cluster. See: https://docs.nvidia.com