def generate_communicating_task_by_axe(self, min_rate, offset, src, dest): while True: ######## time.sleep(1) size = random.randint(structure.PACKET_DEFAULT_SIZE, structure.PACKET_DEFAULT_SIZE * 10) period = self.period_array[random.randint( 0, len(self.period_array) - 1)] lower_bound = int(0.7 * period) deadline = random.randint(0, (period - lower_bound + 1) + lower_bound) message = Message(self.counter, period, size, offset, deadline, src, dest) # calculate message Lu lu = message.get_link_utilization() ######## print("%s -> %s ||| min rate : %d === LU : %f" % (src, dest, min_rate, lu)) if lu > (min_rate / 100): continue else: break return message
def generate_communicating_task_by_axe(self, min_rate, offset, src, dest): while True: size = random.randint(structure.PACKET_DEFAULT_SIZE, structure.PACKET_DEFAULT_SIZE * 10) period = self.period_array[random.randint( 0, len(self.period_array) - 1)] lower_bound = int(0.7 * period) # deadline = random.randint(0, (period - lower_bound + 1) + lower_bound) deadline = period # TODO : temporary Harmonic Taskset priority = random.randint(0, self._nbvc - 1) message = Message(self.counter, period, size, offset, deadline, src, dest, priority) # calculate message Lu lu = message.get_link_utilization() if lu > (min_rate / 100): continue else: break return message
def scenario(self, link): with open(link, 'r') as stream: try: data = yaml.safe_load(stream) # Messages if 'scenario' in data: messages = data['scenario'] for m in messages: src = m['src'] dest = m['dest'] size = m['size'] offset = m['offset'] deadline = m['deadline'] period = m['period'] priority = -1 # set random priority (optional) if self._arbitration == 'PRIORITY_PREEMPT' or self._arbitration == 'PRIORITY_NON_PREEMPT': priority = random.randint(0, self._nbvc - 1) # Temporary :: Compute the deadline for our task lower_bound = int(0.7 * period) deadline = random.randint( 0, (period - lower_bound + 1) + lower_bound) # Message Creation message = Message(self.counter, period, size, offset, deadline, Coordinate(src['i'], src['j']), Coordinate(dest['i'], dest['j']), priority=priority) self.messages.append(message) self.counter += 1 # Generate task conflict self.conflict_task_by_axe(message, 60, 50, 0) # Automatic generation elif 'task' in data: nb_task = data['task'] method = data['method'] load = data['load'] if method == 'UuniFast': self.messages = self.uunifast_generate(nb_task, load) # Generate task conflict # for message in self.messages: # self.conflict_task_by_axe(message, 70, 40, 0) return self.messages except yaml.YAMLError as exc: print(exc)
def setUp(self): self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1]) self.src = Coordinate(0, 0) self.dest = Coordinate(2, 2) self.message = Message(1, 12, 256, 0, 0, self.src, self.dest) self.packet = Packet(1, self.dest, self.message) self.flit = self.packet.flits[0] self.proc_engine = self.noc.router_matrix[0][0].proc_engine self.router = self.noc.router_matrix[0][0] self.generation = Generation() self.generation.set_noc(self.noc) self.generation.set_square_size(4) self.noc.link_array_filling()
def uunifast_generate(self, nb_task, load): self._utilization_array = self.get_utilization_factors(nb_task) self.counter = 0 # Loop while len(self._utilization_array) > 0: # generate parameters utilization_factor = self._utilization_array.pop( random.randrange(len(self._utilization_array))) period = self.period_array[random.randint( 0, len(self.period_array) - 1)] offset = self.offset_array[random.randint( 0, len(self.offset_array) - 1)] size = int(math.ceil(period * utilization_factor)) lower_bound = int(load * period) deadline = random.randint(0, (period - lower_bound + 1) + lower_bound) # Generate messages coord = self.generate_random_coordinate() src = coord[0] dest = coord[1] message = Message(self.counter, period, size, offset, deadline, src, dest) # set random priority (optional) if self._arbitration == 'Priority': priority = random.randint(0, self._nbvc - 1) message.set_priority(priority) # add generated message to messages list self.messages.append(message) # Generate task conflict self.conflict_task_by_axe(message, 70, 40, 0) # TODO : Cleaning LU --> not yet # self.noc.link_array_clean() return self.messages
def setUp(self): self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1]) self.src = Coordinate(0, 0) self.dest = Coordinate(2, 2) self.message = Message(1, 23, 256, 0, 0, self.src, self.dest) self.packet = Packet(1, self.dest, self.message) self.flit = self.packet.flits[0] self.proc_engine = self.noc.router_matrix[0][0].proc_engine self.router = self.noc.router_matrix[0][0]
def setUp(self): self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1]) self.noc.link_array_filling() self.message1 = Message(1, 150, 896, 0, 100, Coordinate(0, 3), Coordinate(0, 1)) self.message2 = Message(2, 150, 256, 0, 100, Coordinate(2, 0), Coordinate(3, 0)) self.message3 = Message(3, 400, 256, 0, 300, Coordinate(0, 2), Coordinate(3, 0)) self.message4 = Message(4, 600, 256, 0, 550, Coordinate(2, 0), Coordinate(3, 0)) self.message5 = Message(5, 300, 3072, 0, 250, Coordinate(0, 1), Coordinate(2, 0)) self.messages = [ self.message1, self.message2, self.message3, self.message4, self.message5 ] self.qinModel = QinModel(self.noc, self.messages) self.tdma = TDMA(self.noc, self.noc.vc_quantum)
def test_is_links_equal(self): message1 = Message(1, 12, 256, 0, 0, Coordinate(0, 2), Coordinate(2, 2)) message2 = Message(1, 12, 256, 0, 0, Coordinate(0, 3), Coordinate(3, 3)) p1 = self.message.get_xy_path_coordinate(self.noc) p2 = message1.get_xy_path_coordinate(self.noc) p3 = message2.get_xy_path_coordinate(self.noc) self.assertEqual(self.generation.task_overlap(p1, p2), True) self.assertEqual(self.generation.task_overlap(p1, p3), False)
def scenario(self, link): with open(link, 'r') as stream: try: data = yaml.load(stream) # Messages if 'scenario' in data: messages = data['scenario'] count = 0 for m in messages: src = m['src'] dest = m['dest'] size = m['size'] offset = m['offset'] deadline = m['deadline'] period = m['period'] self.messages.append( Message( count, period, size, offset, deadline, Coordinate(src['i'], src['j']), Coordinate(dest['i'], dest['j']), )) count += 1 # Automatic generation elif 'task' in data: nb_task = data['task'] method = data['method'] load = data['load'] if method == 'UuniFast': self.messages = self.uunifast_generate(nb_task, load) return self.messages except yaml.YAMLError as exc: print(exc)
class TestAnalysisTool(unittest.TestCase): def setUp(self): self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1]) self.src = Coordinate(0, 0) self.dest = Coordinate(2, 2) self.message = Message(1, 12, 256, 0, 0, self.src, self.dest) self.packet = Packet(1, self.dest, self.message) self.flit = self.packet.flits[0] self.proc_engine = self.noc.router_matrix[0][0].proc_engine self.router = self.noc.router_matrix[0][0] self.generation = Generation() self.generation.set_noc(self.noc) self.generation.set_square_size(4) self.noc.link_array_filling() def test_is_links_equal(self): message1 = Message(1, 12, 256, 0, 0, Coordinate(0, 2), Coordinate(2, 2)) message2 = Message(1, 12, 256, 0, 0, Coordinate(0, 3), Coordinate(3, 3)) p1 = self.message.get_xy_path_coordinate(self.noc) p2 = message1.get_xy_path_coordinate(self.noc) p3 = message2.get_xy_path_coordinate(self.noc) self.assertEqual(self.generation.task_overlap(p1, p2), True) self.assertEqual(self.generation.task_overlap(p1, p3), False) def test_direction_intersection(self): self.assertEqual( len(self.generation.direction_intersection(self.message)), 0) self.generation.conflict_task_by_axe(self.message, 70, 40, 0) self.assertGreater( len(self.generation.direction_intersection(self.message)), 0)
def setUp(self): self.src = Coordinate(1, 1) self.dest = Coordinate(2, 2) self.message = Message(1, 23, 256, 0, 0, self.src, self.dest) self.packet = Packet(1, self.dest, self.message)
class TestConflictByAxe(unittest.TestCase): def setUp(self): self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1]) self.src = Coordinate(0, 0) self.dest = Coordinate(2, 2) self.message = Message(1, 12, 256, 0, 0, self.src, self.dest) self.packet = Packet(1, self.dest, self.message) self.flit = self.packet.flits[0] self.proc_engine = self.noc.router_matrix[0][0].proc_engine self.router = self.noc.router_matrix[0][0] self.generation = Generation() self.generation.set_noc(self.noc) self.generation.set_square_size(4) self.noc.link_array_filling() def test_xy_path_coordinate(self): link_array = self.message.get_xy_path_coordinate(self.noc) self.assertEqual(len(link_array), 4) self.assertEqual(link_array[0][0], 1) self.assertEqual(link_array[0][1], 2) self.assertEqual(link_array[3][0], 7) self.assertEqual(link_array[3][1], 11) def test_find_links_outside_interval(self): link_array = self.message.get_xy_path_coordinate(self.noc) outside_link = self.generation.find_links_outside_interval( link_array, 70, 30, 0) self.assertEqual(len(outside_link), 4) self.generation.add_utilization_rate_to_link(outside_link[0], 50) new_outside_link = self.generation.find_links_outside_interval( link_array, 70, 30, 0) self.assertEqual(len(new_outside_link), 4) def test_get_link_direction(self): link_array = self.message.get_xy_path_coordinate(self.noc) link = link_array.pop() self.assertEqual(self.generation.get_link_direction(link), 0) def test_task_communication_axe(self): link_array = self.message.get_xy_path_coordinate(self.noc) router_src = self.noc.get_router_coordinate_by_id(link_array[0][0]) router_dest = self.noc.get_router_coordinate_by_id(link_array[0][1]) router_src_1 = self.noc.get_router_coordinate_by_id(link_array[3][0]) router_dest_1 = self.noc.get_router_coordinate_by_id(link_array[3][1]) axe = (0 if router_src.i == router_dest.i else 1) self.assertEqual(axe, 0) axe = (0 if router_src_1.i == router_dest_1.i else 1) self.assertEqual(axe, 1) def test_generate_conflict_task_by_axe(self): link_array = self.message.get_xy_path_coordinate(self.noc) link = link_array.pop() router_src = self.noc.get_router_coordinate_by_id(link[0]) router_dest = self.noc.get_router_coordinate_by_id(link[1]) axe = (0 if router_src.i == router_dest.i else 1) conflict_task = self.generation.generate_conflict_task_by_axe( [router_src, router_dest], link, axe, 50, 0) # conflict task generated by the above function has the following characteristics # from -> to : (0,0) -> (0,1) -> (0,2) -> (0,3) : 3 links # has a link utilization < 30 self.assertEqual(len(conflict_task.get_xy_path_coordinate(self.noc)), 3) self.assertLessEqual(conflict_task.get_link_utilization(), 0.3) def test_conflict_task_by_axe(self): self.generation.conflict_task_by_axe(self.message, 70, 40, 0)