gem5 v24.0.0.0
Loading...
Searching...
No Matches
simple_thread.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018, 2020 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2001-2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#include "cpu/simple_thread.hh"
42
43#include <string>
44
46#include "base/callback.hh"
47#include "base/compiler.hh"
48#include "base/cprintf.hh"
49#include "base/output.hh"
50#include "base/trace.hh"
51#include "cpu/base.hh"
52#include "cpu/simple/base.hh"
53#include "cpu/thread_context.hh"
56#include "params/BaseCPU.hh"
57#include "sim/faults.hh"
58#include "sim/full_system.hh"
59#include "sim/process.hh"
60#include "sim/serialize.hh"
61#include "sim/sim_exit.hh"
62#include "sim/system.hh"
63
64namespace gem5
65{
66
67// constructor
68SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys,
69 Process *_process, BaseMMU *_mmu,
70 BaseISA *_isa, InstDecoder *_decoder)
71 : ThreadState(_cpu, _thread_num, _process),
72 regFiles{{
73 {*_isa->regClasses().at(IntRegClass)},
74 {*_isa->regClasses().at(FloatRegClass)},
75 {*_isa->regClasses().at(VecRegClass)},
76 {*_isa->regClasses().at(VecElemClass)},
77 {*_isa->regClasses().at(VecPredRegClass)},
78 {*_isa->regClasses().at(MatRegClass)},
79 {*_isa->regClasses().at(CCRegClass)}
80 }},
81 isa(_isa),
82 predicate(true), memAccPredicate(true),
83 comInstEventQueue("instruction-based event queue"),
84 system(_sys), mmu(_mmu), decoder(_decoder),
85 htmTransactionStarts(0), htmTransactionStops(0)
86{
87 clearArchRegs();
88}
89
90SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys,
91 BaseMMU *_mmu, BaseISA *_isa, InstDecoder *_decoder)
92 : SimpleThread(_cpu, _thread_num, _sys, nullptr, _mmu, _isa, _decoder)
93{}
94
95void
97{
98 gem5::takeOverFrom(*this, *oldContext);
99 decoder->takeOverFrom(oldContext->getDecoderPtr());
100
101 isa->takeOverFrom(this, oldContext);
102
104}
105
106void
108{
109 // copy over functional state
110 _status = oldContext->status();
111 copyArchRegs(oldContext);
112
113 _threadId = oldContext->threadId();
114 _contextId = oldContext->contextId();
115}
116
117void
123
124
125void
131
132void
142
143void
154
155
156void
165
166void
171
172// hardware transactional memory
173void
175{
176 baseCpu->htmSendAbortSignal(threadId(), htm_uid, cause);
177
178 // these must be reset after the abort signal has been sent
181}
182
188
189void
191{
192 _htmCheckpoint = std::move(new_cpt);
193}
194
195} // namespace gem5
virtual void haltContext(ThreadID thread_num)
Notify the CPU that the indicated context is now halted.
Definition base.cc:576
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
Definition base.cc:550
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
Definition base.cc:530
virtual void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid, HtmFailureFaultCause cause)
This function is used to instruct the memory subsystem that a transaction should be aborted and the s...
Definition base.hh:673
const RegClasses & regClasses() const
Definition isa.hh:93
virtual void copyRegsFrom(ThreadContext *src)=0
virtual void takeOverFrom(ThreadContext *new_tc, ThreadContext *old_tc)
Definition isa.hh:84
virtual void takeOverFrom(InstDecoder *old)
Take over the state from an old decoder when switching CPUs.
Definition decoder.hh:89
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
int threadId() const override
void serialize(CheckpointOut &cp) const override
Serialize an object.
Status status() const override
void suspend() override
Set the status to Suspended.
void setHtmCheckpointPtr(BaseHTMCheckpointPtr new_cpt) override
void activate() override
Set the status to Active.
void copyState(ThreadContext *oldContext)
void copyArchRegs(ThreadContext *tc) override
void unserialize(CheckpointIn &cp) override
Unserialize an object.
BaseISA *const isa
void takeOverFrom(ThreadContext *oldContext) override
BaseHTMCheckpointPtr & getHtmCheckpointPtr() override
std::unique_ptr< BaseHTMCheckpoint > _htmCheckpoint
InstDecoder * decoder
void htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause) override
void halt() override
Set the status to Halted.
SimpleThread(BaseCPU *_cpu, int _thread_num, System *_system, BaseMMU *_mmu, BaseISA *_isa, InstDecoder *_decoder)
BaseISA * getIsaPtr() const override
ThreadContext is the external interface to all thread state for anything outside of the CPU.
@ Halted
Permanently shut down.
@ Suspended
Temporarily inactive.
virtual InstDecoder * getDecoderPtr()=0
virtual int threadId() const =0
virtual Status status() const =0
virtual ContextID contextId() const =0
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
std::ostream CheckpointOut
Definition serialize.hh:66
void unserialize(ThreadContext &tc, CheckpointIn &cp)
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
std::unique_ptr< BaseHTMCheckpoint > BaseHTMCheckpointPtr
Definition htm.hh:127
HtmFailureFaultCause
Definition htm.hh:48
@ VecPredRegClass
Definition reg_class.hh:67
@ MatRegClass
Matrix Register.
Definition reg_class.hh:68
@ FloatRegClass
Floating-point register.
Definition reg_class.hh:62
@ CCRegClass
Condition-code register.
Definition reg_class.hh:69
@ VecRegClass
Vector Register.
Definition reg_class.hh:64
@ IntRegClass
Integer register.
Definition reg_class.hh:61
@ VecElemClass
Vector Register Native Elem lane.
Definition reg_class.hh:66
output decoder
Definition nop.cc:61
Struct for holding general thread state that is needed across CPU models.
void serialize(CheckpointOut &cp) const override
Serialize an object.
unsigned storeCondFailures
ThreadContext::Status _status
Tick lastSuspend
Last time suspend was called on this thread.
Tick lastActivate
Last time activate was called on this thread.
void unserialize(CheckpointIn &cp) override
Unserialize an object.

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0