Ejemplo n.º 1
0
    def test_partition_with_more_sdram_than_default(self):
        """
        test that the partitioner works when its machine is slightly malformed
        in that it has more sdram avilable
        """
        self.setup()
        flops = 20000000
        (e, _, n, w, _, s) = range(6)

        processors = list()
        for i in range(18):
            processors.append(Processor(i, flops))

        links = list()
        links.append(Link(0, 0, 0, 0, 1, s, s))

        _sdram = SDRAM(128 * (2**21))

        links = list()

        links.append(Link(0, 0, 0, 1, 1, n, n))
        links.append(Link(0, 1, 1, 1, 0, s, s))
        links.append(Link(1, 1, 2, 0, 0, e, e))
        links.append(Link(1, 0, 3, 0, 1, w, w))
        r = Router(links, False, 100, 1024)

        ip = TestBasicPartitioner.TheTestAddress
        chips = list()
        for x in range(5):
            for y in range(5):
                chips.append(Chip(x, y, processors, r, _sdram, 0, 0, ip))

        self.machine = Machine(chips, 0, 0)
        self.bp(self.graph, self.machine)
Ejemplo n.º 2
0
    def __init__(self, configfile, default_config_paths, validation_cfg):
        """
        :param str configfile:
            The base name of the configuration file(s).
            Should not include any path components.
        :param list(str) default_config_paths:
            The list of files to get default configurations from.
        :type default_config_paths: list(str) or None
        :param validation_cfg:
            The list of files to read a validation configuration from.
            If None, no such validation is performed.
        :type validation_cfg: list(str) or None
        """
        # global params
        if default_config_paths is None:
            default_config_paths = []
        default_config_paths.insert(0, os.path.join(
            os.path.dirname(__file__), CONFIG_FILE))

        self._config = conf_loader.load_config(
            filename=configfile, defaults=default_config_paths,
            validation_cfg=validation_cfg)

        # set up machine targeted data
        self._use_virtual_board = self._config.getboolean(
            "Machine", "virtual_board")

        # Pass max_machine_cores to Machine so if effects everything!
        max_machine_core = self._read_config_int("Machine", "max_machine_core")
        if max_machine_core is not None:
            Machine.set_max_cores_per_chip(max_machine_core)

        self._json_folder = None
        self._provenance_file_path = None
        self._report_default_directory = None
        self._report_simulation_top_directory = None
        self._this_run_time_string = None
Ejemplo n.º 3
0
    def setup(self):
        """
        setup for all basic partitioner tests
        """
        self.vert1 = SimpleTestVertex(10, "New AbstractConstrainedVertex 1")
        self.vert2 = SimpleTestVertex(5, "New AbstractConstrainedVertex 2")
        self.vert3 = SimpleTestVertex(3, "New AbstractConstrainedVertex 3")
        self.edge1 = ApplicationEdge(self.vert1, self.vert2, None,
                                     "First edge")
        self.edge2 = ApplicationEdge(self.vert2, self.vert1, None,
                                     "Second edge")
        self.edge3 = ApplicationEdge(self.vert1, self.vert3, None,
                                     "Third edge")
        self.verts = [self.vert1, self.vert2, self.vert3]
        self.edges = [self.edge1, self.edge2, self.edge3]
        self.graph = ApplicationGraph("Graph")
        self.graph.add_vertices(self.verts)
        self.graph.add_edges(self.edges, "foo")

        flops = 200000000
        (e, _, n, w, _, s) = range(6)

        processors = list()
        for i in range(18):
            processors.append(Processor(i, flops))

        links = list()
        links.append(Link(0, 0, 0, 0, 1, s, s))

        _sdram = SDRAM(128 * (2**20))

        links = list()

        links.append(Link(0, 0, 0, 1, 1, n, n))
        links.append(Link(0, 1, 1, 1, 0, s, s))
        links.append(Link(1, 1, 2, 0, 0, e, e))
        links.append(Link(1, 0, 3, 0, 1, w, w))
        r = Router(links, False, 100, 1024)

        ip = TestBasicPartitioner.TheTestAddress
        chips = list()
        for x in range(5):
            for y in range(5):
                chips.append(Chip(x, y, processors, r, _sdram, 0, 0, ip))

        self.machine = Machine(chips, 0, 0)
        self.bp = BasicPartitioner()
Ejemplo n.º 4
0
    def _make_chip(self, chip_info, machine):
        """ Creates a chip from a ChipSummaryInfo structure.

        :param ChipSummaryInfo chip_info:
            The ChipSummaryInfo structure to create the chip from
        :return: The created chip
        :rtype: ~spinn_machine.Chip
        """
        # Create the down cores set if any
        n_cores = min(chip_info.n_cores, Machine.max_cores_per_chip())
        core_states = chip_info.core_states
        down_cores = self._ignore_cores_map.get((chip_info.x, chip_info.y),
                                                None)
        for i in range(1, n_cores):
            if core_states[i] != CPUState.IDLE:
                self._report_ignore("Not using core {}, {}, {} in state {}",
                                    chip_info.x, chip_info.y, i,
                                    core_states[i])
                if down_cores is None:
                    down_cores = set()
                down_cores.add(i)

        # Create the router
        router = self._make_router(chip_info, machine)

        # Create the chip's SDRAM object
        sdram_size = chip_info.largest_free_sdram_block
        max_sdram_size = get_config_int("Machine",
                                        "max_sdram_allowed_per_chip")
        if (max_sdram_size is not None and sdram_size > max_sdram_size):
            sdram_size = max_sdram_size
        sdram = SDRAM(size=sdram_size)

        # Create the chip
        return Chip(x=chip_info.x,
                    y=chip_info.y,
                    n_processors=n_cores,
                    router=router,
                    sdram=sdram,
                    ip_address=chip_info.ethernet_ip_address,
                    nearest_ethernet_x=chip_info.nearest_ethernet_x,
                    nearest_ethernet_y=chip_info.nearest_ethernet_y,
                    down_cores=down_cores,
                    parent_link=chip_info.parent_link)
    def __locate_destination(self, chip):
        """ Locate destination vertex on (Ethernet-connected) chip to send
            fixed data to

        :param ~spinn_machine.Chip chip:
        :return: processor ID as a int
        :rtype: int
        :raises PacmanConfigurationException: if no placement processor found
        """
        x = chip.x
        y = chip.y
        for p in range(Machine.max_cores_per_chip()):
            # check if occupied and by the right vertex type
            if self._placements.is_processor_occupied(x, y, p) and isinstance(
                    self._placements.get_vertex_on_processor(x, y, p),
                    self._destination_class):
                return p
        raise PacmanConfigurationException(
            "no destination vertex found on Ethernet chip {}:{}".format(
                chip.x, chip.y))
Ejemplo n.º 6
0
    def test_partition_with_insufficient_space(self):
        """
        test that if there's not enough space, the test the partitioner will
        raise an error
        """
        self.setup()
        flops = 1000
        (e, _, n, w, _, s) = range(6)

        processors = list()
        for i in range(18):
            processors.append(Processor(i, flops))

        links = list()
        links.append(Link(0, 0, 0, 0, 1, s, s))

        _sdram = SDRAM(2**11)

        links = list()

        links.append(Link(0, 0, 0, 1, 1, n, n))
        links.append(Link(0, 1, 1, 1, 0, s, s))
        links.append(Link(1, 1, 2, 0, 0, e, e))
        links.append(Link(1, 0, 3, 0, 1, w, w))
        r = Router(links, False, 100, 1024)

        ip = TestBasicPartitioner.TheTestAddress
        chips = list()
        for x in range(5):
            for y in range(5):
                chips.append(Chip(x, y, processors, r, _sdram, 0, 0, ip))

        self.machine = Machine(chips, 0, 0)
        large_vertex = SimpleTestVertex(3000,
                                        "Large vertex",
                                        max_atoms_per_core=1)
        self.assertEqual(large_vertex._model_based_max_atoms_per_core, 1)
        self.graph = ApplicationGraph("Graph with large vertex")
        self.graph.add_vertex(large_vertex)
        with self.assertRaises(PacmanPartitionException):
            self.bp(self.graph, self.machine)
Ejemplo n.º 7
0
    def test_partition_with_barely_sufficient_space(self):
        """
        test that partitioning will work when close to filling the machine
        """
        self.setup()
        flops = 20000000
        (e, _, n, w, _, s) = range(6)

        processors = list()
        for i in range(18):
            processors.append(Processor(i, flops))

        links = list()
        links.append(Link(0, 0, 0, 0, 1, s, s))

        _sdram = SDRAM(2**12)

        links = list()

        links.append(Link(0, 0, 0, 1, 1, n, n))
        links.append(Link(0, 1, 1, 1, 0, s, s))
        links.append(Link(1, 1, 2, 0, 0, e, e))
        links.append(Link(1, 0, 3, 0, 1, w, w))
        r = Router(links, False, 100, 1024)

        ip = TestBasicPartitioner.TheTestAddress
        chips = list()
        for x in range(5):
            for y in range(5):
                chips.append(Chip(x, y, processors, r, _sdram, 0, 0, ip))

        self.machine = Machine(chips, 0, 0)
        singular_vertex = SimpleTestVertex(450,
                                           "Large vertex",
                                           max_atoms_per_core=1)
        self.assertEqual(singular_vertex._model_based_max_atoms_per_core, 1)
        self.graph = ApplicationGraph("Graph with large vertex")
        self.graph.add_vertex(singular_vertex)
        graph, _, _ = self.bp(self.graph, self.machine)
        self.assertEqual(singular_vertex._model_based_max_atoms_per_core, 1)
        self.assertEqual(len(list(graph.vertices)), 450)
Ejemplo n.º 8
0
    def __call__(self,
                 hbp_server_url,
                 total_run_time,
                 max_machine_core_reduction=0):
        """
        :param str hbp_server_url:
        :param int total_run_time:
        :param int max_machine_core_reduction:
        :rtype: ~.Machine
        """

        max_machine = self._max_machine_request(hbp_server_url, total_run_time)

        n_cpus_per_chip = (Machine.max_cores_per_chip() -
                           max_machine_core_reduction)

        # Return the width and height and assume that it has wrap arounds
        return virtual_machine(width=max_machine["width"],
                               height=max_machine["height"],
                               n_cpus_per_chip=n_cpus_per_chip,
                               validate=False)
Ejemplo n.º 9
0
    def setUp(self):
        #######################################################################
        # Setting up vertices, edges and graph                                #
        #######################################################################
        self.vert1 = T_AppVertex(100, "New AbstractConstrainedVertex 1")
        self.vert2 = T_AppVertex(5, "New AbstractConstrainedVertex 2")
        self.vert3 = T_AppVertex(3, "New AbstractConstrainedVertex 3")
        self.edge1 = ApplicationEdge(self.vert1, self.vert2, "First edge")
        self.edge2 = ApplicationEdge(self.vert2, self.vert1, "Second edge")
        self.edge3 = ApplicationEdge(self.vert1, self.vert3, "Third edge")
        self.verts = [self.vert1, self.vert2, self.vert3]
        self.edges = [self.edge1, self.edge2, self.edge3]
        self.graph = ApplicationGraph("Graph", self.verts, self.edges)

        #######################################################################
        # Setting up machine                                                  #
        #######################################################################
        flops = 1000
        (_, _, n, _, _, s) = range(6)

        processors = list()
        for i in range(18):
            processors.append(Processor(i, flops))

        _sdram = SDRAM(128 * (2**20))

        ip = "192.168.240.253"
        chips = list()
        for x in range(10):
            for y in range(10):
                links = list()

                links.append(Link(x, y, 0, (x + 1) % 10, y, n, n))
                links.append(Link(x, y, 1, (x + 1) % 10, (y + 1) % 10, s, s))
                links.append(Link(x, y, 2, x, (y + 1) % 10, n, n))
                links.append(Link(x, y, 3, (x - 1) % 10, y, s, s))
                links.append(Link(x, y, 4, (x - 1) % 10, (y - 1) % 10, n, n))
                links.append(Link(x, y, 5, x, (y - 1) % 10, s, s))

                r = Router(links, False, 100, 1024)
                chips.append(Chip(x, y, processors, r, _sdram, ip))

        self.machine = Machine(chips)
        #######################################################################
        # Setting up graph and graph_mapper                                   #
        #######################################################################
        self.vertices = list()
        self.vertex1 = T_MachineVertex(0, 1,
                                       get_resources_used_by_atoms(0, 1, []),
                                       "First vertex")
        self.vertex2 = T_MachineVertex(1, 5,
                                       get_resources_used_by_atoms(1, 5, []),
                                       "Second vertex")
        self.vertex3 = T_MachineVertex(5, 10,
                                       get_resources_used_by_atoms(5, 10, []),
                                       "Third vertex")
        self.vertex4 = T_MachineVertex(
            10, 100, get_resources_used_by_atoms(10, 100, []), "Fourth vertex")
        self.vertices.append(self.vertex1)
        self.vertices.append(self.vertex2)
        self.vertices.append(self.vertex3)
        self.vertices.append(self.vertex4)
        self.edges = list()
        self.graph = MachineGraph(self.vertices, self.edges)
        self.graph_mapper = GraphMapper()
        self.graph_mapper.add_vertices(self.vertices)
Ejemplo n.º 10
0
    def __call__(
            self, width=None, height=None, version=None,
            down_chips=None, down_cores=None, down_links=None,
            max_sdram_size=None,
            router_entries_per_chip=Router.ROUTER_DEFAULT_AVAILABLE_ENTRIES,
            json_path=None):
        """
        :param int width:
        :param int height:
        :param int version:
        :param list(tuple(int,int)) down_chips:
        :param list(tuple(int,int,int)) down_cores:
        :param list(tuple(int,int,int)) down_links:
        :param int max_sdram_size:
        :param int router_entries_per_chip:
        :param str json_path:
        :rtype: ~.Machine
        :raises Exception:
        """
        # For backward compatibility support version in csf files for now
        if version is not None:
            if version in [2, 3]:
                if height is None:
                    height = 2
                else:
                    assert height == 2
                if width is None:
                    width = 2
                else:
                    assert width == 2
                logger.warning("For virtual Machines version is deprecated."
                               "use width=2, height=2 instead")
            elif version in [4, 5]:
                if height is None:
                    height = 8
                else:
                    assert height == 8
                if width is None:
                    width = 8
                else:
                    assert width == 8
                logger.warning("For virtual Machines version is deprecated."
                               "use width=8, height=8 instead")
            else:
                raise Exception("Unknown version {}".format(version))

        if json_path is None:
            # pylint: disable=too-many-arguments
            machine = virtual_machine(
                width=width, height=height,
                n_cpus_per_chip=Machine.max_cores_per_chip(),
                down_chips=down_chips, down_cores=down_cores,
                down_links=down_links, sdram_per_chip=max_sdram_size,
                router_entries_per_chip=router_entries_per_chip, validate=True)
        else:
            if (height is not None or width is not None or
                    version is not None or down_chips is not None or
                    down_cores is not None or down_links is not None):
                logger.warning("As json_path specified all other virtual "
                               "machine settings ignored.")
            machine = json_machine.machine_from_json(json_path)

        # Work out and add the SpiNNaker links and FPGA links
        machine.add_spinnaker_links()
        machine.add_fpga_links()

        logger.info(
            "Created a virtual machine which has {}".format(
                machine.cores_and_link_output_string()))

        return machine