-
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.
[quidditch_snitch] Basic implementations of DMA operations (#54)
This PR implements DMA copy and wait operations. Snitch's DMA is asnychronous and has special hardware support for faster transfers between L1 and L3 than doing it manually. The currentl lowering to LLVM simple performs calls into the snitch runtime for convenience with the idea of these being later inlined via LTO once implemented. Noteworthy is that the support for various memref shapes, strides and dimension is currently very limited but enough for what IREE generates.
- Loading branch information
Showing
11 changed files
with
274 additions
and
1 deletion.
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
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
11 changes: 11 additions & 0 deletions
11
codegen/compiler/src/Quidditch/Dialect/Snitch/IR/QuidditchSnitchTypes.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 "QuidditchSnitchTypes.h" | ||
|
||
#include "llvm/ADT/TypeSwitch.h" | ||
#include "mlir/IR/DialectImplementation.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
|
||
#include "QuidditchSnitchDialect.h" | ||
|
||
#define GET_TYPEDEF_CLASSES | ||
#include "Quidditch/Dialect/Snitch/IR/QuidditchSnitchTypes.cpp.inc" |
7 changes: 7 additions & 0 deletions
7
codegen/compiler/src/Quidditch/Dialect/Snitch/IR/QuidditchSnitchTypes.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/Snitch/IR/QuidditchSnitchTypes.h.inc" |
18 changes: 18 additions & 0 deletions
18
codegen/compiler/src/Quidditch/Dialect/Snitch/IR/QuidditchSnitchTypes.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,18 @@ | ||
#ifndef QUIDDITCH_DIALECT_SNITCH_QUIDDITCHSNITCHTYPES | ||
#define QUIDDITCH_DIALECT_SNITCH_QUIDDITCHSNITCHTYPES | ||
|
||
include "Quidditch/Dialect/Snitch/IR/QuidditchSnitchDialect.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
|
||
class QuidditchSnitch_Type<string name, list<Trait> traits = []> : | ||
TypeDef<QuidditchSnitch_Dialect, name, traits>; | ||
|
||
def QuidditchSnitch_DMATokenType : QuidditchSnitch_Type<"DMAToken"> { | ||
let mnemonic = "dma_token"; | ||
|
||
let description = [{ | ||
Type representing a potentially active DMA transfer. | ||
}]; | ||
} | ||
|
||
#endif |
15 changes: 15 additions & 0 deletions
15
codegen/tests/Conversion/ConvertSnitchToLLVM/dma_transfer_1d.mlir
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,15 @@ | ||
// RUN: quidditch-opt %s --quidditch-convert-snitch-to-llvm | FileCheck %s | ||
|
||
// CHECK-LABEL: @test | ||
func.func @test(%arg0 : memref<?xf32>, %arg1 : memref<?xf32>) -> !quidditch_snitch.dma_token { | ||
// CHECK: %[[ARG0_PTR:.*]] = llvm.extractvalue %{{.*}}[1] | ||
// CHECK: %[[ARG1_PTR:.*]] = llvm.extractvalue %{{.*}}[1] | ||
// CHECK: %[[ARG0_SIZE:.*]] = llvm.extractvalue %{{.*}}[3, 0] | ||
// CHECK: %[[GEP:.*]] = llvm.getelementptr %{{.*}}[%[[ARG0_SIZE]]] | ||
// CHECK: %[[SIZE:.*]] = llvm.ptrtoint %[[GEP]] | ||
// CHECK: %[[R:.*]] = llvm.call @snrt_dma_start_1d(%[[ARG1_PTR]], %[[ARG0_PTR]], %[[SIZE]]) | ||
%0 = quidditch_snitch.start_dma_transfer from %arg0 : memref<?xf32> to %arg1 : memref<?xf32> | ||
// CHECK: %[[C:.*]] = builtin.unrealized_conversion_cast %[[R]] | ||
// CHECK: return %[[C]] | ||
return %0 : !quidditch_snitch.dma_token | ||
} |
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,9 @@ | ||
// RUN: quidditch-opt %s --quidditch-convert-snitch-to-llvm | FileCheck %s | ||
|
||
// CHECK-LABEL: @test | ||
func.func @test(%arg0 : !quidditch_snitch.dma_token) { | ||
// TODO: This should be a call to snrt_dma_wait but is currently bugged. | ||
// CHECK: call @snrt_dma_wait_all() | ||
quidditch_snitch.wait_for_dma_transfers %arg0 : !quidditch_snitch.dma_token | ||
return | ||
} |