Skip to content

Commit

Permalink
store executuable type
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Dec 2, 2024
1 parent aad2544 commit cbe5c64
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

from sqlite3 import Binary, IntegrityError
import time
from typing import Optional, Tuple
from typing import cast, Optional, Tuple
from spinn_utilities.config_holder import get_config_bool
from spinnman.model.enums.executable_type import ExecutableType
from spinn_front_end_common.abstract_models import AbstractHasAssociatedBinary
from spinn_front_end_common.data import FecDataView
from spinn_front_end_common.utilities.base_database import BaseDatabase

Expand Down Expand Up @@ -524,37 +526,50 @@ def write_session_credentials_to_db(self) -> None:
VALUES(?, ?, ?)
""", [(k1, k2, v) for (k1, k2), v in config.items()])

def _set_core_name(self, x: int, y: int, p: int, core_name: Optional[str]):
def _set_core_name(self, x: int, y: int, p: int, core_name: Optional[str],
executable_type: int):
"""
:param int x:
:param int y:
:param int p:
:param str core_name:
Set the core name and executable type.
"""
try:
self.execute(
"""
INSERT INTO core (x, y, processor, core_name)
VALUES (?, ?, ? ,?)
""", (x, y, p, core_name))
INSERT INTO core (x, y, processor, core_name, executable_type)
VALUES (?, ?, ? ,?, ?)
""", (x, y, p, core_name, executable_type))
except IntegrityError:
self.execute(
"""
UPDATE core SET core_name = ?
UPDATE core SET core_name = ?, executable_type = ?
WHERE x = ? AND y = ? and processor = ?
""", (core_name, x, y, p))
""", (core_name, executable_type, x, y, p))

def store_vertex_labels(self) -> None:
"""
Goes though all placement an monitor cores to set a label.
Goes through all placement and monitor cores to set a label.
"""
# pylint: disable=import-outside-toplevel
from spinn_front_end_common.utility_models \
.chip_power_monitor_machine_vertex \
import (ChipPowerMonitorMachineVertex)
type_value: Optional[int]
for placement in FecDataView.iterate_placemements():
self._set_core_name(
placement.x, placement.y, placement.p, placement.vertex.label)
if isinstance(placement.vertex, AbstractHasAssociatedBinary):
if isinstance(placement.vertex, ChipPowerMonitorMachineVertex):
type_value = len(ExecutableType)
else:
vertex: AbstractHasAssociatedBinary = cast(
AbstractHasAssociatedBinary, placement.vertex)
type_value = vertex.get_binary_start_type().value
else:
type_value = None
self._set_core_name(placement.x, placement.y, placement.p,
placement.vertex.label, type_value)
system = ExecutableType.SYSTEM.value
for chip in FecDataView.get_machine().chips:
for p in chip.scamp_processors_ids:
self._set_core_name(
chip.x, chip.y, p, f"SCAMP(OS)_{chip.x}:{chip.y}")
self._set_core_name(chip.x, chip.y, p,
f"SCAMP(OS)_{chip.x}:{chip.y}", system)

def get_core_name(self, x: int, y: int, p: int) -> Optional[str]:
"""
Expand Down
10 changes: 9 additions & 1 deletion spinn_front_end_common/utilities/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ CREATE TABLE IF NOT EXISTS core(
x INTEGER NOT NULL,
y INTEGER NOT NULL,
processor INTEGER NOT NULL,
core_name STRING);
core_name STRING,
executable_type INTEGER);
-- Every processor has a unique ID
CREATE UNIQUE INDEX IF NOT EXISTS coreSanity ON core(
x ASC, y ASC, processor ASC);

CREATE VIEW IF NOT EXISTS active_cores AS
SELECT x, y, COUNT(processor) AS n_cores
FROM core
WHERE executable_type < 4
GROUP BY x, y
ORDER BY x, y;

CREATE TABLE IF NOT EXISTS setup(
setup_id INTEGER PRIMARY KEY CHECK (setup_id = 0),
hardware_time_step_ms FLOAT NOT NULL,
Expand Down
1 change: 0 additions & 1 deletion spinn_front_end_common/utilities/system_control_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def _report_iobuf_messages(
:param ~logging.Logger logger:
:param str filename_template:
"""
# Import in this function to prevent circular import issue
iobuf_reader = IOBufExtractor(
cores,
filename_template=filename_template, suppress_progress=False)
Expand Down

0 comments on commit cbe5c64

Please sign in to comment.