-
Notifications
You must be signed in to change notification settings - Fork 314
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] Add Initial Cost Model #7360
Conversation
aafdae3
to
d36fc26
Compare
@maerhart @fabianschuiki, What is wrong with the build? |
You are using operations from the Comb and Func dialects but not linking against them in the |
in
|
e10606e
to
ff08abf
Compare
I was also interested with cost model for the whole project, this looks very nice. However, it seems to be the cost for time dimension, could you add cost for memory-space dimiension, which may be determined by data type or data amount? |
@mingzheTerapines Can you please explain a little further? Honestly, I don't get this |
@elhewaty I mean this is calculating static cost for the model, but if we know the size of input(such as vector) we can know the dynamcia memory/register space cost. Code writen by @angelzzzzz looks like this. You can consider output of function/module is liveout.
|
@mingzheTerapines, It seems an interesting idea, I will try to investigate further. @fabianschuiki what do you think, will this affect the vectors' cost significantly?? I am working on minimizing the shuffling cost in vectors. and I will return to this PR. |
@fabianschuiki @maerhart PING |
// FIXME: May be refined and we have more accurate operation costs | ||
enum class OperationCost : size_t { | ||
NOCOST, | ||
NORMALCOST, | ||
PACKCOST = 2, | ||
EXTRACTCOST = 3, | ||
CONCATCOST = 3, | ||
SAMEVECTORNOSHUFFLE = 0, | ||
SAMEVECTORSHUFFLECOST = 2, | ||
DIFFERENTVECTORNOSHUFFLE = 2, | ||
DIFFERENTVECTORSHUFFLECOST = 3 | ||
}; |
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 does not show up as cost in the public interface of the cost model (which is great)! Therefore I would move this into the *.cpp
file.
size_t shufflingCost{0}; | ||
size_t vectoroizeOpsBodyCost{0}; | ||
size_t allVectorizeOpsCost{0}; | ||
DenseMap<Operation *, OperationCosts> opCostCash; |
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.
DenseMap<Operation *, OperationCosts> opCostCash; | |
DenseMap<Operation *, OperationCosts> opCostCache; |
lib/Dialect/Arc/ArcCostModel.cpp
Outdated
if (opCostCash.count(op)) | ||
return opCostCash[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.
You can often use iterators to combine checking if a value exists in a map, and then doing something with the value if it does exist:
if (opCostCash.count(op)) | |
return opCostCash[op]; | |
if (auto it = opCostCache.find(op); it != opCostCache.end()) | |
return it->second; |
lib/Dialect/Arc/ArcCostModel.cpp
Outdated
else if (isa<arc::VectorizeOp>(op)) { | ||
// VectorizeOpCost = packingCost + shufflingCost + bodyCost | ||
OperationCosts inputVecCosts = | ||
getInputVectorsCost(dyn_cast<VectorizeOp>(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.
else if (isa<arc::VectorizeOp>(op)) { | |
// VectorizeOpCost = packingCost + shufflingCost + bodyCost | |
OperationCosts inputVecCosts = | |
getInputVectorsCost(dyn_cast<VectorizeOp>(op)); | |
else if (auto vecOp = dyn_cast<arc::VectorizeOp>(op)) { | |
// VectorizeOpCost = packingCost + shufflingCost + bodyCost | |
OperationCosts inputVecCosts = getInputVectorsCost(vecOp); |
Thanks for the review, I will update and push it now |
@fabianschuiki What is wrong with CMakeList file? |
@@ -0,0 +1,72 @@ | |||
//===- DummyAnalysisTester.cpp --------------------------------------------===// |
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.
Leftover file 😁?
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.
Oh, I will update now. I will finish this PR even it costs my life, it's 12:36 AM here 😭
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.
LGTM! And CI also seems to be happy 😃 Thanks a lot for iterating on this!
Thanks for reviewing, Let's work on the splitting 🚀 🔥 |
@elhewaty Could you add an option for printing the cost explictly in Ops in the future? Maybe using |
No description provided.