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
907fda7b
"vscode:/vscode.git/clone" did not exist on "29b1d19d30db042bba22109bdf8359fac9335a81"
Unverified
Commit
907fda7b
authored
Sep 13, 2024
by
Jakob Görgen
Browse files
fixes in simulation base module + channel impl extension
parent
24d55893
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
experiments/simbricks/orchestration/simulation/base.py
experiments/simbricks/orchestration/simulation/base.py
+16
-5
experiments/simbricks/orchestration/simulation/channel.py
experiments/simbricks/orchestration/simulation/channel.py
+15
-0
No files found.
experiments/simbricks/orchestration/simulation/base.py
View file @
907fda7b
...
...
@@ -186,13 +186,14 @@ class Simulator(utils_base.IdObj):
def
_get_channel
(
self
,
chan
:
sys_conf
.
Channel
)
->
sim_chan
.
Channel
|
None
:
if
self
.
_chan_needs_instance
(
chan
):
return
self
.
experiment
.
retrieve_or_create_channel
(
chan
=
chan
)
return
self
.
_simulation
.
retrieve_or_create_channel
(
chan
=
chan
)
return
None
def
_
get_channels
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
sim_chan
.
Channel
]:
def
get_channels
(
self
)
->
list
[
sim_chan
.
Channel
]:
channels
=
[]
for
comp_spec
in
self
.
_components
:
for
chan
in
self
.
experiment
.
retrieve_or_create_channel
(
chan
=
chan
):
comp_sys_channels
=
comp_spec
.
channels
()
for
chan
in
comp_sys_channels
:
channel
=
self
.
_get_channel
(
chan
=
chan
)
if
channel
is
None
:
continue
...
...
@@ -277,7 +278,7 @@ class Simulation(utils_base.IdObj):
self
.
_sim_list
:
list
[
Simulator
]
=
[]
"""Channel spec and its instanciation"""
def
add_sim
(
self
,
sim
:
Simulator
):
def
add_sim
(
self
,
sim
:
Simulator
):
if
sim
in
self
.
_sim_list
:
raise
Exception
(
"Simulaotr is already added"
)
self
.
_sim_list
.
append
(
sim
)
...
...
@@ -288,7 +289,7 @@ class Simulation(utils_base.IdObj):
raise
Exception
(
"system component is already mapped by simulator"
)
self
.
_sys_sim_map
[
sys
]
=
sim
def
is_channel_instantiated
(
self
,
chan
:
Channel
)
->
bool
:
def
is_channel_instantiated
(
self
,
chan
:
sys_conf
.
Channel
)
->
bool
:
return
chan
in
self
.
_chan_map
def
retrieve_or_create_channel
(
self
,
chan
:
sys_conf
.
Channel
)
->
Channel
:
...
...
@@ -302,6 +303,16 @@ class Simulation(utils_base.IdObj):
def
all_simulators
(
self
)
->
list
[
Simulator
]:
return
self
.
_sim_list
def
get_all_channels
(
self
,
lazy
:
bool
=
False
)
->
list
[
Channel
]:
if
lazy
:
return
list
(
self
.
_chan_map
.
values
())
all_channels
=
[]
for
sim
in
self
.
all_simulators
():
channels
=
sim
.
get_channels
()
all_channels
.
extend
(
channels
)
return
all_channels
def
resreq_mem
(
self
)
->
int
:
"""Memory required to run all simulators in this experiment."""
mem
=
0
...
...
experiments/simbricks/orchestration/simulation/channel.py
View file @
907fda7b
...
...
@@ -20,7 +20,18 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
enum
from
simbricks.orchestration.system
import
base
as
system_base
from
simbricks.orchestration.utils
import
base
as
utils_base
class
Time
(
enum
.
IntEnum
):
Picoseconds
=
10
**
(
-
3
)
Nanoseconds
=
1
Microseconds
=
10
**
(
3
)
Milliseconds
=
10
**
(
6
)
Seconds
=
10
**
(
9
)
class
Channel
:
...
...
@@ -32,3 +43,7 @@ class Channel:
def
full_name
(
self
)
->
str
:
return
"channel."
+
self
.
name
def
set_sync_period
(
self
,
amount
:
int
,
ratio
:
Time
=
Time
.
Nanoseconds
)
->
None
:
utils_base
.
has_expected_type
(
obj
=
ratio
,
expected_type
=
Time
)
self
.
sync_period
=
amount
*
ratio
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