Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assume core always active #1256

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
# limitations under the License.

from collections import defaultdict
import logging
from typing import Final, Optional, cast, Dict, Tuple

import numpy

from spinn_utilities.config_holder import get_config_bool, get_config_int
from spinn_utilities.log import FormatAdapter

from spinn_machine import Machine
from spinn_machine.version.abstract_version import (
AbstractVersion, ChipActiveTime, RouterPackets)

from spinnman.model.enums.executable_type import ExecutableType

from spinn_front_end_common.data import FecDataView
from spinn_front_end_common.interface.provenance import (
GlobalProvenance, ProvenanceReader, TimerCategory, TimerWork)
Expand All @@ -31,6 +38,8 @@
import BufferDatabase
from spinn_front_end_common.abstract_models import AbstractHasAssociatedBinary

logger = FormatAdapter(logging.getLogger(__name__))

#: milliseconds per second
_MS_PER_SECOND: Final = 1000.0
#: microseconds per millisecond
Expand Down Expand Up @@ -123,8 +132,12 @@ def compute_energy_used(checkpoint: Optional[int] = None) -> PowerUsed:
+ FecDataView.get_all_monitor_cores() - 1)
extra_monitors_per_board = (version.n_scamp_cores +
FecDataView.get_ethernet_monitor_cores() - 1)
run_chip_active_time = _extract_cores_active_time(
checkpoint, active_cores, power_cores, version)
if get_config_bool("Reports", "write_energy_report"):
run_chip_active_time = _extract_cores_active_time(
checkpoint, active_cores, power_cores, version)
else:
run_chip_active_time = _assume_core_always_active(
active_cores, execute_on_machine_ms)
load_chip_active_time = _make_extra_monitor_core_use(
data_loading_ms, machine, extra_monitors_per_board,
extra_monitors_per_chip)
Expand Down Expand Up @@ -215,6 +228,25 @@ def _extract_cores_active_time(
return chip_activity


def _assume_core_always_active(
active_cores: Dict[Tuple[int, int], int],
execute_on_machine_ms: float) -> ChipActiveTime:
"""
As there are no power monitors assume cores always active

"""
logger.warning(
"Energy monitoring cores not enabled, assuming all cores were"
" active for whole run time. To get a better energy estimate,"
" set write_energy_report=True in the [Reports] section of the"
" configuration file")
chip_activity: ChipActiveTime = {}
for (x, y), n_cores in active_cores.items():
chip_activity[x, y] = (
(execute_on_machine_ms * n_cores) / _MS_PER_SECOND, n_cores)
return chip_activity


def _make_extra_monitor_core_use(
time_ms: int, machine: Machine, extra_monitors_per_board: int,
extra_monitors_per_chip: int) -> ChipActiveTime:
Expand Down
Loading