netperf_sysconf_jakob.py 8.03 KB
Newer Older
1
2
3
4
5
6
7
from simbricks.orchestration.system import base as sys_base
from simbricks.orchestration.system import pcie as sys_pcie
from simbricks.orchestration.system import eth as sys_eth
from simbricks.orchestration.system import nic as sys_nic
from simbricks.orchestration.system.host import base as sys_host_base
from simbricks.orchestration.system.host import app as sys_app_base
from simbricks.orchestration.helpers import system as helpers_sys
8

9
10
11
12
13
14
15
16
17
18
from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.simulation import pcidev as sim_pcidev
from simbricks.orchestration.simulation import host as sim_host
from simbricks.orchestration.simulation import net as sim_net
from simbricks.orchestration.simulation import channel as sim_chan
from simbricks.orchestration.helpers import simulation as helpers_sim

# TODO: check and change name
experiments = []

19
20

def boilerplate():
21
22
23
24
    """
    SYSTEM CONFIGURATION
    """
    system = sys_base.System()
25
26

    # create client host
27
28
    host0 = sys_host_base.CorundumLinuxHost()
    host0_app = sys_app_base.PingClient(host0)
29
    host0_app.server_ip = "10.0.0.2"
30
31
32
    host0.add_app(host0_app)

    # create client nic
33
    nic0 = sys_nic.CorundumNIC()
34
    nic0.add_ipv4("10.0.0.1")
35
36

    # connect client host and nic
37
    host_pci0 = sys_pcie.PCIeHostInterface(host0)
38
    host0.add_if(host_pci0)
39
    nic_pci0 = sys_pcie.PCIeDeviceInterface(nic0)
40
    nic0.add_if(nic_pci0)
41
42
    host0_nic0_chan = sys_pcie.PCIeChannel(host_pci0, nic_pci0)

43
    # create host server
44
45
    host1 = sys_host_base.I40ELinuxHost()
    host1_app = sys_app_base.Sleep(host1)
46
47
48
    host1.add_app(host1_app)

    # create host nic
49
    nic1 = sys_nic.IntelI40eNIC()
50
    nic1.add_ipv4("10.0.0.2")
51
52

    # connect host server to host client
53
    host_pci1 = sys_pcie.PCIeHostInterface(host0)
54
    host1.add_if(host_pci1)
55
    nic_pci1 = sys_pcie.PCIeDeviceInterface(nic1)
56
    nic1.add_if(nic_pci1)
57
    host1_nic1_chan = sys_pcie.PCIeChannel(host_pci1, nic_pci1)
58
59

    # create first switch
60
    switch0 = sys_eth.EthSwitch(system)
61
62

    # create second switch
63
    switch1 = sys_eth.EthSwitch(system)
64
65

    # connect first switch to client nic
66
    nic_eth0 = sys_eth.EthInterface(nic0)
67
    nic0.add_if(nic_eth0)
68
    switch0_for_nic = sys_eth.EthInterface(switch0)
69
    switch0.add_if(switch0_for_nic)
70
    nic0_switch0_chan = sys_eth.EthChannel(nic_eth0, switch0_for_nic)
71
72

    # connect second switch to server nic
73
    nic_eth1 = sys_eth.EthInterface(nic1)
74
    nic1.add_if(nic_eth1)
75
    switch1_for_nic = sys_eth.EthInterface(switch1)
76
    switch1.add_if(switch1_for_nic)
77
    nic1_switch1_chan = sys_eth.EthChannel(nic_eth1, switch1_for_nic)
78
79

    # connect first switch to second switch
80
    switch0_for_net = sys_eth.EthInterface(switch0)
81
    switch0.add_if(switch0_for_net)
82
    switch1_for_net = sys_eth.EthInterface(switch1)
83
    switch1.add_if(switch1_for_net)
84
85
86
87
88
    switch0_switch1_chan = sys_eth.EthChannel(switch0_for_net, switch1_for_net)

    """
    SIMULATION CONFIGURATION
    """
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
    simulation = sim_base.Simulation("n-" + host_type + "-" + nic_type + "-" + net_type)

    # resolve the host type and simulator
    host_type = ""
    host_sim = None
    match host_type:  # NOTE: synchronized or not is a question of the channel and NOT the simulator anymore!!!!!!!!!
        case "gem5":
            host_sim = sim_host.Gem5Sim
        case "qemu":
            host_sim = sim_host.QemuSim
        case _:
            raise Exception(f"unknown host type {host_type}")
    assert host_sim

    # resolve the nic type and simulator
    nic_type = ""
    nic_sim = None
    match nic_type:  # NOTE: synchronized or not is a question of the channel and NOT the simulator anymore!!!!!!!!!
        case "bm":
            nic_sim = sim_pcidev.CorundumBMNICSim
        case "vr":
            nic_sim = sim_pcidev.CorundumVerilatorNICSim
        case _:
            raise Exception(f"unknown nic type {nic_type}")
    assert nic_sim

    # resolve the network type and simulator
    net_type = ""
    net_sim = None
    match net_type:
        case "bms":
            net_sim = sim_net.SwitchNet
        case "mbms":
            net_sim = sim_net.MemSwitchNet
        case _:
            raise Exception(f"unknown net type {net_type}")
    assert net_type

    host_inst0 = host_sim(simulation)
    host_inst0.add(host0)

    host_inst1 = host_sim(simulation)
    host_inst1.add(host1)

    nic_inst0 = nic_sim(simulation)
    nic_inst0.add(nic0)

    nic_inst1 = nic_sim(simulation)
    nic_inst1.add(nic1)

    switch_inst0 = net_sim(simulation)
    switch_inst0.add(switch0)

    switch_inst1 = net_sim(simulation)
    switch_inst1.add(switch1)

    # enble synchronizaiton
    for chan in simulation.get_all_channels(lazy=False):
        chan._synchronized = True
        chan.set_sync_period(amount=300, ratio=sim_chan.Time.Nanoseconds)

    experiments.append(e)
151
152
153


def syntactic_sugar():
154
    """
155
    SYSTEM CONFIGURATION WITH HELPERS
156
    """
157
158
159
    system = system.System()

    # create client host
160
    host0 = sys_host_base.CorundumLinuxHost()
161
162
163
    helpers_sys.install_app(
        host=host0, app_ty=sys_app_base.PingClient, server_ip="10.0.0.2"
    )
164
165

    # create client nic
166
167
    nic0 = sys_nic.CorundumNIC()
    nic0.add_ipv4("10.0.0.1")
168
169

    # connect client host and nic
170
171
    helpers_sys.connect_host_and_device(host=host0, device=nic0)

172
    # create host server
173
    host1 = sys_host_base.I40ELinuxHost()
174
    helpers_sys.install_app(host=host1, app_ty=sys_app_base.Sleep, delay=10)
175
176

    # create host nic
177
    nic1 = sys_nic.IntelI40eNIC()
178
    nic1.add_ipv4("10.0.0.2")
179
180

    # connect host server to host client
181
    helpers_sys.connect_host_and_device(host=host1, device=nic1)
182
183

    # create first switch
184
    switch0 = sys_eth.EthSwitch(system)
185
186

    # create second switch
187
    switch1 = sys_eth.EthSwitch(system)
188
189

    # connect first switch to client nic
190
    helpers_sys.connect_eth_devices(device_a=nic0, device_b=switch0)
191
192

    # connect second switch to server nic
193
    helpers_sys.connect_eth_devices(device_a=nic1, device_b=switch1)
194
195

    # connect first switch to second switch
196
    helpers_sys.connect_eth_devices(device_a=switch0, device_b=switch1)
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265

    """
    SIMULATION CONFIGURATION WITH HELPERS
    """

    simulation = sim_base.Simulation("n-" + host_type + "-" + nic_type + "-" + net_type)

    # resolve the host type and simulator
    host_type = ""
    host_sim = None
    match host_type:  # NOTE: synchronized or not is a question of the channel and NOT the simulator anymore!!!!!!!!!
        case "gem5":
            host_sim = sim_host.Gem5Sim
        case "qemu":
            host_sim = sim_host.QemuSim
        case _:
            raise Exception(f"unknown host type {host_type}")
    assert host_sim

    # resolve the nic type and simulator
    nic_type = ""
    nic_sim = None
    match nic_type:  # NOTE: synchronized or not is a question of the channel and NOT the simulator anymore!!!!!!!!!
        case "bm":
            nic_sim = sim_pcidev.CorundumBMNICSim
        case "vr":
            nic_sim = sim_pcidev.CorundumVerilatorNICSim
        case _:
            raise Exception(f"unknown nic type {nic_type}")
    assert nic_sim

    # resolve the network type and simulator
    net_type = ""
    net_sim = None
    match net_type:
        case "bms":
            net_sim = sim_net.SwitchNet
        case "mbms":
            net_sim = sim_net.MemSwitchNet
        case _:
            raise Exception(f"unknown net type {net_type}")
    assert net_type

    host_inst0 = host_sim(simulation)
    # helper to add multiple specifications in single func call
    helpers_sim.add_specs(host_inst0, host0)

    host_inst1 = host_sim(simulation)
    host_inst1.add(host1)

    nic_inst0 = nic_sim(simulation)
    nic_inst0.add(nic0)

    nic_inst1 = nic_sim(simulation)
    nic_inst1.add(nic1)

    switch_inst0 = net_sim(simulation)
    switch_inst0.add(switch0)

    switch_inst1 = net_sim(simulation)
    switch_inst1.add(switch1)

    # enble synchronizaiton
    helpers_sim.enable_sync_simulation(
        simulation=simulation, amount=300, ratio=sim_chan.Time.Nanoseconds
    )
    # helpers_sim.disalbe_sync_simulation(simulation=simulation)

    experiments.append(e)