mem: Do not allocate space for packet data if not needed
Review Request #3259 - Created Dec. 15, 2015 and submitted
Information | |
---|---|
Andreas Hansson | |
gem5 | |
default | |
Reviewers | |
Default | |
Changeset 11286:e01b74b38dc5 --------------------------- mem: Do not allocate space for packet data if not needed This patch looks at the request and response command to determine if either actually has any data payload, and if not, we do not allocate any space for packet data. The only tricky case is where the command type is changed as part of the MSHR functionality. In these cases where the original packet had no data, but the new packet does, we need to explicitly call allocate().
I'm curious how much this matters... are there a significant number of cases right now where we're unnecessarily allocating a data buffer? My gut reaction is that if we're really looking to defer buffer allocation until we really know whether or not it's necessary, then we should just wait until setData() and just do the allocation then if needed. (You could also conceivably do the allocation in make*Response(), but I see how that would be complicated by us calling setData() in satisfyCpuSideRequest() before we call make*Response().) If there are really cases where we currently call setData() but which should be protected by a hasData()/hasRespData() check we could add that inside setData().
-
src/mem/cache/cache.cc (Diff revision 1) -
are there read requests which don't expect data in the response? unless that's the case, an assert might be more appropriate.
-
src/mem/cache/cache.cc (Diff revision 1) -
is there a case where we reach this code w/o pkt->hasData() being true? given that 'respond' is only set if we have a modified copy, it seems unlikely... again, if not, perhaps an assert is more apporpriate?
-
src/mem/cache/mshr.cc (Diff revision 1) -
seems complicated to have to track these transitions to know when to call pkt->allocate() and when not to...
Description: |
|
|||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+27 -8) |
Description: |
|
|||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+31 -8) |
-
src/mem/cache/mshr.cc (Diff revision 3) -
this comment is no longer needed
-
src/mem/cache/mshr.cc (Diff revision 3) -
is it worth checking pkt->hasData()? as I said before, I don't see how you could start off with a non-data request and convert it to one that has data, since there's no way to actually set that data field to anything meaningful here.
How about:
if (!has_data) {
assert(!pkt->hasData());
if (pkt->hasRespData()) {
pkt->allocate();
}
}
Description: |
|
|||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+37 -8) |
Ship It!