1//===- DeviceMappingInterface.td - Device mapping interfaces*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// Defines the interfaces for the device mapping specification for the loops. 10// 11//===----------------------------------------------------------------------===// 12 13#ifndef MLIR_DEVICEMAPPINGINTERFACE 14#define MLIR_DEVICEMAPPINGINTERFACE 15 16include "mlir/IR/OpBase.td" 17 18//===----------------------------------------------------------------------===// 19// Attribute interfaces 20//===----------------------------------------------------------------------===// 21 22def DeviceMappingAttrInterface : AttrInterface<"DeviceMappingAttrInterface"> { 23 let cppNamespace = "::mlir"; 24 let description = [{ 25 Attribute interface describing how to map a region to a processing unit. 26 27 It is intended to be a generic mechanism for binding regions to execution 28 units of an actual or virtual device. Each device first expresses its own 29 mappings, and those mappings must implement this interface. These mappings 30 can be used by the device-specific code generators and the desired regions 31 can be connected to the given processing unit. 32 33 Currently, `scf.forall` uses this interface to express the mapping 34 of the loops it contains to the GPU's parallelism units such as threads and 35 thread blocks. 36 }]; 37 38 let methods = [ 39 InterfaceMethod< 40 /*desc=*/"Return mapping as an integer from the attribute.", 41 /*retTy=*/"int64_t", 42 /*methodName=*/"getMappingId", 43 /*args=*/(ins) 44 >, 45 InterfaceMethod< 46 /*desc=*/"Return true if the attribute specifies a linear mapping", 47 /*retTy=*/"bool", 48 /*methodName=*/"isLinearMapping", 49 /*args=*/(ins) 50 >, 51 InterfaceMethod< 52 /*desc=*/[{ 53 Return the [0..n) relative index of the attribute depending on its group. 54 This can be used to index into a contiguous array. 55 }], 56 /*retTy=*/"int64_t", 57 /*methodName=*/"getRelativeIndex", 58 /*args=*/(ins) 59 > 60 ]; 61} 62 63def DeviceMappingArrayAttr : 64 TypedArrayAttrBase<DeviceMappingAttrInterface, 65 "Device Mapping array attribute"> { } 66 67#endif // MLIR_DEVICEMAPPINGINTERFACE 68