[Mlir-commits] [mlir] Reimplementing target description concept using DLTI attribute (PR #92138)

Niranjan Hasabnis llvmlistbot at llvm.org
Fri May 31 01:19:39 PDT 2024


================
@@ -194,6 +194,162 @@ def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface"> {
   }];
 }
 
+def TargetDeviceDescSpecInterface : AttrInterface<"TargetDeviceDescSpecInterface"> {
+  let cppNamespace = "::mlir";
+
+  let description = [{
+    Attribute interface describing a target device description specification.
+
+    A target device description specification is a list of device properties (key)
+    and their values for a specific device. The device is identified using "device_id"
+    (as a key and ui32 value) and "device_type" key which must have a string value.
+    Both "device_id" and "device_type" are mandatory keys. As an example, L1 cache
+    size could be a device property, and its value would be a device specific size.
+
+    A target device description specification is attached to a module as a module level
+    attribute.
+  }];
+
+  let methods = [
+    InterfaceMethod<
+      /*description=*/"Returns the list of layout entries.",
+      /*retTy=*/"::mlir::DataLayoutEntryListRef",
+      /*methodName=*/"getEntries",
+      /*args=*/(ins)
+    >,
----------------
nhasabni wrote:

> Basically, a simpler model would look like:
> 
> ```
> #gpu = #my.gpu_desc<{ some_key = some_value, some_other_key = some_value }>
> #system = #dlti.target_system_spec<
>   devices = {
>     "gpu0" = #gpu,
>     "gpu1" = #gpu
>   },
>   system_key = some_value
> >
> ```
> 
> You can iterate the devices (and they each have a unique id in the system, guaranteed by the key-value pair dictionary), but the device description is orthogonal to the ID which is a property of the system (it just associate a device to a place in the system)

Got it. Would the API to query the value of a property then accept string for the device ID (instead of integer as it is currently)? 

https://github.com/llvm/llvm-project/pull/92138


More information about the Mlir-commits mailing list