================
@@ -110,6 +110,48 @@ def CIR_SourceLanguageAttr :
CIR_EnumAttr<CIR_SourceLanguage, "lang"> {
}];
}
+//===----------------------------------------------------------------------===//
+// OffloadKindAttr
+//===----------------------------------------------------------------------===//
+
+def CIR_OffloadKind : CIR_I32EnumAttr<"OffloadKind", "offload kind", [
+ I32EnumAttrCase<"Host", 0, "host">,
+ I32EnumAttrCase<"Device", 1, "device">
+]> {
+ let genSpecializedAttr = 0;
+}
+
+def CIR_OffloadKindAttr : CIR_EnumAttr<CIR_OffloadKind, "offload_kind"> {
+ let summary = "Offload kind of a module in an offload container";
+ let description = [{
+ Marks a module as either the host module or one of the device modules of
+ an offload container, keeping a host CIR module and its associated device
+ CIR modules in one IR unit while offload merge/split pipeline passes need
+ visibility into both sides.
+
+ A module carrying the `cir.offload.container` unit attribute is such a
+ container. Its body holds only nested modules: the first one is the host
+ module and must carry `cir.offload.kind = #cir.offload_kind<host>`, and
+ all remaining ones are device modules and must carry
+ `cir.offload.kind = #cir.offload_kind<device>`. There must be at least one
+ device module. Keeping the host module first gives later passes a simple
+ convention for finding the host side while iterating the remaining device
+ modules.
+
+ Example:
+ ```mlir
+ module attributes {cir.offload.container} {
+ module @host attributes {cir.offload.kind = #cir.offload_kind<host>} {}
+ module @device attributes {cir.offload.kind = #cir.offload_kind<device>}
{}
+ }
+ ```
----------------
steffenlarsen wrote:
It reads a little disjoint to me. I would prefer that the
`cir.offload.container` attribute is mentioned early to give context to what a
"container" is. Maybe something along the lines of:
```suggestion
Marks a module nested inside an offload container - identified by the
`cir.offload.container` unit attribute - as either the host module (carrying
`cir.offload.kind = #cir.offload_kind<host>`) or one of the device modules
(carrying `cir.offload.kind = #cir.offload_kind<device>`) of the offload
container. This creates a tiered module layout, where a singular offload
container contains a single host module and one or more device modules,
granting the offload merge/split pipeline passes the cross-boundary view.
Example:
```mlir
module attributes {cir.offload.container} {
module @host attributes {cir.offload.kind = #cir.offload_kind<host>} {}
module @device1 attributes {cir.offload.kind = #cir.offload_kind<device>}
{}
module @device2 attributes {cir.offload.kind = #cir.offload_kind<device>}
{}
}
```
Note: In order to simplfy offload passes, the offload container module
requires that the first module inside it is the host module and the rest
of the modules are device modules.
```
Note that I also added an extra device module to the example to illustrate that
it allows multiple device modules.
https://github.com/llvm/llvm-project/pull/206576
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits