@@ -351,6 +351,23 @@ def GPU_OptionalDimSizeHintAttr : ConfinedAttr<OptionalAttr<DenseI32ArrayAttr>,
351351 [AttrConstraint<Or<[IsNullAttr.predicate, DenseArrayCount<3>.predicate]>,
352352 "with 3 elements (if present)">]>;
353353
354+ // Source language of the gpu.func or gpu.launc_func operations.
355+ def GPU_KernelSourceLangOpenACC : I32EnumAttrCase<"OpenACC", 0, "openacc">;
356+ def GPU_KernelSourceLangOpenMP : I32EnumAttrCase<"OpenMP", 1, "openmp">;
357+ def GPU_KernelSourceLangCUDAFortran
358+ : I32EnumAttrCase<"CUDAFortran", 2, "cuda_fortran">;
359+
360+ def GPU_KernelSourceLang
361+ : I32EnumAttr<"KernelSourceLang", "Source language of a kernel",
362+ [GPU_KernelSourceLangOpenACC, GPU_KernelSourceLangOpenMP,
363+ GPU_KernelSourceLangCUDAFortran,
364+ ]> {
365+ let genSpecializedAttr = 0;
366+ let cppNamespace = "::mlir::gpu";
367+ }
368+ def GPU_KernelSourceLangAttr
369+ : EnumAttr<GPU_Dialect, GPU_KernelSourceLang, "kernel_source_lang">;
370+
354371def GPU_GPUFuncOp : GPU_Op<"func", [
355372 HasParent<"GPUModuleOp">, AutomaticAllocationScope, FunctionOpInterface,
356373 IsolatedFromAbove, AffineScope
@@ -426,12 +443,13 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
426443 }];
427444
428445 let arguments = (ins TypeAttrOf<FunctionType>:$function_type,
429- OptionalAttr<DictArrayAttr>:$arg_attrs,
430- OptionalAttr<DictArrayAttr>:$res_attrs,
431- OptionalAttr<DictArrayAttr>:$workgroup_attrib_attrs,
432- OptionalAttr<DictArrayAttr>:$private_attrib_attrs,
433- GPU_OptionalDimSizeHintAttr:$known_block_size,
434- GPU_OptionalDimSizeHintAttr:$known_grid_size);
446+ OptionalAttr<DictArrayAttr>:$arg_attrs,
447+ OptionalAttr<DictArrayAttr>:$res_attrs,
448+ OptionalAttr<DictArrayAttr>:$workgroup_attrib_attrs,
449+ OptionalAttr<DictArrayAttr>:$private_attrib_attrs,
450+ GPU_OptionalDimSizeHintAttr:$known_block_size,
451+ GPU_OptionalDimSizeHintAttr:$known_grid_size,
452+ OptionalAttr<GPU_KernelSourceLangAttr>:$kernel_source_lang);
435453 let regions = (region AnyRegion:$body);
436454
437455 let skipDefaultBuilders = 1;
@@ -793,20 +811,21 @@ def GPU_LaunchFuncOp :GPU_Op<"launch_func", [
793811 let hasVerifier = 1;
794812}
795813
796- def GPU_LaunchOp : GPU_Op<"launch", [
797- AffineScope, AutomaticAllocationScope, AttrSizedOperandSegments,
798- DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>,
799- GPU_AsyncOpInterface, RecursiveMemoryEffects]>,
800- Arguments<(ins Variadic<GPU_AsyncToken>:$asyncDependencies,
801- Index:$gridSizeX, Index:$gridSizeY, Index:$gridSizeZ,
802- Index:$blockSizeX, Index:$blockSizeY, Index:$blockSizeZ,
803- Optional<Index>:$clusterSizeX,
804- Optional<Index>:$clusterSizeY,
805- Optional<Index>:$clusterSizeZ,
806- Optional<I32>:$dynamicSharedMemorySize,
807- OptionalAttr<SymbolRefAttr>:$kernelFunc,
808- OptionalAttr<SymbolRefAttr>:$kernelModule)>,
809- Results<(outs Optional<GPU_AsyncToken>:$asyncToken)> {
814+ def GPU_LaunchOp
815+ : GPU_Op<"launch", [AffineScope, AutomaticAllocationScope,
816+ AttrSizedOperandSegments,
817+ DeclareOpInterfaceMethods<
818+ InferIntRangeInterface, ["inferResultRanges"]>,
819+ GPU_AsyncOpInterface, RecursiveMemoryEffects]>,
820+ Arguments<(ins Variadic<GPU_AsyncToken>:$asyncDependencies,
821+ Index:$gridSizeX, Index:$gridSizeY, Index:$gridSizeZ,
822+ Index:$blockSizeX, Index:$blockSizeY, Index:$blockSizeZ,
823+ Optional<Index>:$clusterSizeX, Optional<Index>:$clusterSizeY,
824+ Optional<Index>:$clusterSizeZ, Optional<I32>:$dynamicSharedMemorySize,
825+ OptionalAttr<SymbolRefAttr>:$kernelFunc,
826+ OptionalAttr<SymbolRefAttr>:$kernelModule,
827+ OptionalAttr<GPU_KernelSourceLangAttr>:$kernelSourceLang)>,
828+ Results<(outs Optional<GPU_AsyncToken>:$asyncToken)> {
810829 let summary = "GPU kernel launch operation";
811830
812831 let description = [{
@@ -840,7 +859,10 @@ def GPU_LaunchOp : GPU_Op<"launch", [
840859 - a variadic number of Private memory attributions.
841860
842861 The `kernelFunc` and `kernelModule` attributes are optional and specifies
843- the kernel name and a module in which the kernel should be outlined.
862+ the kernel name and a module in which the kernel should be outlined.
863+
864+ The optional `kernelSourceLang` attribute can be set to specify the Source
865+ language of the kernel.
844866
845867 Syntax:
846868
0 commit comments