2005-05-27 05:30:12 +02:00
|
|
|
/*
|
2014-09-03 13:42:37 +02:00
|
|
|
* Copyright (c) 2011-2012, 2014 ARM Limited
|
2013-10-15 20:22:43 +02:00
|
|
|
* Copyright (c) 2013 Advanced Micro Devices, Inc.
|
2012-01-17 19:55:08 +01:00
|
|
|
* All rights reserved
|
|
|
|
*
|
|
|
|
* The license below extends only to copyright in the software and shall
|
|
|
|
* not be construed as granting a license to any other intellectual
|
|
|
|
* property including but not limited to intellectual property relating
|
|
|
|
* to a hardware implementation of the functionality of the software
|
|
|
|
* licensed hereunder. You may use the software subject to the license
|
|
|
|
* terms below provided that you ensure that this notice is replicated
|
|
|
|
* unmodified and in its entirety in all distributions of the software,
|
|
|
|
* modified or unmodified, in source code or in binary form.
|
|
|
|
*
|
2006-05-19 21:37:52 +02:00
|
|
|
* Copyright (c) 2004-2006 The Regents of The University of Michigan
|
2011-02-07 07:14:17 +01:00
|
|
|
* Copyright (c) 2011 Regents of the University of California
|
2005-05-27 05:30:12 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
|
|
|
* Authors: Kevin Lim
|
2006-06-16 04:01:28 +02:00
|
|
|
* Korey Sewell
|
2011-02-07 07:14:17 +01:00
|
|
|
* Rick Strong
|
2005-05-27 05:30:12 +02:00
|
|
|
*/
|
|
|
|
|
2011-11-01 12:01:13 +01:00
|
|
|
#include "arch/kernel_stats.hh"
|
2009-09-23 17:34:21 +02:00
|
|
|
#include "config/the_isa.hh"
|
2012-03-09 15:59:27 +01:00
|
|
|
#include "cpu/checker/cpu.hh"
|
|
|
|
#include "cpu/checker/thread_context.hh"
|
2011-04-15 19:44:06 +02:00
|
|
|
#include "cpu/o3/cpu.hh"
|
|
|
|
#include "cpu/o3/isa_specific.hh"
|
|
|
|
#include "cpu/o3/thread_context.hh"
|
2006-05-19 21:37:52 +02:00
|
|
|
#include "cpu/activity.hh"
|
2011-11-01 12:01:13 +01:00
|
|
|
#include "cpu/quiesce_event.hh"
|
2006-06-07 21:29:53 +02:00
|
|
|
#include "cpu/simple_thread.hh"
|
2006-06-06 23:32:21 +02:00
|
|
|
#include "cpu/thread_context.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/Activity.hh"
|
2012-08-15 16:38:08 +02:00
|
|
|
#include "debug/Drain.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/O3CPU.hh"
|
|
|
|
#include "debug/Quiesce.hh"
|
2007-07-24 06:51:38 +02:00
|
|
|
#include "enums/MemoryMode.hh"
|
2007-03-06 20:13:43 +01:00
|
|
|
#include "sim/core.hh"
|
2011-11-18 10:33:28 +01:00
|
|
|
#include "sim/full_system.hh"
|
2011-11-01 12:01:13 +01:00
|
|
|
#include "sim/process.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
#include "sim/stat_control.hh"
|
2011-07-10 19:56:08 +02:00
|
|
|
#include "sim/system.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2008-10-20 22:22:59 +02:00
|
|
|
#if THE_ISA == ALPHA_ISA
|
|
|
|
#include "arch/alpha/osfpal.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/Activity.hh"
|
2008-10-20 22:22:59 +02:00
|
|
|
#endif
|
|
|
|
|
2012-01-31 18:05:52 +01:00
|
|
|
struct BaseCPUParams;
|
2008-08-11 21:22:16 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
using namespace TheISA;
|
2009-05-26 18:23:13 +02:00
|
|
|
using namespace std;
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2008-08-11 21:22:16 +02:00
|
|
|
BaseO3CPU::BaseO3CPU(BaseCPUParams *params)
|
2008-11-03 03:56:57 +01:00
|
|
|
: BaseCPU(params)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-06-16 23:08:47 +02:00
|
|
|
BaseO3CPU::regStats()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2006-04-23 00:26:48 +02:00
|
|
|
BaseCPU::regStats();
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:08 +01:00
|
|
|
template<class Impl>
|
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
FullO3CPU<Impl>::IcachePort::recvTimingResp(PacketPtr pkt)
|
2012-01-17 19:55:08 +01:00
|
|
|
{
|
|
|
|
DPRINTF(O3CPU, "Fetch unit received timing\n");
|
2015-05-05 09:22:29 +02:00
|
|
|
// We shouldn't ever get a cacheable block in ownership state
|
|
|
|
assert(pkt->req->isUncacheable() ||
|
|
|
|
!(pkt->memInhibitAsserted() && !pkt->sharedAsserted()));
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
fetch->processCacheCompletion(pkt);
|
2012-01-17 19:55:08 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Impl>
|
|
|
|
void
|
2015-03-02 10:00:35 +01:00
|
|
|
FullO3CPU<Impl>::IcachePort::recvReqRetry()
|
2012-01-17 19:55:08 +01:00
|
|
|
{
|
2015-03-02 10:00:35 +01:00
|
|
|
fetch->recvReqRetry();
|
2012-01-17 19:55:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
FullO3CPU<Impl>::DcachePort::recvTimingResp(PacketPtr pkt)
|
2012-01-17 19:55:08 +01:00
|
|
|
{
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
return lsq->recvTimingResp(pkt);
|
2012-01-17 19:55:08 +01:00
|
|
|
}
|
|
|
|
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
template <class Impl>
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::DcachePort::recvTimingSnoopReq(PacketPtr pkt)
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
{
|
2014-11-06 12:42:22 +01:00
|
|
|
// X86 ISA: Snooping an invalidation for monitor/mwait
|
|
|
|
if(cpu->getCpuAddrMonitor()->doMonitor(pkt)) {
|
|
|
|
cpu->wakeup();
|
|
|
|
}
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
lsq->recvTimingSnoopReq(pkt);
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:08 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2015-03-02 10:00:35 +01:00
|
|
|
FullO3CPU<Impl>::DcachePort::recvReqRetry()
|
2012-01-17 19:55:08 +01:00
|
|
|
{
|
2015-03-02 10:00:35 +01:00
|
|
|
lsq->recvReqRetry();
|
2012-01-17 19:55:08 +01:00
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::TickEvent::TickEvent(FullO3CPU<Impl> *c)
|
2008-10-09 13:58:24 +02:00
|
|
|
: Event(CPU_Tick_Pri), cpu(c)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::TickEvent::process()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
|
|
|
cpu->tick();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
const char *
|
2008-02-06 22:32:40 +01:00
|
|
|
FullO3CPU<Impl>::TickEvent::description() const
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2007-07-01 02:45:58 +02:00
|
|
|
return "FullO3CPU tick";
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
2008-10-09 09:08:50 +02:00
|
|
|
FullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params)
|
2006-06-16 23:08:47 +02:00
|
|
|
: BaseO3CPU(params),
|
2006-12-06 17:36:40 +01:00
|
|
|
itb(params->itb),
|
|
|
|
dtb(params->dtb),
|
2004-08-20 20:54:07 +02:00
|
|
|
tickEvent(this),
|
2008-11-10 20:51:18 +01:00
|
|
|
#ifndef NDEBUG
|
|
|
|
instcount(0),
|
|
|
|
#endif
|
2006-04-23 00:26:48 +02:00
|
|
|
removeInstsThisCycle(false),
|
2008-10-09 09:08:50 +02:00
|
|
|
fetch(this, params),
|
|
|
|
decode(this, params),
|
|
|
|
rename(this, params),
|
|
|
|
iew(this, params),
|
|
|
|
commit(this, params),
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2013-10-15 20:22:43 +02:00
|
|
|
regFile(params->numPhysIntRegs,
|
2013-10-15 20:22:44 +02:00
|
|
|
params->numPhysFloatRegs,
|
|
|
|
params->numPhysCCRegs),
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
freeList(name() + ".freelist", ®File),
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2013-10-31 19:41:13 +01:00
|
|
|
rob(this, params),
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2013-10-15 20:22:43 +02:00
|
|
|
scoreboard(name() + ".scoreboard",
|
|
|
|
regFile.totalNumPhysRegs(), TheISA::NumMiscRegs,
|
|
|
|
TheISA::ZeroReg, TheISA::ZeroReg),
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2013-01-07 19:05:35 +01:00
|
|
|
isa(numThreads, NULL),
|
|
|
|
|
2012-01-17 19:55:08 +01:00
|
|
|
icachePort(&fetch, this),
|
|
|
|
dcachePort(&iew.ldstQueue, this),
|
|
|
|
|
2006-07-10 21:40:28 +02:00
|
|
|
timeBuffer(params->backComSize, params->forwardComSize),
|
|
|
|
fetchQueue(params->backComSize, params->forwardComSize),
|
|
|
|
decodeQueue(params->backComSize, params->forwardComSize),
|
|
|
|
renameQueue(params->backComSize, params->forwardComSize),
|
|
|
|
iewQueue(params->backComSize, params->forwardComSize),
|
2009-01-21 23:56:18 +01:00
|
|
|
activityRec(name(), NumStages,
|
2006-07-10 21:40:28 +02:00
|
|
|
params->backComSize + params->forwardComSize,
|
|
|
|
params->activity),
|
2004-08-20 20:54:07 +02:00
|
|
|
|
|
|
|
globalSeqNum(1),
|
2006-04-23 00:26:48 +02:00
|
|
|
system(params->system),
|
2013-01-07 19:05:46 +01:00
|
|
|
drainManager(NULL),
|
2012-08-28 20:30:33 +02:00
|
|
|
lastRunningCycle(curCycle())
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2013-01-07 19:05:45 +01:00
|
|
|
if (!params->switched_out) {
|
2006-10-08 06:53:41 +02:00
|
|
|
_status = Running;
|
|
|
|
} else {
|
2012-08-15 16:38:08 +02:00
|
|
|
_status = SwitchedOut;
|
2006-10-08 06:53:41 +02:00
|
|
|
}
|
2005-05-03 16:56:47 +02:00
|
|
|
|
2007-06-20 17:15:06 +02:00
|
|
|
if (params->checker) {
|
2006-05-16 20:06:35 +02:00
|
|
|
BaseCPU *temp_checker = params->checker;
|
2012-01-31 16:46:03 +01:00
|
|
|
checker = dynamic_cast<Checker<Impl> *>(temp_checker);
|
2012-01-17 19:55:08 +01:00
|
|
|
checker->setIcachePort(&icachePort);
|
2006-05-16 20:06:35 +02:00
|
|
|
checker->setSystem(params->system);
|
2007-06-20 17:15:06 +02:00
|
|
|
} else {
|
|
|
|
checker = NULL;
|
2005-05-03 16:56:47 +02:00
|
|
|
}
|
|
|
|
|
2011-11-18 10:33:28 +01:00
|
|
|
if (!FullSystem) {
|
|
|
|
thread.resize(numThreads);
|
|
|
|
tids.resize(numThreads);
|
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-05-19 21:37:52 +02:00
|
|
|
// The stages also need their CPU pointer setup. However this
|
|
|
|
// must be done at the upper level CPU because they have pointers
|
|
|
|
// to the upper level CPU, and not this FullO3CPU.
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// Set up Pointers to the activeThreads list for each stage
|
|
|
|
fetch.setActiveThreads(&activeThreads);
|
|
|
|
decode.setActiveThreads(&activeThreads);
|
|
|
|
rename.setActiveThreads(&activeThreads);
|
|
|
|
iew.setActiveThreads(&activeThreads);
|
|
|
|
commit.setActiveThreads(&activeThreads);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
|
|
|
// Give each of the stages the time buffer they will use.
|
|
|
|
fetch.setTimeBuffer(&timeBuffer);
|
|
|
|
decode.setTimeBuffer(&timeBuffer);
|
|
|
|
rename.setTimeBuffer(&timeBuffer);
|
|
|
|
iew.setTimeBuffer(&timeBuffer);
|
|
|
|
commit.setTimeBuffer(&timeBuffer);
|
|
|
|
|
|
|
|
// Also setup each of the stages' queues.
|
|
|
|
fetch.setFetchQueue(&fetchQueue);
|
|
|
|
decode.setFetchQueue(&fetchQueue);
|
2006-04-23 00:26:48 +02:00
|
|
|
commit.setFetchQueue(&fetchQueue);
|
2004-08-20 20:54:07 +02:00
|
|
|
decode.setDecodeQueue(&decodeQueue);
|
|
|
|
rename.setDecodeQueue(&decodeQueue);
|
|
|
|
rename.setRenameQueue(&renameQueue);
|
|
|
|
iew.setRenameQueue(&renameQueue);
|
|
|
|
iew.setIEWQueue(&iewQueue);
|
|
|
|
commit.setIEWQueue(&iewQueue);
|
|
|
|
commit.setRenameQueue(&renameQueue);
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
commit.setIEWStage(&iew);
|
|
|
|
rename.setIEWStage(&iew);
|
|
|
|
rename.setCommitStage(&commit);
|
|
|
|
|
2011-11-18 10:33:28 +01:00
|
|
|
ThreadID active_threads;
|
|
|
|
if (FullSystem) {
|
|
|
|
active_threads = 1;
|
|
|
|
} else {
|
|
|
|
active_threads = params->workload.size();
|
2006-07-03 05:11:24 +02:00
|
|
|
|
2011-11-18 10:33:28 +01:00
|
|
|
if (active_threads > Impl::MaxThreads) {
|
|
|
|
panic("Workload Size too large. Increase the 'MaxThreads' "
|
|
|
|
"constant in your O3CPU impl. file (e.g. o3/alpha/impl.hh) "
|
|
|
|
"or edit your workload size.");
|
|
|
|
}
|
2006-07-03 05:11:24 +02:00
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-05-16 20:06:35 +02:00
|
|
|
//Make Sure That this a Valid Architeture
|
2006-04-23 00:26:48 +02:00
|
|
|
assert(params->numPhysIntRegs >= numThreads * TheISA::NumIntRegs);
|
|
|
|
assert(params->numPhysFloatRegs >= numThreads * TheISA::NumFloatRegs);
|
2013-10-15 20:22:44 +02:00
|
|
|
assert(params->numPhysCCRegs >= numThreads * TheISA::NumCCRegs);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
rename.setScoreboard(&scoreboard);
|
|
|
|
iew.setScoreboard(&scoreboard);
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
// Setup the rename map for whichever stages need it.
|
2009-05-26 18:23:13 +02:00
|
|
|
for (ThreadID tid = 0; tid < numThreads; tid++) {
|
2013-01-07 19:05:35 +01:00
|
|
|
isa[tid] = params->isa[tid];
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
// Only Alpha has an FP zero register, so for other ISAs we
|
|
|
|
// use an invalid FP register index to avoid special treatment
|
|
|
|
// of any valid FP reg.
|
|
|
|
RegIndex invalidFPReg = TheISA::NumFloatRegs + 1;
|
|
|
|
RegIndex fpZeroReg =
|
|
|
|
(THE_ISA == ALPHA_ISA) ? TheISA::ZeroReg : invalidFPReg;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
commitRenameMap[tid].init(®File, TheISA::ZeroReg, fpZeroReg,
|
|
|
|
&freeList);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
renameMap[tid].init(®File, TheISA::ZeroReg, fpZeroReg,
|
|
|
|
&freeList);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
// Initialize rename map to assign physical registers to the
|
|
|
|
// architectural registers for active threads only.
|
|
|
|
for (ThreadID tid = 0; tid < active_threads; tid++) {
|
|
|
|
for (RegIndex ridx = 0; ridx < TheISA::NumIntRegs; ++ridx) {
|
|
|
|
// Note that we can't use the rename() method because we don't
|
|
|
|
// want special treatment for the zero register at this point
|
|
|
|
PhysRegIndex phys_reg = freeList.getIntReg();
|
|
|
|
renameMap[tid].setIntEntry(ridx, phys_reg);
|
|
|
|
commitRenameMap[tid].setIntEntry(ridx, phys_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (RegIndex ridx = 0; ridx < TheISA::NumFloatRegs; ++ridx) {
|
|
|
|
PhysRegIndex phys_reg = freeList.getFloatReg();
|
|
|
|
renameMap[tid].setFloatEntry(ridx, phys_reg);
|
|
|
|
commitRenameMap[tid].setFloatEntry(ridx, phys_reg);
|
|
|
|
}
|
2013-10-15 20:22:44 +02:00
|
|
|
|
|
|
|
for (RegIndex ridx = 0; ridx < TheISA::NumCCRegs; ++ridx) {
|
|
|
|
PhysRegIndex phys_reg = freeList.getCCReg();
|
|
|
|
renameMap[tid].setCCEntry(ridx, phys_reg);
|
|
|
|
commitRenameMap[tid].setCCEntry(ridx, phys_reg);
|
|
|
|
}
|
2013-10-15 20:22:44 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
rename.setRenameMap(renameMap);
|
|
|
|
commit.setRenameMap(commitRenameMap);
|
2004-08-20 20:54:07 +02:00
|
|
|
rename.setFreeList(&freeList);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
// Setup the ROB for whichever stages need it.
|
|
|
|
commit.setROB(&rob);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2012-08-21 11:49:09 +02:00
|
|
|
lastActivatedCycle = 0;
|
2009-05-26 18:23:13 +02:00
|
|
|
#if 0
|
2006-09-01 02:51:30 +02:00
|
|
|
// Give renameMap & rename stage access to the freeList;
|
2009-05-26 18:23:13 +02:00
|
|
|
for (ThreadID tid = 0; tid < numThreads; tid++)
|
|
|
|
globalSeqNum[tid] = 1;
|
|
|
|
#endif
|
2006-09-01 02:51:30 +02:00
|
|
|
|
2008-10-09 09:08:50 +02:00
|
|
|
DPRINTF(O3CPU, "Creating O3CPU object.\n");
|
|
|
|
|
|
|
|
// Setup any thread state.
|
|
|
|
this->thread.resize(this->numThreads);
|
|
|
|
|
2009-05-26 18:23:13 +02:00
|
|
|
for (ThreadID tid = 0; tid < this->numThreads; ++tid) {
|
2011-11-18 10:33:28 +01:00
|
|
|
if (FullSystem) {
|
|
|
|
// SMT is not supported in FS mode yet.
|
|
|
|
assert(this->numThreads == 1);
|
|
|
|
this->thread[tid] = new Thread(this, 0, NULL);
|
2008-10-09 09:08:50 +02:00
|
|
|
} else {
|
2011-11-18 10:33:28 +01:00
|
|
|
if (tid < params->workload.size()) {
|
|
|
|
DPRINTF(O3CPU, "Workload[%i] process is %#x",
|
|
|
|
tid, this->thread[tid]);
|
|
|
|
this->thread[tid] = new typename FullO3CPU<Impl>::Thread(
|
|
|
|
(typename Impl::O3CPU *)(this),
|
|
|
|
tid, params->workload[tid]);
|
|
|
|
|
|
|
|
//usedTids[tid] = true;
|
|
|
|
//threadMap[tid] = tid;
|
|
|
|
} else {
|
|
|
|
//Allocate Empty thread so M5 can use later
|
|
|
|
//when scheduling threads to CPU
|
|
|
|
Process* dummy_proc = NULL;
|
|
|
|
|
|
|
|
this->thread[tid] = new typename FullO3CPU<Impl>::Thread(
|
|
|
|
(typename Impl::O3CPU *)(this),
|
|
|
|
tid, dummy_proc);
|
|
|
|
//usedTids[tid] = false;
|
|
|
|
}
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ThreadContext *tc;
|
|
|
|
|
|
|
|
// Setup the TC that will serve as the interface to the threads/CPU.
|
|
|
|
O3ThreadContext<Impl> *o3_tc = new O3ThreadContext<Impl>;
|
|
|
|
|
|
|
|
tc = o3_tc;
|
|
|
|
|
|
|
|
// If we're using a checker, then the TC should be the
|
|
|
|
// CheckerThreadContext.
|
|
|
|
if (params->checker) {
|
|
|
|
tc = new CheckerThreadContext<O3ThreadContext<Impl> >(
|
|
|
|
o3_tc, this->checker);
|
|
|
|
}
|
|
|
|
|
|
|
|
o3_tc->cpu = (typename Impl::O3CPU *)(this);
|
|
|
|
assert(o3_tc->cpu);
|
2009-05-26 18:23:13 +02:00
|
|
|
o3_tc->thread = this->thread[tid];
|
2008-10-09 09:08:50 +02:00
|
|
|
|
2011-11-18 10:33:28 +01:00
|
|
|
if (FullSystem) {
|
|
|
|
// Setup quiesce event.
|
|
|
|
this->thread[tid]->quiesceEvent = new EndQuiesceEvent(tc);
|
|
|
|
}
|
2008-10-09 09:08:50 +02:00
|
|
|
// Give the thread the TC.
|
2009-05-26 18:23:13 +02:00
|
|
|
this->thread[tid]->tc = tc;
|
2008-10-09 09:08:50 +02:00
|
|
|
|
|
|
|
// Add the TC to the CPU's list of TC's.
|
|
|
|
this->threadContexts.push_back(tc);
|
|
|
|
}
|
|
|
|
|
2012-03-02 15:21:48 +01:00
|
|
|
// FullO3CPU always requires an interrupt controller.
|
2013-01-07 19:05:45 +01:00
|
|
|
if (!params->switched_out && !interrupts) {
|
2012-03-02 15:21:48 +01:00
|
|
|
fatal("FullO3CPU %s has no interrupt controller.\n"
|
|
|
|
"Ensure createInterruptController() is called.\n", name());
|
|
|
|
}
|
|
|
|
|
2009-05-26 18:23:13 +02:00
|
|
|
for (ThreadID tid = 0; tid < this->numThreads; tid++)
|
|
|
|
this->thread[tid]->setFuncExeInst(0);
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::~FullO3CPU()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
base: add support for probe points and common probes
The probe patch is motivated by the desire to move analytical and trace code
away from functional code. This is achieved by the probe interface which is
essentially a glorified observer model.
What this means to users:
* add a probe point and a "notify" call at the source of an "event"
* add an isolated module, that is being used to carry out *your* analysis (e.g. generate a trace)
* register that module as a probe listener
Note: an example is given for reference in src/cpu/o3/simple_trace.[hh|cc] and src/cpu/SimpleTrace.py
What is happening under the hood:
* every SimObject maintains has a ProbeManager.
* during initialization (src/python/m5/simulate.py) first regProbePoints and
the regProbeListeners is called on each SimObject. this hooks up the probe
point notify calls with the listeners.
FAQs:
Why did you develop probe points:
* to remove trace, stats gathering, analytical code out of the functional code.
* the belief that probes could be generically useful.
What is a probe point:
* a probe point is used to notify upon a given event (e.g. cpu commits an instruction)
What is a probe listener:
* a class that handles whatever the user wishes to do when they are notified
about an event.
What can be passed on notify:
* probe points are templates, and so the user can generate probes that pass any
type of argument (by const reference) to a listener.
What relationships can be generated (1:1, 1:N, N:M etc):
* there isn't a restriction. You can hook probe points and listeners up in a
1:1, 1:N, N:M relationship. They become useful when a number of modules
listen to the same probe points. The idea being that you can add a small
number of probes into the source code and develop a larger number of useful
analysis modules that use information passed by the probes.
Can you give examples:
* adding a probe point to the cpu's commit method allows you to build a trace
module (outputting assembler), you could re-use this to gather instruction
distribution (arithmetic, load/store, conditional, control flow) stats.
Why is the probe interface currently restricted to passing a const reference:
* the desire, initially at least, is to allow an interface to observe
functionality, but not to change functionality.
* of course this can be subverted by const-casting.
What is the performance impact of adding probes:
* when nothing is actively listening to the probes they should have a
relatively minor impact. Profiling has suggested even with a large number of
probes (60) the impact of them (when not active) is very minimal (<1%).
2014-01-24 22:29:30 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::regProbePoints()
|
|
|
|
{
|
2014-10-16 11:49:41 +02:00
|
|
|
BaseCPU::regProbePoints();
|
|
|
|
|
base: add support for probe points and common probes
The probe patch is motivated by the desire to move analytical and trace code
away from functional code. This is achieved by the probe interface which is
essentially a glorified observer model.
What this means to users:
* add a probe point and a "notify" call at the source of an "event"
* add an isolated module, that is being used to carry out *your* analysis (e.g. generate a trace)
* register that module as a probe listener
Note: an example is given for reference in src/cpu/o3/simple_trace.[hh|cc] and src/cpu/SimpleTrace.py
What is happening under the hood:
* every SimObject maintains has a ProbeManager.
* during initialization (src/python/m5/simulate.py) first regProbePoints and
the regProbeListeners is called on each SimObject. this hooks up the probe
point notify calls with the listeners.
FAQs:
Why did you develop probe points:
* to remove trace, stats gathering, analytical code out of the functional code.
* the belief that probes could be generically useful.
What is a probe point:
* a probe point is used to notify upon a given event (e.g. cpu commits an instruction)
What is a probe listener:
* a class that handles whatever the user wishes to do when they are notified
about an event.
What can be passed on notify:
* probe points are templates, and so the user can generate probes that pass any
type of argument (by const reference) to a listener.
What relationships can be generated (1:1, 1:N, N:M etc):
* there isn't a restriction. You can hook probe points and listeners up in a
1:1, 1:N, N:M relationship. They become useful when a number of modules
listen to the same probe points. The idea being that you can add a small
number of probes into the source code and develop a larger number of useful
analysis modules that use information passed by the probes.
Can you give examples:
* adding a probe point to the cpu's commit method allows you to build a trace
module (outputting assembler), you could re-use this to gather instruction
distribution (arithmetic, load/store, conditional, control flow) stats.
Why is the probe interface currently restricted to passing a const reference:
* the desire, initially at least, is to allow an interface to observe
functionality, but not to change functionality.
* of course this can be subverted by const-casting.
What is the performance impact of adding probes:
* when nothing is actively listening to the probes they should have a
relatively minor impact. Profiling has suggested even with a large number of
probes (60) the impact of them (when not active) is very minimal (<1%).
2014-01-24 22:29:30 +01:00
|
|
|
ppInstAccessComplete = new ProbePointArg<PacketPtr>(getProbeManager(), "InstAccessComplete");
|
|
|
|
ppDataAccessComplete = new ProbePointArg<std::pair<DynInstPtr, PacketPtr> >(getProbeManager(), "DataAccessComplete");
|
2014-10-16 11:49:41 +02:00
|
|
|
|
base: add support for probe points and common probes
The probe patch is motivated by the desire to move analytical and trace code
away from functional code. This is achieved by the probe interface which is
essentially a glorified observer model.
What this means to users:
* add a probe point and a "notify" call at the source of an "event"
* add an isolated module, that is being used to carry out *your* analysis (e.g. generate a trace)
* register that module as a probe listener
Note: an example is given for reference in src/cpu/o3/simple_trace.[hh|cc] and src/cpu/SimpleTrace.py
What is happening under the hood:
* every SimObject maintains has a ProbeManager.
* during initialization (src/python/m5/simulate.py) first regProbePoints and
the regProbeListeners is called on each SimObject. this hooks up the probe
point notify calls with the listeners.
FAQs:
Why did you develop probe points:
* to remove trace, stats gathering, analytical code out of the functional code.
* the belief that probes could be generically useful.
What is a probe point:
* a probe point is used to notify upon a given event (e.g. cpu commits an instruction)
What is a probe listener:
* a class that handles whatever the user wishes to do when they are notified
about an event.
What can be passed on notify:
* probe points are templates, and so the user can generate probes that pass any
type of argument (by const reference) to a listener.
What relationships can be generated (1:1, 1:N, N:M etc):
* there isn't a restriction. You can hook probe points and listeners up in a
1:1, 1:N, N:M relationship. They become useful when a number of modules
listen to the same probe points. The idea being that you can add a small
number of probes into the source code and develop a larger number of useful
analysis modules that use information passed by the probes.
Can you give examples:
* adding a probe point to the cpu's commit method allows you to build a trace
module (outputting assembler), you could re-use this to gather instruction
distribution (arithmetic, load/store, conditional, control flow) stats.
Why is the probe interface currently restricted to passing a const reference:
* the desire, initially at least, is to allow an interface to observe
functionality, but not to change functionality.
* of course this can be subverted by const-casting.
What is the performance impact of adding probes:
* when nothing is actively listening to the probes they should have a
relatively minor impact. Profiling has suggested even with a large number of
probes (60) the impact of them (when not active) is very minimal (<1%).
2014-01-24 22:29:30 +01:00
|
|
|
fetch.regProbePoints();
|
|
|
|
iew.regProbePoints();
|
|
|
|
commit.regProbePoints();
|
|
|
|
}
|
|
|
|
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2008-10-09 09:08:50 +02:00
|
|
|
FullO3CPU<Impl>::regStats()
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
{
|
2006-06-16 23:08:47 +02:00
|
|
|
BaseO3CPU::regStats();
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-16 23:08:47 +02:00
|
|
|
// Register any of the O3CPU's stats here.
|
2006-04-23 00:26:48 +02:00
|
|
|
timesIdled
|
|
|
|
.name(name() + ".timesIdled")
|
|
|
|
.desc("Number of times that the entire CPU went into an idle state and"
|
|
|
|
" unscheduled itself")
|
|
|
|
.prereq(timesIdled);
|
|
|
|
|
|
|
|
idleCycles
|
|
|
|
.name(name() + ".idleCycles")
|
|
|
|
.desc("Total number of cycles that the CPU has spent unscheduled due "
|
|
|
|
"to idling")
|
|
|
|
.prereq(idleCycles);
|
|
|
|
|
2011-12-01 09:15:22 +01:00
|
|
|
quiesceCycles
|
|
|
|
.name(name() + ".quiesceCycles")
|
|
|
|
.desc("Total number of cycles that CPU has spent quiesced or waiting "
|
|
|
|
"for an interrupt")
|
|
|
|
.prereq(quiesceCycles);
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// Number of Instructions simulated
|
|
|
|
// --------------------------------
|
|
|
|
// Should probably be in Base CPU but need templated
|
|
|
|
// MaxThreads so put in here instead
|
|
|
|
committedInsts
|
|
|
|
.init(numThreads)
|
|
|
|
.name(name() + ".committedInsts")
|
2014-05-23 13:07:02 +02:00
|
|
|
.desc("Number of Instructions Simulated")
|
|
|
|
.flags(Stats::total);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2012-02-12 23:07:39 +01:00
|
|
|
committedOps
|
|
|
|
.init(numThreads)
|
|
|
|
.name(name() + ".committedOps")
|
2014-05-23 13:07:02 +02:00
|
|
|
.desc("Number of Ops (including micro ops) Simulated")
|
|
|
|
.flags(Stats::total);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
cpi
|
|
|
|
.name(name() + ".cpi")
|
|
|
|
.desc("CPI: Cycles Per Instruction")
|
|
|
|
.precision(6);
|
2007-04-22 21:11:54 +02:00
|
|
|
cpi = numCycles / committedInsts;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
totalCpi
|
|
|
|
.name(name() + ".cpi_total")
|
|
|
|
.desc("CPI: Total CPI of All Threads")
|
|
|
|
.precision(6);
|
2014-05-23 13:07:02 +02:00
|
|
|
totalCpi = numCycles / sum(committedInsts);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
ipc
|
|
|
|
.name(name() + ".ipc")
|
|
|
|
.desc("IPC: Instructions Per Cycle")
|
|
|
|
.precision(6);
|
2007-04-22 21:11:54 +02:00
|
|
|
ipc = committedInsts / numCycles;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
totalIpc
|
|
|
|
.name(name() + ".ipc_total")
|
|
|
|
.desc("IPC: Total IPC of All Threads")
|
|
|
|
.precision(6);
|
2014-05-23 13:07:02 +02:00
|
|
|
totalIpc = sum(committedInsts) / numCycles;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2008-10-09 09:08:50 +02:00
|
|
|
this->fetch.regStats();
|
|
|
|
this->decode.regStats();
|
|
|
|
this->rename.regStats();
|
|
|
|
this->iew.regStats();
|
|
|
|
this->commit.regStats();
|
2011-02-07 07:14:17 +01:00
|
|
|
this->rob.regStats();
|
|
|
|
|
|
|
|
intRegfileReads
|
|
|
|
.name(name() + ".int_regfile_reads")
|
|
|
|
.desc("number of integer regfile reads")
|
|
|
|
.prereq(intRegfileReads);
|
|
|
|
|
|
|
|
intRegfileWrites
|
|
|
|
.name(name() + ".int_regfile_writes")
|
|
|
|
.desc("number of integer regfile writes")
|
|
|
|
.prereq(intRegfileWrites);
|
|
|
|
|
|
|
|
fpRegfileReads
|
|
|
|
.name(name() + ".fp_regfile_reads")
|
|
|
|
.desc("number of floating regfile reads")
|
|
|
|
.prereq(fpRegfileReads);
|
|
|
|
|
|
|
|
fpRegfileWrites
|
|
|
|
.name(name() + ".fp_regfile_writes")
|
|
|
|
.desc("number of floating regfile writes")
|
|
|
|
.prereq(fpRegfileWrites);
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
ccRegfileReads
|
|
|
|
.name(name() + ".cc_regfile_reads")
|
|
|
|
.desc("number of cc regfile reads")
|
|
|
|
.prereq(ccRegfileReads);
|
|
|
|
|
|
|
|
ccRegfileWrites
|
|
|
|
.name(name() + ".cc_regfile_writes")
|
|
|
|
.desc("number of cc regfile writes")
|
|
|
|
.prereq(ccRegfileWrites);
|
|
|
|
|
2011-02-07 07:14:17 +01:00
|
|
|
miscRegfileReads
|
|
|
|
.name(name() + ".misc_regfile_reads")
|
|
|
|
.desc("number of misc regfile reads")
|
|
|
|
.prereq(miscRegfileReads);
|
|
|
|
|
|
|
|
miscRegfileWrites
|
|
|
|
.name(name() + ".misc_regfile_writes")
|
|
|
|
.desc("number of misc regfile writes")
|
|
|
|
.prereq(miscRegfileWrites);
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::tick()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "\n\nFullO3CPU: Ticking main, FullO3CPU.\n");
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!switchedOut());
|
|
|
|
assert(getDrainState() != Drainable::Drained);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
++numCycles;
|
2014-10-16 11:49:41 +02:00
|
|
|
ppCycles->notify(1);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-05-19 21:37:52 +02:00
|
|
|
// activity = false;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
//Tick each of the stages
|
2004-08-20 20:54:07 +02:00
|
|
|
fetch.tick();
|
|
|
|
|
|
|
|
decode.tick();
|
|
|
|
|
|
|
|
rename.tick();
|
|
|
|
|
|
|
|
iew.tick();
|
|
|
|
|
|
|
|
commit.tick();
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// Now advance the time buffers
|
2004-08-20 20:54:07 +02:00
|
|
|
timeBuffer.advance();
|
|
|
|
|
|
|
|
fetchQueue.advance();
|
|
|
|
decodeQueue.advance();
|
|
|
|
renameQueue.advance();
|
|
|
|
iewQueue.advance();
|
|
|
|
|
2006-05-19 21:37:52 +02:00
|
|
|
activityRec.advance();
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
if (removeInstsThisCycle) {
|
|
|
|
cleanUpRemovedInsts();
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:37:52 +02:00
|
|
|
if (!tickEvent.scheduled()) {
|
2013-01-07 19:05:46 +01:00
|
|
|
if (_status == SwitchedOut) {
|
2006-10-09 17:01:19 +02:00
|
|
|
DPRINTF(O3CPU, "Switched out!\n");
|
2006-05-19 21:37:52 +02:00
|
|
|
// increment stat
|
2012-08-28 20:30:31 +02:00
|
|
|
lastRunningCycle = curCycle();
|
2006-10-08 06:53:41 +02:00
|
|
|
} else if (!activityRec.active() || _status == Idle) {
|
2006-10-09 17:01:19 +02:00
|
|
|
DPRINTF(O3CPU, "Idle!\n");
|
2012-08-28 20:30:31 +02:00
|
|
|
lastRunningCycle = curCycle();
|
2006-05-19 21:37:52 +02:00
|
|
|
timesIdled++;
|
|
|
|
} else {
|
2012-08-28 20:30:33 +02:00
|
|
|
schedule(tickEvent, clockEdge(Cycles(1)));
|
2006-10-09 17:01:19 +02:00
|
|
|
DPRINTF(O3CPU, "Scheduling next tick!\n");
|
2006-05-19 21:37:52 +02:00
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2011-11-18 10:33:28 +01:00
|
|
|
if (!FullSystem)
|
|
|
|
updateThreadPriority();
|
2013-01-07 19:05:46 +01:00
|
|
|
|
|
|
|
tryDrain();
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::init()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2008-11-03 03:57:07 +01:00
|
|
|
BaseCPU::init();
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2012-03-30 15:38:35 +02:00
|
|
|
for (ThreadID tid = 0; tid < numThreads; ++tid) {
|
2013-01-07 19:05:33 +01:00
|
|
|
// Set noSquashFromTC so that the CPU doesn't squash when initially
|
2012-03-30 15:38:35 +02:00
|
|
|
// setting up registers.
|
2013-01-07 19:05:33 +01:00
|
|
|
thread[tid]->noSquashFromTC = true;
|
2012-03-30 15:38:35 +02:00
|
|
|
// Initialise the ThreadContext's memory proxies
|
|
|
|
thread[tid]->initMemProxies(thread[tid]->getTC());
|
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2013-01-07 19:05:45 +01:00
|
|
|
if (FullSystem && !params()->switched_out) {
|
2011-11-18 10:33:28 +01:00
|
|
|
for (ThreadID tid = 0; tid < numThreads; tid++) {
|
|
|
|
ThreadContext *src_tc = threadContexts[tid];
|
|
|
|
TheISA::initCPU(src_tc, src_tc->contextId());
|
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2013-01-07 19:05:33 +01:00
|
|
|
// Clear noSquashFromTC.
|
2009-05-26 18:23:13 +02:00
|
|
|
for (int tid = 0; tid < numThreads; ++tid)
|
2013-01-07 19:05:33 +01:00
|
|
|
thread[tid]->noSquashFromTC = false;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
commit.setThreads(thread);
|
|
|
|
}
|
|
|
|
|
2013-01-07 19:05:44 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::startup()
|
|
|
|
{
|
2013-12-03 17:36:04 +01:00
|
|
|
BaseCPU::startup();
|
2013-01-13 05:09:48 +01:00
|
|
|
for (int tid = 0; tid < numThreads; ++tid)
|
|
|
|
isa[tid]->startup(threadContexts[tid]);
|
|
|
|
|
2013-01-07 19:05:44 +01:00
|
|
|
fetch.startupStage();
|
2013-01-07 19:05:46 +01:00
|
|
|
decode.startupStage();
|
2013-01-07 19:05:44 +01:00
|
|
|
iew.startupStage();
|
|
|
|
rename.startupStage();
|
|
|
|
commit.startupStage();
|
|
|
|
}
|
|
|
|
|
2006-07-07 10:06:26 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::activateThread(ThreadID tid)
|
2006-07-07 10:06:26 +02:00
|
|
|
{
|
2009-05-26 18:23:13 +02:00
|
|
|
list<ThreadID>::iterator isActive =
|
2008-01-02 21:20:15 +01:00
|
|
|
std::find(activeThreads.begin(), activeThreads.end(), tid);
|
2006-07-07 10:06:26 +02:00
|
|
|
|
2006-10-09 17:01:19 +02:00
|
|
|
DPRINTF(O3CPU, "[tid:%i]: Calling activate thread.\n", tid);
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!switchedOut());
|
2006-10-09 17:01:19 +02:00
|
|
|
|
2006-07-07 10:06:26 +02:00
|
|
|
if (isActive == activeThreads.end()) {
|
|
|
|
DPRINTF(O3CPU, "[tid:%i]: Adding to active threads list\n",
|
|
|
|
tid);
|
|
|
|
|
|
|
|
activeThreads.push_back(tid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::deactivateThread(ThreadID tid)
|
2006-07-07 10:06:26 +02:00
|
|
|
{
|
|
|
|
//Remove From Active List, if Active
|
2009-05-26 18:23:13 +02:00
|
|
|
list<ThreadID>::iterator thread_it =
|
2008-01-02 21:20:15 +01:00
|
|
|
std::find(activeThreads.begin(), activeThreads.end(), tid);
|
2006-07-07 10:06:26 +02:00
|
|
|
|
2006-10-09 17:01:19 +02:00
|
|
|
DPRINTF(O3CPU, "[tid:%i]: Calling deactivate thread.\n", tid);
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!switchedOut());
|
2006-10-09 17:01:19 +02:00
|
|
|
|
2006-07-07 10:06:26 +02:00
|
|
|
if (thread_it != activeThreads.end()) {
|
|
|
|
DPRINTF(O3CPU,"[tid:%i]: Removing from active threads list\n",
|
|
|
|
tid);
|
|
|
|
activeThreads.erase(thread_it);
|
|
|
|
}
|
2014-09-03 13:42:37 +02:00
|
|
|
|
|
|
|
fetch.deactivateThread(tid);
|
|
|
|
commit.deactivateThread(tid);
|
2006-07-07 10:06:26 +02:00
|
|
|
}
|
|
|
|
|
2009-05-26 18:23:13 +02:00
|
|
|
template <class Impl>
|
|
|
|
Counter
|
2012-02-12 23:07:39 +01:00
|
|
|
FullO3CPU<Impl>::totalInsts() const
|
2009-05-26 18:23:13 +02:00
|
|
|
{
|
|
|
|
Counter total(0);
|
|
|
|
|
|
|
|
ThreadID size = thread.size();
|
|
|
|
for (ThreadID i = 0; i < size; i++)
|
|
|
|
total += thread[i]->numInst;
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2012-02-12 23:07:39 +01:00
|
|
|
template <class Impl>
|
|
|
|
Counter
|
|
|
|
FullO3CPU<Impl>::totalOps() const
|
|
|
|
{
|
|
|
|
Counter total(0);
|
|
|
|
|
|
|
|
ThreadID size = thread.size();
|
|
|
|
for (ThreadID i = 0; i < size; i++)
|
|
|
|
total += thread[i]->numOp;
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2006-07-07 10:06:26 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
alpha,arm,mips,power,x86,cpu,sim: Cleanup activate/deactivate
activate(), suspend(), and halt() used on thread contexts had an optional
delay parameter. However this parameter was often ignored. Also, when used,
the delay was seemily arbitrarily set to 0 or 1 cycle (no other delays were
ever specified). This patch removes the delay parameter and 'Events'
associated with them across all ISAs and cores. Unused activate logic
is also removed.
2014-09-20 23:18:35 +02:00
|
|
|
FullO3CPU<Impl>::activateContext(ThreadID tid)
|
2006-07-07 10:06:26 +02:00
|
|
|
{
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!switchedOut());
|
|
|
|
|
2006-07-07 10:06:26 +02:00
|
|
|
// Needs to set each stage to running as well.
|
alpha,arm,mips,power,x86,cpu,sim: Cleanup activate/deactivate
activate(), suspend(), and halt() used on thread contexts had an optional
delay parameter. However this parameter was often ignored. Also, when used,
the delay was seemily arbitrarily set to 0 or 1 cycle (no other delays were
ever specified). This patch removes the delay parameter and 'Events'
associated with them across all ISAs and cores. Unused activate logic
is also removed.
2014-09-20 23:18:35 +02:00
|
|
|
activateThread(tid);
|
2006-07-07 10:06:26 +02:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
// We don't want to wake the CPU if it is drained. In that case,
|
|
|
|
// we just want to flag the thread as active and schedule the tick
|
|
|
|
// event from drainResume() instead.
|
|
|
|
if (getDrainState() == Drainable::Drained)
|
|
|
|
return;
|
|
|
|
|
2012-08-21 11:49:09 +02:00
|
|
|
// If we are time 0 or if the last activation time is in the past,
|
|
|
|
// schedule the next tick and wake up the fetch unit
|
|
|
|
if (lastActivatedCycle == 0 || lastActivatedCycle < curTick()) {
|
alpha,arm,mips,power,x86,cpu,sim: Cleanup activate/deactivate
activate(), suspend(), and halt() used on thread contexts had an optional
delay parameter. However this parameter was often ignored. Also, when used,
the delay was seemily arbitrarily set to 0 or 1 cycle (no other delays were
ever specified). This patch removes the delay parameter and 'Events'
associated with them across all ISAs and cores. Unused activate logic
is also removed.
2014-09-20 23:18:35 +02:00
|
|
|
scheduleTickEvent(Cycles(0));
|
2006-07-07 10:06:26 +02:00
|
|
|
|
|
|
|
// Be sure to signal that there's some activity so the CPU doesn't
|
|
|
|
// deschedule itself.
|
|
|
|
activityRec.activity();
|
|
|
|
fetch.wakeFromQuiesce();
|
|
|
|
|
2012-08-28 20:30:33 +02:00
|
|
|
Cycles cycles(curCycle() - lastRunningCycle);
|
|
|
|
// @todo: This is an oddity that is only here to match the stats
|
2012-08-28 20:30:31 +02:00
|
|
|
if (cycles != 0)
|
|
|
|
--cycles;
|
|
|
|
quiesceCycles += cycles;
|
2011-12-01 09:15:22 +01:00
|
|
|
|
2011-01-08 06:50:29 +01:00
|
|
|
lastActivatedCycle = curTick();
|
2006-07-07 10:06:26 +02:00
|
|
|
|
|
|
|
_status = Running;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::suspendContext(ThreadID tid)
|
2006-07-07 10:06:26 +02:00
|
|
|
{
|
|
|
|
DPRINTF(O3CPU,"[tid: %i]: Suspending Thread Context.\n", tid);
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!switchedOut());
|
2014-09-20 23:18:36 +02:00
|
|
|
|
|
|
|
deactivateThread(tid);
|
alpha,arm,mips,power,x86,cpu,sim: Cleanup activate/deactivate
activate(), suspend(), and halt() used on thread contexts had an optional
delay parameter. However this parameter was often ignored. Also, when used,
the delay was seemily arbitrarily set to 0 or 1 cycle (no other delays were
ever specified). This patch removes the delay parameter and 'Events'
associated with them across all ISAs and cores. Unused activate logic
is also removed.
2014-09-20 23:18:35 +02:00
|
|
|
|
2006-10-08 06:53:41 +02:00
|
|
|
// If this was the last thread then unschedule the tick event.
|
2015-02-07 03:01:22 +01:00
|
|
|
if (activeThreads.size() == 0) {
|
2006-07-14 19:06:37 +02:00
|
|
|
unscheduleTickEvent();
|
2015-02-07 03:01:22 +01:00
|
|
|
lastRunningCycle = curCycle();
|
|
|
|
_status = Idle;
|
|
|
|
}
|
2011-12-01 09:15:22 +01:00
|
|
|
|
|
|
|
DPRINTF(Quiesce, "Suspending Context\n");
|
2006-07-07 10:06:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::haltContext(ThreadID tid)
|
2006-07-07 10:06:26 +02:00
|
|
|
{
|
2006-07-14 19:06:37 +02:00
|
|
|
//For now, this is the same as deallocate
|
|
|
|
DPRINTF(O3CPU,"[tid:%i]: Halt Context called. Deallocating", tid);
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!switchedOut());
|
2014-09-20 23:18:36 +02:00
|
|
|
|
|
|
|
deactivateThread(tid);
|
|
|
|
removeThread(tid);
|
2006-07-07 10:06:26 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::insertThread(ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
2006-07-06 17:25:44 +02:00
|
|
|
DPRINTF(O3CPU,"[tid:%i] Initializing thread into CPU");
|
2006-04-23 00:26:48 +02:00
|
|
|
// Will change now that the PC and thread state is internal to the CPU
|
2006-06-07 21:29:53 +02:00
|
|
|
// and not in the ThreadContext.
|
2011-11-18 10:33:28 +01:00
|
|
|
ThreadContext *src_tc;
|
|
|
|
if (FullSystem)
|
|
|
|
src_tc = system->threadContexts[tid];
|
|
|
|
else
|
|
|
|
src_tc = tcBase(tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
//Bind Int Regs to Rename Map
|
|
|
|
for (int ireg = 0; ireg < TheISA::NumIntRegs; ireg++) {
|
|
|
|
PhysRegIndex phys_reg = freeList.getIntReg();
|
|
|
|
|
|
|
|
renameMap[tid].setEntry(ireg,phys_reg);
|
|
|
|
scoreboard.setReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Bind Float Regs to Rename Map
|
2013-10-15 20:22:44 +02:00
|
|
|
int max_reg = TheISA::NumIntRegs + TheISA::NumFloatRegs;
|
|
|
|
for (int freg = TheISA::NumIntRegs; freg < max_reg; freg++) {
|
2006-04-23 00:26:48 +02:00
|
|
|
PhysRegIndex phys_reg = freeList.getFloatReg();
|
|
|
|
|
|
|
|
renameMap[tid].setEntry(freg,phys_reg);
|
|
|
|
scoreboard.setReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
//Bind condition-code Regs to Rename Map
|
|
|
|
max_reg = TheISA::NumIntRegs + TheISA::NumFloatRegs + TheISA::NumCCRegs;
|
|
|
|
for (int creg = TheISA::NumIntRegs + TheISA::NumFloatRegs;
|
|
|
|
creg < max_reg; creg++) {
|
|
|
|
PhysRegIndex phys_reg = freeList.getCCReg();
|
|
|
|
|
|
|
|
renameMap[tid].setEntry(creg,phys_reg);
|
|
|
|
scoreboard.setReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
//Copy Thread Data Into RegFile
|
2006-07-06 17:25:44 +02:00
|
|
|
//this->copyFromTC(tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-07-06 17:25:44 +02:00
|
|
|
//Set PC/NPC/NNPC
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
pcState(src_tc->pcState(), tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-06 23:32:21 +02:00
|
|
|
src_tc->setStatus(ThreadContext::Active);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
alpha,arm,mips,power,x86,cpu,sim: Cleanup activate/deactivate
activate(), suspend(), and halt() used on thread contexts had an optional
delay parameter. However this parameter was often ignored. Also, when used,
the delay was seemily arbitrarily set to 0 or 1 cycle (no other delays were
ever specified). This patch removes the delay parameter and 'Events'
associated with them across all ISAs and cores. Unused activate logic
is also removed.
2014-09-20 23:18:35 +02:00
|
|
|
activateContext(tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
//Reset ROB/IQ/LSQ Entries
|
|
|
|
commit.rob->resetEntries();
|
|
|
|
iew.resetEntries();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::removeThread(ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
2006-07-07 21:58:03 +02:00
|
|
|
DPRINTF(O3CPU,"[tid:%i] Removing thread context from CPU.\n", tid);
|
2006-07-06 17:25:44 +02:00
|
|
|
|
|
|
|
// Copy Thread Data From RegFile
|
|
|
|
// If thread is suspended, it might be re-allocated
|
2008-02-27 23:50:29 +01:00
|
|
|
// this->copyToTC(tid);
|
|
|
|
|
|
|
|
|
|
|
|
// @todo: 2-27-2008: Fix how we free up rename mappings
|
|
|
|
// here to alleviate the case for double-freeing registers
|
|
|
|
// in SMT workloads.
|
2006-07-06 17:25:44 +02:00
|
|
|
|
|
|
|
// Unbind Int Regs from Rename Map
|
2006-04-23 00:26:48 +02:00
|
|
|
for (int ireg = 0; ireg < TheISA::NumIntRegs; ireg++) {
|
|
|
|
PhysRegIndex phys_reg = renameMap[tid].lookup(ireg);
|
|
|
|
scoreboard.unsetReg(phys_reg);
|
|
|
|
freeList.addReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
2006-07-06 17:25:44 +02:00
|
|
|
// Unbind Float Regs from Rename Map
|
2014-10-20 23:47:55 +02:00
|
|
|
int max_reg = TheISA::FP_Reg_Base + TheISA::NumFloatRegs;
|
|
|
|
for (int freg = TheISA::FP_Reg_Base; freg < max_reg; freg++) {
|
2006-04-23 00:26:48 +02:00
|
|
|
PhysRegIndex phys_reg = renameMap[tid].lookup(freg);
|
|
|
|
scoreboard.unsetReg(phys_reg);
|
|
|
|
freeList.addReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
// Unbind condition-code Regs from Rename Map
|
2014-10-20 23:47:55 +02:00
|
|
|
max_reg = TheISA::CC_Reg_Base + TheISA::NumCCRegs;
|
|
|
|
for (int creg = TheISA::CC_Reg_Base; creg < max_reg; creg++) {
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = renameMap[tid].lookup(creg);
|
|
|
|
scoreboard.unsetReg(phys_reg);
|
|
|
|
freeList.addReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
2006-07-06 17:25:44 +02:00
|
|
|
// Squash Throughout Pipeline
|
2011-03-18 01:20:19 +01:00
|
|
|
DynInstPtr inst = commit.rob->readHeadInst(tid);
|
|
|
|
InstSeqNum squash_seq_num = inst->seqNum;
|
|
|
|
fetch.squash(0, squash_seq_num, inst, tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
decode.squash(tid);
|
2006-07-23 19:39:42 +02:00
|
|
|
rename.squash(squash_seq_num, tid);
|
2006-07-07 10:06:26 +02:00
|
|
|
iew.squash(tid);
|
2008-02-27 22:53:08 +01:00
|
|
|
iew.ldstQueue.squash(squash_seq_num, tid);
|
2006-07-23 19:39:42 +02:00
|
|
|
commit.rob->squash(squash_seq_num, tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2008-02-27 22:48:33 +01:00
|
|
|
|
|
|
|
assert(iew.instQueue.getCount(tid) == 0);
|
2006-04-23 00:26:48 +02:00
|
|
|
assert(iew.ldstQueue.getCount(tid) == 0);
|
|
|
|
|
2006-07-06 17:25:44 +02:00
|
|
|
// Reset ROB/IQ/LSQ Entries
|
2006-10-10 04:49:58 +02:00
|
|
|
|
|
|
|
// Commented out for now. This should be possible to do by
|
|
|
|
// telling all the pipeline stages to drain first, and then
|
|
|
|
// checking until the drain completes. Once the pipeline is
|
|
|
|
// drained, call resetEntries(). - 10-09-06 ktlim
|
|
|
|
/*
|
2006-04-23 00:26:48 +02:00
|
|
|
if (activeThreads.size() >= 1) {
|
|
|
|
commit.rob->resetEntries();
|
|
|
|
iew.resetEntries();
|
|
|
|
}
|
2006-10-10 04:49:58 +02:00
|
|
|
*/
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2008-10-20 22:22:59 +02:00
|
|
|
template <class Impl>
|
|
|
|
Fault
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::hwrei(ThreadID tid)
|
2008-10-20 22:22:59 +02:00
|
|
|
{
|
|
|
|
#if THE_ISA == ALPHA_ISA
|
|
|
|
// Need to clear the lock flag upon returning from an interrupt.
|
|
|
|
this->setMiscRegNoEffect(AlphaISA::MISCREG_LOCKFLAG, false, tid);
|
|
|
|
|
|
|
|
this->thread[tid]->kernelStats->hwrei();
|
|
|
|
|
|
|
|
// FIXME: XXX check for interrupts? XXX
|
|
|
|
#endif
|
|
|
|
return NoFault;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
bool
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::simPalCheck(int palFunc, ThreadID tid)
|
2008-10-20 22:22:59 +02:00
|
|
|
{
|
|
|
|
#if THE_ISA == ALPHA_ISA
|
|
|
|
if (this->thread[tid]->kernelStats)
|
|
|
|
this->thread[tid]->kernelStats->callpal(palFunc,
|
|
|
|
this->threadContexts[tid]);
|
|
|
|
|
|
|
|
switch (palFunc) {
|
|
|
|
case PAL::halt:
|
|
|
|
halt();
|
|
|
|
if (--System::numSystemsRunning == 0)
|
|
|
|
exitSimLoop("all cpus halted");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAL::bpt:
|
|
|
|
case PAL::bugchk:
|
|
|
|
if (this->system->breakpoint())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-10-09 09:08:50 +02:00
|
|
|
template <class Impl>
|
|
|
|
Fault
|
|
|
|
FullO3CPU<Impl>::getInterrupts()
|
|
|
|
{
|
|
|
|
// Check if there are any outstanding interrupts
|
2008-10-12 18:09:56 +02:00
|
|
|
return this->interrupts->getInterrupt(this->threadContexts[0]);
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2014-09-19 16:35:18 +02:00
|
|
|
FullO3CPU<Impl>::processInterrupts(const Fault &interrupt)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
|
|
|
// Check for interrupts here. For now can copy the code that
|
|
|
|
// exists within isa_fullsys_traits.hh. Also assume that thread 0
|
|
|
|
// is the one that handles the interrupts.
|
|
|
|
// @todo: Possibly consolidate the interrupt checking code.
|
|
|
|
// @todo: Allow other threads to handle interrupts.
|
|
|
|
|
|
|
|
assert(interrupt != NoFault);
|
2008-10-12 18:09:56 +02:00
|
|
|
this->interrupts->updateIntrInfo(this->threadContexts[0]);
|
2008-10-09 09:08:50 +02:00
|
|
|
|
|
|
|
DPRINTF(O3CPU, "Interrupt %s being handled\n", interrupt->name());
|
2014-09-27 15:08:36 +02:00
|
|
|
this->trap(interrupt, 0, nullptr);
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2014-09-27 15:08:36 +02:00
|
|
|
FullO3CPU<Impl>::trap(const Fault &fault, ThreadID tid,
|
|
|
|
const StaticInstPtr &inst)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
|
|
|
// Pass the thread's TC into the invoke method.
|
2010-09-20 11:46:42 +02:00
|
|
|
fault->invoke(this->threadContexts[tid], inst);
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::syscall(int64_t callnum, ThreadID tid)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
|
|
|
DPRINTF(O3CPU, "[tid:%i] Executing syscall().\n\n", tid);
|
|
|
|
|
|
|
|
DPRINTF(Activity,"Activity: syscall() called.\n");
|
|
|
|
|
|
|
|
// Temporarily increase this by one to account for the syscall
|
|
|
|
// instruction.
|
|
|
|
++(this->thread[tid]->funcExeInst);
|
|
|
|
|
|
|
|
// Execute the actual syscall.
|
|
|
|
this->thread[tid]->syscall(callnum);
|
|
|
|
|
|
|
|
// Decrease funcExeInst by one as the normal commit will handle
|
|
|
|
// incrementing it.
|
|
|
|
--(this->thread[tid]->funcExeInst);
|
|
|
|
}
|
|
|
|
|
2006-07-07 05:13:38 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2013-01-07 19:05:52 +01:00
|
|
|
FullO3CPU<Impl>::serializeThread(std::ostream &os, ThreadID tid)
|
2006-07-07 05:13:38 +02:00
|
|
|
{
|
2013-01-07 19:05:52 +01:00
|
|
|
thread[tid]->serialize(os);
|
2006-07-07 05:13:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2013-01-07 19:05:52 +01:00
|
|
|
FullO3CPU<Impl>::unserializeThread(Checkpoint *cp, const std::string §ion,
|
|
|
|
ThreadID tid)
|
2006-07-07 05:13:38 +02:00
|
|
|
{
|
2013-01-07 19:05:52 +01:00
|
|
|
thread[tid]->unserialize(cp, section);
|
2006-07-07 05:13:38 +02:00
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
2006-07-13 19:08:58 +02:00
|
|
|
unsigned int
|
2012-11-02 17:32:01 +01:00
|
|
|
FullO3CPU<Impl>::drain(DrainManager *drain_manager)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2006-11-09 17:33:44 +01:00
|
|
|
// If the CPU isn't doing anything, then return immediately.
|
2013-01-07 19:05:46 +01:00
|
|
|
if (switchedOut()) {
|
|
|
|
setDrainState(Drainable::Drained);
|
2006-11-09 17:33:44 +01:00
|
|
|
return 0;
|
2013-01-07 19:05:46 +01:00
|
|
|
}
|
2006-11-09 17:33:44 +01:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
DPRINTF(Drain, "Draining...\n");
|
|
|
|
setDrainState(Drainable::Draining);
|
|
|
|
|
|
|
|
// We only need to signal a drain to the commit stage as this
|
|
|
|
// initiates squashing controls the draining. Once the commit
|
|
|
|
// stage commits an instruction where it is safe to stop, it'll
|
|
|
|
// squash the rest of the instructions in the pipeline and force
|
|
|
|
// the fetch stage to stall. The pipeline will be drained once all
|
|
|
|
// in-flight instructions have retired.
|
2006-07-06 19:59:02 +02:00
|
|
|
commit.drain();
|
2006-05-19 21:37:52 +02:00
|
|
|
|
|
|
|
// Wake the CPU and record activity so everything can drain out if
|
2006-07-06 23:57:20 +02:00
|
|
|
// the CPU was not able to immediately drain.
|
2013-01-07 19:05:46 +01:00
|
|
|
if (!isDrained()) {
|
2012-11-02 17:32:01 +01:00
|
|
|
drainManager = drain_manager;
|
2006-07-07 05:13:38 +02:00
|
|
|
|
2006-07-06 23:57:20 +02:00
|
|
|
wakeCPU();
|
|
|
|
activityRec.activity();
|
2006-07-06 19:59:02 +02:00
|
|
|
|
2012-08-15 16:38:08 +02:00
|
|
|
DPRINTF(Drain, "CPU not drained\n");
|
|
|
|
|
2006-07-13 19:08:58 +02:00
|
|
|
return 1;
|
2006-07-06 23:57:20 +02:00
|
|
|
} else {
|
2013-01-07 19:05:46 +01:00
|
|
|
setDrainState(Drainable::Drained);
|
|
|
|
DPRINTF(Drain, "CPU is already drained\n");
|
|
|
|
if (tickEvent.scheduled())
|
|
|
|
deschedule(tickEvent);
|
|
|
|
|
|
|
|
// Flush out any old data from the time buffers. In
|
|
|
|
// particular, there might be some data in flight from the
|
|
|
|
// fetch stage that isn't visible in any of the CPU buffers we
|
|
|
|
// test in isDrained().
|
|
|
|
for (int i = 0; i < timeBuffer.getSize(); ++i) {
|
|
|
|
timeBuffer.advance();
|
|
|
|
fetchQueue.advance();
|
|
|
|
decodeQueue.advance();
|
|
|
|
renameQueue.advance();
|
|
|
|
iewQueue.advance();
|
|
|
|
}
|
|
|
|
|
|
|
|
drainSanityCheck();
|
2006-07-13 19:08:58 +02:00
|
|
|
return 0;
|
2006-07-06 23:57:20 +02:00
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
template <class Impl>
|
|
|
|
bool
|
|
|
|
FullO3CPU<Impl>::tryDrain()
|
|
|
|
{
|
|
|
|
if (!drainManager || !isDrained())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (tickEvent.scheduled())
|
|
|
|
deschedule(tickEvent);
|
|
|
|
|
|
|
|
DPRINTF(Drain, "CPU done draining, processing drain event\n");
|
|
|
|
drainManager->signalDrainDone();
|
|
|
|
drainManager = NULL;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2013-01-07 19:05:46 +01:00
|
|
|
FullO3CPU<Impl>::drainSanityCheck() const
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(isDrained());
|
|
|
|
fetch.drainSanityCheck();
|
|
|
|
decode.drainSanityCheck();
|
|
|
|
rename.drainSanityCheck();
|
|
|
|
iew.drainSanityCheck();
|
|
|
|
commit.drainSanityCheck();
|
|
|
|
}
|
2006-07-06 19:59:02 +02:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
template <class Impl>
|
|
|
|
bool
|
|
|
|
FullO3CPU<Impl>::isDrained() const
|
|
|
|
{
|
|
|
|
bool drained(true);
|
2006-07-13 19:08:58 +02:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
if (!instList.empty() || !removeList.empty()) {
|
|
|
|
DPRINTF(Drain, "Main CPU structures not drained.\n");
|
|
|
|
drained = false;
|
2013-01-07 19:05:41 +01:00
|
|
|
}
|
2006-10-18 23:59:11 +02:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
if (!fetch.isDrained()) {
|
|
|
|
DPRINTF(Drain, "Fetch not drained.\n");
|
|
|
|
drained = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!decode.isDrained()) {
|
|
|
|
DPRINTF(Drain, "Decode not drained.\n");
|
|
|
|
drained = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rename.isDrained()) {
|
|
|
|
DPRINTF(Drain, "Rename not drained.\n");
|
|
|
|
drained = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iew.isDrained()) {
|
|
|
|
DPRINTF(Drain, "IEW not drained.\n");
|
|
|
|
drained = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!commit.isDrained()) {
|
|
|
|
DPRINTF(Drain, "Commit not drained.\n");
|
|
|
|
drained = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return drained;
|
2006-07-06 19:59:02 +02:00
|
|
|
}
|
2006-05-16 20:06:35 +02:00
|
|
|
|
2006-07-06 19:59:02 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2013-01-07 19:05:46 +01:00
|
|
|
FullO3CPU<Impl>::commitDrained(ThreadID tid)
|
2006-07-06 19:59:02 +02:00
|
|
|
{
|
2013-01-07 19:05:46 +01:00
|
|
|
fetch.drainStall(tid);
|
|
|
|
}
|
2006-07-06 23:57:20 +02:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::drainResume()
|
|
|
|
{
|
|
|
|
setDrainState(Drainable::Running);
|
|
|
|
if (switchedOut())
|
|
|
|
return;
|
|
|
|
|
|
|
|
DPRINTF(Drain, "Resuming...\n");
|
2013-02-15 23:40:08 +01:00
|
|
|
verifyMemoryMode();
|
2013-01-07 19:05:46 +01:00
|
|
|
|
|
|
|
fetch.drainResume();
|
|
|
|
commit.drainResume();
|
2006-07-06 23:57:20 +02:00
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
_status = Idle;
|
|
|
|
for (ThreadID i = 0; i < thread.size(); i++) {
|
|
|
|
if (thread[i]->status() == ThreadContext::Active) {
|
|
|
|
DPRINTF(Drain, "Activating thread: %i\n", i);
|
|
|
|
activateThread(i);
|
|
|
|
_status = Running;
|
2006-07-06 23:57:20 +02:00
|
|
|
}
|
2006-05-16 20:06:35 +02:00
|
|
|
}
|
2013-01-07 19:05:46 +01:00
|
|
|
|
|
|
|
assert(!tickEvent.scheduled());
|
|
|
|
if (_status == Running)
|
|
|
|
schedule(tickEvent, nextCycle());
|
2006-07-06 19:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::switchOut()
|
|
|
|
{
|
2013-01-07 19:05:46 +01:00
|
|
|
DPRINTF(O3CPU, "Switching out\n");
|
2013-01-07 19:05:44 +01:00
|
|
|
BaseCPU::switchOut();
|
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
activityRec.reset();
|
2006-07-06 19:59:02 +02:00
|
|
|
|
|
|
|
_status = SwitchedOut;
|
2012-03-09 15:59:27 +01:00
|
|
|
|
2006-07-06 19:59:02 +02:00
|
|
|
if (checker)
|
|
|
|
checker->switchOut();
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::takeOverFrom(BaseCPU *oldCPU)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2012-01-31 18:05:52 +01:00
|
|
|
BaseCPU::takeOverFrom(oldCPU);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-05-04 17:36:20 +02:00
|
|
|
fetch.takeOverFrom();
|
|
|
|
decode.takeOverFrom();
|
|
|
|
rename.takeOverFrom();
|
|
|
|
iew.takeOverFrom();
|
|
|
|
commit.takeOverFrom();
|
|
|
|
|
2013-01-07 19:05:46 +01:00
|
|
|
assert(!tickEvent.scheduled());
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2012-08-15 16:38:08 +02:00
|
|
|
FullO3CPU<Impl> *oldO3CPU = dynamic_cast<FullO3CPU<Impl>*>(oldCPU);
|
|
|
|
if (oldO3CPU)
|
|
|
|
globalSeqNum = oldO3CPU->globalSeqNum;
|
|
|
|
|
2012-08-28 20:30:31 +02:00
|
|
|
lastRunningCycle = curCycle();
|
2013-01-07 19:05:46 +01:00
|
|
|
_status = Idle;
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2013-02-15 23:40:08 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::verifyMemoryMode() const
|
|
|
|
{
|
2013-02-15 23:40:09 +01:00
|
|
|
if (!system->isTimingMode()) {
|
2013-02-15 23:40:08 +01:00
|
|
|
fatal("The O3 CPU requires the memory system to be in "
|
|
|
|
"'timing' mode.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-09 09:08:50 +02:00
|
|
|
template <class Impl>
|
|
|
|
TheISA::MiscReg
|
2015-02-16 09:33:28 +01:00
|
|
|
FullO3CPU<Impl>::readMiscRegNoEffect(int misc_reg, ThreadID tid) const
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
2013-01-07 19:05:35 +01:00
|
|
|
return this->isa[tid]->readMiscRegNoEffect(misc_reg);
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
TheISA::MiscReg
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::readMiscReg(int misc_reg, ThreadID tid)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
miscRegfileReads++;
|
2013-01-07 19:05:35 +01:00
|
|
|
return this->isa[tid]->readMiscReg(misc_reg, tcBase(tid));
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::setMiscRegNoEffect(int misc_reg,
|
2009-05-26 18:23:13 +02:00
|
|
|
const TheISA::MiscReg &val, ThreadID tid)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
2013-01-07 19:05:35 +01:00
|
|
|
this->isa[tid]->setMiscRegNoEffect(misc_reg, val);
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::setMiscReg(int misc_reg,
|
2009-05-26 18:23:13 +02:00
|
|
|
const TheISA::MiscReg &val, ThreadID tid)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
miscRegfileWrites++;
|
2013-01-07 19:05:35 +01:00
|
|
|
this->isa[tid]->setMiscReg(misc_reg, val, tcBase(tid));
|
2008-10-09 09:08:50 +02:00
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
uint64_t
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::readIntReg(int reg_idx)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
intRegfileReads++;
|
2004-08-20 20:54:07 +02:00
|
|
|
return regFile.readIntReg(reg_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
2006-03-14 21:55:00 +01:00
|
|
|
FloatReg
|
|
|
|
FullO3CPU<Impl>::readFloatReg(int reg_idx)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileReads++;
|
2006-03-14 21:55:00 +01:00
|
|
|
return regFile.readFloatReg(reg_idx);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2006-03-14 21:55:00 +01:00
|
|
|
template <class Impl>
|
|
|
|
FloatRegBits
|
|
|
|
FullO3CPU<Impl>::readFloatRegBits(int reg_idx)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileReads++;
|
2006-03-14 21:55:00 +01:00
|
|
|
return regFile.readFloatRegBits(reg_idx);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
template <class Impl>
|
|
|
|
CCReg
|
|
|
|
FullO3CPU<Impl>::readCCReg(int reg_idx)
|
|
|
|
{
|
|
|
|
ccRegfileReads++;
|
|
|
|
return regFile.readCCReg(reg_idx);
|
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::setIntReg(int reg_idx, uint64_t val)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
intRegfileWrites++;
|
2004-08-20 20:54:07 +02:00
|
|
|
regFile.setIntReg(reg_idx, val);
|
|
|
|
}
|
|
|
|
|
2006-03-14 21:55:00 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::setFloatReg(int reg_idx, FloatReg val)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileWrites++;
|
2006-03-14 21:55:00 +01:00
|
|
|
regFile.setFloatReg(reg_idx, val);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2006-03-14 21:55:00 +01:00
|
|
|
FullO3CPU<Impl>::setFloatRegBits(int reg_idx, FloatRegBits val)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileWrites++;
|
2006-03-14 21:55:00 +01:00
|
|
|
regFile.setFloatRegBits(reg_idx, val);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::setCCReg(int reg_idx, CCReg val)
|
|
|
|
{
|
|
|
|
ccRegfileWrites++;
|
|
|
|
regFile.setCCReg(reg_idx, val);
|
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
uint64_t
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::readArchIntReg(int reg_idx, ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
intRegfileReads++;
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupInt(reg_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
return regFile.readIntReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
float
|
2009-07-09 08:02:20 +02:00
|
|
|
FullO3CPU<Impl>::readArchFloatReg(int reg_idx, ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileReads++;
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupFloat(reg_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
return regFile.readFloatReg(phys_reg);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
uint64_t
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::readArchFloatRegInt(int reg_idx, ThreadID tid)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileReads++;
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupFloat(reg_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
return regFile.readFloatRegBits(phys_reg);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
template <class Impl>
|
|
|
|
CCReg
|
|
|
|
FullO3CPU<Impl>::readArchCCReg(int reg_idx, ThreadID tid)
|
|
|
|
{
|
|
|
|
ccRegfileReads++;
|
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupCC(reg_idx);
|
|
|
|
|
|
|
|
return regFile.readCCReg(phys_reg);
|
|
|
|
}
|
|
|
|
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::setArchIntReg(int reg_idx, uint64_t val, ThreadID tid)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
intRegfileWrites++;
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupInt(reg_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
regFile.setIntReg(phys_reg, val);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-07-09 08:02:20 +02:00
|
|
|
FullO3CPU<Impl>::setArchFloatReg(int reg_idx, float val, ThreadID tid)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileWrites++;
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupFloat(reg_idx);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
regFile.setFloatReg(phys_reg, val);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::setArchFloatRegInt(int reg_idx, uint64_t val, ThreadID tid)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2011-02-07 07:14:17 +01:00
|
|
|
fpRegfileWrites++;
|
2013-10-15 20:22:44 +02:00
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupFloat(reg_idx);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
regFile.setFloatRegBits(phys_reg, val);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 20:22:44 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::setArchCCReg(int reg_idx, CCReg val, ThreadID tid)
|
|
|
|
{
|
|
|
|
ccRegfileWrites++;
|
|
|
|
PhysRegIndex phys_reg = commitRenameMap[tid].lookupCC(reg_idx);
|
|
|
|
|
|
|
|
regFile.setCCReg(phys_reg, val);
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
TheISA::PCState
|
|
|
|
FullO3CPU<Impl>::pcState(ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
return commit.pcState(tid);
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
FullO3CPU<Impl>::pcState(const TheISA::PCState &val, ThreadID tid)
|
2007-04-14 19:13:18 +02:00
|
|
|
{
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
commit.pcState(val, tid);
|
2007-04-14 19:13:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
Addr
|
|
|
|
FullO3CPU<Impl>::instAddr(ThreadID tid)
|
2007-04-14 19:13:18 +02:00
|
|
|
{
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
return commit.instAddr(tid);
|
2007-04-14 19:13:18 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
Addr
|
|
|
|
FullO3CPU<Impl>::nextInstAddr(ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
return commit.nextInstAddr(tid);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
MicroPC
|
|
|
|
FullO3CPU<Impl>::microPC(ThreadID tid)
|
2007-04-14 19:13:18 +02:00
|
|
|
{
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
return commit.microPC(tid);
|
2007-04-14 19:13:18 +02:00
|
|
|
}
|
|
|
|
|
2008-10-09 09:08:50 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::squashFromTC(ThreadID tid)
|
2008-10-09 09:08:50 +02:00
|
|
|
{
|
2013-01-07 19:05:33 +01:00
|
|
|
this->thread[tid]->noSquashFromTC = true;
|
2008-10-09 09:08:50 +02:00
|
|
|
this->commit.generateTCEvent(tid);
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
typename FullO3CPU<Impl>::ListIt
|
|
|
|
FullO3CPU<Impl>::addInst(DynInstPtr &inst)
|
|
|
|
{
|
|
|
|
instList.push_back(inst);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
return --(instList.end());
|
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2012-02-12 23:07:39 +01:00
|
|
|
FullO3CPU<Impl>::instDone(ThreadID tid, DynInstPtr &inst)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
|
|
|
// Keep an instruction count.
|
2012-02-12 23:07:39 +01:00
|
|
|
if (!inst->isMicroop() || inst->isLastMicroop()) {
|
|
|
|
thread[tid]->numInst++;
|
|
|
|
thread[tid]->numInsts++;
|
|
|
|
committedInsts[tid]++;
|
2015-04-03 18:42:10 +02:00
|
|
|
system->totalNumInsts++;
|
|
|
|
|
|
|
|
// Check for instruction-count-based events.
|
|
|
|
comInstEventQueue[tid]->serviceEvents(thread[tid]->numInst);
|
|
|
|
system->instEventQueue.serviceEvents(system->totalNumInsts);
|
2012-02-12 23:07:39 +01:00
|
|
|
}
|
|
|
|
thread[tid]->numOp++;
|
|
|
|
thread[tid]->numOps++;
|
|
|
|
committedOps[tid]++;
|
|
|
|
|
2014-10-16 11:49:41 +02:00
|
|
|
probeInstCommit(inst->staticInst);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::removeFrontInst(DynInstPtr &inst)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
DPRINTF(O3CPU, "Removing committed instruction [tid:%i] PC %s "
|
2006-04-23 00:26:48 +02:00
|
|
|
"[sn:%lli]\n",
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
inst->threadNumber, inst->pcState(), inst->seqNum);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
removeInstsThisCycle = true;
|
2004-08-20 20:54:07 +02:00
|
|
|
|
|
|
|
// Remove the front instruction.
|
2006-04-23 00:26:48 +02:00
|
|
|
removeList.push(inst->getInstListIt());
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::removeInstsNotInROB(ThreadID tid)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "Thread %i: Deleting instructions from instruction"
|
2006-04-23 00:26:48 +02:00
|
|
|
" list.\n", tid);
|
|
|
|
|
|
|
|
ListIt end_it;
|
|
|
|
|
|
|
|
bool rob_empty = false;
|
|
|
|
|
|
|
|
if (instList.empty()) {
|
|
|
|
return;
|
2014-04-19 16:00:30 +02:00
|
|
|
} else if (rob.isEmpty(tid)) {
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "ROB is empty, squashing all insts.\n");
|
2006-04-23 00:26:48 +02:00
|
|
|
end_it = instList.begin();
|
|
|
|
rob_empty = true;
|
|
|
|
} else {
|
|
|
|
end_it = (rob.readTailInst(tid))->getInstListIt();
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "ROB is not empty, squashing insts not in ROB.\n");
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
removeInstsThisCycle = true;
|
|
|
|
|
|
|
|
ListIt inst_it = instList.end();
|
|
|
|
|
|
|
|
inst_it--;
|
|
|
|
|
|
|
|
// Walk through the instruction list, removing any instructions
|
|
|
|
// that were inserted after the given instruction iterator, end_it.
|
|
|
|
while (inst_it != end_it) {
|
|
|
|
assert(!instList.empty());
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
squashInstIt(inst_it, tid);
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
inst_it--;
|
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// If the ROB was empty, then we actually need to remove the first
|
|
|
|
// instruction as well.
|
|
|
|
if (rob_empty) {
|
|
|
|
squashInstIt(inst_it, tid);
|
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
}
|
|
|
|
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid)
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
{
|
2006-04-23 00:26:48 +02:00
|
|
|
assert(!instList.empty());
|
|
|
|
|
|
|
|
removeInstsThisCycle = true;
|
|
|
|
|
|
|
|
ListIt inst_iter = instList.end();
|
|
|
|
|
|
|
|
inst_iter--;
|
|
|
|
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "Deleting instructions from instruction "
|
2006-04-23 00:26:48 +02:00
|
|
|
"list that are from [tid:%i] and above [sn:%lli] (end=%lli).\n",
|
|
|
|
tid, seq_num, (*inst_iter)->seqNum);
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
while ((*inst_iter)->seqNum > seq_num) {
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
bool break_loop = (inst_iter == instList.begin());
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
squashInstIt(inst_iter, tid);
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
inst_iter--;
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
if (break_loop)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
inline void
|
2009-05-26 18:23:13 +02:00
|
|
|
FullO3CPU<Impl>::squashInstIt(const ListIt &instIt, ThreadID tid)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
|
|
|
if ((*instIt)->threadNumber == tid) {
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "Squashing instruction, "
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
"[tid:%i] [sn:%lli] PC %s\n",
|
2006-04-23 00:26:48 +02:00
|
|
|
(*instIt)->threadNumber,
|
|
|
|
(*instIt)->seqNum,
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
(*instIt)->pcState());
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
|
|
|
// Mark it as squashed.
|
2006-04-23 00:26:48 +02:00
|
|
|
(*instIt)->setSquashed();
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
|
2006-05-19 21:37:52 +02:00
|
|
|
// @todo: Formulate a consistent method for deleting
|
|
|
|
// instructions from the instruction list
|
2006-04-23 00:26:48 +02:00
|
|
|
// Remove the instruction from the list.
|
|
|
|
removeList.push(instIt);
|
|
|
|
}
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::cleanUpRemovedInsts()
|
|
|
|
{
|
|
|
|
while (!removeList.empty()) {
|
2006-06-16 23:08:47 +02:00
|
|
|
DPRINTF(O3CPU, "Removing instruction, "
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
"[tid:%i] [sn:%lli] PC %s\n",
|
2006-04-23 00:26:48 +02:00
|
|
|
(*removeList.front())->threadNumber,
|
|
|
|
(*removeList.front())->seqNum,
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
(*removeList.front())->pcState());
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
instList.erase(removeList.front());
|
|
|
|
|
|
|
|
removeList.pop();
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
removeInstsThisCycle = false;
|
Check in of various updates to the CPU. Mainly adds in stats, improves
branch prediction, and makes memory dependence work properly.
SConscript:
Added return address stack, tournament predictor.
cpu/base_cpu.cc:
Added debug break and print statements.
cpu/base_dyn_inst.cc:
cpu/base_dyn_inst.hh:
Comment out possibly unneeded variables.
cpu/beta_cpu/2bit_local_pred.cc:
2bit predictor no longer speculatively updates itself.
cpu/beta_cpu/alpha_dyn_inst.hh:
Comment formatting.
cpu/beta_cpu/alpha_full_cpu.hh:
Formatting
cpu/beta_cpu/alpha_full_cpu_builder.cc:
Added new parameters for branch predictors, and IQ parameters.
cpu/beta_cpu/alpha_full_cpu_impl.hh:
Register stats.
cpu/beta_cpu/alpha_params.hh:
Added parameters for IQ, branch predictors, and store sets.
cpu/beta_cpu/bpred_unit.cc:
Removed one class.
cpu/beta_cpu/bpred_unit.hh:
Add in RAS, stats. Changed branch predictor unit functionality
so that it holds a history of past branches so it can update, and also
hold a proper history of the RAS so it can be restored on branch
mispredicts.
cpu/beta_cpu/bpred_unit_impl.hh:
Added in stats, history of branches, RAS. Now bpred unit actually
modifies the instruction's predicted next PC.
cpu/beta_cpu/btb.cc:
Add in sanity checks.
cpu/beta_cpu/comm.hh:
Add in communication where needed, remove it where it's not.
cpu/beta_cpu/commit.hh:
cpu/beta_cpu/rename.hh:
cpu/beta_cpu/rename_impl.hh:
Add in stats.
cpu/beta_cpu/commit_impl.hh:
Stats, update what is sent back on branch mispredict.
cpu/beta_cpu/cpu_policy.hh:
Change the bpred unit being used.
cpu/beta_cpu/decode.hh:
cpu/beta_cpu/decode_impl.hh:
Stats.
cpu/beta_cpu/fetch.hh:
Stats, change squash so it can handle squashes from decode differently
than squashes from commit.
cpu/beta_cpu/fetch_impl.hh:
Add in stats. Change how a cache line is fetched. Update to work with
caches. Also have separate functions for different behavior if squash
is coming from decode vs commit.
cpu/beta_cpu/free_list.hh:
Remove some old comments.
cpu/beta_cpu/full_cpu.cc:
cpu/beta_cpu/full_cpu.hh:
Added function to remove instructions from back of instruction list
until a certain sequence number.
cpu/beta_cpu/iew.hh:
Stats, separate squashing behavior due to branches vs memory.
cpu/beta_cpu/iew_impl.hh:
Stats, separate squashing behavior for branches vs memory.
cpu/beta_cpu/inst_queue.cc:
Debug stuff
cpu/beta_cpu/inst_queue.hh:
Stats, change how mem dep unit works, debug stuff
cpu/beta_cpu/inst_queue_impl.hh:
Stats, change how mem dep unit works, debug stuff. Also add in
parameters that used to be hardcoded.
cpu/beta_cpu/mem_dep_unit.hh:
cpu/beta_cpu/mem_dep_unit_impl.hh:
Add in stats, change how memory dependence unit works. It now holds
the memory instructions that are waiting for their memory dependences
to resolve. It provides which instructions are ready directly to the
IQ.
cpu/beta_cpu/regfile.hh:
Fix up sanity checks.
cpu/beta_cpu/rename_map.cc:
Fix loop variable type.
cpu/beta_cpu/rob_impl.hh:
Remove intermediate DynInstPtr
cpu/beta_cpu/store_set.cc:
Add in debugging statements.
cpu/beta_cpu/store_set.hh:
Reorder function arguments to match the rest of the calls.
--HG--
extra : convert_revision : aabf9b1fecd1d743265dfc3b174d6159937c6f44
2004-10-22 00:02:36 +02:00
|
|
|
}
|
2006-05-19 21:37:52 +02:00
|
|
|
/*
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::removeAllInsts()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
|
|
|
instList.clear();
|
|
|
|
}
|
2006-05-19 21:37:52 +02:00
|
|
|
*/
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::dumpInsts()
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
|
|
|
int num = 0;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
ListIt inst_list_it = instList.begin();
|
|
|
|
|
|
|
|
cprintf("Dumping Instruction List\n");
|
|
|
|
|
|
|
|
while (inst_list_it != instList.end()) {
|
|
|
|
cprintf("Instruction:%i\nPC:%#x\n[tid:%i]\n[sn:%lli]\nIssued:%i\n"
|
|
|
|
"Squashed:%i\n\n",
|
ISA,CPU,etc: Create an ISA defined PC type that abstracts out ISA behaviors.
This change is a low level and pervasive reorganization of how PCs are managed
in M5. Back when Alpha was the only ISA, there were only 2 PCs to worry about,
the PC and the NPC, and the lsb of the PC signaled whether or not you were in
PAL mode. As other ISAs were added, we had to add an NNPC, micro PC and next
micropc, x86 and ARM introduced variable length instruction sets, and ARM
started to keep track of mode bits in the PC. Each CPU model handled PCs in
its own custom way that needed to be updated individually to handle the new
dimensions of variability, or, in the case of ARMs mode-bit-in-the-pc hack,
the complexity could be hidden in the ISA at the ISA implementation's expense.
Areas like the branch predictor hadn't been updated to handle branch delay
slots or micropcs, and it turns out that had introduced a significant (10s of
percent) performance bug in SPARC and to a lesser extend MIPS. Rather than
perpetuate the problem by reworking O3 again to handle the PC features needed
by x86, this change was introduced to rework PC handling in a more modular,
transparent, and hopefully efficient way.
PC type:
Rather than having the superset of all possible elements of PC state declared
in each of the CPU models, each ISA defines its own PCState type which has
exactly the elements it needs. A cross product of canned PCState classes are
defined in the new "generic" ISA directory for ISAs with/without delay slots
and microcode. These are either typedef-ed or subclassed by each ISA. To read
or write this structure through a *Context, you use the new pcState() accessor
which reads or writes depending on whether it has an argument. If you just
want the address of the current or next instruction or the current micro PC,
you can get those through read-only accessors on either the PCState type or
the *Contexts. These are instAddr(), nextInstAddr(), and microPC(). Note the
move away from readPC. That name is ambiguous since it's not clear whether or
not it should be the actual address to fetch from, or if it should have extra
bits in it like the PAL mode bit. Each class is free to define its own
functions to get at whatever values it needs however it needs to to be used in
ISA specific code. Eventually Alpha's PAL mode bit could be moved out of the
PC and into a separate field like ARM.
These types can be reset to a particular pc (where npc = pc +
sizeof(MachInst), nnpc = npc + sizeof(MachInst), upc = 0, nupc = 1 as
appropriate), printed, serialized, and compared. There is a branching()
function which encapsulates code in the CPU models that checked if an
instruction branched or not. Exactly what that means in the context of branch
delay slots which can skip an instruction when not taken is ambiguous, and
ideally this function and its uses can be eliminated. PCStates also generally
know how to advance themselves in various ways depending on if they point at
an instruction, a microop, or the last microop of a macroop. More on that
later.
Ideally, accessing all the PCs at once when setting them will improve
performance of M5 even though more data needs to be moved around. This is
because often all the PCs need to be manipulated together, and by getting them
all at once you avoid multiple function calls. Also, the PCs of a particular
thread will have spatial locality in the cache. Previously they were grouped
by element in arrays which spread out accesses.
Advancing the PC:
The PCs were previously managed entirely by the CPU which had to know about PC
semantics, try to figure out which dimension to increment the PC in, what to
set NPC/NNPC, etc. These decisions are best left to the ISA in conjunction
with the PC type itself. Because most of the information about how to
increment the PC (mainly what type of instruction it refers to) is contained
in the instruction object, a new advancePC virtual function was added to the
StaticInst class. Subclasses provide an implementation that moves around the
right element of the PC with a minimal amount of decision making. In ISAs like
Alpha, the instructions always simply assign NPC to PC without having to worry
about micropcs, nnpcs, etc. The added cost of a virtual function call should
be outweighed by not having to figure out as much about what to do with the
PCs and mucking around with the extra elements.
One drawback of making the StaticInsts advance the PC is that you have to
actually have one to advance the PC. This would, superficially, seem to
require decoding an instruction before fetch could advance. This is, as far as
I can tell, realistic. fetch would advance through memory addresses, not PCs,
perhaps predicting new memory addresses using existing ones. More
sophisticated decisions about control flow would be made later on, after the
instruction was decoded, and handed back to fetch. If branching needs to
happen, some amount of decoding needs to happen to see that it's a branch,
what the target is, etc. This could get a little more complicated if that gets
done by the predecoder, but I'm choosing to ignore that for now.
Variable length instructions:
To handle variable length instructions in x86 and ARM, the predecoder now
takes in the current PC by reference to the getExtMachInst function. It can
modify the PC however it needs to (by setting NPC to be the PC + instruction
length, for instance). This could be improved since the CPU doesn't know if
the PC was modified and always has to write it back.
ISA parser:
To support the new API, all PC related operand types were removed from the
parser and replaced with a PCState type. There are two warts on this
implementation. First, as with all the other operand types, the PCState still
has to have a valid operand type even though it doesn't use it. Second, using
syntax like PCS.npc(target) doesn't work for two reasons, this looks like the
syntax for operand type overriding, and the parser can't figure out if you're
reading or writing. Instructions that use the PCS operand (which I've
consistently called it) need to first read it into a local variable,
manipulate it, and then write it back out.
Return address stack:
The return address stack needed a little extra help because, in the presence
of branch delay slots, it has to merge together elements of the return PC and
the call PC. To handle that, a buildRetPC utility function was added. There
are basically only two versions in all the ISAs, but it didn't seem short
enough to put into the generic ISA directory. Also, the branch predictor code
in O3 and InOrder were adjusted so that they always store the PC of the actual
call instruction in the RAS, not the next PC. If the call instruction is a
microop, the next PC refers to the next microop in the same macroop which is
probably not desirable. The buildRetPC function advances the PC intelligently
to the next macroop (in an ISA specific way) so that that case works.
Change in stats:
There were no change in stats except in MIPS and SPARC in the O3 model. MIPS
runs in about 9% fewer ticks. SPARC runs with 30%-50% fewer ticks, which could
likely be improved further by setting call/return instruction flags and taking
advantage of the RAS.
TODO:
Add != operators to the PCState classes, defined trivially to be !(a==b).
Smooth out places where PCs are split apart, passed around, and put back
together later. I think this might happen in SPARC's fault code. Add ISA
specific constructors that allow setting PC elements without calling a bunch
of accessors. Try to eliminate the need for the branching() function. Factor
out Alpha's PAL mode pc bit into a separate flag field, and eliminate places
where it's blindly masked out or tested in the PC.
2010-10-31 08:07:20 +01:00
|
|
|
num, (*inst_list_it)->instAddr(), (*inst_list_it)->threadNumber,
|
2006-04-23 00:26:48 +02:00
|
|
|
(*inst_list_it)->seqNum, (*inst_list_it)->isIssued(),
|
|
|
|
(*inst_list_it)->isSquashed());
|
2004-08-20 20:54:07 +02:00
|
|
|
inst_list_it++;
|
|
|
|
++num;
|
|
|
|
}
|
|
|
|
}
|
2006-05-19 21:37:52 +02:00
|
|
|
/*
|
2004-08-20 20:54:07 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
2005-06-05 09:25:26 +02:00
|
|
|
FullO3CPU<Impl>::wakeDependents(DynInstPtr &inst)
|
2004-08-20 20:54:07 +02:00
|
|
|
{
|
|
|
|
iew.wakeDependents(inst);
|
|
|
|
}
|
2006-05-19 21:37:52 +02:00
|
|
|
*/
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::wakeCPU()
|
|
|
|
{
|
2006-05-19 21:37:52 +02:00
|
|
|
if (activityRec.active() || tickEvent.scheduled()) {
|
|
|
|
DPRINTF(Activity, "CPU already running.\n");
|
2006-04-23 00:26:48 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:37:52 +02:00
|
|
|
DPRINTF(Activity, "Waking up CPU\n");
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2012-08-28 20:30:33 +02:00
|
|
|
Cycles cycles(curCycle() - lastRunningCycle);
|
|
|
|
// @todo: This is an oddity that is only here to match the stats
|
2014-10-16 11:49:41 +02:00
|
|
|
if (cycles > 1) {
|
2012-08-28 20:30:31 +02:00
|
|
|
--cycles;
|
2014-10-16 11:49:41 +02:00
|
|
|
idleCycles += cycles;
|
|
|
|
numCycles += cycles;
|
|
|
|
ppCycles->notify(cycles);
|
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2013-04-22 19:20:31 +02:00
|
|
|
schedule(tickEvent, clockEdge());
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2009-01-24 16:27:21 +01:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::wakeup()
|
|
|
|
{
|
|
|
|
if (this->thread[0]->status() != ThreadContext::Suspended)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this->wakeCPU();
|
|
|
|
|
|
|
|
DPRINTF(Quiesce, "Suspended Processor woken\n");
|
|
|
|
this->threadContexts[0]->activate();
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
2009-05-26 18:23:13 +02:00
|
|
|
ThreadID
|
2006-04-23 00:26:48 +02:00
|
|
|
FullO3CPU<Impl>::getFreeTid()
|
|
|
|
{
|
2009-05-26 18:23:13 +02:00
|
|
|
for (ThreadID tid = 0; tid < numThreads; tid++) {
|
|
|
|
if (!tids[tid]) {
|
|
|
|
tids[tid] = true;
|
|
|
|
return tid;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 18:23:13 +02:00
|
|
|
return InvalidThreadID;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
FullO3CPU<Impl>::updateThreadPriority()
|
|
|
|
{
|
2009-05-26 18:23:13 +02:00
|
|
|
if (activeThreads.size() > 1) {
|
2006-04-23 00:26:48 +02:00
|
|
|
//DEFAULT TO ROUND ROBIN SCHEME
|
|
|
|
//e.g. Move highest priority to end of thread list
|
2009-05-26 18:23:13 +02:00
|
|
|
list<ThreadID>::iterator list_begin = activeThreads.begin();
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
unsigned high_thread = *list_begin;
|
|
|
|
|
|
|
|
activeThreads.erase(list_begin);
|
|
|
|
|
|
|
|
activeThreads.push_back(high_thread);
|
|
|
|
}
|
|
|
|
}
|
2004-08-20 20:54:07 +02:00
|
|
|
|
2005-06-05 09:25:26 +02:00
|
|
|
// Forward declaration of FullO3CPU.
|
2006-07-01 02:49:31 +02:00
|
|
|
template class FullO3CPU<O3CPUImpl>;
|