commit.hh
来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· HH 代码 · 共 491 行 · 第 1/2 页
HH
491 行
/* * Copyright (c) 2004, 2005, 2006 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. * * Authors: Kevin T. Lim * Korey L. Sewell */#ifndef __CPU_O3_COMMIT_HH__#define __CPU_O3_COMMIT_HH__#include "base/statistics.hh"#include "base/timebuf.hh"#include "cpu/exetrace.hh"#include "cpu/inst_seq.hh"template <class>class O3ThreadState;/** * DefaultCommit handles single threaded and SMT commit. Its width is * specified by the parameters; each cycle it tries to commit that * many instructions. The SMT policy decides which thread it tries to * commit instructions from. Non- speculative instructions must reach * the head of the ROB before they are ready to execute; once they * reach the head, commit will broadcast the instruction's sequence * number to the previous stages so that they can issue/ execute the * instruction. Only one non-speculative instruction is handled per * cycle. Commit is responsible for handling all back-end initiated * redirects. It receives the redirect, and then broadcasts it to all * stages, indicating the sequence number they should squash until, * and any necessary branch misprediction information as well. It * priortizes redirects by instruction's age, only broadcasting a * redirect if it corresponds to an instruction that should currently * be in the ROB. This is done by tracking the sequence number of the * youngest instruction in the ROB, which gets updated to any * squashing instruction's sequence number, and only broadcasting a * redirect if it corresponds to an older instruction. Commit also * supports multiple cycle squashing, to model a ROB that can only * remove a certain number of instructions per cycle. */template<class Impl>class DefaultCommit{ public: // Typedefs from the Impl. typedef typename Impl::O3CPU O3CPU; typedef typename Impl::DynInstPtr DynInstPtr; typedef typename Impl::Params Params; typedef typename Impl::CPUPol CPUPol; typedef typename CPUPol::RenameMap RenameMap; typedef typename CPUPol::ROB ROB; typedef typename CPUPol::TimeStruct TimeStruct; typedef typename CPUPol::FetchStruct FetchStruct; typedef typename CPUPol::IEWStruct IEWStruct; typedef typename CPUPol::RenameStruct RenameStruct; typedef typename CPUPol::Fetch Fetch; typedef typename CPUPol::IEW IEW; typedef O3ThreadState<Impl> Thread; /** Event class used to schedule a squash due to a trap (fault or * interrupt) to happen on a specific cycle. */ class TrapEvent : public Event { private: DefaultCommit<Impl> *commit; unsigned tid; public: TrapEvent(DefaultCommit<Impl> *_commit, unsigned _tid); void process(); const char *description() const; }; /** Overall commit status. Used to determine if the CPU can deschedule * itself due to a lack of activity. */ enum CommitStatus{ Active, Inactive }; /** Individual thread status. */ enum ThreadStatus { Running, Idle, ROBSquashing, TrapPending, FetchTrapPending }; /** Commit policy for SMT mode. */ enum CommitPolicy { Aggressive, RoundRobin, OldestReady }; private: /** Overall commit status. */ CommitStatus _status; /** Next commit status, to be set at the end of the cycle. */ CommitStatus _nextStatus; /** Per-thread status. */ ThreadStatus commitStatus[Impl::MaxThreads]; /** Commit policy used in SMT mode. */ CommitPolicy commitPolicy; public: /** Construct a DefaultCommit with the given parameters. */ DefaultCommit(O3CPU *_cpu, Params *params); /** Returns the name of the DefaultCommit. */ std::string name() const; /** Registers statistics. */ void regStats(); /** Sets the list of threads. */ void setThreads(std::vector<Thread *> &threads); /** Sets the main time buffer pointer, used for backwards communication. */ void setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr); void setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr); /** Sets the pointer to the queue coming from rename. */ void setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr); /** Sets the pointer to the queue coming from IEW. */ void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr); /** Sets the pointer to the IEW stage. */ void setIEWStage(IEW *iew_stage); /** Skid buffer between rename and commit. */ std::queue<DynInstPtr> skidBuffer; /** The pointer to the IEW stage. Used solely to ensure that * various events (traps, interrupts, syscalls) do not occur until * all stores have written back. */ IEW *iewStage; /** Sets pointer to list of active threads. */ void setActiveThreads(std::list<unsigned> *at_ptr); /** Sets pointer to the commited state rename map. */ void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]); /** Sets pointer to the ROB. */ void setROB(ROB *rob_ptr); /** Initializes stage by sending back the number of free entries. */ void initStage(); /** Initializes the draining of commit. */ bool drain(); /** Resumes execution after draining. */ void resume(); /** Completes the switch out of commit. */ void switchOut(); /** Takes over from another CPU's thread. */ void takeOverFrom(); /** Ticks the commit stage, which tries to commit instructions. */ void tick(); /** Handles any squashes that are sent from IEW, and adds instructions * to the ROB and tries to commit instructions. */ void commit(); /** Returns the number of free ROB entries for a specific thread. */ unsigned numROBFreeEntries(unsigned tid); /** Generates an event to schedule a squash due to a trap. */ void generateTrapEvent(unsigned tid); /** Records that commit needs to initiate a squash due to an * external state update through the TC. */ void generateTCEvent(unsigned tid); private: /** Updates the overall status of commit with the nextStatus, and * tell the CPU if commit is active/inactive. */ void updateStatus(); /** Sets the next status based on threads' statuses, which becomes the * current status at the end of the cycle. */ void setNextStatus(); /** Checks if the ROB is completed with squashing. This is for the case * where the ROB can take multiple cycles to complete squashing. */ bool robDoneSquashing(); /** Returns if any of the threads have the number of ROB entries changed * on this cycle. Used to determine if the number of free ROB entries needs * to be sent back to previous stages. */ bool changedROBEntries(); /** Squashes all in flight instructions. */ void squashAll(unsigned tid); /** Handles squashing due to a trap. */ void squashFromTrap(unsigned tid); /** Handles squashing due to an TC write. */ void squashFromTC(unsigned tid);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?