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
bef618ad
Unverified
Commit
bef618ad
authored
Sep 09, 2024
by
Jakob Görgen
Browse files
fixed circular import issues
parent
8eb3a0ac
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
74 deletions
+22
-74
experiments/simbricks/orchestration/instantiation/base.py
experiments/simbricks/orchestration/instantiation/base.py
+1
-8
experiments/simbricks/orchestration/runtime_new/runs/base.py
experiments/simbricks/orchestration/runtime_new/runs/base.py
+2
-1
experiments/simbricks/orchestration/runtime_new/simulation_executor.py
...imbricks/orchestration/runtime_new/simulation_executor.py
+4
-3
experiments/simbricks/orchestration/simulation/base.py
experiments/simbricks/orchestration/simulation/base.py
+4
-50
experiments/simbricks/orchestration/simulation/channel.py
experiments/simbricks/orchestration/simulation/channel.py
+3
-6
experiments/simbricks/orchestration/simulation/host.py
experiments/simbricks/orchestration/simulation/host.py
+5
-4
experiments/simbricks/orchestration/simulation/pcidev.py
experiments/simbricks/orchestration/simulation/pcidev.py
+3
-2
No files found.
experiments/simbricks/orchestration/instantiation/base.py
View file @
bef618ad
...
...
@@ -27,7 +27,6 @@ import enum
import
pathlib
import
shutil
from
simbricks.orchestration.utils
import
base
as
util_base
from
simbricks.orchestration.simulation
import
base
as
sim_base
from
simbricks.orchestration.system
import
base
as
sys_base
from
simbricks.orchestration.runtime_new
import
command_executor
...
...
@@ -77,11 +76,9 @@ class Instantiation(util_base.IdObj):
def
__init__
(
self
,
simulation
:
sim_base
.
Simulation
,
env
:
InstantiationEnvironment
=
InstantiationEnvironment
(),
):
super
().
__init__
()
self
.
_simulation
:
sim_base
.
Simulation
=
simulation
self
.
_env
:
InstantiationEnvironment
=
env
self
.
_socket_per_interface
:
dict
[
sys_base
.
Interface
,
Socket
]
=
{}
...
...
@@ -216,10 +213,6 @@ class Instantiation(util_base.IdObj):
def
shm_base_dir
(
self
)
->
str
:
return
pathlib
.
Path
(
self
.
_env
.
_shm_base
).
absolute
()
def
checkpointing_enabled
(
self
)
->
bool
:
# TODO: not sure if needed wanted here like this
return
self
.
_simulation
.
checkpointing_enabled
()
def
create_cp
(
self
)
->
bool
:
return
self
.
_env
.
_create_cp
...
...
@@ -294,7 +287,7 @@ class Instantiation(util_base.IdObj):
# TODO: fixme
def
cfgtar_path
(
self
,
sim
:
Simulator
)
->
str
:
return
f
'
{
self
.
workdir
}
/cfg.
{
sim
.
name
}
.tar
'
return
f
"
{
self
.
workdir
}
/cfg.
{
sim
.
name
}
.tar
"
def
join_tmp_base
(
self
,
relative_path
:
str
)
->
str
:
return
self
.
_join_paths
(
...
...
experiments/simbricks/orchestration/runtime_new/runs/base.py
View file @
bef618ad
...
...
@@ -29,6 +29,7 @@ import shutil
import
typing
as
tp
import
abc
from
simbricks.orchestration.simulation
import
output
from
simbricks.orchestration.simulation
import
base
as
sim_base
from
simbricks.orchestration.instantiation
import
base
as
inst_base
from
simbricks.orchestration.runtime_new
import
command_executor
...
...
@@ -50,7 +51,7 @@ class Run:
self
.
_simulation
:
sim_base
.
Simulation
=
simulation
self
.
_run_nr
=
next
(
self
.
__run_nr
)
self
.
_instantiation
:
inst_base
.
Instantiation
=
instantiation
self
.
_output
:
sim_base
.
SimulationOutput
|
None
=
output
self
.
_output
:
output
.
SimulationOutput
|
None
=
output
self
.
_prereq
:
Run
|
None
=
prereq
self
.
_job_id
:
int
|
None
=
job_id
"""Slurm job id."""
...
...
experiments/simbricks/orchestration/runtime_new/simulation_executor.py
View file @
bef618ad
...
...
@@ -31,6 +31,7 @@ import abc
from
simbricks.orchestration.utils
import
graphlib
from
simbricks.orchestration.simulation
import
output
from
simbricks.orchestration.simulation
import
base
as
sim_base
from
simbricks.orchestration.instantiation
import
base
as
inst_base
from
simbricks.orchestration.runtime_new
import
command_executor
...
...
@@ -43,7 +44,7 @@ class ExperimentBaseRunner(abc.ABC):
self
.
_instantiation
:
inst_base
.
Instantiation
=
instantiation
self
.
_verbose
:
bool
=
verbose
self
.
_profile_int
:
int
|
None
=
None
self
.
_out
=
sim_base
.
SimulationOutput
(
self
.
_simulation
)
self
.
_out
=
output
.
SimulationOutput
(
self
.
_simulation
)
self
.
_running
:
list
[
tuple
[
sim_base
.
Simulator
,
command_executor
.
SimpleComponent
]]
=
[]
self
.
_sockets
:
list
[
tuple
[
command_executor
.
Executor
,
inst_base
.
Socket
]]
=
[]
self
.
_wait_sims
:
list
[
command_executor
.
Component
]
=
[]
...
...
@@ -152,7 +153,7 @@ class ExperimentBaseRunner(abc.ABC):
for
sc
in
self
.
_wait_sims
:
await
sc
.
wait
()
async
def
terminate_collect_sims
(
self
)
->
sim_base
.
SimulationOutput
:
async
def
terminate_collect_sims
(
self
)
->
output
.
SimulationOutput
:
"""Terminates all simulators and collects output."""
self
.
_out
.
set_end
()
if
self
.
_verbose
:
...
...
@@ -187,7 +188,7 @@ class ExperimentBaseRunner(abc.ABC):
for
(
_
,
sc
)
in
self
.
_running
:
await
sc
.
sigusr1
()
async
def
run
(
self
)
->
sim_base
.
SimulationOutput
:
async
def
run
(
self
)
->
output
.
SimulationOutput
:
profiler_task
=
None
try
:
...
...
experiments/simbricks/orchestration/simulation/base.py
View file @
bef618ad
...
...
@@ -27,11 +27,9 @@ import itertools
import
time
import
typing
as
tp
import
simbricks.orchestration.system
as
sys_conf
from
simbricks.orchestration.experiment
import
experiment_environment_new
as
exp_env
from
simbricks.orchestration.instantiation
import
base
as
inst_base
from
simbricks.orchestration.simulation
import
channel
as
sim_chan
from
simbricks.orchestration.utils
import
base
as
utils_base
from
simbricks.orchestration.runtime_new
import
command_executor
import
simbricks.orchestration.instantiation.base
as
inst_base
import
simbricks.orchestration.simulation.channel
as
sim_chan
import
simbricks.orchestration.utils.base
as
utils_base
if
tp
.
TYPE_CHECKING
:
from
simbricks.orchestration.simulation
import
(
...
...
@@ -50,7 +48,7 @@ class Simulator(utils_base.IdObj):
self
,
simulation
:
sim_base
.
Simulation
,
name
:
str
=
""
,
elative_executable_path
:
str
=
""
,
r
elative_executable_path
:
str
=
""
,
)
->
None
:
super
().
__init__
()
self
.
name
:
str
=
name
...
...
@@ -340,47 +338,3 @@ class Simulation(utils_base.IdObj):
def
is_checkpointing_enabled
(
self
)
->
bool
:
raise
Exception
(
"not implemented"
)
class
SimulationOutput
:
"""Manages an experiment's output."""
def
__init__
(
self
,
sim
:
Simulation
)
->
None
:
self
.
_sim_name
:
str
=
sim
.
name
self
.
_start_time
:
float
=
None
self
.
_end_time
:
float
=
None
self
.
_success
:
bool
=
True
self
.
_interrupted
:
bool
=
False
self
.
_metadata
=
exp
.
metadata
self
.
_sims
:
dict
[
str
,
dict
[
str
,
str
|
list
[
str
]]]
=
{}
def
set_start
(
self
)
->
None
:
self
.
_start_time
=
time
.
time
()
def
set_end
(
self
)
->
None
:
self
.
_end_time
=
time
.
time
()
def
set_failed
(
self
)
->
None
:
self
.
_success
=
False
def
set_interrupted
(
self
)
->
None
:
self
.
_success
=
False
self
.
_interrupted
=
True
def
add_sim
(
self
,
sim
:
Simulator
,
comp
:
command_executor
.
Component
)
->
None
:
obj
=
{
"class"
:
sim
.
__class__
.
__name__
,
"cmd"
:
comp
.
cmd_parts
,
"stdout"
:
comp
.
stdout
,
"stderr"
:
comp
.
stderr
,
}
self
.
_sims
[
sim
.
full_name
()]
=
obj
def
dump
(
self
,
outpath
:
str
)
->
None
:
pathlib
.
Path
(
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
outpath
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
json
.
dump
(
self
.
__dict__
,
file
,
indent
=
4
)
def
load
(
self
,
file
:
str
)
->
None
:
with
open
(
file
,
"r"
,
encoding
=
"utf-8"
)
as
fp
:
for
k
,
v
in
json
.
load
(
fp
).
items
():
self
.
__dict__
[
k
]
=
v
experiments/simbricks/orchestration/simulation/channel.py
View file @
bef618ad
...
...
@@ -20,15 +20,12 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
typing
as
tp
import
simbricks.orchestration.system.base
as
system_base
import
simbricks.orchestration.simulation.base
as
sim_base
from
simbricks.orchestration.system
import
base
as
system_base
class
Channel
(
sim_base
.
Simulator
)
:
class
Channel
:
def
__init__
(
self
,
e
:
sim_base
.
Simulation
,
chan
:
system_base
.
Channel
):
super
().
__init__
(
e
)
def
__init__
(
self
,
chan
:
system_base
.
Channel
):
self
.
_synchronized
:
bool
=
True
self
.
sync_period
:
int
=
500
# nano second
self
.
sys_channel
:
system_base
.
Channel
=
chan
...
...
experiments/simbricks/orchestration/simulation/host.py
View file @
bef618ad
...
...
@@ -56,8 +56,9 @@ class HostSim(sim_base.Simulator):
def
add
(
self
,
host
:
'Host'
):
self
.
hosts
.
append
(
host
)
self
.
name
=
f
'
{
self
.
_id
}
'
self
.
experiment
.
add_host
(
self
)
self
.
experiment
.
sys_sim_map
[
host
]
=
self
# TODO: FIXME, call super method...
# self.experiment.add_host(self)
# self.experiment.sys_sim_map[host] = self
def
config_str
(
self
)
->
str
:
return
[]
...
...
@@ -170,8 +171,8 @@ class Gem5Sim(HostSim):
f
':latency=
{
dev
.
channel
.
latency
}
ns'
f
':sync_interval=
{
chn_sim
.
sync_period
}
ns'
)
if
cpu_type
==
'TimingSimpleCPU'
and
:
#TODO
cmd
+=
':sync'
#
if cpu_type == 'TimingSimpleCPU' and: #TODO
: FIXME
#
cmd += ':sync'
cmd
+=
' '
return
cmd
...
...
experiments/simbricks/orchestration/simulation/pcidev.py
View file @
bef618ad
...
...
@@ -65,8 +65,9 @@ class NICSim(PCIDevSim):
def
add
(
self
,
nic
:
sys_conf
.
SimplePCIeNIC
):
self
.
nics
.
append
(
nic
)
# nic.sim = self
self
.
experiment
.
add_nic
(
self
)
self
.
experiment
.
sys_sim_map
[
nic
]
=
self
# TODO: FIXME, call super method...
#self.experiment.add_nic(self)
#self.experiment.sys_sim_map[nic] = self
self
.
name
=
f
'
{
nic
.
_id
}
'
def
basic_args
(
self
,
env
:
ExpEnv
,
extra
:
tp
.
Optional
[
str
]
=
None
)
->
str
:
...
...
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