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

SpiNNakerManchester / SpiNNMachine / 6615543458

23 Oct 2023 03:33PM UTC coverage: 92.79% (+0.03%) from 92.758%
6615543458

push

github

web-flow
Merge pull request #229 from SpiNNakerManchester/chip_str

Chip String fixes

751 of 850 branches covered (0.0%)

Branch coverage included in aggregate %.

10 of 10 new or added lines in 2 files covered. (100.0%)

2196 of 2326 relevant lines covered (94.41%)

0.94 hits per line

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

92.16
/spinn_machine/processor.py
1
# Copyright (c) 2014 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
1✔
15
from .exceptions import SpinnMachineInvalidParameterException
1✔
16

17
non_monitor: Dict[int, 'Processor'] = dict()
1✔
18
monitor: Dict[int, 'Processor'] = dict()
1✔
19

20

21
class Processor(object):
1✔
22
    """
23
    A processor object included in a SpiNNaker chip.
24
    """
25

26
    CLOCK_SPEED = 200 * 1000 * 1000
1✔
27
    DTCM_AVAILABLE = 2 ** 16
1✔
28

29
    __slots__ = (
1✔
30
        "_processor_id", "_clock_speed", "_is_monitor", "_dtcm_available"
31
    )
32

33
    def __init__(self, processor_id: int,
1✔
34
                 clock_speed: int = CLOCK_SPEED,
35
                 is_monitor: bool = False,
36
                 dtcm_available: int = DTCM_AVAILABLE):
37
        """
38
        :param int processor_id:
39
            ID of the processor in the chip
40
        :param int clock_speed:
41
            The number of CPU cycles per second of the processor
42
        :param bool is_monitor:
43
            Determines if the processor is considered the
44
            monitor processor, and so should not be otherwise allocated
45
        :param int dtcm_available:
46
            Data Tightly Coupled Memory available
47
        :raise spinn_machine.exceptions.SpinnMachineInvalidParameterException:
48
            If the clock speed is negative
49
        """
50

51
        if clock_speed < 0:
1✔
52
            raise SpinnMachineInvalidParameterException(
1✔
53
                "clock_speed", str(clock_speed),
54
                "Clock speed cannot be less than 0")
55

56
        self._processor_id = processor_id
1✔
57
        self._clock_speed = clock_speed
1✔
58
        self._is_monitor = is_monitor
1✔
59
        self._dtcm_available = dtcm_available
1✔
60

61
    @property
1✔
62
    def processor_id(self) -> int:
1✔
63
        """
64
        The ID of the processor.
65

66
        :rtype: int
67
        """
68
        return self._processor_id
1✔
69

70
    @property
1✔
71
    def dtcm_available(self) -> int:
1✔
72
        """
73
        The amount of DTCM available on this processor.
74

75
        :rtype: int
76
        """
77
        return self._dtcm_available
×
78

79
    @property
1✔
80
    def cpu_cycles_available(self) -> int:
1✔
81
        """
82
        The number of CPU cycles available from this processor per ms.
83

84
        :rtype: int
85
        """
86
        return self._clock_speed // 1000
×
87

88
    @property
1✔
89
    def clock_speed(self) -> int:
1✔
90
        """
91
        The clock speed of the processor in cycles per second.
92

93
        :rtype: int
94
        """
95
        return self._clock_speed
1✔
96

97
    @property
1✔
98
    def is_monitor(self) -> bool:
1✔
99
        """
100
        Determines if the processor is the monitor, and therefore not
101
        to be allocated.
102

103
        .. warning::
104
            Currently rejection processors are also marked as monitors.
105

106
        :rtype: bool
107
        """
108
        return self._is_monitor
1✔
109

110
    def __str__(self) -> str:
1✔
111
        return (
×
112
            f"[CPU: id={self._processor_id}, "
113
            f"clock_speed={self._clock_speed // 1000000} MHz, "
114
            f"monitor={self._is_monitor}]")
115

116
    def __repr__(self) -> str:
1✔
117
        return self.__str__()
×
118

119
    @staticmethod
1✔
120
    def factory(processor_id: int, is_monitor: bool = False) -> 'Processor':
1✔
121
        if is_monitor:
1✔
122
            if processor_id not in monitor:
1✔
123
                monitor[processor_id] = Processor(
1✔
124
                    processor_id, is_monitor=is_monitor)
125
            return monitor[processor_id]
1✔
126
        else:
127
            if processor_id not in non_monitor:
1✔
128
                non_monitor[processor_id] = Processor(
1✔
129
                    processor_id, is_monitor=is_monitor)
130
            return non_monitor[processor_id]
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