Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Channels-to-ObjectFifos: join and distribute pattern support in L2 #439

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

abisca
Copy link
Collaborator

@abisca abisca commented Feb 20, 2024

No description provided.

Operation *endOfLink = nullptr; // one end of a LinkOp (i.e., a put or get)
int numLinkEnds = 0; // # ends in this link (i.e., # users of AIE.BufferOp)

AIE::BDDimLayoutArrayAttr dimensionsToStream = AIE::BDDimLayoutArrayAttr::get(channel->getContext(), {});;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
AIE::BDDimLayoutArrayAttr dimensionsToStream = AIE::BDDimLayoutArrayAttr::get(channel->getContext(), {});;
AIE::BDDimLayoutArrayAttr dimensionsToStream =
AIE::BDDimLayoutArrayAttr::get(channel->getContext(), {});
;

@@ -1198,33 +1206,50 @@ struct LowerAIRChannelsPattern : public OpRewritePattern<air::ChannelOp> {
if (res.failed())
return res;

setChannelBufferResources(rewriter, channel, channelPuts[0].getOperation());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
setChannelBufferResources(rewriter, channel, channelPuts[0].getOperation());
setChannelBufferResources(rewriter, channel,
channelPuts[0].getOperation());

Comment on lines 1225 to 1229
? ndcpy.getDstSizes()
: ndcpy.getSrcSizes();
SmallVector<Value> strides = isTileInbound(ndcpy, (int)air::MemorySpace::L1)
? ndcpy.getDstStrides()
: ndcpy.getSrcStrides();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
? ndcpy.getDstSizes()
: ndcpy.getSrcSizes();
SmallVector<Value> strides = isTileInbound(ndcpy, (int)air::MemorySpace::L1)
? ndcpy.getDstStrides()
: ndcpy.getSrcStrides();
? ndcpy.getDstSizes()
: ndcpy.getSrcSizes();
SmallVector<Value> strides =
isTileInbound(ndcpy, (int)air::MemorySpace::L1)
? ndcpy.getDstStrides()
: ndcpy.getSrcStrides();

auto wraps_and_strides =
AIE::BDDimLayoutArrayAttr::get(ndcpy->getContext(), ArrayRef(dims));
bool useDefaultDataAccessPattern =
isAIE2 ? isDefaultDataAccessPattern(sizes, strides, channelPuts[0].getMemref()) : true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
isAIE2 ? isDefaultDataAccessPattern(sizes, strides, channelPuts[0].getMemref()) : true;
isAIE2 ? isDefaultDataAccessPattern(sizes, strides,
channelPuts[0].getMemref())
: true;

Comment on lines 1281 to 1285
? ndcpy.getDstSizes()
: ndcpy.getSrcSizes();
SmallVector<Value> strides = isTileInbound(ndcpy, (int)air::MemorySpace::L1)
? ndcpy.getDstStrides()
: ndcpy.getSrcStrides();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
? ndcpy.getDstSizes()
: ndcpy.getSrcSizes();
SmallVector<Value> strides = isTileInbound(ndcpy, (int)air::MemorySpace::L1)
? ndcpy.getDstStrides()
: ndcpy.getSrcStrides();
? ndcpy.getDstSizes()
: ndcpy.getSrcSizes();
SmallVector<Value> strides =
isTileInbound(ndcpy, (int)air::MemorySpace::L1)
? ndcpy.getDstStrides()
: ndcpy.getSrcStrides();

Comment on lines 1403 to 1404
LogicalResult findChannelPutGetTile(MyOp op, Value *tile,
AIE::AIEObjectFifoType *datatype) const {
std::pair<int, MemRefType> *datatype) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
LogicalResult findChannelPutGetTile(MyOp op, Value *tile,
AIE::AIEObjectFifoType *datatype) const {
std::pair<int, MemRefType> *datatype) const {
LogicalResult
findChannelPutGetTile(MyOp op, Value *tile,
std::pair<int, MemRefType> *datatype) const {

Comment on lines 1435 to 1436
air::ChannelOp channel,
Operation* op) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
air::ChannelOp channel,
Operation* op) const {
air::ChannelOp channel, Operation *op) const {

Comment on lines 1448 to 1453
AIE::ObjectFifoCreateOp createObjectFifo(PatternRewriter &rewriter,
MemRefType datatype, Value prodTile,
const std::vector<Value> &consTile,
int depth, StringRef name) const {
AIE::ObjectFifoCreateOp fifo = builder.create<AIE::ObjectFifoCreateOp>(
builder.getUnknownLoc(), builder.getStringAttr(name), prodTile,
consTile, builder.getIntegerAttr(builder.getI32Type(), depth),
datatype);
return fifo;
int depth, StringRef name,
AIE::BDDimLayoutArrayAttr dimensionsToStream,
AIE::BDDimLayoutArrayArrayAttr dimensionsFromStreamPerConsumer) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
AIE::ObjectFifoCreateOp createObjectFifo(PatternRewriter &rewriter,
MemRefType datatype, Value prodTile,
const std::vector<Value> &consTile,
int depth, StringRef name) const {
AIE::ObjectFifoCreateOp fifo = builder.create<AIE::ObjectFifoCreateOp>(
builder.getUnknownLoc(), builder.getStringAttr(name), prodTile,
consTile, builder.getIntegerAttr(builder.getI32Type(), depth),
datatype);
return fifo;
int depth, StringRef name,
AIE::BDDimLayoutArrayAttr dimensionsToStream,
AIE::BDDimLayoutArrayArrayAttr dimensionsFromStreamPerConsumer) const {
AIE::ObjectFifoCreateOp createObjectFifo(
PatternRewriter &rewriter, MemRefType datatype, Value prodTile,
const std::vector<Value> &consTile, int depth, StringRef name,
AIE::BDDimLayoutArrayAttr dimensionsToStream,
AIE::BDDimLayoutArrayArrayAttr dimensionsFromStreamPerConsumer) const {

return rewriter.create<AIE::ObjectFifoCreateOp>(
rewriter.getUnknownLoc(), rewriter.getStringAttr(name), prodTile,
consTile, rewriter.getIntegerAttr(rewriter.getI32Type(), depth),
AIE::AIEObjectFifoType::get(datatype), dimensionsToStream, dimensionsFromStreamPerConsumer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
AIE::AIEObjectFifoType::get(datatype), dimensionsToStream, dimensionsFromStreamPerConsumer);
AIE::AIEObjectFifoType::get(datatype), dimensionsToStream,
dimensionsFromStreamPerConsumer);

{SymbolRefAttr::get(ctx, objFifo.name()), offset});
}

static bool sortLinkObjectFifos(std::pair<Attribute, int64_t> op0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
static bool sortLinkObjectFifos(std::pair<Attribute, int64_t> op0,
static bool sortLinkObjectFifos(std::pair<Attribute, int64_t> op0,

// remove mem_space from memref for objFifo datatype
if (datatype->first != (int)air::MemorySpace::L1) {
*datatype = {mem_space, memref};
//MemRefType::get(memref.getShape(), memref.getElementType())};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
//MemRefType::get(memref.getShape(), memref.getElementType())};
// MemRefType::get(memref.getShape(), memref.getElementType())};

Comment on lines +1587 to +1589
//std::sort(input_pairs.begin(), input_pairs.end(), sortLinkObjectFifos);
//std::sort(output_pairs.begin(), output_pairs.end(), sortLinkObjectFifos);
// retrieve only objectFifo symbol ref attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
//std::sort(input_pairs.begin(), input_pairs.end(), sortLinkObjectFifos);
//std::sort(output_pairs.begin(), output_pairs.end(), sortLinkObjectFifos);
// retrieve only objectFifo symbol ref attributes
// std::sort(input_pairs.begin(), input_pairs.end(), sortLinkObjectFifos);
// std::sort(output_pairs.begin(), output_pairs.end(), sortLinkObjectFifos);
// retrieve only objectFifo symbol ref attributes

Comment on lines +1609 to +1610
rewriter.getArrayAttr(ArrayRef(output_ofs)),
srcOffsets, dstOffsets);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
rewriter.getArrayAttr(ArrayRef(output_ofs)),
srcOffsets, dstOffsets);
rewriter.getArrayAttr(ArrayRef(output_ofs)), srcOffsets, dstOffsets);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant