[MLIR][GPU] Add cooperative launch support to gpu.launch_func (#190639) Add a `cooperative` UnitAttr to `gpu.launch_func` that enables cooperative kernel launch semantics. Cooperative launches guarantee that all thread blocks in the grid are co-resident on the GPU simultaneously, enabling grid-wide synchronization patterns. ## Implementation When `cooperative` is set (with or without cluster sizes), the lowering emits a call to the new `mgpuLaunchKernelCooperative` runtime function, which uses `cuLaunchKernelEx` with a `CUlaunchConfig` and `CU_LAUNCH_ATTRIBUTE_COOPERATIVE`. This API is guarded behind `CUDA_VERSION >= 12000`. The HIP path funnels through `hipModuleLaunchCooperativeKernel`. ## Changes - **GPUOps.td**: add `cooperative` UnitAttr and assembly format keyword - **SelectObjectAttr.cpp**: add `getKernelLaunchExFn()`, route cooperative and/or cluster launches through `mgpuLaunchKernelEx` - **CudaRuntimeWrappers.cpp**: implement `mgpuLaunchKernelCooperative` via `cuLaunchKernelEx` or `hipModuleLaunchCooperativeKernel`, depending on platform - **GPUToLLVMConversion.cpp**: propagate cooperative attribute through the legalization pattern - **test/Dialect/GPU/ops.mlir**: round-trip tests for cooperative keyword with and without clusters ## Context MLIR currently has no support for cooperative kernel launches. Flang works around this with a CUF-specific attribute (PRs #124325, #124362), but there is no first-class support in the GPU dialect. This patch adds it at the `gpu.launch_func` level so all frontends can use it. Assisted-by: Claude (Anthropic)
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.