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

[Arc] Initial SLP support #7061

Merged
merged 2 commits into from
May 27, 2024
Merged

[Arc] Initial SLP support #7061

merged 2 commits into from
May 27, 2024

Conversation

elhewaty
Copy link
Member

@elhewaty elhewaty commented May 17, 2024

co-authors: @fabianschuiki

@elhewaty elhewaty marked this pull request as draft May 17, 2024 22:32
@elhewaty
Copy link
Member Author

It's not finished yet, but I need to know whether I am on the right track or not.

@fabianschuiki @maerhart

Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

This already looks pretty nice! Some comments inline below.

lib/Dialect/Arc/Transforms/FindInitialVectors.cpp Outdated Show resolved Hide resolved

LogicalResult vectorize();
// Store Isomorphic ops together
std::unordered_map<std::string, SmallVector<Operation *>> candidates;
Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to turn this into a DenseMap, which is common in LLVM code bases.

lib/Dialect/Arc/Transforms/FindInitialVectors.cpp Outdated Show resolved Hide resolved
@fabianschuiki fabianschuiki added the Arc Involving the `arc` dialect label May 21, 2024
@elhewaty elhewaty force-pushed the arc-vectorize branch 4 times, most recently from a502143 to c1e0851 Compare May 27, 2024 15:19
@elhewaty elhewaty marked this pull request as ready for review May 27, 2024 15:24
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

Nice! This looks very cool 😎 🥳

Comment on lines 64 to 65
let dependentDialects = ["arc::ArcDialect", "comb::CombDialect",
"hw::HWDialect"];
Copy link
Contributor

Choose a reason for hiding this comment

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

The dependent dialects field lists the dialects of operations that your pass creates in some builder.create<...> call. If I haven't overlooked anything, your pass just creates arc.* ops, so you should be fine with just the Arc dialect here:

Suggested change
let dependentDialects = ["arc::ArcDialect", "comb::CombDialect",
"hw::HWDialect"];
let dependentDialects = ["arc::ArcDialect"];

Comment on lines 46 to 47
using llvm::SmallVector;
using mlir::Operation;
Copy link
Contributor

Choose a reason for hiding this comment

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

You may be able to delete these. I think we have re-exports for these in the circt namespace.

Suggested change
using llvm::SmallVector;
using mlir::Operation;

Comment on lines 104 to 115
using Key = std::tuple<unsigned, StringRef, SmallVector<Type>,
SmallVector<Type>, ArrayRef<NamedAttribute>>;

Key computeKey(Operation *op, unsigned rank) {
// The key = concat(op_rank, op_name, op_operands_types, op_result_types,
// op_attrs)
return std::make_tuple(
rank, op->getName().getStringRef(),
SmallVector<Type>(op->operand_type_begin(), op->operand_type_end()),
SmallVector<Type>(op->result_type_begin(), op->result_type_end()),
op->getAttrs());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can directly use the attribute dictionary instead of an array of named attributes. That makes the key cheaper to compare: the dictionary is just a pointer (interned in the MLIRContext), so it's just a pointer comparison:

Suggested change
using Key = std::tuple<unsigned, StringRef, SmallVector<Type>,
SmallVector<Type>, ArrayRef<NamedAttribute>>;
Key computeKey(Operation *op, unsigned rank) {
// The key = concat(op_rank, op_name, op_operands_types, op_result_types,
// op_attrs)
return std::make_tuple(
rank, op->getName().getStringRef(),
SmallVector<Type>(op->operand_type_begin(), op->operand_type_end()),
SmallVector<Type>(op->result_type_begin(), op->result_type_end()),
op->getAttrs());
}
using Key = std::tuple<unsigned, StringRef, SmallVector<Type>,
SmallVector<Type>, DictionaryAttr>;
Key computeKey(Operation *op, unsigned rank) {
// The key = concat(op_rank, op_name, op_operands_types, op_result_types,
// op_attrs)
return std::make_tuple(
rank, op->getName().getStringRef(),
SmallVector<Type>(op->operand_type_begin(), op->operand_type_end()),
SmallVector<Type>(op->result_type_begin(), op->result_type_end()),
op->getAttrDictionary());
}

@elhewaty
Copy link
Member Author

I am working on adding the statistics too.

@fabianschuiki fabianschuiki merged commit 030ad3d into llvm:main May 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arc Involving the `arc` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants