Skip to content

Commit ac16df9

Browse files
committed
feat: integrate RiscvBebopInOCPU into gem5
1 parent 14e501c commit ac16df9

File tree

4 files changed

+166
-11
lines changed

4 files changed

+166
-11
lines changed

host/gem5/BebopInOCPU/BaseBebopInOCPU.py

Lines changed: 160 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,170 @@
44
from m5.objects.DummyChecker import DummyChecker
55
from m5.objects.FuncUnit import OpClass
66
from m5.objects.TimingExpr import TimingExpr
7+
from m5.objects.BebopInOFU import (
8+
BebopInOOpClass,
9+
BebopInOOpClassSet,
10+
BebopInOFUTiming,
11+
BebopInOFU,
12+
BebopInOFUPool,
13+
)
714
from m5.params import *
815
from m5.proxy import *
916
from m5.SimObject import SimObject
1017

1118

19+
def bebopMakeOpClassSet(op_classes):
20+
def boxOpClass(op_class):
21+
return BebopInOOpClass(opClass=op_class)
22+
23+
return BebopInOOpClassSet(opClasses=[boxOpClass(o) for o in op_classes])
24+
25+
26+
class BebopInODefaultIntFU(BebopInOFU):
27+
opClasses = bebopMakeOpClassSet(["IntAlu"])
28+
timings = [BebopInOFUTiming(description="Int", srcRegsRelativeLats=[2])]
29+
opLat = 3
30+
31+
32+
class BebopInODefaultIntMulFU(BebopInOFU):
33+
opClasses = bebopMakeOpClassSet(["IntMult"])
34+
timings = [BebopInOFUTiming(description="Mul", srcRegsRelativeLats=[0])]
35+
opLat = 3
36+
37+
38+
class BebopInODefaultIntDivFU(BebopInOFU):
39+
opClasses = bebopMakeOpClassSet(["IntDiv"])
40+
issueLat = 9
41+
opLat = 9
42+
43+
44+
class BebopInODefaultFloatSimdFU(BebopInOFU):
45+
opClasses = bebopMakeOpClassSet(
46+
[
47+
"FloatAdd",
48+
"FloatCmp",
49+
"FloatCvt",
50+
"FloatMisc",
51+
"FloatMult",
52+
"FloatMultAcc",
53+
"FloatDiv",
54+
"FloatSqrt",
55+
"Bf16Cvt",
56+
"SimdAdd",
57+
"SimdAddAcc",
58+
"SimdAlu",
59+
"SimdCmp",
60+
"SimdCvt",
61+
"SimdMisc",
62+
"SimdMult",
63+
"SimdMultAcc",
64+
"SimdMatMultAcc",
65+
"SimdShift",
66+
"SimdShiftAcc",
67+
"SimdDiv",
68+
"SimdSqrt",
69+
"SimdFloatAdd",
70+
"SimdFloatAlu",
71+
"SimdFloatCmp",
72+
"SimdFloatCvt",
73+
"SimdFloatDiv",
74+
"SimdFloatMisc",
75+
"SimdFloatMult",
76+
"SimdFloatMultAcc",
77+
"SimdFloatMatMultAcc",
78+
"SimdFloatSqrt",
79+
"SimdReduceAdd",
80+
"SimdReduceAlu",
81+
"SimdReduceCmp",
82+
"SimdFloatReduceAdd",
83+
"SimdFloatReduceCmp",
84+
"SimdAes",
85+
"SimdAesMix",
86+
"SimdSha1Hash",
87+
"SimdSha1Hash2",
88+
"SimdSha256Hash",
89+
"SimdSha256Hash2",
90+
"SimdShaSigma2",
91+
"SimdShaSigma3",
92+
"SimdSha3",
93+
"SimdSm4e",
94+
"SimdCrc",
95+
"Matrix",
96+
"MatrixMov",
97+
"MatrixOP",
98+
"SimdExt",
99+
"SimdFloatExt",
100+
"SimdFloatCvt",
101+
"SimdConfig",
102+
"SimdDotProd",
103+
"SimdBf16Add",
104+
"SimdBf16Cmp",
105+
"SimdBf16Cvt",
106+
"SimdBf16DotProd",
107+
"SimdBf16MatMultAcc",
108+
"SimdBf16Mult",
109+
"SimdBf16MultAcc",
110+
]
111+
)
112+
113+
timings = [
114+
BebopInOFUTiming(description="FloatSimd", srcRegsRelativeLats=[2])
115+
]
116+
opLat = 6
117+
118+
119+
class BebopInODefaultPredFU(BebopInOFU):
120+
opClasses = bebopMakeOpClassSet(["SimdPredAlu"])
121+
timings = [BebopInOFUTiming(description="Pred", srcRegsRelativeLats=[2])]
122+
opLat = 3
123+
124+
125+
class BebopInODefaultMemFU(BebopInOFU):
126+
opClasses = bebopMakeOpClassSet(
127+
[
128+
"MemRead",
129+
"MemWrite",
130+
"FloatMemRead",
131+
"FloatMemWrite",
132+
"SimdUnitStrideLoad",
133+
"SimdUnitStrideStore",
134+
"SimdUnitStrideMaskLoad",
135+
"SimdUnitStrideMaskStore",
136+
"SimdStridedLoad",
137+
"SimdStridedStore",
138+
"SimdIndexedLoad",
139+
"SimdIndexedStore",
140+
"SimdUnitStrideFaultOnlyFirstLoad",
141+
"SimdWholeRegisterLoad",
142+
"SimdWholeRegisterStore",
143+
]
144+
)
145+
timings = [
146+
BebopInOFUTiming(
147+
description="Mem", srcRegsRelativeLats=[1], extraAssumedLat=2
148+
)
149+
]
150+
opLat = 1
151+
152+
153+
class BebopInODefaultMiscFU(BebopInOFU):
154+
opClasses = bebopMakeOpClassSet(["InstPrefetch", "System"])
155+
opLat = 1
156+
157+
158+
class BebopInODefaultFUPool(BebopInOFUPool):
159+
funcUnits = [
160+
BebopInODefaultIntFU(),
161+
BebopInODefaultIntFU(),
162+
BebopInODefaultIntMulFU(),
163+
BebopInODefaultIntDivFU(),
164+
BebopInODefaultFloatSimdFU(),
165+
BebopInODefaultPredFU(),
166+
BebopInODefaultMemFU(),
167+
BebopInODefaultMiscFU(),
168+
]
169+
170+
12171
class BaseBebopInOCPU(BaseCPU):
13172
type = "BaseBebopInOCPU"
14173
cxx_header = "BebopInOCPU/cpu.hh"
@@ -157,6 +316,6 @@ def addCheckerCpu(self):
157316

158317
# Functional unit pool
159318
executeFuncUnits = Param.BebopInOFUPool(
160-
"FU pool for this processor"
319+
BebopInODefaultFUPool(), "FU pool for this processor"
161320
)
162321

host/gem5/BebopInOCPU/BebopInOCPUArch.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88
from m5.objects.ArmCPU import ArmCPU, ArmMMU
99

1010
class ArmBebopInOCPU(BaseBebopInOCPU, ArmCPU):
11-
type = "ArmBebopInOCPU"
12-
cxx_header = "BebopInOCPU/cpu.hh"
13-
cxx_class = "gem5::BebopInOCPU"
1411
mmu = ArmMMU()
1512

1613

1714
if buildEnv.get("USE_RISCV_ISA"):
1815
class RiscvBebopInOCPU(BaseBebopInOCPU, RiscvCPU):
19-
type = "RiscvBebopInOCPU"
20-
cxx_header = "BebopInOCPU/cpu.hh"
21-
cxx_class = "gem5::BebopInOCPU"
2216
mmu = RiscvMMU()
2317

host/gem5/BebopInOCPU/BebopInOFU.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BebopInOFUTiming(SimObject):
3535
[], "per-src-reg relative latencies"
3636
)
3737
opClasses = Param.BebopInOOpClassSet(
38-
NULL, "op classes to apply timing to"
38+
BebopInOOpClassSet(), "op classes to apply timing to"
3939
)
4040
description = Param.String("", "description string")
4141

host/gem5/riscv-se.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import m5
1212
import m5.stats
1313
from m5.objects import *
14+
from m5.objects import RiscvBebopInOCPU
1415

1516
# Parse command line arguments
1617
parser = argparse.ArgumentParser(description='Run a binary on RISCV using gem5')
@@ -33,12 +34,13 @@
3334
system.clk_domain.voltage_domain = VoltageDomain()
3435

3536
# Set memory mode and range
36-
system.mem_mode = "atomic"
37-
# system.mem_mode = "timing"
37+
# system.mem_mode = "atomic"
38+
system.mem_mode = "timing"
3839
system.mem_ranges = [AddrRange("32GiB")]
3940

4041
# Create CPU
41-
system.cpu = AtomicSimpleCPU()
42+
# system.cpu = AtomicSimpleCPU()
43+
system.cpu = RiscvBebopInOCPU()
4244
# system.cpu = RiscvTimingSimpleCPU()
4345
# system.cpu = RiscvMinorCPU()
4446
# system.cpu = RiscvO3CPU()

0 commit comments

Comments
 (0)