• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNFrontEndCommon / 8246920254

12 Mar 2024 10:03AM UTC coverage: 47.983% (+0.01%) from 47.973%
8246920254

push

github

web-flow
Merge pull request #1163 from SpiNNakerManchester/live_tweaks

Live tweaks

2046 of 4791 branches covered (42.71%)

Branch coverage included in aggregate %.

6 of 12 new or added lines in 3 files covered. (50.0%)

1 existing line in 1 file now uncovered.

5485 of 10904 relevant lines covered (50.3%)

0.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.01
/spinn_front_end_common/interface/interface_functions/load_executable_images.py
1
# Copyright (c) 2015 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
from typing import Callable
1✔
15
import logging
1✔
16
from spinn_utilities.progress_bar import ProgressBar
1✔
17
from spinn_utilities.log import FormatAdapter
1✔
18
from spinnman.messages.scp.enums import Signal
1✔
19
from spinnman.model import ExecutableTargets
1✔
20
from spinnman.model.enums import CPUState, ExecutableType
1✔
21
from spinnman.exceptions import (
1✔
22
    SpiNNManCoresNotInStateException, SpinnmanException)
23
from spinn_front_end_common.data import FecDataView
1✔
24
from spinn_front_end_common.utilities.helpful_functions import (
1✔
25
    flood_fill_binary_to_spinnaker)
26
from spinn_front_end_common.utilities.emergency_recovery import (
1✔
27
    emergency_recover_states_from_failure)
28
from spinn_front_end_common.utilities.iobuf_extractor import IOBufExtractor
1✔
29

30
# 10 seconds is lots of time to wait for the application to become ready!
31
_APP_READY_TIMEOUT = 10.0
1✔
32
_running_state = frozenset([CPUState.RUNNING])
1✔
33
logger = FormatAdapter(logging.getLogger(__name__))
1✔
34

35

36
def load_app_images() -> None:
1✔
37
    """
38
    Go through the executable targets and load each binary to everywhere
39
    and then send a start request to the cores that actually use it.
40
    """
41
    _load_images(lambda ty: ty is not ExecutableType.SYSTEM,
1✔
42
                 "Loading executables onto the machine")
43

44

45
def load_sys_images() -> None:
1✔
46
    """
47
    Go through the executable targets and load each binary to everywhere
48
    and then send a start request to the cores that actually use it.
49
    """
50
    _load_images(lambda ty: ty is ExecutableType.SYSTEM,
×
51
                 "Loading system executables onto the machine")
52
    try:
×
53
        cores = filter_targets(lambda ty: ty is ExecutableType.SYSTEM)
×
54
        FecDataView.get_transceiver().wait_for_cores_to_be_in_state(
×
55
            cores.all_core_subsets, FecDataView.get_app_id(),
56
            _running_state, timeout=10)
57
    except SpiNNManCoresNotInStateException as e:
×
58
        emergency_recover_states_from_failure()
×
59
        raise e
×
60

61

62
def _load_images(
1✔
63
        filter_predicate: Callable[[ExecutableType], bool], label: str):
64
    """
65
    :param callable(ExecutableType,bool) filter_predicate:
66
    :param str label
67
    """
68
    # Compute what work is to be done here
69
    cores = filter_targets(filter_predicate)
1✔
70

71
    try:
1✔
72
        with ProgressBar(cores.total_processors + 1, label) as progress:
1✔
73
            for binary in cores.binaries:
1✔
74
                progress.update(flood_fill_binary_to_spinnaker(binary))
1✔
75

76
            _start_simulation(cores, FecDataView.get_app_id())
1✔
77
            progress.update()
1✔
78
    except Exception as e:
×
79
        try:
×
80

NEW
81
            transceiver = FecDataView.get_transceiver()
×
NEW
82
            unsuccessful_cores = transceiver.get_cpu_infos(
×
83
                    cores.all_core_subsets, [CPUState.READY], False)
NEW
84
            logger.error(unsuccessful_cores.get_status_string())
×
NEW
85
            IOBufExtractor().extract_iobuf()
×
NEW
86
            transceiver.stop_application(FecDataView.get_app_id())
×
UNCOV
87
        except SpinnmanException:
×
88
            # Ignore this, this was just an attempt at recovery
89
            pass
×
90
        raise e
×
91

92

93
def filter_targets(
1✔
94
        filter_predicate: Callable[[ExecutableType], bool]
95
        ) -> ExecutableTargets:
96
    """
97
    :param callable(ExecutableType,bool) filter_predicate:
98
    :rtype: ~spinnman.model.ExecutableTargets
99
    """
100
    cores = ExecutableTargets()
1✔
101
    targets = FecDataView.get_executable_targets()
1✔
102
    for exe_type in targets.executable_types_in_binary_set():
1✔
103
        if filter_predicate(exe_type):
1!
104
            for aplx in targets.get_binaries_of_executable_type(exe_type):
1✔
105
                cores.add_subsets(
1✔
106
                    aplx, targets.get_cores_for_binary(aplx), exe_type)
107
    return cores
1✔
108

109

110
def _start_simulation(cores: ExecutableTargets, app_id: int):
1✔
111
    """
112
    :param ~.ExecutableTargets cores:
113
        Possible subset of all ExecutableTargets to start
114
    :param int app_id:
115
    """
116
    txrx = FecDataView.get_transceiver()
1✔
117
    txrx.wait_for_cores_to_be_in_state(
1✔
118
        cores.all_core_subsets, app_id, frozenset([CPUState.READY]),
119
        timeout=_APP_READY_TIMEOUT)
120
    txrx.send_signal(app_id, Signal.START)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc