gem5 v24.0.0.0
Loading...
Searching...
No Matches
ALUFreeListArray.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 The University of Wisconsin
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
31
32#include "base/intmath.hh"
34#include "sim/cur_tick.hh"
35
36namespace gem5
37{
38
39namespace ruby
40{
41
42/*
43*
44* Models num_ALUs pipelined atomic ALUs with a depth of access_latency ticks.
45* Rather than reserving ALUs, this class assumes multiple requests can go
46* through an ALU at the same time. As such, up to numALU new requests can
47* go through at once, with the caveat that a line already being processed
48* in an ALU can't start processing again until the previous request has exited
49* the pipeline.
50*
51* ALUs aren't mapped directly to cache lines. Rather, ALUs are treated as
52* a free list.
53*
54* Behavior:
55* Requests will go through unless one/both of the following are met:
56* - There have been more than [numALUs] requests in the current cycle
57* - The same line has been accessed in the past accessLatency ticks
58*/
59
60ALUFreeListArray::ALUFreeListArray(unsigned int num_ALUs, Tick access_latency)
61{
62 this->numALUs = num_ALUs;
63 this->accessLatency = access_latency;
64}
65
67{
68 uint32_t accesses_this_tick = 0;
69
70 // Remove requests from the tail of the queue that occured more than
71 // accessLatency ticks ago
72 Tick oldestValidRecordStart = curTick() - this->accessLatency;
73
74 while (accessQueue.size() > 0 &&
75 (accessQueue.back().startTick < oldestValidRecordStart)) {
76 accessQueue.pop_back();
77 }
78
79 for (AccessRecord& record : accessQueue) {
80 // Block access if we would be using more ALUs than we have in a
81 // single tick
82 if (record.startTick == curTick() &&
83 (++accesses_this_tick > numALUs)) {
84 return false;
85 }
86
87 // Block access if the line is already being used
88 if (record.lineAddr == makeLineAddress(addr)) {
89 return false;
90 }
91 }
92
93 return true;
94}
95
97{
98 // Only called after tryAccess, so we know queue is up to date and that
99 // the access is valid
100
101 // Add record to queue
103}
104
105} // namespace ruby
106} // namespace gem5
ALUFreeListArray(unsigned int num_ALUs, Tick access_latency)
std::deque< AccessRecord > accessQueue
Bitfield< 3 > addr
Definition types.hh:84
Addr makeLineAddress(Addr addr)
Definition Address.cc:60
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
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58

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