def multi_board_spike_output(self):
        self.assert_not_spin_three()
        TestMultiBoardSpikeOutput.counts = dict()
        p.setup(1.0, n_chips_required=((48 * 2) + 1))
        machine = p.get_machine()

        labels = list()
        pops = list()
        for chip in machine.ethernet_connected_chips:
            # print("Adding population on {}, {}".format(chip.x, chip.y))
            label = "{}, {}".format(chip.x, chip.y)
            spike_cells = {"spike_times": [i for i in range(100)]}
            pop = p.Population(10, p.SpikeSourceArray(**spike_cells),
                               label=label)
            pop.add_placement_constraint(chip.x, chip.y)
            labels.append(label)
            pops.append(pop)
            TestMultiBoardSpikeOutput.counts[label] = 0

        live_output = p.external_devices.SpynnakerLiveSpikesConnection(
            receive_labels=labels, local_port=None)
        for label, pop in zip(labels, pops):
            p.external_devices.activate_live_output_for(
                pop, database_notify_port_num=live_output.local_port)
            live_output.add_receive_callback(
                label, TestMultiBoardSpikeOutput.spike_receiver)

        p.run(1000)
        p.end()

        for label in labels:
            # print("Received {} of 1000 spikes from {}".format(
            #     TestMultiBoardSpikeOutput.counts[label], label))
            self.assertEqual(TestMultiBoardSpikeOutput.counts[label], 1000)
示例#2
0
    def setup(self, n_boards, n_neurons, simtime):
        sim.setup(timestep=1.0, n_boards_required=n_boards)
        try:
            machine = sim.get_machine()
        except ConfigurationException as oops:
            if "Failure to detect machine " in str(oops):
                raise SkipTest(
                    "You Need at least {} boards to run this test".format(
                        n_boards))
            raise (oops)

        input_spikes = list(range(0, simtime - 100, 10))
        self._expected_spikes = len(input_spikes)
        input = sim.Population(1,
                               sim.SpikeSourceArray(spike_times=input_spikes),
                               label="input")
        self._pops = []
        for i, chip in enumerate(machine.ethernet_connected_chips):
            if i >= n_boards:
                break
            offset = machine.BOARD_48_CHIPS[i % 48]
            x = chip.x + offset[0]
            y = chip.y + offset[1]
            # safety code in case there is a hole in the board
            if not machine.is_chip_at(x, y):
                x = chip.x
                y = chip.y
            self._pops.append(self.add_pop(x, y, n_neurons, input))
示例#3
0
    def multi_board_spike_output(self):
        TestMultiBoardSpikeOutput.counts = dict()
        try:
            p.setup(1.0, n_chips_required=((48 * 2) + 1))
            machine = p.get_machine()
        except ConfigurationException as oops:
            if "Failure to detect machine of " in str(oops):
                raise SkipTest("You Need at least 3 boards to run this test")

        labels = list()
        for chip in machine.ethernet_connected_chips:
            # print("Adding population on {}, {}".format(chip.x, chip.y))
            label = "{}, {}".format(chip.x, chip.y)
            labels.append(label)
            pop = p.Population(
                10,
                p.SpikeSourceArray(spike_times=[i for i in range(100)]),
                label=label)
            pop.add_placement_constraint(chip.x, chip.y)
            e.activate_live_output_for(pop)
            TestMultiBoardSpikeOutput.counts[label] = 0

        live_output = e.SpynnakerLiveSpikesConnection(receive_labels=labels)
        for label in labels:
            live_output.add_receive_callback(
                label, TestMultiBoardSpikeOutput.spike_receiver)

        p.run(250)
        live_output.close()
        p.end()

        for label in labels:
            # print("Received {} of 1000 spikes from {}".format(
            #    TestMultiBoardSpikeOutput.counts[label], label))
            self.assertEqual(TestMultiBoardSpikeOutput.counts[label], 1000)
    def test_multi_board_spike_output(self):
        TestMultiBoardSpikeOutput.counts = dict()
        p.setup(1.0, n_chips_required=((48 * 2) + 1))
        machine = p.get_machine()

        labels = list()
        for chip in machine.ethernet_connected_chips:
            print("Adding population on {}, {}".format(chip.x, chip.y))
            label = "{}, {}".format(chip.x, chip.y)
            labels.append(label)
            pop = p.Population(
                10,
                p.SpikeSourceArray(spike_times=[i for i in range(100)]),
                label=label)
            pop.add_placement_constraint(chip.x, chip.y)
            e.activate_live_output_for(pop)
            TestMultiBoardSpikeOutput.counts[label] = 0

        live_output = e.SpynnakerLiveSpikesConnection(receive_labels=labels)
        for label in labels:
            live_output.add_receive_callback(
                label, TestMultiBoardSpikeOutput.spike_receiver)

        p.run(1000)
        p.end()

        for label in labels:
            print("Received {} of 1000 spikes from {}".format(
                TestMultiBoardSpikeOutput.counts[label], label))
            self.assertEqual(TestMultiBoardSpikeOutput.counts[label], 1000)
示例#5
0
def do_one_run():
    n_source = 2000
    n_target = 16
    n_neurons = 1
    n_boards = math.ceil((n_source + n_target) / 16 / 48)

    sim.setup(timestep=1.0, n_boards_required=n_boards)
    try:
        machine = sim.get_machine()
    except ConfigurationException as oops:
        if "Failure to detect machine " in str(oops):
            raise SkipTest(
                "You Need at least {} boards to run this test".format(
                    n_boards)) from oops
        raise oops
    target_x, target_y = find_good_chip(machine, n_target)
    print(machine)
    print(target_x, target_y)

    sources = []
    for s in range(n_source):
        sources.append(
            sim.Population(n_neurons,
                           sim.IF_curr_exp(),
                           label="source_{}".format(s),
                           additional_parameters={
                               "splitter":
                               SplitterAbstractPopulationVertexSlice()
                           }))
    targets = []
    for t in range(n_target):
        pop = sim.Population(n_neurons,
                             sim.IF_curr_exp(),
                             label="target_{}".format(t),
                             additional_parameters={
                                 "splitter":
                                 SplitterAbstractPopulationVertexSlice()
                             })
        pop.add_placement_constraint(x=target_x, y=target_y)
        targets.append(pop)

    for s in range(n_source):
        for t in range(n_target):
            sim.Projection(sources[s],
                           targets[t],
                           sim.AllToAllConnector(),
                           synapse_type=sim.StaticSynapse(weight=5, delay=1),
                           receptor_type="excitatory")
            if t > 1 and s % t == 0:
                sim.Projection(sources[s],
                               targets[t],
                               sim.AllToAllConnector(),
                               synapse_type=sim.StaticSynapse(weight=5,
                                                              delay=1),
                               receptor_type="inhibitory")

    sim.run(1)
    sim.end()
示例#6
0
    def test_with_actual_ip_address(self):
        sim.setup(timestep=1.0, n_boards_required=6)
        self.assert_not_spin_three()

        # Hack in to set the ignores with used ipaddress
        GetMachineProcess._receive_chip_info = hacked_receive_chip_info

        machine = sim.get_machine()
        sim.end()

        # global 3,3 should exists
        three_zero = machine.get_chip_at(3, 0)
        if three_zero is None:
            raise SkipTest("Unexpected but not impossible missing chip")

        three_three = machine.get_chip_at(3, 3)
        if three_three is None:
            raise SkipTest("Unexpected but not impossible missing chip")

        ten_six = machine.get_chip_at(10, 6)
        if ten_six is None:
            raise SkipTest("Unexpected but not impossible missing chip")

        # self._ignore_chips.add((3, 3, chip_info.ethernet_ip_address))
        self.assertFalse(machine.is_chip_at(11, 7))

        # self._ignore_links.add((4, 4, 1, chip_info.ethernet_ip_address))
        self.assertFalse(machine.is_link_at(12, 8, 1))

        # self._ignore_cores.add((2, 2, -10, chip_info.ethernet_ip_address))
        # physical 10 is nearly always the monitor so skip discarded
        self.assertTrue(ten_six.is_processor_with_id(0))

        # self._ignore_cores.add((2, 2, 4, chip_info.ethernet_ip_address))
        self.assertFalse(ten_six.is_processor_with_id(4))

        # self._ignore_cores.add((2, 2, -9, chip_info.ethernet_ip_address))
        if ten_six.is_processor_with_id(10):
            raise SkipTest("Physical core 9 nearly always maps to virtual 10")

        # down_cores = 3,0,-4
        if three_zero.is_processor_with_id(5):
            raise SkipTest("Physical core 4 nearly always maps to virtual 5")

        # down_chips = 6,7
        self.assertFalse(machine.is_chip_at(6, 7))

        # down_links = 5,5,2
        self.assertFalse(machine.is_link_at(5, 5, 2))

        # down_cores = 3,3,4,127.0.0.1
        self.assertTrue(three_three.is_processor_with_id(4))

        # down_links = 3,3,4,127.0.0.1
        if not machine.is_link_at(3, 3, 4):
            raise SkipTest("Link 3 3 4 missing could be random hardware")
示例#7
0
    def do_run(self):
        sim.setup(timestep=1.0, n_boards_required=2)
        sim.Population(3, sim.IF_curr_exp(), label="pop_1")
        machine1 = sim.get_machine()
        id1 = id(machine1)
        sim.run(1)
        machine2 = sim.get_machine()
        id2 = id(machine2)
        self.assertEqual(id1, id2)
        sim.run(2)

        machine3 = sim.get_machine()
        id3 = id(machine3)
        self.assertEqual(id1, id3)

        sim.reset()  # soft
        sim.run(3)
        machine4 = sim.get_machine()
        id4 = id(machine4)
        self.assertEqual(id1, id4)

        sim.reset()  # hard due to get_machine
        machine5 = sim.get_machine()
        id5 = id(machine5)
        self.assertNotEqual(id1, id5)
        sim.run(3)

        machine6 = sim.get_machine()
        id6 = id(machine6)
        self.assertEqual(id5, id6)

        sim.reset()  # Hhard due to new pop
        sim.Population(3, sim.IF_curr_exp(), label="pop_2")
        sim.run(3)
        machine7 = sim.get_machine()
        id7 = id(machine7)
        self.assertNotEqual(id1, id7)
        self.assertNotEqual(id5, id7)

        sim.reset()  # soft
        sim.run(3)
        machine8 = sim.get_machine()
        id8 = id(machine8)
        self.assertEqual(id7, id8)

        sim.end()
    def multi_board_spike_output(self):
        TestMultiBoardSpikeOutput.counts = dict()
        try:
            p.setup(1.0, n_chips_required=((48 * 2) + 1))
            machine = p.get_machine()
        except ConfigurationException as oops:
            if "Failure to detect machine of " in str(oops):
                raise SkipTest(
                    "You Need at least 3 boards to run this test") from oops

        labels = list()
        for chip in machine.ethernet_connected_chips:
            # print("Adding population on {}, {}".format(chip.x, chip.y))
            label = "{}, {}".format(chip.x, chip.y)
            labels.append(label)
            pop = p.Population(
                10,
                p.SpikeSourceArray(spike_times=[i for i in range(100)]),
                label=label)
            pop.add_placement_constraint(chip.x, chip.y)
            e.activate_live_output_for(pop)
            TestMultiBoardSpikeOutput.counts[label] = 0

        live_output = e.SpynnakerLiveSpikesConnection(receive_labels=labels,
                                                      local_port=None)
        p.external_devices.add_database_socket_address(
            live_output.local_ip_address, live_output.local_port, None)
        for label in labels:
            live_output.add_receive_callback(
                label, TestMultiBoardSpikeOutput.spike_receiver)

        p.run(250)
        live_output.close()
        p.end()

        for label in labels:
            # Lost packets might mean some get lost, but no more than 1000
            # can be received
            count = TestMultiBoardSpikeOutput.counts[label]
            self.assertGreaterEqual(count, 500)
            self.assertLessEqual(count, 1000)
示例#9
0
        self.assertFalse(ten_six.is_processor_with_id(4))

        # self._ignore_cores.add((2, 2, -9, chip_info.ethernet_ip_address))
        if ten_six.is_processor_with_id(10):
            raise SkipTest("Physical core 9 nearly always maps to virtual 10")

        # down_cores = 3,0,-4
        if three_zero.is_processor_with_id(5):
            raise SkipTest("Physical core 4 nearly always maps to virtual 5")

        # down_chips = 6,7
        self.assertFalse(machine.is_chip_at(6, 7))

        # down_links = 5,5,2
        self.assertFalse(machine.is_link_at(5, 5, 2))

        # down_cores = 3,3,4,127.0.0.1
        self.assertTrue(three_three.is_processor_with_id(4))

        # down_links = 3,3,4,127.0.0.1
        self.assertTrue(machine.is_link_at(3, 3, 4))


if __name__ == '__main__':
    # Hack in to set the ignores with used ipaddress
    GetMachineProcess._receive_chip_info = hacked_receive_chip_info

    sim.setup(timestep=1.0, n_boards_required=6)
    machine = sim.get_machine()
    sim.end()