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

SpiNNakerManchester / sPyNNaker / 9164270718

20 May 2024 08:00PM UTC coverage: 68.553%. Remained the same
9164270718

Pull #1454

github

web-flow
---
updated-dependencies:
- dependency-name: JamesIves/github-pages-deploy-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1454: Bump JamesIves/github-pages-deploy-action from 4.6.0 to 4.6.1

6128 of 8625 branches covered (71.05%)

Branch coverage included in aggregate %.

13075 of 19387 relevant lines covered (67.44%)

0.67 hits per line

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

25.0
/spynnaker/pyNN/extra_algorithms/synapse_expander.py
1
# Copyright (c) 2017 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
import logging
1✔
15
from typing import List, Tuple, cast
1✔
16
from spinn_utilities.config_holder import get_config_bool
1✔
17
from spinn_utilities.log import FormatAdapter
1✔
18
from spinn_utilities.progress_bar import ProgressBar
1✔
19
from spinnman.model.enums import ExecutableType
1✔
20
from spinnman.model import ExecutableTargets
1✔
21
from spinnman.model.enums import CPUState, UserRegister
1✔
22
from pacman.model.placements import Placement
1✔
23
from spinn_front_end_common.utilities.system_control_logic import (
1✔
24
    run_system_application)
25
from spynnaker.pyNN.data import SpynnakerDataView
1✔
26
from spynnaker.pyNN.models.abstract_models import (
1✔
27
    AbstractSynapseExpandable, SYNAPSE_EXPANDER_APLX)
28

29
logger = FormatAdapter(logging.getLogger(__name__))
1✔
30

31

32
def synapse_expander() -> None:
1✔
33
    """
34
    Run the synapse expander.
35

36
    .. note::
37
        Needs to be done after data has been loaded.
38
    """
39
    # Find the places where the synapse expander and delay receivers should run
40
    expander_cores, expanded_placements, timeout = _plan_expansion()
×
41

42
    if expander_cores.total_processors:
×
43
        with ProgressBar(expander_cores.total_processors,
×
44
                         "Expanding Synapses") as progress:
45
            expander_app_id = SpynnakerDataView.get_new_id()
×
46
            run_system_application(
×
47
                expander_cores, expander_app_id,
48
                get_config_bool("Reports", "write_expander_iobuf") or False,
49
                None, frozenset({CPUState.FINISHED}), False,
50
                "synapse_expander_on_{}_{}_{}.txt",
51
                progress_bar=progress, logger=logger, timeout=timeout)
52

53
    # Once expander has run, fill in the connection data.
54
    if expanded_placements:
×
55
        with ProgressBar(len(expanded_placements),
×
56
                         "Reading generated connections") as progress:
57
            for placement in progress.over(expanded_placements):
×
58
                vertex = cast(AbstractSynapseExpandable, placement.vertex)
×
59
                vertex.read_generated_connection_holders(placement)
×
60

61

62
def _plan_expansion() -> Tuple[ExecutableTargets, List[Placement], float]:
1✔
63
    """
64
    Plan the expansion of synapses and set up the regions using USER1.
65

66
    :return: The places to load the synapse expander and delay expander
67
        executables, the target machine vertices to read synapses back from,
68
        and an estimated timeout for how long the expansion should be let run.
69
    :rtype: tuple(~.ExecutableTargets, list(~.Placement), float)
70
    """
71
    synapse_bin = SpynnakerDataView.get_executable_path(SYNAPSE_EXPANDER_APLX)
×
72
    expander_cores = ExecutableTargets()
×
73
    expanded_placements = list()
×
74
    txrx = SpynnakerDataView.get_transceiver()
×
75

76
    max_data = 0
×
77
    max_bit_field = 0
×
78
    progress = ProgressBar(
×
79
        SpynnakerDataView.get_n_placements(), "Preparing to Expand Synapses")
80
    for placement in progress.over(SpynnakerDataView.iterate_placemements()):
×
81
        # Add all machine vertices of the population vertex to ones
82
        # that need synapse expansion
83
        vertex = placement.vertex
×
84
        if isinstance(vertex, AbstractSynapseExpandable):
×
85
            if vertex.gen_on_machine():
×
86
                expander_cores.add_processor(
×
87
                    synapse_bin, placement.x, placement.y, placement.p,
88
                    executable_type=ExecutableType.SYSTEM)
89
                expanded_placements.append(placement)
×
90
                # Write the region to USER1, as that is the best we can do
91
                txrx.write_user(
×
92
                    placement.x, placement.y, placement.p, UserRegister.USER_1,
93
                    vertex.connection_generator_region)
94
                max_data = max(max_data, vertex.max_gen_data)
×
95
                max_bit_field = max(max_bit_field, vertex.bit_field_size)
×
96

97
    # Allow 1 seconds per ~1000 synapses, with minimum of 2 seconds
98
    timeout = max(2.0, max_data / 1000.0)
×
99
    # Also allow 1s per 1000 bytes of bitfields
100
    timeout += max(2.0, max_bit_field / 1000.0)
×
101
    return expander_cores, expanded_placements, timeout
×
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

© 2025 Coveralls, Inc