Пример #1
0
    def __call__(self,
                 spalloc_server,
                 spalloc_port=22244,
                 spalloc_machine=None,
                 max_sdram_size=None,
                 max_machine_core_reduction=0):
        """
        :param str spalloc_server:
        :param int spalloc_port:
        :param str spalloc_machine:
        :param int max_sdram_size:
        :param int max_machine_core_reduction:
        :rtype: ~.Machine
        """
        with ProtocolClient(spalloc_server, spalloc_port) as client:
            machines = client.list_machines()
            # Close the context immediately; don't want to keep this particular
            # connection around as there's not a great chance of this code
            # being rerun in this process any time soon.
        max_width = None
        max_height = None
        max_area = -1

        for machine in self._filter(machines, spalloc_machine):
            # Get the width and height in chips, and logical area in chips**2
            width, height, area = self._get_size(machine)

            # The "biggest" board is the one with the most chips
            if area > max_area:
                max_area = area
                max_width = width
                max_height = height

        if max_width is None:
            raise Exception(
                "The spalloc server appears to have no compatible machines")

        n_cpus_per_chip = (Machine.max_cores_per_chip() -
                           max_machine_core_reduction)

        # Return the width and height, and make no assumption about wrap-
        # arounds or version.
        return virtual_machine(width=max_width,
                               height=max_height,
                               sdram_per_chip=max_sdram_size,
                               n_cpus_per_chip=n_cpus_per_chip,
                               validate=False)