Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions experimental/include/experimental/Support/FtdSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ class BlockIndexing {
};

/// Checks if the source and destination are in a loop
/// (including any of their ancestor loops).
bool isSameLoopBlocks(Block *source, Block *dest, const mlir::CFGLoopInfo &li);

/// Checks whether the loop of `source` is the same as, or nested inside,
/// the loop of `dest`. Returns true if `source` lives in
/// `dest`'s loop or in any inner loop of it.
bool isSameOrInnerLoopBlocks(Block *source, Block *dest,
const mlir::CFGLoopInfo &li);

/// Gets all the paths from block `start` to block `end` using a DFS search.
/// If `blockToTraverse` is non null, then we want the paths having
/// `blockToTraverse` in the path; filters paths that do not contain blocks in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//===- HandshakeStraightToQueue.h - Implement S2Q algorithm --*- C++ -*----===//
//
// Dynamatic is under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file declares the pass which allows to implement straight to the queue,
// a different way of allocating basic blocks in the LSQ, based on an ASAP
// approach rather than relying on the network of cmerges.
//
//===----------------------------------------------------------------------===//

#ifndef DYNAMATIC_TRANSFORMS_HANDSHAKESTRAIGHTTOQUEUE_H
#define DYNAMATIC_TRANSFORMS_HANDSHAKESTRAIGHTTOQUEUE_H
#include "dynamatic/Support/DynamaticPass.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"

namespace dynamatic {
namespace experimental {
namespace ftd {

std::unique_ptr<dynamatic::DynamaticPass> createStraightToQueue();

#define GEN_PASS_DECL_HANDSHAKESTRAIGHTTOQUEUE
#define GEN_PASS_DEF_HANDSHAKESTRAIGHTTOQUEUE
#include "experimental/Transforms/Passes.h.inc"

} // namespace ftd
} // namespace experimental
} // namespace dynamatic
#endif // DYNAMATIC_TRANSFORMS_HANDSHAKESTRAIGHTTOQUEUE_H
1 change: 1 addition & 0 deletions experimental/include/experimental/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "dynamatic/Support/LLVM.h"
#include "experimental/Transforms/HandshakeCombineSteeringLogic.h"
#include "experimental/Transforms/HandshakePlaceBuffersCustom.h"
#include "experimental/Transforms/HandshakeStraightToQueue.h"
#include "experimental/Transforms/LSQSizing/HandshakeSizeLSQs.h"
#include "experimental/Transforms/ResourceSharing/Crush.h"
#include "experimental/Transforms/Rigidification/HandshakeRigidification.h"
Expand Down
10 changes: 10 additions & 0 deletions experimental/include/experimental/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def HandshakeCombineSteeringLogic : DynamaticPass< "handshake-combine-steering-l
}];
let constructor = "dynamatic::experimental::ftd::combineSteeringLogic()";
}
def HandshakeStraightToQueue : DynamaticPass< "handshake-straight-to-queue"> {
let summary = "Use the FPGA'23 technique to allocate the basic blocks in the LSQs";
let description = [{
"Straight to the queue" allows to allocate the basic blocks in the LSQ
according to an ASAP approach rather than by following the control flow
relationships coming from the network of cmerges.
}];
let constructor = "dynamatic::experimental::ftd::createStraightToQueue()";
let dependentDialects = ["mlir::cf::ControlFlowDialect", "mlir::func::FuncDialect"];
}

def HandshakeSpeculation : DynamaticPass<"handshake-speculation"> {
let summary = "Place Speculation operations";
Expand Down
13 changes: 13 additions & 0 deletions experimental/lib/Support/FtdSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ bool ftd::isSameLoopBlocks(Block *source, Block *dest,
return isSameLoop(li.getLoopFor(source), li.getLoopFor(dest));
}

//// Recursively check whether `inner` is the same loop as `outer`, or is
/// nested inside `outer` (i.e., any ancestor of `inner` matches `outer`).
static bool isSameOrInnerLoop(const CFGLoop *inner, const CFGLoop *outer) {
if (!inner || !outer)
return false;
return (inner == outer || isSameOrInnerLoop(inner->getParentLoop(), outer));
}

bool ftd::isSameOrInnerLoopBlocks(Block *source, Block *dest,
const mlir::CFGLoopInfo &li) {
return isSameOrInnerLoop(li.getLoopFor(source), li.getLoopFor(dest));
}

/// Recursive function which allows to obtain all the paths from block `start`
/// to block `end` using a DFS.
static void dfsAllPaths(Block *start, Block *end, std::vector<Block *> &path,
Expand Down
1 change: 1 addition & 0 deletions experimental/lib/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_dynamatic_library(DynamaticExperimentalTransforms
HandshakePlaceBuffersCustom.cpp
HandshakeCombineSteeringLogic.cpp
HandshakeStraightToQueue.cpp

DEPENDS
DynamaticExperimentalTransformsPassIncGen
Expand Down
Loading