Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
74fcfa90
Unverified
Commit
74fcfa90
authored
Sep 16, 2024
by
Jakob Görgen
Browse files
added more helpers for simulation module
parent
e4df1372
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
206 additions
and
9 deletions
+206
-9
experiments/pyexps/netperf_sysconf_jakob.py
experiments/pyexps/netperf_sysconf_jakob.py
+152
-9
experiments/simbricks/orchestration/helpers/simulation.py
experiments/simbricks/orchestration/helpers/simulation.py
+54
-0
No files found.
experiments/pyexps/netperf_sysconf_jakob.py
View file @
74fcfa90
...
...
@@ -6,6 +6,16 @@ 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
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
=
[]
def
boilerplate
():
"""
...
...
@@ -16,7 +26,7 @@ def boilerplate():
# create client host
host0
=
sys_host_base
.
CorundumLinuxHost
()
host0_app
=
sys_app_base
.
PingClient
(
host0
)
host0_app
.
server_ip
=
'
10.0.0.2
'
host0_app
.
server_ip
=
"
10.0.0.2
"
host0
.
add_app
(
host0_app
)
# create client nic
...
...
@@ -54,39 +64,103 @@ def boilerplate():
# connect first switch to client nic
nic_eth0
=
sys_eth
.
EthInterface
(
nic0
)
nic0
.
set_eth
_if
(
nic_eth0
)
nic0
.
add
_if
(
nic_eth0
)
switch0_for_nic
=
sys_eth
.
EthInterface
(
switch0
)
switch0
.
if_
add
(
switch0_for_nic
)
switch0
.
add
_if
(
switch0_for_nic
)
nic0_switch0_chan
=
sys_eth
.
EthChannel
(
nic_eth0
,
switch0_for_nic
)
# connect second switch to server nic
nic_eth1
=
sys_eth
.
EthInterface
(
nic1
)
nic1
.
set_eth
_if
(
nic_eth1
)
nic1
.
add
_if
(
nic_eth1
)
switch1_for_nic
=
sys_eth
.
EthInterface
(
switch1
)
switch1
.
if_
add
(
switch1_for_nic
)
switch1
.
add
_if
(
switch1_for_nic
)
nic1_switch1_chan
=
sys_eth
.
EthChannel
(
nic_eth1
,
switch1_for_nic
)
# connect first switch to second switch
switch0_for_net
=
sys_eth
.
EthInterface
(
switch0
)
switch0
.
if_
add
(
switch0_for_net
)
switch0
.
add
_if
(
switch0_for_net
)
switch1_for_net
=
sys_eth
.
EthInterface
(
switch1
)
switch1
.
if_
add
(
switch1_for_net
)
switch1
.
add
_if
(
switch1_for_net
)
switch0_switch1_chan
=
sys_eth
.
EthChannel
(
switch0_for_net
,
switch1_for_net
)
"""
SIMULATION CONFIGURATION
"""
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
)
def
syntactic_sugar
():
"""
SYSTEM CONFIGURATION
SYNTACTIC SUGAR
SYSTEM CONFIGURATION
WITH HELPERS
"""
system
=
system
.
System
()
# create client host
host0
=
sys_host_base
.
CorundumLinuxHost
()
helpers_sys
.
install_app
(
host
=
host0
,
app_ty
=
sys_app_base
.
PingClient
,
server_ip
=
'10.0.0.2'
)
helpers_sys
.
install_app
(
host
=
host0
,
app_ty
=
sys_app_base
.
PingClient
,
server_ip
=
"10.0.0.2"
)
# create client nic
nic0
=
sys_nic
.
CorundumNIC
()
...
...
@@ -120,3 +194,72 @@ def syntactic_sugar():
# connect first switch to second switch
helpers_sys
.
connect_eth_devices
(
device_a
=
switch0
,
device_b
=
switch1
)
"""
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
)
experiments/simbricks/orchestration/helpers/simulation.py
0 → 100644
View file @
74fcfa90
# Copyright 2024 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.
from
simbricks.orchestration
import
system
from
simbricks.orchestration
import
simulation
from
simbricks.orchestration.utils
import
base
as
utils_base
def
add_specs
(
simulator
:
simulation
.
Simulator
,
*
specifications
)
->
None
:
utils_base
.
has_expected_type
(
obj
=
simulator
,
expected_type
=
simulation
.
Simulator
)
for
spec
in
specifications
:
utils_base
.
has_expected_type
(
obj
=
spec
,
expected_type
=
system
.
Component
)
simulator
.
add
(
comp
=
spec
)
def
enable_sync_simulation
(
simulation
:
simulation
.
Simulation
,
amount
:
int
=
None
,
ratio
:
simulation
.
Time
=
None
)
->
None
:
utils_base
.
has_expected_type
(
obj
=
simulation
,
expected_type
=
simulation
.
Simulation
)
set_period
:
bool
=
amount
is
not
None
and
ratio
is
not
None
if
set_period
:
utils_base
.
has_expected_type
(
obj
=
amount
,
expected_type
=
int
)
utils_base
.
has_expected_type
(
obj
=
ratio
,
expected_type
=
simulation
.
Time
)
for
chan
in
simulation
.
get_all_channels
():
chan
.
_synchronized
=
True
if
set_period
:
chan
.
set_sync_period
(
amount
=
amount
,
ratio
=
ratio
)
def
disalbe_sync_simulation
(
simulation
:
simulation
.
Simulation
)
->
None
:
utils_base
.
has_expected_type
(
obj
=
simulation
,
expected_type
=
simulation
.
Simulation
)
for
chan
in
simulation
.
get_all_channels
(
lazy
=
False
):
chan
.
_synchronized
=
False
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment