Index: flang/include/flang/Tools/CrossToolHelpers.h =================================================================== --- flang/include/flang/Tools/CrossToolHelpers.h +++ flang/include/flang/Tools/CrossToolHelpers.h @@ -61,7 +61,7 @@ if (Opts.OpenMPIsDevice) { offloadMod.setFlags(Opts.OpenMPTargetDebug, Opts.OpenMPTeamSubscription, Opts.OpenMPThreadSubscription, Opts.OpenMPNoThreadState, - Opts.OpenMPNoNestedParallelism); + Opts.OpenMPNoNestedParallelism, 50 /* Default OpenMP version */); if (!Opts.OMPHostIRFile.empty()) offloadMod.setHostIRFilePath(Opts.OMPHostIRFile); Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td =================================================================== --- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -53,6 +53,14 @@ let assemblyFormat = "`<` struct(params) `>`"; } +def VersionAttr : OpenMP_Attr<"Version", "version"> { + let parameters = (ins + "uint32_t":$version + ); + + let assemblyFormat = "`<` struct(params) `>`"; +} + //===----------------------------------------------------------------------===// // Runtime library flag's attribute that holds information for lowering to LLVM //===----------------------------------------------------------------------===// @@ -63,7 +71,8 @@ DefaultValuedParameter<"bool", "false">:$assume_teams_oversubscription, DefaultValuedParameter<"bool", "false">:$assume_threads_oversubscription, DefaultValuedParameter<"bool", "false">:$assume_no_thread_state, - DefaultValuedParameter<"bool", "false">:$assume_no_nested_parallelism + DefaultValuedParameter<"bool", "false">:$assume_no_nested_parallelism, + DefaultValuedParameter<"uint32_t", "50">:$openmp_device_version ); let assemblyFormat = "`<` struct(params) `>`"; Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td =================================================================== --- mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td @@ -104,11 +104,12 @@ "bool":$assumeTeamsOversubscription, "bool":$assumeThreadsOversubscription, "bool":$assumeNoThreadState, - "bool":$assumeNoNestedParallelism), [{}], [{ + "bool":$assumeNoNestedParallelism, + "uint32_t":$openmpDeviceVersion), [{}], [{ $_op->setAttr(("omp." + mlir::omp::FlagsAttr::getMnemonic()).str(), mlir::omp::FlagsAttr::get($_op->getContext(), debugKind, assumeTeamsOversubscription, assumeThreadsOversubscription, - assumeNoThreadState, assumeNoNestedParallelism)); + assumeNoThreadState, assumeNoNestedParallelism, openmpDeviceVersion)); }]>, InterfaceMethod< /*description=*/[{ Index: mlir/test/Dialect/OpenMP/attr.mlir =================================================================== --- mlir/test/Dialect/OpenMP/attr.mlir +++ mlir/test/Dialect/OpenMP/attr.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s | mlir-opt | FileCheck %s // CHECK: module attributes {omp.flags = #omp.flags<>} { -module attributes {omp.flags = #omp.flags} {} +module attributes {omp.flags = #omp.flags} {} // CHECK: module attributes {omp.flags = #omp.flags} { module attributes {omp.flags = #omp.flags} {} @@ -29,3 +29,30 @@ // CHECK: module attributes {omp.flags = #omp.flags} { module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +//: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.flags = #omp.flags} { +module attributes {omp.flags = #omp.flags} {} + +// CHECK: module attributes {omp.version = #omp.version} { +module attributes {omp.version = #omp.version} {}