"vscode:/vscode.git/clone" did not exist on "8e83708427449f5a80b96a27ad4185216f950d01"
dist_multinet.py 4.85 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import simbricks.nodeconfig as node
Jonas Kaufmann's avatar
Jonas Kaufmann committed
24
import simbricks.simulators as sim
25
from simbricks.simulator_utils import create_basic_hosts
26

Jonas Kaufmann's avatar
Jonas Kaufmann committed
27
import simbricks.experiments as exp
28
from simbricks import proxy
Jonas Kaufmann's avatar
Jonas Kaufmann committed
29

30
31
host_types = ['qemu', 'gem5', 'qt']
n_nets = [1, 2, 3, 4]
32
n_clients = [1, 10, 20, 30, 40, 50]
33
experiments = []
34
separate_net = False
35
36
37
separate_server = True

for host_type in host_types:
Jonas Kaufmann's avatar
Jonas Kaufmann committed
38
39
40
41
42
43
44
45
    for n in n_nets:
        for n_client in n_clients:
            nh = n if not separate_net else n + 1
            e = exp.DistributedExperiment(
                f'dist_multinet-{host_type}-{n}-{n_client}', nh
            )

            # host
46
            if host_type == 'qemu':
47
                HostClass = sim.QemuHost
Jonas Kaufmann's avatar
Jonas Kaufmann committed
48
49
50
51
52
53
54
            elif host_type == 'qt':

                def qemu_timing():
                    h = sim.QemuHost()
                    h.sync = True
                    return h

55
                HostClass = qemu_timing
Jonas Kaufmann's avatar
Jonas Kaufmann committed
56
            elif host_type == 'gem5':
57
                HostClass = sim.Gem5Host
Jonas Kaufmann's avatar
Jonas Kaufmann committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
                e.checkpoint = True
            else:
                raise NameError(host_type)

            switch_top = sim.SwitchNet()
            switch_top.name = 'switch_top'
            if host_type == 'qemu':
                switch_top.sync = False
            e.add_network(switch_top)
            e.assign_sim_host(switch_top, 0)

            for i in range(0, n):
                h_i = i if not separate_net else i + 1
                switch = sim.SwitchNet()
72
                switch.name = f'switch_{i}'
73
                if host_type == 'qemu':
Jonas Kaufmann's avatar
Jonas Kaufmann committed
74
75
76
77
78
79
80
81
82
83
84
85
                    switch.sync = False
                e.add_network(switch)
                e.assign_sim_host(switch, h_i)

                switch_top.connect_network(switch)

                # create servers and clients
                m = n_client
                if i == 0 or separate_server:
                    servers = create_basic_hosts(
                        e,
                        1,
86
                        f'server_{i}',
Jonas Kaufmann's avatar
Jonas Kaufmann committed
87
88
                        switch,
                        sim.I40eNIC,
89
                        HostClass,
Jonas Kaufmann's avatar
Jonas Kaufmann committed
90
91
92
93
94
95
96
97
98
99
100
101
102
                        node.I40eLinuxNode,
                        node.NetperfServer,
                        ip_start=i * (n_client + 1) + 1
                    )
                    if not separate_server:
                        m = m - 1

                    e.assign_sim_host(servers[0], h_i)
                    e.assign_sim_host(servers[0].pcidevs[0], h_i)

                clients = create_basic_hosts(
                    e,
                    m,
103
                    f'client_{i}',
Jonas Kaufmann's avatar
Jonas Kaufmann committed
104
105
                    switch,
                    sim.I40eNIC,
106
                    HostClass,
Jonas Kaufmann's avatar
Jonas Kaufmann committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
                    node.I40eLinuxNode,
                    node.NetperfClient,
                    ip_start=i * (n_client + 1) + 2
                )

                for c in clients:
                    c.wait = True
                    c.node_config.app.server_ip = servers[0].node_config.ip
                    if host_type == 'qemu':
                        c.extra_deps.append(servers[0])

                    e.assign_sim_host(c, h_i)
                    e.assign_sim_host(c.pcidevs[0], h_i)

                if h_i != 0:
                    lp = proxy.SocketsNetProxyListener()
123
                    lp.name = f'listener-{i}'
Jonas Kaufmann's avatar
Jonas Kaufmann committed
124
125
126
127
                    e.add_proxy(lp)
                    e.assign_sim_host(lp, h_i)

                    cp = proxy.SocketsNetProxyConnecter(lp)
128
                    cp.name = f'connecter-{i}'
Jonas Kaufmann's avatar
Jonas Kaufmann committed
129
130
131
132
133
134
135
136
137
138
                    e.add_proxy(cp)
                    e.assign_sim_host(cp, 0)

                    lp.add_n2n(switch_top, switch)

                for c in clients + servers:
                    c.pcidevs[0].start_tick = 580000000000

            # add to experiments
            experiments.append(e)