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

SpiNNakerManchester / PACMAN / 8911737749

01 May 2024 03:54PM UTC coverage: 88.011% (+1.9%) from 86.14%
8911737749

push

github

Christian-B
merged in master

2278 of 2641 branches covered (86.26%)

Branch coverage included in aggregate %.

4725 of 5316 relevant lines covered (88.88%)

0.89 hits per line

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

88.57
/pacman/operations/routing_table_generators/basic_routing_table_generator.py
1
# Copyright (c) 2016 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 Dict, Tuple
1✔
15
from spinn_utilities.progress_bar import ProgressBar
1✔
16
from spinn_machine import MulticastRoutingEntry, RoutingEntry
1✔
17
from pacman.data import PacmanDataView
1✔
18
from pacman.model.routing_tables import (
1✔
19
    UnCompressedMulticastRoutingTable, MulticastRoutingTables)
20
from pacman.model.graphs import AbstractVertex
1✔
21
from pacman.model.routing_info import RoutingInfo
1✔
22

23

24
def basic_routing_table_generator() -> MulticastRoutingTables:
1✔
25
    """
26
    An basic algorithm that can produce routing tables.
27

28
    :rtype: MulticastRoutingTables
29
    """
30
    routing_infos = PacmanDataView.get_routing_infos()
1✔
31
    routing_table_by_partitions = (
1✔
32
        PacmanDataView.get_routing_table_by_partition())
33
    progress = ProgressBar(
1✔
34
        routing_table_by_partitions.n_routers, "Generating routing tables")
35
    routing_tables = MulticastRoutingTables()
1✔
36
    for x, y in progress.over(routing_table_by_partitions.get_routers()):
1✔
37
        parts = routing_table_by_partitions.get_entries_for_router(x, y)
1✔
38
        # Should be there; skip if not
39
        if parts is None:
1!
40
            continue
×
41
        routing_tables.add_routing_table(__create_routing_table(
1✔
42
            x, y, parts, routing_infos))
43

44
    return routing_tables
1✔
45

46

47
def __create_routing_table(
1✔
48
        x: int, y: int, partitions_in_table: Dict[
49
            Tuple[AbstractVertex, str], RoutingEntry],
50
        routing_infos: RoutingInfo):
51
    """
52
    :param int x:
53
    :param int y:
54
    :param partitions_in_table:
55
    :type partitions_in_table:
56
        dict(((ApplicationVertex or MachineVertex), str),
57
        RoutingEntry)
58
    :param RoutingInfo routing_infos:
59
    :rtype: MulticastRoutingTable
60
    """
61
    table = UnCompressedMulticastRoutingTable(x, y)
1✔
62
    for source_vertex, partition_id in partitions_in_table:
1✔
63
        r_info = routing_infos.get_routing_info_from_pre_vertex(
1✔
64
            source_vertex, partition_id)
65
        # Should be there; skip if not
66
        if r_info is None:
1!
67
            continue
×
68
        entry = partitions_in_table[source_vertex, partition_id]
1✔
69
        table.add_multicast_routing_entry(MulticastRoutingEntry(
1✔
70
            key=r_info.key_and_mask.key_combo,
71
            mask=r_info.key_and_mask.mask, routing_entry=entry))
72

73
    return table
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