[flang][cuda] Decouple CUFInit from CUDA language features (#209846)
In some cases, we do not want to emit the CUFInit function in the main. Add a specific language feature for it so we can decouple it.
This commit is contained in:
parent
1ffd509c4b
commit
c63bfe581c
5 changed files with 15 additions and 4 deletions
|
|
@ -61,7 +61,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
|
|||
MultipleProgramUnitsOnSameLine, AllocatedForAssociated,
|
||||
OpenMPThreadprivateEquivalence, RelaxedCLocChecks, CudaPinned,
|
||||
OpenAccDefaultNoneScalarsStrict, OpenACCMultipleNamesInRoutine,
|
||||
EnumerationType)
|
||||
EnumerationType, CUDAInit)
|
||||
|
||||
// Portability and suspicious usage warnings
|
||||
ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
|
||||
|
|
|
|||
|
|
@ -618,8 +618,10 @@ public:
|
|||
createBuilderOutsideOfFuncOpAndDo([&]() {
|
||||
fir::runtime::genMain(*builder, toLocation(),
|
||||
bridge.getEnvironmentDefaults(),
|
||||
getFoldingContext().languageFeatures().IsEnabled(
|
||||
Fortran::common::LanguageFeature::CUDA),
|
||||
(getFoldingContext().languageFeatures().IsEnabled(
|
||||
Fortran::common::LanguageFeature::CUDA) &&
|
||||
getFoldingContext().languageFeatures().IsEnabled(
|
||||
Fortran::common::LanguageFeature::CUDAInit)),
|
||||
getFoldingContext().languageFeatures().IsEnabled(
|
||||
Fortran::common::LanguageFeature::Coarray));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
|
|||
disable_.set(LanguageFeature::CudaManaged);
|
||||
disable_.set(LanguageFeature::CudaUnified);
|
||||
disable_.set(LanguageFeature::CudaPinned);
|
||||
disable_.set(LanguageFeature::CUDAInit);
|
||||
disable_.set(LanguageFeature::ImplicitNoneTypeNever);
|
||||
disable_.set(LanguageFeature::ImplicitNoneTypeAlways);
|
||||
disable_.set(LanguageFeature::ImplicitNoneExternal);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
! RUN: bbc -emit-fir -fcuda %s -o - | FileCheck %s --check-prefixes=ALL,CUDA
|
||||
! RUN: bbc -emit-fir -fcuda -fcuda-init %s -o - | FileCheck %s --check-prefixes=ALL,CUDA
|
||||
! RUN: bbc -emit-fir -fcuda %s -o - | FileCheck %s --check-prefixes=ALL,NOCUDA
|
||||
! RUN: bbc -emit-fir %s -o - | FileCheck %s --check-prefixes=ALL,NOCUDA
|
||||
|
||||
program test_init
|
||||
|
|
|
|||
|
|
@ -230,6 +230,10 @@ static llvm::cl::opt<bool> enableCUDA("fcuda",
|
|||
llvm::cl::desc("enable CUDA Fortran"),
|
||||
llvm::cl::init(false));
|
||||
|
||||
static llvm::cl::opt<bool> enableCUDAInit("fcuda-init",
|
||||
llvm::cl::desc("enable CUDA Init"),
|
||||
llvm::cl::init(false));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
enableDoConcurrentOffload("fdoconcurrent-offload",
|
||||
llvm::cl::desc("enable do concurrent offload"),
|
||||
|
|
@ -685,6 +689,9 @@ int main(int argc, char **argv) {
|
|||
if (enableCUDA) {
|
||||
options.features.Enable(Fortran::common::LanguageFeature::CUDA);
|
||||
}
|
||||
if (enableCUDAInit) {
|
||||
options.features.Enable(Fortran::common::LanguageFeature::CUDAInit);
|
||||
}
|
||||
|
||||
if (enableDoConcurrentOffload) {
|
||||
options.features.Enable(
|
||||
|
|
|
|||
Loading…
Reference in a new issue