def test_adding_a_reverse_iptag(self):
     """
     check that adding a reverse iptag works correctly
     :return:
     """
     tag_info = Tags()
     reverse_iptag = ReverseIPTag("", 1, 23, 0, 0, 1, 1)
     parttiioned_vertex = PartitionedVertex(None, "")
     tag_info.add_reverse_ip_tag(reverse_iptag, parttiioned_vertex)
 def test_adding_a_iptag_to_tag_info(self):
     """
     check that adding a tag after init works
     :return:
     """
     tag_info = Tags()
     iptag = IPTag("", 1, "122.2.2.2", 1, False)
     parttiioned_vertex = PartitionedVertex(None, "")
     tag_info.add_ip_tag(iptag, parttiioned_vertex)
 def test_add_reverse_iptag_then_locate_tag(self):
     """
     check that asking for a reverse iptag for a speific partitioned vertex
     works
     :return:
     """
     tag_info = Tags()
     reverse_iptag = ReverseIPTag("", 1, 23, 0, 0, 1, 1)
     parttiioned_vertex = PartitionedVertex(None, "")
     tag_info.add_reverse_ip_tag(reverse_iptag, parttiioned_vertex)
     gotton_tag = tag_info.get_reverse_ip_tags_for_vertex(parttiioned_vertex)
     self.assertEqual(gotton_tag[0], reverse_iptag)
    def test_add_iptag_then_locate_tag(self):
        """
        check that locating a iptag via get_ip_tags_for_vertex function
        :return:
        """
        tag_info = Tags()
        iptag = IPTag("", 1, "122.2.2.2", 1, False)
        parttiioned_vertex = PartitionedVertex(None, "")
        tag_info.add_ip_tag(iptag, parttiioned_vertex)

        gotton_tag = tag_info.get_ip_tags_for_vertex(parttiioned_vertex)
        self.assertEqual(gotton_tag[0], iptag)
 def test_add_reverse_iptag_then_not_locate_tag(self):
     """
     check that asking for a reverse iptag with a incorrect partitioned vertex
     will cause a none returned
     :return:
     """
     tag_info = Tags()
     reverse_iptag = ReverseIPTag("", 1, 23, 0, 0, 1, 1)
     parttiioned_vertex = PartitionedVertex(None, "")
     parttiioned_vertex2 = PartitionedVertex(None, "")
     tag_info.add_reverse_ip_tag(reverse_iptag, parttiioned_vertex2)
     gotton_tag = tag_info.get_reverse_ip_tags_for_vertex(parttiioned_vertex)
     self.assertEqual(gotton_tag, None)
    def test_add_iptag_then_fail_to_locate(self):
        """
        test that asking for a invalid iptag returns a None value
        :return:
        """
        tag_info = Tags()
        iptag = IPTag("", 1, "122.2.2.2", 1, False)
        parttiioned_vertex = PartitionedVertex(None, "")
        parttiioned_vertex_2 = PartitionedVertex(None, "")
        tag_info.add_ip_tag(iptag, parttiioned_vertex)

        gotton_tag = tag_info.get_ip_tags_for_vertex(parttiioned_vertex_2)
        self.assertEqual(gotton_tag, None)
Beispiel #7
0
# general imports
import logging
import os

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
for handler in logging.root.handlers:
    handler.setFormatter(
        logging.Formatter(fmt="%(asctime)-15s %(levelname)s: %(message)s",
                          datefmt="%Y-%m-%d %H:%M:%S"))

application_data = list()
binaries = ExecutableTargets()
iptags = list()
reverse_iptags = list()
buffered_tags = Tags()
buffered_placements = Placements()

routing_tables = MulticastRoutingTables()
# database params
socket_addresses = list()

reports_states = ReportState(False, False, False, False, False, False, False,
                             False, False, False)
machine_name = "192.168.240.253"
machine_version = 3
bmp_details = "None"
down_chips = "None"
down_cores = "None"
number_of_boards = 1
height = None
    def __call__(self, machine, placements):
        """ see AbstractTagAllocatorAlgorithm.allocate_tags
        """

        resource_tracker = ResourceTracker(machine)

        # Check that the algorithm can handle the constraints
        progress_bar = ProgressBar(placements.n_placements,
                                   "Allocating tags")
        placements_with_tags = list()
        for placement in placements.placements:
            utility_calls.check_algorithm_can_support_constraints(
                constrained_vertices=[placement.subvertex],
                supported_constraints=[
                    TagAllocatorRequireIptagConstraint,
                    TagAllocatorRequireReverseIptagConstraint
                ],
                abstract_constraint_type=AbstractTagAllocatorConstraint)
            if len(utility_calls.locate_constraints_of_type(
                    placement.subvertex.constraints,
                    AbstractTagAllocatorConstraint)):
                placements_with_tags.append(placement)
            progress_bar.update()

        # Go through and allocate the tags
        tags = Tags()
        for placement in placements_with_tags:
            vertex = placement.subvertex

            # Get the constraint details for the tags
            (board_address, ip_tags, reverse_ip_tags) =\
                utility_calls.get_ip_tag_info(vertex.constraints)

            # Allocate the tags, first-come, first-served, using the
            # fixed placement of the vertex, and the required resources
            chips = [(placement.x, placement.y)]
            resources = vertex.resources_required
            (_, _, _, returned_ip_tags, returned_reverse_ip_tags) = \
                resource_tracker.allocate_resources(
                    resources, chips, placement.p, board_address, ip_tags,
                    reverse_ip_tags)

            # Put the allocated ip tag information into the tag object
            if returned_ip_tags is not None:
                for (tag_constraint, (board_address, tag)) in zip(
                        ip_tags, returned_ip_tags):
                    ip_tag = IPTag(
                        board_address, tag, tag_constraint.ip_address,
                        tag_constraint.port, tag_constraint.strip_sdp)
                    tags.add_ip_tag(ip_tag, vertex)

            # Put the allocated reverse ip tag information into the tag object
            if returned_reverse_ip_tags is not None:
                for (tag_constraint, (board_address, tag)) in zip(
                        reverse_ip_tags, returned_reverse_ip_tags):
                    reverse_ip_tag = ReverseIPTag(
                        board_address, tag, tag_constraint.port, placement.x,
                        placement.y, placement.p, tag_constraint.sdp_port)
                    tags.add_reverse_ip_tag(reverse_ip_tag, vertex)

        progress_bar.end()
        return {'tags': tags}
enable_reinjection = True
scamp_connection_data = "None"
boot_port_num = None
reset_machine_on_start_up = False
max_sdram_per_chip = None

router_tables = MulticastRoutingTables()
iptags = list()
reverse_iptags = list()
app_data_runtime_folder = os.path.abspath(
    os.path.join(os.path.realpath("__file__"), os.pardir))
dsg_targets = dict()
exec_dse_on_host = True
dse_app_id = 31

buffered_tags = Tags()
buffered_placements = Placements()

wait_for_read_confirmation = True
database_socket_addresses = list()
database_file_path = r"None"
send_start_notification = True

executable_targets = ExecutableTargets()
app_id = 30
runtime = 100.0
time_scale_factor = 1
total_machine_timesteps = 100
time_threshold = 5

router_tables.add_routing_table(
    def __call__(self, machine, placements):
        """ see AbstractTagAllocatorAlgorithm.allocate_tags
        """

        resource_tracker = ResourceTracker(machine)

        # Check that the algorithm can handle the constraints
        progress_bar = ProgressBar(placements.n_placements, "Allocating tags")
        placements_with_tags = list()
        for placement in placements.placements:
            utility_calls.check_algorithm_can_support_constraints(
                constrained_vertices=[placement.subvertex],
                supported_constraints=[
                    TagAllocatorRequireIptagConstraint,
                    TagAllocatorRequireReverseIptagConstraint
                ],
                abstract_constraint_type=AbstractTagAllocatorConstraint)
            if len(
                    utility_calls.locate_constraints_of_type(
                        placement.subvertex.constraints,
                        AbstractTagAllocatorConstraint)):
                placements_with_tags.append(placement)
            progress_bar.update()

        # Go through and allocate the tags
        tags = Tags()
        for placement in placements_with_tags:
            vertex = placement.subvertex

            # Get the constraint details for the tags
            (board_address, ip_tags, reverse_ip_tags) =\
                utility_calls.get_ip_tag_info(vertex.constraints)

            # Allocate the tags, first-come, first-served, using the
            # fixed placement of the vertex, and the required resources
            chips = [(placement.x, placement.y)]
            resources = vertex.resources_required
            (_, _, _, returned_ip_tags, returned_reverse_ip_tags) = \
                resource_tracker.allocate_resources(
                    resources, chips, placement.p, board_address, ip_tags,
                    reverse_ip_tags)

            # Put the allocated ip tag information into the tag object
            if returned_ip_tags is not None:
                for (tag_constraint, (board_address,
                                      tag)) in zip(ip_tags, returned_ip_tags):
                    ip_tag = IPTag(board_address, tag,
                                   tag_constraint.ip_address,
                                   tag_constraint.port,
                                   tag_constraint.strip_sdp)
                    tags.add_ip_tag(ip_tag, vertex)

            # Put the allocated reverse ip tag information into the tag object
            if returned_reverse_ip_tags is not None:
                for (tag_constraint, (board_address,
                                      tag)) in zip(reverse_ip_tags,
                                                   returned_reverse_ip_tags):
                    reverse_ip_tag = ReverseIPTag(board_address, tag,
                                                  tag_constraint.port,
                                                  placement.x, placement.y,
                                                  placement.p,
                                                  tag_constraint.sdp_port)
                    tags.add_reverse_ip_tag(reverse_ip_tag, vertex)

        progress_bar.end()
        return {'tags': tags}