def test_simple_tree(self): tree = TopologyTree([4, 2]) mapping = compact(self.application, tree) self.assertEqual(mapping[0], 0) self.assertEqual(mapping[1], 1) self.assertEqual(mapping[2], 2) self.assertEqual(mapping[3], 3)
def test_greedy(self): tree = TopologyTree([4, 2]) mapping = greedy_pairs(self.application, tree) self.assertEqual(mapping[0], 0) self.assertEqual(mapping[1], 2) self.assertEqual(mapping[2], 3) self.assertEqual(mapping[3], 4) self.assertEqual(mapping[4], 1) self.assertEqual(mapping[5], 5)
def test_eager(self): tree = TopologyTree([2, 2, 2]) mapping = eagermap(self.application, tree) dilation = compute_hopbytes(self.application, tree, mapping) # expected pairs: (0,4), (1,2), (3,5), artificial (6,7) # expected pair of pairs: ((1,2),(3,5)), ((0,4),(6,7)) expected_dilation = (5 * 6 + 7 * 2 + 1 * 6) + ( 4 * 2 + 3 * 4 + 4 * 4) + (1 * 4 + 3 * 4) + (2 * 2) + (9 * 6) self.assertTrue(dilation < expected_dilation + 1)
def test_simple_tree(self): tree = TopologyTree([4, 2]) mapping = scatter(self.application, tree) self.assertEqual(mapping[0], 0) self.assertEqual(mapping[1], 4) self.assertEqual(mapping[2], 2) self.assertEqual(mapping[3], 6) self.assertEqual(mapping[4], 1) self.assertEqual(mapping[5], 5)
def test_together(self): topology = TopologyTree([2, 2, 2, 2, 2, 2]) mapping = [0, 0, 0, 0] dilation = compute_hopbytes(self.application, topology, mapping) self.assertEqual(dilation, 0)
def test_very_far(self): topology = TopologyTree([2, 2, 2, 2, 2, 2]) mapping = [0, 63, 3, 61] dilation = compute_hopbytes(self.application, topology, mapping) self.assertEqual(dilation, 144)
def test_bin_tree(self): topology = TopologyTree([2, 2]) mapping = [0, 1, 2, 3] dilation = compute_hopbytes(self.application, topology, mapping) self.assertEqual(dilation, 32)
def test_simple_tree(self): topology = TopologyTree([4]) mapping = [0, 1, 2, 3] dilation = compute_hopbytes(self.application, topology, mapping) self.assertEqual(dilation, 24)
writes a mapping and computes the dilation of said mapping. Second part: - Reads a linear topology from a file, and computes the dilation using the previous mapping Third part: - Same problem as the first part, but now uses the greedy_pairs algorithm for mapping """ from simulator.application import ApplicationGraph from simulator.topology import TopologyTree, Topology from simulator.support import compute_hopbytes from simulator.schedulers import greedy_pairs print('First part: Mapping on a binary tree') application = ApplicationGraph('inputs/simple_comm.csv') topology = TopologyTree([2, 2]) # binary tree with four leaves mapping = [3, 1, 2, 0] dilation = compute_hopbytes(application, topology, mapping) print(f'The dilation for the given mapping is equal to {dilation}') print('Second part: Mapping on a linear topology') linear = Topology.from_csv('inputs/simple_topo.csv') dilation = compute_hopbytes(application, linear, mapping) print(f'The dilation for the given mapping is equal to {dilation}') print('Third part: Mapping using an algorithm') mapping = greedy_pairs(application, topology) dilation = compute_hopbytes(application, topology, mapping) print(f'The dilation for the given mapping is equal to {dilation}')