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)
示例#2
0
 def test_topology(self):
     topology = Topology([[0, 2, 2, 2], [2, 0, 1, 4], [2, 1, 0, 3],
                          [2, 4, 3, 0]])
     mapping = [0, 1, 2, 3]
     dilation = compute_hopbytes(self.application, topology, mapping)
     self.assertEqual(dilation, 2 * 2 + 1 * 4 + 6 * 3)
示例#3
0
 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)
示例#4
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)
示例#5
0
 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)
示例#6
0
 def test_simple_tree(self):
     topology = TopologyTree([4])
     mapping = [0, 1, 2, 3]
     dilation = compute_hopbytes(self.application, topology, mapping)
     self.assertEqual(dilation, 24)
示例#7
0
  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}')