def test_create_empty_core_subset_add_processor(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, [])
     self.assertEqual(cs.x, 0)
     self.assertEqual(cs.y, 0)
     for proc in proc_list:
         cs.add_processor(proc)
     for proc in cs.processor_ids:
         self.assertIn(proc, proc_list)
     self.assertEqual(len([x for x in cs.processor_ids]), len(proc_list))
Ejemplo n.º 2
0
 def test_create_empty_core_subset_add_processor(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, [])
     self.assertEqual(cs.x, 0)
     self.assertEqual(cs.y, 0)
     for proc in proc_list:
         cs.add_processor(proc)
     for proc in cs.processor_ids:
         self.assertIn(proc, proc_list)
     self.assertEqual(len([x for x in cs.processor_ids]), len(proc_list))
 def test_create_new_core_subsets(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, proc_list)
     css = CoreSubsets([cs])
     self.assertIn(cs, css.core_subsets)
     for core_subset in css.core_subsets:
         self.assertIn(core_subset, [cs])
Ejemplo n.º 4
0
    def test_clear_iobuf_process(self):
        receiver = MockMachine()
        receiver.start()

        # Set up a connection to the "machine"
        connection = SCAMPConnection(0,
                                     0,
                                     remote_host="127.0.0.1",
                                     remote_port=receiver.local_port)
        selector = RoundRobinConnectionSelector([connection])

        # Create the process and run it
        process = ClearIOBUFProcess(selector)
        process.clear_iobuf(CoreSubsets([CoreSubset(0, 0, [1])]), 1)
        receiver.stop()

        # Check the message received
        self.assertTrue(receiver.is_next_message)
        data = receiver.next_message
        sdp_header = SDPHeader.from_bytestring(data, 2)
        self.assertEqual(sdp_header.destination_chip_x, 0)
        self.assertEqual(sdp_header.destination_chip_y, 0)
        self.assertEqual(sdp_header.destination_cpu, 1)
        command = struct.unpack_from("<H", data, 10)[0]
        self.assertEqual(command,
                         SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE.value)
 def testcall(self):
     x = 0
     y = 0
     p = 1
     filename = "myfile.c"
     error = "Test Error"
     warning = "Test Warning"
     error_text = "[ERROR]    ({}): {}\n".format(filename, error)
     result_error = "{}, {}, {}: {} ({})".format(x, y, p, error, filename)
     warning_text = "[WARNING]    ({}): {}\n".format(filename, warning)
     result_warning = "{}, {}, {}: {} ({})".format(x, y, p, warning,
                                                   filename)
     text = "Test\n" + warning_text + error_text
     extractor = ChipIOBufExtractor()
     core_subsets = CoreSubsets([CoreSubset(x, y, [p])])
     transceiver = _PretendTransceiver([IOBuffer(x, y, p, text)])
     folder = tempfile.mkdtemp()
     error_entries, warn_entries = extractor(transceiver,
                                             has_ran=True,
                                             core_subsets=core_subsets,
                                             provenance_file_path=folder)
     testfile = os.path.join(folder, "0_0_1.txt")
     self.assertTrue(os.path.exists(testfile))
     self.assertEqual(error_entries[0], result_error)
     self.assertEqual(warn_entries[0], result_warning)
     os.unlink(testfile)
     os.rmdir(folder)
def get_cores_in_run_state(txrx, app_id, print_all_chips):
    """
    :param Transceiver txrx:
    :param int app_id:
    :param bool print_all_chips:
    """
    count_finished = txrx.get_core_state_count(app_id, CPUState.FINISHED)
    count_run = txrx.get_core_state_count(app_id, CPUState.RUNNING)
    print('running: {} finished: {}'.format(count_run, count_finished))

    machine = txrx.get_machine_details()
    print('machine max x: {} max y: {}'.format(machine.max_chip_x,
                                               machine.max_chip_y))
    if print_all_chips:
        print('machine chips: {}'.format(list(machine.chips)))

    all_cores = []
    for chip in machine.chips:
        all_cores.append(CoreSubset(chip.x, chip.y, range(1, 17)))

    all_cores = CoreSubsets(core_subsets=all_cores)

    cores_finished = txrx.get_cores_in_state(all_cores, CPUState.FINISHED)
    cores_running = txrx.get_cores_in_state(all_cores, CPUState.RUNNING)
    cores_watchdog = txrx.get_cores_in_state(all_cores, CPUState.WATCHDOG)

    for (x, y, p), _ in cores_running:
        if p not in IGNORED_IDS:
            print('run core: {} {} {}'.format(x, y, p))

    for (x, y, p), _ in cores_finished:
        print('finished core: {} {} {}'.format(x, y, p))

    for (x, y, p), _ in cores_watchdog:
        print('watchdog core: {} {} {}'.format(x, y, p))
 def test_add_processor(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, proc_list)
     css = CoreSubsets()
     css.add_core_subset(cs)
     self.assertIn(cs, css.core_subsets)
     for core_subset in css.core_subsets:
         self.assertIn(core_subset, [cs])
Ejemplo n.º 8
0
 def test_create_new_core_subset(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, proc_list)
     self.assertEqual(cs.x, 0)
     self.assertEqual(cs.y, 0)
     for proc in cs.processor_ids:
         self.assertIn(proc, proc_list)
     self.assertEqual(len([x for x in cs.processor_ids]), len(proc_list))
def test_coresubset():
    core_subset = CoreSubset(0, 0, [1, 2, 3])
    assert len(core_subset) == 3
    assert core_subset.x == 0
    assert core_subset.y == 0
    assert 2 in core_subset

    core_subset.add_processor(3)
    assert len(core_subset) == 3

    core_subset.add_processor(4)
    assert len(core_subset) == 4

    assert list(core_subset.processor_ids) == [1, 2, 3, 4]
    assert core_subset.__repr__() == ("0:0:OrderedSet([1, 2, 3, 4])")
 def test_add_core_subset_duplicate_core_subset(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, proc_list)
     css = CoreSubsets([cs])
     css.add_core_subset(cs)
 def test_add_processor_duplicate_processor_different_chip(self):
     proc_list = [0, 1, 2, 3, 5, 8, 13]
     cs = CoreSubset(0, 0, proc_list)
     css = CoreSubsets([cs])
     css.add_processor(0, 1, 0)
Ejemplo n.º 12
0
    return os.path.join(path, "mock{}.aplx".format(id))


extractor = ChipIOBufExtractor()
executableFinder = ExecutableFinder([path])

transceiver = _PretendTransceiver([
    IOBuffer(0, 0, 1, text001),
    IOBuffer(0, 0, 2, text002),
    IOBuffer(1, 1, 1, text111),
    IOBuffer(1, 1, 2, text112),
    IOBuffer(0, 0, 3, text003)
])

executable_targets = ExecutableTargets()
core_subsets = CoreSubsets([CoreSubset(0, 0, [1, 2])])
fooaplx = mock_aplx("foo")
executable_targets.add_subsets(fooaplx, core_subsets)
core_subsets = CoreSubsets([CoreSubset(1, 1, [1, 2])])
baraplx = mock_aplx("bar")
executable_targets.add_subsets(baraplx, core_subsets)
core_subsets = CoreSubsets([CoreSubset(0, 0, [3])])
alphaaplx = mock_aplx("alpha")
executable_targets.add_subsets(alphaaplx, core_subsets)


class TestFrontEndCommonChipIOBufExtractor(unittest.TestCase):
    def testExectuableFinder(self):
        self.assertIn(fooaplx, executableFinder.get_executable_path(fooaplx))

    def testCallSimple(self):
Ejemplo n.º 13
0
 def test_create_new_core_subset_duplicate_processors(self):
     cs = CoreSubset(0, 0, [0, 1, 1, 2, 3, 5, 8, 13])
     self.assertIsNotNone(cs, "must make instance of CoreSubset")