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
d8d53650
Commit
d8d53650
authored
Sep 05, 2024
by
Hejing Li
Browse files
some imports
parent
2741f329
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
37 deletions
+38
-37
experiments/simbricks/orchestration/simulation/channel.py
experiments/simbricks/orchestration/simulation/channel.py
+2
-5
experiments/simbricks/orchestration/simulation/host.py
experiments/simbricks/orchestration/simulation/host.py
+8
-7
experiments/simbricks/orchestration/simulation/net/__init__.py
...iments/simbricks/orchestration/simulation/net/__init__.py
+3
-1
experiments/simbricks/orchestration/simulation/net/base.py
experiments/simbricks/orchestration/simulation/net/base.py
+12
-11
experiments/simbricks/orchestration/simulation/pcidev.py
experiments/simbricks/orchestration/simulation/pcidev.py
+9
-9
experiments/simbricks/orchestration/system/base.py
experiments/simbricks/orchestration/system/base.py
+4
-4
No files found.
experiments/simbricks/orchestration/simulation/channel.py
View file @
d8d53650
...
@@ -21,16 +21,13 @@
...
@@ -21,16 +21,13 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
typing
as
tp
import
typing
as
tp
import
simbricks.orchestration.simulation.base
as
sim_base
import
simbricks.orchestration.experiments
as
exp
import
simbricks.orchestration.system.base
as
system_base
import
simbricks.orchestration.system.base
as
system_base
import
simbricks.orchestration.simulation.base
as
sim_base
from
simbricks.orchestration.experiment.experiment_environment_new
import
ExpEnv
class
Channel
(
sim_base
.
Simulator
):
class
Channel
(
sim_base
.
Simulator
):
def
__init__
(
self
,
e
:
exp
.
Experiment
,
chan
:
system_base
.
Channel
):
def
__init__
(
self
,
e
:
sim_base
.
Simulation
,
chan
:
system_base
.
Channel
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
_synchronized
:
bool
=
True
self
.
_synchronized
:
bool
=
True
self
.
sync_period
:
int
=
500
# nano second
self
.
sync_period
:
int
=
500
# nano second
...
...
experiments/simbricks/orchestration/simulation/host.py
View file @
d8d53650
...
@@ -25,18 +25,19 @@ import tarfile
...
@@ -25,18 +25,19 @@ import tarfile
import
math
import
math
import
typing
as
tp
import
typing
as
tp
import
simbricks.orchestration.simulation.base
as
sim_base
import
simbricks.orchestration.simulation.base
as
sim_base
import
simbricks.orchestration.system.host.base
as
system_host
import
simbricks.orchestration.system.pcie
as
system_pcie
import
simbricks.orchestration.system.pcie
as
system_pcie
import
simbricks.orchestration.system
as
system
import
simbricks.orchestration.system
as
system
import
simbricks.orchestration.experiments
as
exp
from
simbricks.orchestration.experiment.experiment_environment_new
import
ExpEnv
from
simbricks.orchestration.experiment.experiment_environment_new
import
ExpEnv
if
tp
.
TYPE_CHECKING
:
from
simbricks.orchestration.system.host.base
import
(
Host
)
class
HostSim
(
sim_base
.
Simulator
):
class
HostSim
(
sim_base
.
Simulator
):
def
__init__
(
self
,
e
:
exp
.
Experiment
):
def
__init__
(
self
,
e
:
sim_base
.
Simulation
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
hosts
:
system_host
.
Host
=
[
]
self
.
hosts
:
tp
.
List
[
'Host'
]
self
.
wait
=
True
self
.
wait
=
True
def
full_name
(
self
)
->
str
:
def
full_name
(
self
)
->
str
:
...
@@ -51,7 +52,7 @@ class HostSim(sim_base.Simulator):
...
@@ -51,7 +52,7 @@ class HostSim(sim_base.Simulator):
deps
.
append
(
self
.
experiment
.
find_sim
(
dev
.
component
))
deps
.
append
(
self
.
experiment
.
find_sim
(
dev
.
component
))
return
deps
return
deps
def
add
(
self
,
host
:
system_host
.
Host
):
def
add
(
self
,
host
:
'
Host
'
):
self
.
hosts
.
append
(
host
)
self
.
hosts
.
append
(
host
)
self
.
name
=
f
'
{
self
.
hosts
.
id
}
'
self
.
name
=
f
'
{
self
.
hosts
.
id
}
'
self
.
experiment
.
add_host
(
self
)
self
.
experiment
.
add_host
(
self
)
...
@@ -94,7 +95,7 @@ class HostSim(sim_base.Simulator):
...
@@ -94,7 +95,7 @@ class HostSim(sim_base.Simulator):
class
Gem5Sim
(
HostSim
):
class
Gem5Sim
(
HostSim
):
def
__init__
(
self
,
e
:
exp
.
Experiment
):
def
__init__
(
self
,
e
:
sim_base
.
Simulation
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
name
=
''
self
.
name
=
''
...
@@ -183,7 +184,7 @@ class Gem5Sim(HostSim):
...
@@ -183,7 +184,7 @@ class Gem5Sim(HostSim):
class
QemuSim
(
HostSim
):
class
QemuSim
(
HostSim
):
def
__init__
(
self
,
e
:
exp
.
Experiment
):
def
__init__
(
self
,
e
:
sim_base
.
Simulation
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
...
...
experiments/simbricks/orchestration/simulation/net/__init__.py
View file @
d8d53650
...
@@ -18,4 +18,6 @@
...
@@ -18,4 +18,6 @@
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
from
simbricks.orchestration.simulation.net.base
import
*
experiments/simbricks/orchestration/simulation/net/base.py
View file @
d8d53650
...
@@ -22,16 +22,17 @@
...
@@ -22,16 +22,17 @@
import
abc
import
abc
import
sys
import
sys
from
simbricks.orchestration.simulation
import
base
import
simbricks.orchestration.simulation
.base
as
sim_
base
from
simbricks.orchestration.system
import
eth
from
simbricks.orchestration.system
import
eth
from
simbricks.orchestration.instantiation
import
base
as
inst_base
from
simbricks.orchestration.instantiation
import
base
as
inst_base
from
simbricks.orchestration.experiment.experiment_environment_new
import
ExpEnv
class
NetSim
(
base
.
Simulator
):
class
NetSim
(
sim_
base
.
Simulator
):
"""Base class for network simulators."""
"""Base class for network simulators."""
def
__init__
(
def
__init__
(
self
,
simulation
:
base
.
Simulation
,
relative_executable_path
:
str
=
""
self
,
simulation
:
sim_
base
.
Simulation
,
relative_executable_path
:
str
=
""
)
->
None
:
)
->
None
:
super
().
__init__
(
simulation
,
relative_executable_path
=
relative_executable_path
)
super
().
__init__
(
simulation
,
relative_executable_path
=
relative_executable_path
)
# TODO: do we want them here?
# TODO: do we want them here?
...
@@ -41,7 +42,7 @@ class NetSim(base.Simulator):
...
@@ -41,7 +42,7 @@ class NetSim(base.Simulator):
def
full_name
(
self
)
->
str
:
def
full_name
(
self
)
->
str
:
return
"net."
+
self
.
name
return
"net."
+
self
.
name
def
dependencies
(
self
)
->
list
[
base
.
Simulator
]:
def
dependencies
(
self
)
->
list
[
sim_
base
.
Simulator
]:
# TODO
# TODO
deps
=
[]
deps
=
[]
for
s
in
self
.
switches
:
for
s
in
self
.
switches
:
...
@@ -50,7 +51,7 @@ class NetSim(base.Simulator):
...
@@ -50,7 +51,7 @@ class NetSim(base.Simulator):
return
deps
return
deps
# TODO
# TODO
def
sockets_wait
(
self
,
env
:
exp_env
.
ExpEnv
)
->
list
[
str
]:
def
sockets_wait
(
self
,
env
:
ExpEnv
)
->
list
[
str
]:
pass
pass
def
wait_terminate
(
self
)
->
bool
:
def
wait_terminate
(
self
)
->
bool
:
...
@@ -60,14 +61,14 @@ class NetSim(base.Simulator):
...
@@ -60,14 +61,14 @@ class NetSim(base.Simulator):
def
init_network
(
self
)
->
None
:
def
init_network
(
self
)
->
None
:
pass
pass
def
sockets_cleanup
(
self
,
env
:
exp_env
.
ExpEnv
)
->
list
[
str
]:
def
sockets_cleanup
(
self
,
env
:
ExpEnv
)
->
list
[
str
]:
# TODO
# TODO
return
[]
return
[]
class
WireNet
(
NetSim
):
class
WireNet
(
NetSim
):
def
__init__
(
self
,
simulation
:
base
.
Simulation
)
->
None
:
def
__init__
(
self
,
simulation
:
sim_
base
.
Simulation
)
->
None
:
super
().
__init__
(
super
().
__init__
(
simulation
=
simulation
,
simulation
=
simulation
,
relative_executable_path
=
"/sims/net/wire/net_wire"
,
relative_executable_path
=
"/sims/net/wire/net_wire"
,
...
@@ -75,7 +76,7 @@ class WireNet(NetSim):
...
@@ -75,7 +76,7 @@ class WireNet(NetSim):
)
)
# TODO: probably we want to store these in a common base class...
# TODO: probably we want to store these in a common base class...
self
.
_wire_comp
:
eth
.
EthWire
|
None
=
None
self
.
_wire_comp
:
eth
.
EthWire
|
None
=
None
self
.
_relative_pcap_file_path
:
str
|
None
=
relative_pcap_file_path
self
.
_relative_pcap_file_path
:
str
|
None
=
'
relative_pcap_file_path
'
def
add_wire
(
self
,
wire
:
eth
.
EthWire
):
def
add_wire
(
self
,
wire
:
eth
.
EthWire
):
assert
self
.
_wire_comp
is
None
assert
self
.
_wire_comp
is
None
...
@@ -118,7 +119,7 @@ class SwitchNet(NetSim):
...
@@ -118,7 +119,7 @@ class SwitchNet(NetSim):
def
__init__
(
def
__init__
(
self
,
self
,
simulation
:
base
.
Simulation
,
simulation
:
sim_
base
.
Simulation
,
relative_executable_path
=
"/sims/net/switch/net_switch"
,
relative_executable_path
=
"/sims/net/switch/net_switch"
,
relative_pcap_file_path
=
None
,
relative_pcap_file_path
=
None
,
)
->
None
:
)
->
None
:
...
@@ -167,7 +168,7 @@ class SwitchNet(NetSim):
...
@@ -167,7 +168,7 @@ class SwitchNet(NetSim):
cmd
+=
" "
+
pcap_file
cmd
+=
" "
+
pcap_file
sockets
=
self
.
_get_sockets
(
inst
=
inst
)
sockets
=
self
.
_get_sockets
(
inst
=
inst
)
listen
,
connect
=
base
.
Simulator
.
split_sockets_by_type
(
sockets
)
listen
,
connect
=
sim_
base
.
Simulator
.
split_sockets_by_type
(
sockets
)
for
sock
in
connect
:
for
sock
in
connect
:
cmd
+=
" -s "
+
sock
.
_path
cmd
+=
" -s "
+
sock
.
_path
...
@@ -181,7 +182,7 @@ class SwitchNet(NetSim):
...
@@ -181,7 +182,7 @@ class SwitchNet(NetSim):
class
MemSwitchNet
(
SwitchNet
):
class
MemSwitchNet
(
SwitchNet
):
def
__init__
(
def
__init__
(
self
,
simulation
:
base
.
Simulation
,
relative_pcap_file_path
=
None
self
,
simulation
:
sim_
base
.
Simulation
,
relative_pcap_file_path
=
None
)
->
None
:
)
->
None
:
super
().
__init__
(
super
().
__init__
(
simulation
=
simulation
,
simulation
=
simulation
,
...
...
experiments/simbricks/orchestration/simulation/pcidev.py
View file @
d8d53650
...
@@ -20,16 +20,16 @@
...
@@ -20,16 +20,16 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
simbricks.orchestration.simulation
as
sim_conf
import
simbricks.orchestration.system
as
sys_conf
import
simbricks.orchestration.system
as
sys_conf
import
typing
as
tp
import
typing
as
tp
from
simbricks.orchestration.experiment.experiment_environment_new
import
ExpEnv
from
simbricks.orchestration.experiment.experiment_environment_new
import
ExpEnv
from
simbricks.orchestration.simulation
import
base
class
PCIDevSim
(
sim_conf
.
Simulator
):
class
PCIDevSim
(
base
.
Simulator
):
"""Base class for PCIe device simulators."""
"""Base class for PCIe device simulators."""
def
__init__
(
self
,
e
:
sim_conf
.
Simulation
)
->
None
:
def
__init__
(
self
,
e
:
base
.
Simulation
)
->
None
:
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
start_tick
=
0
self
.
start_tick
=
0
...
@@ -56,13 +56,13 @@ class PCIDevSim(sim_conf.Simulator):
...
@@ -56,13 +56,13 @@ class PCIDevSim(sim_conf.Simulator):
class
NICSim
(
PCIDevSim
):
class
NICSim
(
PCIDevSim
):
"""Base class for NIC simulators."""
"""Base class for NIC simulators."""
def
__init__
(
self
,
e
:
sim_conf
.
Simulation
)
->
None
:
def
__init__
(
self
,
e
:
base
.
Simulation
)
->
None
:
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
experiment
=
e
self
.
experiment
=
e
self
.
nics
:
tp
.
List
[
sim_conf
.
PCIDevSim
]
=
[]
self
.
nics
:
tp
.
List
[
PCIDevSim
]
=
[]
self
.
start_tick
=
0
self
.
start_tick
=
0
def
add
(
self
,
nic
:
sim_conf
.
PCIDevSim
):
def
add
(
self
,
nic
:
PCIDevSim
):
self
.
nics
.
append
(
nic
)
self
.
nics
.
append
(
nic
)
# nic.sim = self
# nic.sim = self
self
.
experiment
.
add_nic
(
self
)
self
.
experiment
.
add_nic
(
self
)
...
@@ -102,7 +102,7 @@ class NICSim(PCIDevSim):
...
@@ -102,7 +102,7 @@ class NICSim(PCIDevSim):
class
I40eNicSim
(
NICSim
):
class
I40eNicSim
(
NICSim
):
def
__init__
(
self
,
e
:
sim_conf
.
Simulation
):
def
__init__
(
self
,
e
:
'
Simulation
'
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
...
@@ -110,7 +110,7 @@ class I40eNicSim(NICSim):
...
@@ -110,7 +110,7 @@ class I40eNicSim(NICSim):
class
CorundumBMNICSim
(
NICSim
):
class
CorundumBMNICSim
(
NICSim
):
def
__init__
(
self
,
e
:
sim_conf
.
Simulation
):
def
__init__
(
self
,
e
:
'
Simulation
'
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
...
@@ -121,7 +121,7 @@ class CorundumBMNICSim(NICSim):
...
@@ -121,7 +121,7 @@ class CorundumBMNICSim(NICSim):
class
CorundumVerilatorNICSim
(
NICSim
):
class
CorundumVerilatorNICSim
(
NICSim
):
def
__init__
(
self
,
e
:
sim_conf
.
Simulation
):
def
__init__
(
self
,
e
:
'
Simulation
'
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
clock_freq
=
250
# MHz
self
.
clock_freq
=
250
# MHz
...
...
experiments/simbricks/orchestration/system/base.py
View file @
d8d53650
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
from
__future__
import
annotations
from
__future__
import
annotations
import
abc
import
abc
from
simbricks.orchestration.utils
import
base
from
simbricks.orchestration.utils
import
base
as
util_base
class
System
:
class
System
:
...
@@ -36,7 +36,7 @@ class System:
...
@@ -36,7 +36,7 @@ class System:
self
.
all_component
.
append
(
c
)
self
.
all_component
.
append
(
c
)
class
Component
(
base
.
IdObj
):
class
Component
(
util_
base
.
IdObj
):
def
__init__
(
self
,
s
:
System
)
->
None
:
def
__init__
(
self
,
s
:
System
)
->
None
:
super
().
__init__
()
super
().
__init__
()
...
@@ -53,7 +53,7 @@ class Component(base.IdObj):
...
@@ -53,7 +53,7 @@ class Component(base.IdObj):
return
[
i
.
channel
for
i
in
self
.
interfaces
()
if
i
.
is_connected
()]
return
[
i
.
channel
for
i
in
self
.
interfaces
()
if
i
.
is_connected
()]
class
Interface
(
base
.
IdObj
):
class
Interface
(
util_
base
.
IdObj
):
def
__init__
(
self
,
c
:
Component
)
->
None
:
def
__init__
(
self
,
c
:
Component
)
->
None
:
super
().
__init__
()
super
().
__init__
()
self
.
component
=
c
self
.
component
=
c
...
@@ -70,7 +70,7 @@ class Interface(base.IdObj):
...
@@ -70,7 +70,7 @@ class Interface(base.IdObj):
self
.
channel
=
c
self
.
channel
=
c
class
Channel
(
base
.
IdObj
):
class
Channel
(
util_
base
.
IdObj
):
def
__init__
(
self
,
a
:
Interface
,
b
:
Interface
)
->
None
:
def
__init__
(
self
,
a
:
Interface
,
b
:
Interface
)
->
None
:
super
().
__init__
()
super
().
__init__
()
self
.
latency
=
500
self
.
latency
=
500
...
...
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