-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SnitchDMA] Introduce
SnitchDMA
dialect (#128)
The DMA dialect represents DMA operations in their purest forms: Moving data from one MemRef to another. The real world is unfortunately not as pretty: Snitch's DMA only supports two-dimensional transfers, the zero region is of a specific size and DMA configuration is relatively expensive. This PR introduces the `SnitchDMA` dialect which is meant to handle any Snitch specific legalizations but also optimizations. The intention for the future is to have lowering of DMA operations split into multiple passes and phases performing 1) legalization of DMA transfers, 2) Optimization of configuration, 3) optimization of number of waits and 4) lowering to LLVM. As a first step, this PR only introduces the dialect and the equivalent of the `dmstati` instruction which is used in the current one-shot to LLVM lowering.
- Loading branch information
Showing
21 changed files
with
282 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
iree_add_all_subdirs() |
73 changes: 73 additions & 0 deletions
73
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
iree_add_all_subdirs() | ||
|
||
iree_cc_library( | ||
NAME | ||
SnitchDMADialect | ||
HDRS | ||
"SnitchDMADialect.h" | ||
"SnitchDMAOps.h" | ||
TEXTUAL_HDRS | ||
"SnitchDMAAttrs.cpp.inc" | ||
"SnitchDMAAttrs.h.inc" | ||
"SnitchDMADialect.cpp.inc" | ||
"SnitchDMADialect.h.inc" | ||
"SnitchDMAOps.cpp.inc" | ||
"SnitchDMAOps.h.inc" | ||
"SnitchDMATypes.cpp.inc" | ||
"SnitchDMATypes.h.inc" | ||
SRCS | ||
"SnitchDMAAttrs.cpp" | ||
"SnitchDMADialect.cpp" | ||
"SnitchDMAOps.cpp" | ||
"SnitchDMATypes.cpp" | ||
DEPS | ||
::SnitchDMAAttrsGen | ||
::SnitchDMADialectGen | ||
::SnitchDMAOpsGen | ||
::SnitchDMATypesGen | ||
LLVMSupport | ||
MLIRIR | ||
MLIRInferTypeOpInterface | ||
MLIRSupport | ||
PUBLIC | ||
) | ||
|
||
iree_tablegen_library( | ||
NAME | ||
SnitchDMAOpsGen | ||
TD_FILE | ||
"SnitchDMAOps.td" | ||
OUTS | ||
--gen-op-decls SnitchDMAOps.h.inc | ||
--gen-op-defs SnitchDMAOps.cpp.inc | ||
) | ||
|
||
iree_tablegen_library( | ||
NAME | ||
SnitchDMADialectGen | ||
TD_FILE | ||
"SnitchDMADialect.td" | ||
OUTS | ||
--gen-dialect-decls SnitchDMADialect.h.inc | ||
--gen-dialect-defs SnitchDMADialect.cpp.inc | ||
) | ||
|
||
iree_tablegen_library( | ||
NAME | ||
SnitchDMAAttrsGen | ||
TD_FILE | ||
"SnitchDMAAttrs.td" | ||
OUTS | ||
--gen-attrdef-decls SnitchDMAAttrs.h.inc | ||
--gen-attrdef-defs SnitchDMAAttrs.cpp.inc | ||
) | ||
|
||
iree_tablegen_library( | ||
NAME | ||
SnitchDMATypesGen | ||
TD_FILE | ||
"SnitchDMATypes.td" | ||
OUTS | ||
--gen-typedef-decls SnitchDMATypes.h.inc | ||
--gen-typedef-defs SnitchDMATypes.cpp.inc | ||
) |
1 change: 1 addition & 0 deletions
1
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMAAttrs.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "SnitchDMAAttrs.h" |
7 changes: 7 additions & 0 deletions
7
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMAAttrs.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
#pragma once | ||
|
||
#include "mlir/IR/Attributes.h" | ||
|
||
#define GET_ATTRDEF_CLASSES | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMAAttrs.h.inc" |
11 changes: 11 additions & 0 deletions
11
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMAAttrs.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMAATTRS | ||
#define QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMAATTRS | ||
|
||
include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
|
||
class SnitchDMA_Attr<string name, list<Trait> traits = []> : | ||
AttrDef<SnitchDMA_Dialect, name, traits>; | ||
|
||
|
||
#endif |
36 changes: 36 additions & 0 deletions
36
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "SnitchDMADialect.h" | ||
|
||
#include "SnitchDMAAttrs.h" | ||
#include "SnitchDMAOps.h" | ||
#include "SnitchDMATypes.h" | ||
#include "llvm/ADT/TypeSwitch.h" | ||
#include "mlir/IR/DialectImplementation.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
|
||
#define GET_ATTRDEF_CLASSES | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMAAttrs.cpp.inc" | ||
|
||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.cpp.inc" | ||
|
||
using namespace mlir; | ||
using namespace quidditch::SnitchDMA; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// DMADialect | ||
//===----------------------------------------------------------------------===// | ||
|
||
void SnitchDMADialect::initialize() { | ||
addOperations< | ||
#define GET_OP_LIST | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMAOps.cpp.inc" | ||
>(); | ||
addAttributes< | ||
#define GET_ATTRDEF_LIST | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMAAttrs.cpp.inc" | ||
>(); | ||
addTypes< | ||
#define GET_TYPEDEF_LIST | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.cpp.inc" | ||
>(); | ||
} |
7 changes: 7 additions & 0 deletions
7
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
#pragma once | ||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/Operation.h" | ||
|
||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.h.inc" |
21 changes: 21 additions & 0 deletions
21
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMADIALECT | ||
#define QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMADIALECT | ||
|
||
include "mlir/IR/DialectBase.td" | ||
|
||
def SnitchDMA_Dialect : Dialect { | ||
let name = "snitch_dma"; | ||
let cppNamespace = "::quidditch::SnitchDMA"; | ||
|
||
let description = [{ | ||
Dialect dealing with all implementation details specific to Snitch's DMA | ||
engine. | ||
Used to progressively lower and optimize the `dma` dialect. | ||
}]; | ||
|
||
let useDefaultAttributePrinterParser = 0; | ||
let useDefaultTypePrinterParser = 0; | ||
let hasConstantMaterializer = 0; | ||
} | ||
|
||
#endif |
11 changes: 11 additions & 0 deletions
11
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMAOps.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "SnitchDMAOps.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMAOps.cpp.inc" | ||
|
||
using namespace mlir; | ||
using namespace quidditch::SnitchDMA; | ||
|
||
StringRef QueueResource::getName() { | ||
return "queue"; | ||
} |
20 changes: 20 additions & 0 deletions
20
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMAOps.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
#pragma once | ||
|
||
#include "mlir/Bytecode/BytecodeOpInterface.h" | ||
#include "mlir/IR/BuiltinAttributes.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
#include "mlir/Interfaces/InferTypeOpInterface.h" | ||
#include "mlir/Interfaces/SideEffectInterfaces.h" | ||
|
||
#include "SnitchDMATypes.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMAOps.h.inc" | ||
|
||
namespace quidditch::SnitchDMA { | ||
class QueueResource : public mlir::SideEffects::Resource::Base<QueueResource> { | ||
public: | ||
llvm::StringRef getName() override; | ||
}; | ||
} // namespace quidditch::SnitchDMA |
31 changes: 31 additions & 0 deletions
31
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMAOps.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMAOPS | ||
#define QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMAOPS | ||
|
||
include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.td" | ||
include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.td" | ||
include "mlir/IR/CommonTypeConstraints.td" | ||
include "mlir/IR/OpBase.td" | ||
include "mlir/Interfaces/InferTypeOpInterface.td" | ||
include "mlir/Interfaces/SideEffectInterfaces.td" | ||
|
||
class SnitchDMA_Op<string mnemonic, list<Trait> traits = []> : | ||
Op<SnitchDMA_Dialect, mnemonic, traits>; | ||
|
||
def SnitchDMA_QueueResource | ||
: Resource<"quidditch::SnitchDMA::QueueResource">; | ||
|
||
def SnitchDMA_StatOp : SnitchDMA_Op<"stat", | ||
[MemoryEffects<[MemRead<SnitchDMA_QueueResource>]>]> { | ||
|
||
let description = [{ | ||
Returns the id of the last DMA transfer that has been completed. | ||
}]; | ||
|
||
let results = (outs I32:$completed_id); | ||
|
||
let assemblyFormat = [{ | ||
attr-dict | ||
}]; | ||
} | ||
|
||
#endif |
11 changes: 11 additions & 0 deletions
11
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "SnitchDMATypes.h" | ||
|
||
#include "llvm/ADT/TypeSwitch.h" | ||
#include "mlir/IR/DialectImplementation.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
|
||
#include "SnitchDMADialect.h" | ||
|
||
#define GET_TYPEDEF_CLASSES | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.cpp.inc" |
7 changes: 7 additions & 0 deletions
7
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
#pragma once | ||
|
||
#include "mlir/IR/Types.h" | ||
|
||
#define GET_TYPEDEF_CLASSES | ||
#include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.h.inc" |
10 changes: 10 additions & 0 deletions
10
codegen/compiler/src/Quidditch/Dialect/SnitchDMA/IR/SnitchDMATypes.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMATYPES | ||
#define QUIDDITCH_DIALECT_SNITCHDMA_IR_SNITCHDMATYPES | ||
|
||
include "Quidditch/Dialect/SnitchDMA/IR/SnitchDMADialect.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
|
||
class SnitchDMA_Type<string name, list<Trait> traits = []> : | ||
TypeDef<SnitchDMA_Dialect, name, traits>; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters