-
Notifications
You must be signed in to change notification settings - Fork 23
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
Bit optim #1
Bit optim #1
Conversation
update new features implemented in StandardToHandshakeFPGA18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
I've done a sort-of superficial review and will take a closer look at everything soon. In the meantime you can start addressing the comments that are already there. Most of them are about code style or about using the MLIR API to make your life easier :)
Also, please run clang-format
(with default parameters) on all the files you have pushed. You just have to install the tool on your machine and then enable "format on save" in your IDE, so that your code is always properly formatted.
.gitignore
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .gitignore
file should not be changed.
.vscode/c_cpp_properties.json
Outdated
@@ -15,7 +15,7 @@ | |||
"${workspaceFolder}/circt/llvm/build/tools/mlir/include/" | |||
], | |||
"intelliSenseMode": "linux-clang-x64", | |||
"compilerPath": "/usr/bin/clang", | |||
"compilerPath": "/usr/local/bin/clang", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is just provided as an example project configuration for VSCode, so it should not be changed based on your local install.
@@ -0,0 +1,19 @@ | |||
//===- BackwardUpdate.h ---------*- C++ -*-===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick: follow the conventions from other file here and make the line 80 characters long
//===- <file_name> - <short description> ---*- C++ -*-===//
The same applies to all other files.
|
||
#include "dynamatic/Transforms/UtilsBitsUpdate.h" | ||
|
||
namespace backward { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every namespace should be declared under the namespace dynamatic
(so that they can be used as e.g., ::dynamatic::backward
).
|
||
#include "dynamatic/Transforms/UtilsBitsUpdate.h" | ||
|
||
namespace forward { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for the backward
namespace: this should be declared under the dynamatic
namespace.
Also, the number of public functions declared for the pass is small so I don't think we should have multiple namespaces for them (not even sure we should have a namespace below dynamatic
...). Please merge backward
and forward
into one or simply use dynamatic
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Lucas, different namespace is used because we define the same constructFuncMap function for forward, backward and validation(same functionality, different rules to revise the bit width). I think It might be easier for understanding, but since we pass different arguments for the same named function, I can also merge them into one.
Please let me know which one you think is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is more in line with MLIR conventions to not have very small named namespaces. I think you should just remove all custom namespaces, and use the dynamatic
namespace whenever you want to declare public functions. You can name your functions constructForwardFuncMap
, constructBackwardFuncMap
, etc., which makes it clear what each function is for.
lib/Transforms/InitIndexType.cpp
Outdated
@@ -0,0 +1,108 @@ | |||
//===- InitIndexType.cpp - Transform the Index Type to IntegerType with system bit width -------*- C++ -*-===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: make this fit on 80 characters
lib/Transforms/InitIndexType.cpp
Outdated
OpBuilder builder(ctx); | ||
SmallVector<Operation *> indexCastOps; | ||
|
||
for (Operation &op : funcOp.getOps()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use auto
for the type
lib/Transforms/UtilsBitsUpdate.cpp
Outdated
isa<handshake::ConditionalBranchOp>(*Op)) | ||
pass = true; | ||
|
||
if (isa<mlir::arith::AddIOp>(*Op) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for multiple types at once in a single isa
call, like isa<Type1, Type2, ...>(op)
instead of checking for each type individually.
lib/Transforms/UtilsBitsUpdate.cpp
Outdated
|
||
unsigned int opWidth; | ||
if (isa<IndexType>(opVal.getType())) | ||
opWidth = 64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use IndexType::kInternalStorageBitWidth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally had time to completely review this. There are a lot of comments but the vast majority are trivial fixes. Once everything is addressed we'll be able to merge :) There are one or two things in UtilsBitsUpdate.cpp
that I haven't looked at in details yet and I may still do a pass on them in the near future.
lib/Transforms/InitCstWidth.cpp
Outdated
op->erase(); | ||
} | ||
} | ||
// llvm::errs() << "Constant saved bits " << savedBits << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to use LLVM_DEBUG
here, for example
LLVM_DEBUG(llvm::dbgs() << "Number of saved bits is `" << savedBits << "\n");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple details to address still, but we're super close!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my last comments cover everything. I also reopened two resolved conversations, but they're just about a formatting issue. After you address those and fix the merge conflict with main
we can merge this :)
Merge bits optimization passes into main