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

SpiNNakerManchester / SpiNNMachine / 4563230880

pending completion
4563230880

push

github

GitHub
Merge pull request #197 from SpiNNakerManchester/doc-polish

734 of 804 branches covered (91.29%)

Branch coverage included in aggregate %.

14 of 14 new or added lines in 11 files covered. (100.0%)

1948 of 2041 relevant lines covered (95.44%)

0.95 hits per line

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

96.0
/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

15
from .exceptions import SpinnMachineInvalidParameterException
1✔
16

17
non_monitor = dict()
1✔
18
monitor = 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, clock_speed=CLOCK_SPEED, is_monitor=False,
1✔
34
                 dtcm_available=DTCM_AVAILABLE):
35
        """
36
        :param int processor_id:
37
            ID of the processor in the chip
38
        :param int clock_speed:
39
            The number of CPU cycles per second of the processor
40
        :param bool is_monitor:
41
            Determines if the processor is considered the
42
            monitor processor, and so should not be otherwise allocated
43
        :param int dtcm_available:
44
            Data Tightly Coupled Memory available
45
        :raise spinn_machine.exceptions.SpinnMachineInvalidParameterException:
46
            If the clock speed is negative
47
        """
48

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

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

59
    @property
1✔
60
    def processor_id(self):
1✔
61
        """
62
        The ID of the processor.
63

64
        :rtype: int
65
        """
66
        return self._processor_id
1✔
67

68
    @property
1✔
69
    def dtcm_available(self):
1✔
70
        """
71
        The amount of DTCM available on this processor.
72

73
        :rtype: int
74
        """
75
        return self._dtcm_available
×
76

77
    @property
1✔
78
    def cpu_cycles_available(self):
1✔
79
        """
80
        The number of CPU cycles available from this processor per ms.
81

82
        :rtype: int
83
        """
84
        return self._clock_speed // 1000
×
85

86
    @property
1✔
87
    def clock_speed(self):
1✔
88
        """
89
        The clock speed of the processor in cycles per second.
90

91
        :rtype: int
92
        """
93
        return self._clock_speed
1✔
94

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

101
        .. warning::
102
            Currently rejection processors are also marked as monitors.
103

104
        :rtype: bool
105
        """
106
        return self._is_monitor
1✔
107

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

114
    def __repr__(self):
1✔
115
        return self.__str__()
1✔
116

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