Пример #1
0
    def add_database_socket_address(database_notify_host,
                                    database_notify_port_num,
                                    database_ack_port_num):
        """
        :param database_notify_host:
            Host to talk to tell that the database (and application) is ready.
        :type database_notify_host: str or None
        :param database_notify_port_num:
            Port to talk to tell that the database (and application) is ready.
        :type database_notify_port_num: int or None
        :param database_ack_port_num:
            Port on which to listen for an acknowledgement that the
            simulation should start.
        :type database_ack_port_num: int or None
        """
        if database_notify_port_num is None:
            database_notify_port_num = get_config_int("Database",
                                                      "notify_port")
        if database_notify_host is None:
            database_notify_host = get_config_str("Database",
                                                  "notify_hostname")
        elif database_notify_host == "0.0.0.0":
            database_notify_host = "localhost"
        if database_ack_port_num is None:
            database_ack_port_num = get_config_int("Database", "listen_port")

        # build the database socket address used by the notification interface
        database_socket = SocketAddress(
            listen_port=database_ack_port_num,
            notify_host_name=database_notify_host,
            notify_port_no=database_notify_port_num)

        # update socket interface with new demands.
        SpynnakerExternalDevicePluginManager.add_socket_address(
            database_socket)
Пример #2
0
    def _preprocess_ignore_cores(self, machine):
        """
        Converts the collection of ignore cores into a map of ignore by xy

        Converts any local x, y ipaddress to global xy

        Discards (with log messages) any ignores which are known to have no\
        affect based on the already read chip_info

        Converts any physical  cores to virtual ones.\
        Core numbers <= 0 are assumed to be 0 - physical_id

        :param ~spinn_machine.Machine machine:
            An empty machine to handle wraparounds
        """
        # Convert by ip to global
        for ignore in IgnoreCore.parse_string(
                get_config_str("Machine", "down_cores")):
            global_xy = self._ignores_local_to_global(ignore.x, ignore.y,
                                                      ignore.ip_address,
                                                      machine)
            if global_xy is None:
                continue
            p = self._get_virtual_p(global_xy, ignore.p)
            if p is not None:
                self._ignore_cores_map[global_xy].add(p)
Пример #3
0
 def _execute_delay_support_adder(self):
     """
     Runs, times and logs the DelaySupportAdder if required
     """
     name = get_config_str("Mapping", "delay_support_adder")
     if name is None:
         return
     with FecTimer(MAPPING, "DelaySupportAdder"):
         if name == "DelaySupportAdder":
             delay_support_adder(self._application_graph)
             return
         raise ConfigurationException(
             f"Unexpected cfg setting delay_support_adder: {name}")
Пример #4
0
    def _process_ignore_links(self, machine):
        """
        Processes the collection of ignore links to remove then from chipinfo

        Converts any local x, y, IP address to global xy

        Discards any ignores which are known to have no\
        affect based on the already read chip_info

        Also removes any inverse links

        Logs all actions except for ignores with unused IP addresses

        :param ~spinn_machine.Machine machine:
            An empty machine to handle wraparounds
        """
        for ignore in IgnoreLink.parse_string(
                get_config_str("Machine", "down_links")):
            global_xy = self._ignores_local_to_global(ignore.x, ignore.y,
                                                      ignore.ip_address,
                                                      machine)
            if global_xy is None:
                continue
            chip_info = self._chip_info.get(global_xy, None)
            if chip_info is None:
                self._report_ignore(
                    "Discarding ignore link on chip {} as it is not/ no longer"
                    " in info", global_xy)
                continue
            link = ignore.link
            if link in chip_info.working_links:
                chip_info.working_links.remove(link)
                self._report_ignore("On chip {} ignoring link:{}", global_xy,
                                    link)
                # ignore the inverse link too
                inv_xy = machine.xy_over_link(global_xy[0], global_xy[1], link)
                if inv_xy in self._chip_info:
                    inv_chip_info = self._chip_info[inv_xy]
                    inv_link = (link + 3) % 6
                    if inv_link in inv_chip_info.working_links:
                        inv_chip_info.working_links.remove(inv_link)
                        self._report_ignore(
                            "On chip {} ignoring link {} as it is the inverse "
                            "of link {} on chip {}", inv_xy, inv_link, link,
                            global_xy)
            else:
                self._report_ignore(
                    "Discarding ignore link {} on chip {} as it is not/"
                    "no longer in info", link, global_xy)
    def __call__(self, application_graph):
        """
        :param str report_folder: the report folder to put figure into
        :param ~pacman.model.graphs.application.ApplicationGraph \
                application_graph:
            the app graph
        """
        # create holders for data
        dot_diagram, exeNotFoundExn = self._get_diagram(self._GRAPH_TITLE)

        graph_format = get_config_str("Reports", "network_graph_format")
        if graph_format is None:
            if (application_graph.n_vertices +
                    application_graph.n_outgoing_edge_partitions) > CUTOFF:
                logger.warning(
                    "cfg write_network_graph ignored as network_graph_format "
                    "is None and the network is big")
                return
            else:
                graph_format = self._GRAPH_FORMAT
        # build progress bar for the vertices, edges, and rendering
        progress = ProgressBar(
            application_graph.n_vertices +
            application_graph.n_outgoing_edge_partitions + 1,
            "generating the graphical representation of the neural network")

        # write vertices into dot diagram
        vertex_ids = self._generate_vertices(application_graph, dot_diagram,
                                             progress)
        # write edges into dot diagram
        self._generate_edges(application_graph, dot_diagram, vertex_ids,
                             progress)

        # write dot file and generate pdf
        file_to_output = os.path.join(report_default_directory(),
                                      self._GRAPH_NAME)
        try:
            dot_diagram.render(file_to_output, view=False, format=graph_format)
        except exeNotFoundExn:
            logger.exception("could not render diagram in {}", file_to_output)
        progress.update()
        progress.end()
Пример #6
0
    def _preprocess_ignore_chips(self, machine):
        """
        Processes the collection of ignore chips and discards their chipinfo

        Converts any local x, y ipaddress to global xy

        Discards any ignores which are known to have no\
        affect based on the already read chip_info

        Logs all actions except for ignores with unused ip addresses

        :param ~spinn_machine.Machine machine:
            An empty machine to handle wraparounds
        """
        for ignore in IgnoreChip.parse_string(
                get_config_str("Machine", "down_chips")):
            # Convert by ip to global
            global_xy = self._ignores_local_to_global(ignore.x, ignore.y,
                                                      ignore.ip_address,
                                                      machine)
            if global_xy is None:
                continue  # Never on this machine
            chip_info = self._chip_info.pop(global_xy, None)
            if chip_info is None:
                continue  # Already ignored maybe by a dead chip list
            self._report_ignore("Chip {} will be ignored", global_xy)
            for link in chip_info.working_links:
                # ignore the inverse link
                inv_xy = machine.xy_over_link(global_xy[0], global_xy[1], link)
                if inv_xy in self._chip_info:
                    inv_chip_info = self._chip_info[inv_xy]
                    inv_link = (link + 3) % 6
                    if inv_link in inv_chip_info.working_links:
                        inv_chip_info.working_links.remove(inv_link)
                        self._report_ignore(
                            "On chip {} ignoring link {} as it points to "
                            "ignored chip chip {}", inv_xy, inv_link,
                            global_xy)
def _is_allocated_machine():
    return (get_config_str("Machine", "spalloc_server") or
            get_config_str("Machine", "remote_spinnaker_url"))
Пример #8
0
    def activate_live_output_for(population,
                                 database_notify_host=None,
                                 database_notify_port_num=None,
                                 database_ack_port_num=None,
                                 port=None,
                                 host=None,
                                 tag=None,
                                 strip_sdp=True,
                                 use_prefix=False,
                                 key_prefix=None,
                                 prefix_type=None,
                                 message_type=EIEIOType.KEY_32_BIT,
                                 right_shift=0,
                                 payload_as_time_stamps=True,
                                 notify=True,
                                 use_payload_prefix=True,
                                 payload_prefix=None,
                                 payload_right_shift=0,
                                 number_of_packets_sent_per_time_step=0):
        """ Output the spikes from a given population from SpiNNaker as they\
            occur in the simulation.

        :param ~spynnaker.pyNN.models.populations.Population population:
            The population to activate the live output for
        :param str database_notify_host:
            The hostname for the device which is listening to the database
            notification.
        :param int database_ack_port_num:
            The port number to which a external device will acknowledge that
            they have finished reading the database and are ready for it to
            start execution
        :param int database_notify_port_num:
            The port number to which a external device will receive the
            database is ready command
        :param key_prefix: the prefix to be applied to the key
        :type key_prefix: int or None
        :param ~spinnman.messages.eieio.EIEIOPrefix prefix_type:
            if the prefix type is 32 bit or 16 bit
        :param ~spinnman.messages.eieio.EIEIOType message_type:
            If the message is a EIEIO command message, or an EIEIO data
            message with 16 bit or 32 bit keys.
        :param bool payload_as_time_stamps:
        :param int right_shift:
        :param bool use_payload_prefix:
        :param bool notify:
        :param payload_prefix:
        :type payload_prefix: int or None
        :param int payload_right_shift:
        :param int number_of_packets_sent_per_time_step:
        :param int port:
            The UDP port to which the live spikes will be sent. If not
            specified, the port will be taken from the "live_spike_port"
            parameter in the "Recording" section of the sPyNNaker
            configuration file.
        :param str host:
            The host name or IP address to which the live spikes will be
            sent. If not specified, the host will be taken from the
            "live_spike_host" parameter in the "Recording" section of the
            sPyNNaker configuration file.
        :param int tag:
            The IP tag to be used for the spikes. If not specified, one will
            be automatically assigned
        :param bool strip_sdp:
            Determines if the SDP headers will be stripped from the
            transmitted packet.
        :param bool use_prefix:
            Determines if the spike packet will contain a common prefix for
            the spikes
        :param str label: The label of the gatherer vertex
        :param list(str) partition_ids:
            The names of the partitions to create edges for
        """
        # pylint: disable=too-many-arguments, too-many-locals, protected-access
        # get default params if none set
        if port is None:
            port = get_config_int("Recording", "live_spike_port")
        if host is None:
            host = get_config_str("Recording", "live_spike_host")

        # add new edge and vertex if required to SpiNNaker graph
        SpynnakerExternalDevicePluginManager.update_live_packet_gather_tracker(
            population._vertex,
            "LiveSpikeReceiver",
            port,
            host,
            tag,
            strip_sdp,
            use_prefix,
            key_prefix,
            prefix_type,
            message_type,
            right_shift,
            payload_as_time_stamps,
            use_payload_prefix,
            payload_prefix,
            payload_right_shift,
            number_of_packets_sent_per_time_step,
            partition_ids=[SPIKE_PARTITION_ID])

        if notify:
            SpynnakerExternalDevicePluginManager.add_database_socket_address(
                database_notify_host, database_notify_port_num,
                database_ack_port_num)