Exemple #1
0
 def test_radial_placement_from_chip_constraint(self):
     c1 = RadialPlacementFromChipConstraint(1, 2)
     self.assertEqual(c1.x, 1)
     self.assertEqual(c1.y, 2)
     self.assertEqual(c1, RadialPlacementFromChipConstraint(1, 2))
     self.assertEqual(str(c1),
                      'RadialPlacementFromChipConstraint(x=1, y=2)')
     c2 = RadialPlacementFromChipConstraint(2, 1)
     self.assertNotEqual(c1, c2)
     self.assertNotEqual(c1, "1.2.3.4")
     d = {}
     d[c1] = 1
     d[c2] = 2
     self.assertEqual(len(d), 2)
Exemple #2
0
    def __init__(
            self, hostname, port, board_address=None, tag=None,
            strip_sdp=True, use_prefix=False, key_prefix=None,
            prefix_type=None, message_type=EIEIOType.KEY_32_BIT, right_shift=0,
            payload_as_time_stamps=True, use_payload_prefix=True,
            payload_prefix=None, payload_right_shift=0,
            number_of_packets_sent_per_time_step=0, constraints=None,
            label=None):
        """
        """
        if ((message_type == EIEIOType.KEY_PAYLOAD_32_BIT or
             message_type == EIEIOType.KEY_PAYLOAD_16_BIT) and
                use_payload_prefix and payload_as_time_stamps):
            raise ConfigurationException(
                "Timestamp can either be included as payload prefix or as "
                "payload to each key, not both")
        if ((message_type == EIEIOType.KEY_32_BIT or
             message_type == EIEIOType.KEY_16_BIT) and
                not use_payload_prefix and payload_as_time_stamps):
            raise ConfigurationException(
                "Timestamp can either be included as payload prefix or as"
                " payload to each key, but current configuration does not "
                "specify either of these")
        if (not isinstance(prefix_type, EIEIOPrefix) and
                prefix_type is not None):
            raise ConfigurationException(
                "the type of a prefix type should be of a EIEIOPrefix, "
                "which can be located in :"
                "SpinnMan.messages.eieio.eieio_prefix_type")

        if label is None:
            label = "Live Packet Gatherer"

        ApplicationVertex.__init__(self, label, constraints, 1)

        # Try to place this near the Ethernet
        self.add_constraint(RadialPlacementFromChipConstraint(0, 0))

        # storage objects
        self._iptags = None

        # tag info
        self._ip_address = hostname
        self._port = port
        self._board_address = board_address
        self._tag = tag
        self._strip_sdp = strip_sdp

        # eieio info
        self._prefix_type = prefix_type
        self._use_prefix = use_prefix
        self._key_prefix = key_prefix
        self._message_type = message_type
        self._right_shift = right_shift
        self._payload_as_time_stamps = payload_as_time_stamps
        self._use_payload_prefix = use_payload_prefix
        self._payload_prefix = payload_prefix
        self._payload_right_shift = payload_right_shift
        self._number_of_packets_sent_per_time_step = \
            number_of_packets_sent_per_time_step
Exemple #3
0
def constraint_from_json(json_dict, graph=None):
    if json_dict["class"] == "BoardConstraint":
        return BoardConstraint(json_dict["board_address"])
    if json_dict["class"] == "ChipAndCoreConstraint":
        if "p" in json_dict:
            p = json_dict["p"]
        else:
            p = None
        return ChipAndCoreConstraint(json_dict["x"], json_dict["y"], p)
    if json_dict["class"] == "ContiguousKeyRangeContraint":
        return ContiguousKeyRangeContraint()
    if json_dict["class"] == "FixedKeyAndMaskConstraint":
        if "key_list_function" in json_dict:
            raise NotImplementedError("key_list_function {}".format(
                json_dict["key_list_function"]))
        return FixedKeyAndMaskConstraint(
            key_masks_from_json(json_dict["keys_and_masks"]))
    if json_dict["class"] == "FixedMaskConstraint":
        return FixedMaskConstraint(json_dict["mask"])
    if json_dict["class"] == "FixedVertexAtomsConstraint":
        return FixedVertexAtomsConstraint(json_dict["size"])
    if json_dict["class"] == "MaxVertexAtomsConstraint":
        return MaxVertexAtomsConstraint(json_dict["size"])
    if json_dict["class"] == "RadialPlacementFromChipConstraint":
        return RadialPlacementFromChipConstraint(json_dict["x"],
                                                 json_dict["y"])
    if json_dict["class"] == "SameChipAsConstraint":
        return SameChipAsConstraint(vertex_lookup(json_dict["vertex"], graph))
    if json_dict["class"] == "SameAtomsAsVertexConstraint":
        return SameAtomsAsVertexConstraint(
            vertex_lookup(json_dict["vertex"], graph))
    raise NotImplementedError("constraint {}".format(json_dict["class"]))
Exemple #4
0
 def test_deal_with_constraint_placement_vertices_dont_have_vertex(self):
     self.vertex2.add_constraint(ChipAndCoreConstraint(3, 5, 7))
     self.vertex3.add_constraint(RadialPlacementFromChipConstraint(2, 4))
     placements = RadialPlacer()(self.mach_graph, self.machine, 100)
     for placement in placements.placements:
         if placement.vertex == self.vertex2:
             self.assertEqual(placement.x, 3)
             self.assertEqual(placement.y, 5)
             self.assertEqual(placement.p, 7)
         if placement.vertex == self.vertex3:
             self.assertEqual(placement.x, 2)
             self.assertEqual(placement.y, 4)
     self.assertEqual(len(self.vertices), len(placements))
    def test_radial_some(self):
        sim.setup(timestep=1.0)
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 50)

        pop_1 = sim.Population(200, sim.IF_curr_exp(), label="pop_1")
        pop_1.set_constraint(RadialPlacementFromChipConstraint(1, 1))
        input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]),
                               label="input")
        sim.Projection(input, pop_1, sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5, delay=1))
        simtime = 10
        sim.run(simtime)
        placements = self.get_placements("pop_1")
        sim.end()
        self.assertEqual(4, len(placements))
        for [x, y, _] in placements:
            self.assertEqual("1", x)
            self.assertEqual("1", y)
    def test_radial_many(self):
        sim.setup(timestep=1.0)
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 10)

        pop_1 = sim.Population(200, sim.IF_curr_exp(), label="pop_1")
        pop_1.set_constraint(RadialPlacementFromChipConstraint(1, 1))
        input = sim.Population(1,
                               sim.SpikeSourceArray(spike_times=[0]),
                               label="input")
        sim.Projection(input,
                       pop_1,
                       sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5, delay=1))
        simtime = 10
        sim.run(simtime)
        placements = self.get_placements("pop_1")
        sim.end()
        self.assertGreater(len(placements), 0)
        count = 0
        for [x, y, _] in placements:
            if x == "1" and y == "1":
                count += 1
        self.assertGreater(count, 0)
Exemple #7
0
 def test_radial_placement_from_chip_constraint(self):
     c1 = RadialPlacementFromChipConstraint(1, 2)
     self.constraint_there_and_back(c1)
#!/usr/bin/python
"""
Synfirechain-like example
"""

from pacman.model.constraints.placer_constraints import (
    RadialPlacementFromChipConstraint)
from p8_integration_tests.base_test_case import BaseTestCase
from p8_integration_tests.scripts.synfire_run import SynfireRunner

nNeurons = 200  # number of neurons in each population
constraint = RadialPlacementFromChipConstraint(3, 3)
delay = 1
neurons_per_core = 10
record_v = False
record_gsyn = False
synfire_run = SynfireRunner()


class Synfire200n10pc2chipsWithNoDelaysSpikeRecording(BaseTestCase):
    def test_run(self):
        pass

    #    synfire_run.do_run(nNeurons, delay=delay,
    #                       neurons_per_core=neurons_per_core,
    #                       constraint=constraint,
    #                       record_v=record_v,
    #                       record_gsyn_exc=record_gsyn,
    #                       record_gsyn_inh=record_gsyn)