-
Notifications
You must be signed in to change notification settings - Fork 21
Clean up MemReq and associated code #219
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
Conversation
This reverts commit 1d69316.
|
Not a concern but for future consideration (or maybe this is already there). If I wanted to put in another memory agent, like a DMA, it would be nice to build it on the MemCtl/MemReq classes. The receiving agent would receive a block of data and have a custom completion. The requests could go through the same queue to the same memory port or in parallel to a separate memory port. I've been playing with this in a coprocessor memory agent sharing the same lsq. Thanks much |
That seems a bigger scope than the |
rkabrick
left a comment
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
This is cleanup I did when exhaustively reviewing PR #205 .
In compressed instructions where
rs1 = rd, make the decoding code assign to bothrs1andrdin the same statement, to avoid mistakes and to prevent creating a dependency on whetherrs1orrdis initialized first (some of the previous code assigned to one and then used it in a later statement to assign to the other, which is confusing -- this makes it clear that both are being assigned the same value at once).Rename
make_lsq_hash()toLSQHash(), keeping in line with CamelCase.Clean up
MemReqclass to only have a constructor, and not a.Set()function to change it after it's created (it still has an assignmentoperator=which is used inRevMemOp::setMemReq()). Split the constructor across multiple lines, one member per line, for readability. Directly initializeMemReqobjects using this constructor, instead of default-initializing aMemReqvalue and using.Set()afterwards.Since they are common operations, add
LSQHash()andLSQHashPair()functions toMemReq.LSQHash()returns the namespace-scopeLSQHash()on selectedMemReqmembers, andLSQHashPair()returns{LSQHash(), *this}, a pair consisting of the hash and the request, for storing instd::unordered_map.Make data members of
MemReqprivate, only visible toMemReqand friend classesRevTracer,RevMemandRevProc.Instead of
MarkLoadComplete()being a member functor ofMemReqwhich expects aMemReqargument, changeMarkLoadComplete()to be a member function ofMemReqwhich takes no arguments and calls aMarkLoadCompleteFuncfunctor with*thisas its argument, so thatreq.MarkLoadComplete(req)can simply be called asreq.MarkLoadComplete().Use
std::function<void(const MemReq&)>consistently throughout the code. Previouslystd::function<void(MemReq)>was used in some places. While it may work because of conversions, it is not as clean.Using the new helper functions, replace the common idiom
R->LSQueue->insert({make_lsq_hash(Inst.rd, RevRegClass::RegGPR, F->GetHartToExecID()), req});with the shorterR->LSQueue->insert(req.LSQHashPair());Add
std::move()aroundMemReqobjects the last time that they are used locally, as a minor optimization (prevents having to create deep copies of dynamically-allocated objects such as lambda captures -- allows them to be shallowly moved instead).Make the underlying type for
RevRegexplicitlyuint16_t, sinceuint16_tis the type used for register numbers in a lot of APIs.Templatize the
MemReqconstructor and theLSQHash(),DependencySet()andDependencyClear()functions, so that they accept eitherRevRegenum classor an integer register number. Replace hard-coded10withRevReg::a0and0withRevReg::zero.In many
.cppfiles,using namespace SST::RevCPU;was used to pull in symbols, but the rest of the file still defined functions in global namespace unless they were qualified names (using::). Change all of those files to usenamespace SST::RevCPU{ ... }instead ofusing namespace SST::RevCPU;, so that everything in the file is defined in theSST::RevCPUnamespace.