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
98edd40c
Commit
98edd40c
authored
Sep 22, 2024
by
Hejing Li
Browse files
add pre_tar
parent
f8a439be
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
21 deletions
+32
-21
experiments/simbricks/orchestration/runtime_new/simulation_executor.py
...imbricks/orchestration/runtime_new/simulation_executor.py
+12
-12
experiments/simbricks/orchestration/simulation/base.py
experiments/simbricks/orchestration/simulation/base.py
+3
-0
experiments/simbricks/orchestration/simulation/host.py
experiments/simbricks/orchestration/simulation/host.py
+14
-4
experiments/simbricks/orchestration/system/host/disk_images.py
...iments/simbricks/orchestration/system/host/disk_images.py
+3
-5
No files found.
experiments/simbricks/orchestration/runtime_new/simulation_executor.py
View file @
98edd40c
...
@@ -120,22 +120,22 @@ class ExperimentBaseRunner(abc.ABC):
...
@@ -120,22 +120,22 @@ class ExperimentBaseRunner(abc.ABC):
async
def
prepare
(
self
)
->
None
:
async
def
prepare
(
self
)
->
None
:
# generate config tars
# generate config tars
copies
=
[]
# copies = []
# TODO: FIXME
# for host in self.exp.hosts:
for
host
in
self
.
exp
.
hosts
:
# path = self.env.cfgtar_path(host)
path
=
self
.
env
.
cfgtar_path
(
host
)
# if self._verbose:
if
self
.
_verbose
:
# print('preparing config tar:', path)
print
(
'preparing config tar:'
,
path
)
# # TODO: FIXME
# TODO: FIXME
# host.node_config.make_tar(self.env, path)
host
.
node_config
.
make_tar
(
self
.
env
,
path
)
# executor = self.sim_executor(host)
executor
=
self
.
sim_executor
(
host
)
# task = asyncio.create_task(executor.send_file(path, self._verbose))
task
=
asyncio
.
create_task
(
executor
.
send_file
(
path
,
self
.
_verbose
))
# copies.append(task)
copies
.
append
(
task
)
# await asyncio.gather(*copies)
await
asyncio
.
gather
(
*
copies
)
# prepare all simulators in parallel
# prepare all simulators in parallel
sims
=
[]
sims
=
[]
for
sim
in
self
.
_simulation
.
all_simulators
():
for
sim
in
self
.
_simulation
.
all_simulators
():
sim
.
prep_tar
(
self
.
_instantiation
)
prep_cmds
=
list
(
sim
.
prep_cmds
(
inst
=
self
.
_instantiation
))
prep_cmds
=
list
(
sim
.
prep_cmds
(
inst
=
self
.
_instantiation
))
executor
=
self
.
sim_executor
(
sim
)
executor
=
self
.
sim_executor
(
sim
)
task
=
asyncio
.
create_task
(
task
=
asyncio
.
create_task
(
...
...
experiments/simbricks/orchestration/simulation/base.py
View file @
98edd40c
...
@@ -117,6 +117,9 @@ class Simulator(utils_base.IdObj):
...
@@ -117,6 +117,9 @@ class Simulator(utils_base.IdObj):
"""Full name of the simulator."""
"""Full name of the simulator."""
return
""
return
""
def
prep_tar
(
self
,
inst
)
->
None
:
pass
# pylint: disable=unused-argument
# pylint: disable=unused-argument
def
prep_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
str
]:
def
prep_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
str
]:
"""Commands to prepare execution of this simulator."""
"""Commands to prepare execution of this simulator."""
...
...
experiments/simbricks/orchestration/simulation/host.py
View file @
98edd40c
...
@@ -95,7 +95,7 @@ class Gem5Sim(HostSim):
...
@@ -95,7 +95,7 @@ class Gem5Sim(HostSim):
def
__init__
(
self
,
e
:
sim_base
.
Simulation
):
def
__init__
(
self
,
e
:
sim_base
.
Simulation
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
name
:
str
=
''
self
.
name
=
super
().
full_name
()
self
.
cpu_type_cp
=
'X86KvmCPU'
self
.
cpu_type_cp
=
'X86KvmCPU'
self
.
cpu_type
=
'TimingSimpleCPU'
self
.
cpu_type
=
'TimingSimpleCPU'
self
.
extra_main_args
:
list
[
str
]
=
[]
self
.
extra_main_args
:
list
[
str
]
=
[]
...
@@ -110,6 +110,7 @@ class Gem5Sim(HostSim):
...
@@ -110,6 +110,7 @@ class Gem5Sim(HostSim):
def
resreq_mem
(
self
)
->
int
:
def
resreq_mem
(
self
)
->
int
:
return
4096
return
4096
# TODO: remove it
def
config_str
(
self
)
->
str
:
def
config_str
(
self
)
->
str
:
cp_es
=
[]
if
self
.
nockp
else
[
'm5 checkpoint'
]
cp_es
=
[]
if
self
.
nockp
else
[
'm5 checkpoint'
]
exit_es
=
[
'm5 exit'
]
exit_es
=
[
'm5 exit'
]
...
@@ -119,10 +120,19 @@ class Gem5Sim(HostSim):
...
@@ -119,10 +120,19 @@ class Gem5Sim(HostSim):
host
.
run_cmds
()
+
host
.
cleanup_cmds
()
+
exit_es
host
.
run_cmds
()
+
host
.
cleanup_cmds
()
+
exit_es
return
'
\n
'
.
join
(
es
)
return
'
\n
'
.
join
(
es
)
def
prep_tar
(
self
,
inst
:
inst_base
.
Instantiation
)
->
None
:
path
=
inst
.
cfgtar_path
(
self
)
print
(
self
.
name
,
' preparing config tar:'
,
path
)
for
c
in
self
.
_components
:
for
d
in
c
.
disks
:
d
.
prepare_image_path
(
inst
,
path
)
def
prep_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
tp
.
List
[
str
]:
def
prep_cmds
(
self
,
env
:
ExpEnv
)
->
tp
.
List
[
str
]:
cmds
=
[
f
'mkdir -p
{
env
.
gem5_cpdir
(
self
)
}
'
]
cmds
=
[
f
'mkdir -p
{
env
.
gem5_cpdir
(
self
)
}
'
]
if
env
.
restore_cp
and
self
.
modify_checkpoint_tick
:
if
inst
.
env
.
restore_cp
and
self
.
modify_checkpoint_tick
:
cmds
.
append
(
cmds
.
append
(
f
'python3
{
env
.
utilsdir
}
/modify_gem5_cp_tick.py --tick 0 '
f
'python3
{
env
.
utilsdir
}
/modify_gem5_cp_tick.py --tick 0 '
f
'--cpdir
{
env
.
gem5_cpdir
(
self
)
}
'
f
'--cpdir
{
env
.
gem5_cpdir
(
self
)
}
'
...
...
experiments/simbricks/orchestration/system/host/disk_images.py
View file @
98edd40c
...
@@ -89,14 +89,12 @@ class LinuxConfigDiskImage(DiskImage):
...
@@ -89,14 +89,12 @@ class LinuxConfigDiskImage(DiskImage):
def
available_formats
(
self
)
->
list
[
str
]:
def
available_formats
(
self
)
->
list
[
str
]:
return
[
"raw"
]
return
[
"raw"
]
async
def
prepare_image_path
(
self
,
env
:
expenv
.
ExpEnv
,
format
:
str
)
->
str
:
def
prepare_image_path
(
self
,
inst
,
path
)
->
str
:
# TODO: build tar from host path parameters and then return path
path
=
env
.
dynamic_img_path
(
self
,
format
)
with
tarfile
.
open
(
path
,
'w:'
)
as
tar
:
with
tarfile
.
open
(
path
,
'w:'
)
as
tar
:
# add main run script
# add main run script
cfg_i
=
tarfile
.
TarInfo
(
'guest/run.sh'
)
cfg_i
=
tarfile
.
TarInfo
(
'guest/run.sh'
)
cfg_i
.
mode
=
0o777
cfg_i
.
mode
=
0o777
cfg_f
=
self
.
host
.
strfile
(
self
.
host
.
config_str
())
cfg_f
=
self
.
host
.
strfile
(
self
.
host
.
_
config_str
(
inst
))
cfg_f
.
seek
(
0
,
io
.
SEEK_END
)
cfg_f
.
seek
(
0
,
io
.
SEEK_END
)
cfg_i
.
size
=
cfg_f
.
tell
()
cfg_i
.
size
=
cfg_f
.
tell
()
cfg_f
.
seek
(
0
,
io
.
SEEK_SET
)
cfg_f
.
seek
(
0
,
io
.
SEEK_SET
)
...
@@ -104,7 +102,7 @@ class LinuxConfigDiskImage(DiskImage):
...
@@ -104,7 +102,7 @@ class LinuxConfigDiskImage(DiskImage):
cfg_f
.
close
()
cfg_f
.
close
()
# add additional config files
# add additional config files
for
(
n
,
f
)
in
self
.
host
.
config_files
(
env
).
items
():
for
(
n
,
f
)
in
self
.
host
.
config_files
(
inst
).
items
():
f_i
=
tarfile
.
TarInfo
(
'guest/'
+
n
)
f_i
=
tarfile
.
TarInfo
(
'guest/'
+
n
)
f_i
.
mode
=
0o777
f_i
.
mode
=
0o777
f
.
seek
(
0
,
io
.
SEEK_END
)
f
.
seek
(
0
,
io
.
SEEK_END
)
...
...
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