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
5eac59d3
Unverified
Commit
5eac59d3
authored
Sep 26, 2024
by
Jakob Görgen
Browse files
nic cli fix
parent
306451d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
29 deletions
+34
-29
experiments/run_new.py
experiments/run_new.py
+8
-8
experiments/simbricks/orchestration/instantiation/base.py
experiments/simbricks/orchestration/instantiation/base.py
+22
-18
experiments/simbricks/orchestration/simulation/pcidev.py
experiments/simbricks/orchestration/simulation/pcidev.py
+4
-3
No files found.
experiments/run_new.py
View file @
5eac59d3
...
...
@@ -272,7 +272,7 @@ def add_exp(
outpath
=
f
"
{
args
.
outdir
}
/
{
simulation
.
name
}
-
{
run_number
}
.json"
if
os
.
path
.
exists
(
outpath
)
and
not
args
.
force
:
print
(
f
"skip
{
e
.
name
}
run
{
run_number
}
"
)
print
(
f
"skip
{
simulation
.
name
}
run
{
run_number
}
"
)
return
None
workdir
=
f
"
{
args
.
workdir
}
/
{
simulation
.
name
}
/
{
run_number
}
"
...
...
@@ -291,13 +291,13 @@ def add_exp(
inst_env
=
inst_base
.
InstantiationEnvironment
(
repo_path
=
args
.
repo
,
workdir
=
workdir
,
cpdir
=
cpdir
,
create_cp
=
create_cp
,
restore_cp
=
restore_cp
,
shm_base
=
shm_base
,
output_base
=
output_base
,
tmp_simulation_files
=
tmp_sim_files
,
#
workdir=workdir,
#
cpdir=cpdir,
#
create_cp=create_cp,
#
restore_cp=restore_cp,
#
shm_base=shm_base,
#
output_base=output_base,
#
tmp_simulation_files=tmp_sim_files,
)
inst_
=
inst_base
.
Instantiation
(
sim
=
simulation
,
env
=
inst_env
)
...
...
experiments/simbricks/orchestration/instantiation/base.py
View file @
5eac59d3
...
...
@@ -45,9 +45,10 @@ class SockType(enum.Enum):
CONNECT
=
enum
.
auto
()
class
Socket
:
class
Socket
(
util_base
.
IdObj
)
:
def
__init__
(
self
,
path
:
str
=
""
,
ty
:
SockType
=
SockType
.
LISTEN
):
super
().
__init__
()
self
.
_path
=
path
self
.
_type
=
ty
...
...
@@ -68,29 +69,29 @@ class InstantiationEnvironment(util_base.IdObj):
qemu_path
:
str
|
None
=
None
,
):
super
().
__init__
()
self
.
_repodir
:
str
=
pathlib
.
Path
(
repo_path
).
ab
sol
ut
e
()
self
.
_repodir
:
str
=
pathlib
.
Path
(
repo_path
).
re
sol
v
e
()
self
.
_workdir
:
str
=
(
workdir
if
workdir
else
pathlib
.
Path
(
f
"
{
self
.
_repodir
}
/
experiment-
wrkdir"
).
ab
sol
ut
e
()
else
pathlib
.
Path
(
f
"
{
self
.
_repodir
}
/wrkdir"
).
re
sol
v
e
()
)
self
.
_output_base
:
str
=
(
output_base
if
output_base
else
pathlib
.
Path
(
f
"
{
self
.
_workdir
}
/output"
).
ab
sol
ut
e
()
else
pathlib
.
Path
(
f
"
{
self
.
_workdir
}
/output"
).
re
sol
v
e
()
)
self
.
_cpdir
:
str
=
(
cpdir
if
cpdir
else
pathlib
.
Path
(
f
"
{
self
.
_output_base
}
/checkpoints"
).
ab
sol
ut
e
()
else
pathlib
.
Path
(
f
"
{
self
.
_output_base
}
/checkpoints"
).
re
sol
v
e
()
)
self
.
_shm_base
:
str
=
(
shm_base
if
shm_base
else
pathlib
.
Path
(
f
"
{
self
.
_workdir
}
/shm"
).
ab
sol
ut
e
()
shm_base
if
shm_base
else
pathlib
.
Path
(
f
"
{
self
.
_workdir
}
/shm"
).
re
sol
v
e
()
)
self
.
_tmp_simulation_files
:
str
=
(
tmp_simulation_files
if
tmp_simulation_files
else
(
pathlib
.
Path
(
f
"
{
self
.
_workdir
}
/tmp"
).
ab
sol
ut
e
())
else
(
pathlib
.
Path
(
f
"
{
self
.
_workdir
}
/tmp"
).
re
sol
v
e
())
)
self
.
_create_cp
:
bool
=
create_cp
self
.
_restore_cp
:
bool
=
restore_cp
...
...
@@ -201,17 +202,18 @@ class Instantiation(util_base.IdObj):
queue_type
=
None
match
interface
:
case
sys_pcie
.
PCIeHostInterface
()
|
sys_pcie
.
PCIeDeviceInterface
():
queue_type
=
"
shm.
pci"
queue_type
=
"pci"
case
sys_mem
.
MemDeviceInterface
()
|
sys_mem
.
MemHostInterface
():
queue_type
=
"
shm.
mem"
queue_type
=
"mem"
case
sys_eth
.
EthInterface
():
queue_type
=
"
shm.
eth"
queue_type
=
"eth"
case
_
:
raise
Exception
(
"cannot create socket path for given interface type"
)
assert
queue_type
is
not
None
print
(
f
"_interface_to_sock_path: self._env._shm_base=
{
self
.
shm_base_dir
()
}
"
)
return
self
.
_join_paths
(
base
=
self
.
_env
.
_
shm_base
,
base
=
self
.
shm_base
_dir
()
,
relative_path
=
f
"
{
queue_type
}
/
{
queue_ident
}
"
,
enforce_existence
=
False
,
)
...
...
@@ -251,6 +253,7 @@ class Instantiation(util_base.IdObj):
socket
=
socket
,
supported_sock_types
=
supported_sock_types
)
self
.
_updated_tracker_mapping
(
interface
=
interface
,
socket
=
new_socket
)
print
(
f
"created socket:
{
new_socket
.
_path
}
"
)
return
new_socket
# neither connecting nor listening side already created a socket, thus we
...
...
@@ -268,6 +271,7 @@ class Instantiation(util_base.IdObj):
sock_path
=
self
.
_interface_to_sock_path
(
interface
=
interface
)
new_socket
=
Socket
(
path
=
sock_path
,
ty
=
sock_type
)
self
.
_updated_tracker_mapping
(
interface
=
interface
,
socket
=
new_socket
)
print
(
f
"created socket:
{
new_socket
.
_path
}
"
)
return
new_socket
def
_build_simulation_topology
(
self
)
->
None
:
...
...
@@ -353,10 +357,10 @@ class Instantiation(util_base.IdObj):
# TODO: add more methods constructing paths as required by methods in simulators or image handling classes
def
wrkdir
(
self
)
->
str
:
return
pathlib
.
Path
(
self
.
_env
.
_workdir
).
ab
sol
ut
e
()
return
pathlib
.
Path
(
self
.
_env
.
_workdir
).
re
sol
v
e
()
def
shm_base_dir
(
self
)
->
str
:
return
pathlib
.
Path
(
self
.
_env
.
_shm_base
).
ab
sol
ut
e
()
return
pathlib
.
Path
(
self
.
_env
.
_shm_base
).
re
sol
v
e
()
def
create_cp
(
self
)
->
bool
:
return
self
.
_env
.
_create_cp
...
...
@@ -365,10 +369,10 @@ class Instantiation(util_base.IdObj):
return
self
.
_env
.
_restore_cp
def
cpdir
(
self
)
->
str
:
return
pathlib
.
Path
(
self
.
_env
.
_cpdir
).
ab
sol
ut
e
()
return
pathlib
.
Path
(
self
.
_env
.
_cpdir
).
re
sol
v
e
()
def
wrkdir
(
self
)
->
str
:
return
pathlib
.
Path
(
self
.
_env
.
_workdir
).
ab
sol
ut
e
()
return
pathlib
.
Path
(
self
.
_env
.
_workdir
).
re
sol
v
e
()
async
def
prepare
(
self
)
->
None
:
wrkdir
=
self
.
wrkdir
()
...
...
@@ -406,11 +410,11 @@ class Instantiation(util_base.IdObj):
f
"cannot join with base=
{
base
}
because relative_path=
{
relative_path
}
starts with '/'"
)
joined
=
pathlib
.
Path
(
base
).
joinpath
(
relative_path
)
print
(
f
"joined=
{
joined
}
"
)
joined
=
pathlib
.
Path
(
base
).
joinpath
(
relative_path
)
.
resolve
()
print
(
f
"joined=
{
joined
}
from base=
{
base
}
, relative_path=
{
relative_path
}
"
)
if
enforce_existence
and
not
joined
.
exists
():
raise
Exception
(
f
"couldn't join
{
base
}
and
{
relative_path
}
"
)
return
joined
.
absolute
().
as_posix
()
return
joined
.
as_posix
()
def
join_repo_base
(
self
,
relative_path
:
str
)
->
str
:
return
self
.
_join_paths
(
...
...
experiments/simbricks/orchestration/simulation/pcidev.py
View file @
5eac59d3
...
...
@@ -71,13 +71,13 @@ class NICSim(PCIDevSim):
assert
len
(
pci_devices
)
==
1
socket
=
self
.
_get_socket
(
inst
=
inst
,
interface
=
pci_devices
[
0
].
_eth_if
)
assert
socket
is
not
None
cmd
+=
socket
.
_path
cmd
+=
f
"
{
socket
.
_path
}
"
eth_devices
=
self
.
filter_components_by_type
(
ty
=
sys_pcie
.
PCIeSimpleDevice
)
assert
len
(
eth_devices
)
==
1
socket
=
self
.
_get_socket
(
inst
=
inst
,
interface
=
eth_devices
[
0
].
_pci_if
)
assert
socket
is
not
None
cmd
+=
socket
.
_path
cmd
+=
f
"
{
socket
.
_path
}
"
cmd
+=
(
f
"
{
inst
.
get_simulator_shm_pool_path
(
sim
=
self
)
}
{
run_sync
}
{
self
.
_start_tick
}
"
...
...
@@ -90,11 +90,12 @@ class NICSim(PCIDevSim):
if
self
.
extra_args
is
not
None
:
cmd
+=
" "
+
self
.
extra_args
print
(
f
"NIC RUN COMMAND!!! =====
{
cmd
}
"
)
return
cmd
class
I40eNicSim
(
NICSim
):
def
__init__
(
self
,
simulation
:
sim_base
.
Simulation
):
super
().
__init__
(
simulation
=
simulation
,
...
...
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