def __call__(self, placements, app_graph, executable_finder, transceiver,
                 machine_graph, routing_infos):
        """ Loads and runs the bit field generator on chip.

        :param ~pacman.model.placements.Placements placements: placements
        :param ~pacman.model.graphs.application.ApplicationGraph app_graph:
            the app graph
        :param executable_finder: the executable finder
        :type executable_finder:
            ~spinn_front_end_common.utilities.utility_objs.ExecutableFinder
        :param ~spinnman.transceiver.Transceiver transceiver:
            the SpiNNMan instance
        :param ~pacman.model.graphs.machine.MachineGraph machine_graph:
            the machine graph
        :param ~pacman.model.routing_info.RoutingInfo routing_infos:
            the key to edge map
        """
        self.__txrx = transceiver
        self.__placements = placements
        self.__aplx = executable_finder.get_executable_path(
            self._BIT_FIELD_EXPANDER_APLX)

        # progress bar
        progress = ProgressBar(
            app_graph.n_vertices + machine_graph.n_vertices + 1,
            "Running bitfield generation on chip")

        # get data
        expander_cores = self._calculate_core_data(app_graph, progress)

        # load data
        bit_field_app_id = transceiver.app_id_tracker.get_new_id()
        progress.update(1)

        # run app
        system_control_logic.run_system_application(
            expander_cores,
            bit_field_app_id,
            transceiver,
            executable_finder,
            get_config_bool("Reports", "write_bit_field_iobuf"),
            self.__check_for_success, [CPUState.FINISHED],
            False,
            "bit_field_expander_on_{}_{}_{}.txt",
            progress_bar=progress)
        # update progress bar
        progress.end()

        # read in bit fields for debugging purposes
        if get_config_bool("Reports", "generate_bit_field_report"):
            self._full_report_bit_fields(
                app_graph,
                os.path.join(report_default_directory(),
                             self._BIT_FIELD_REPORT_FILENAME))
            self._summary_report_bit_fields(
                app_graph,
                os.path.join(report_default_directory(),
                             self._BIT_FIELD_SUMMARY_REPORT_FILENAME))
Beispiel #2
0
 def do_run(self):
     synfire_run.do_run(n_neurons,
                        neurons_per_core=neurons_per_core,
                        run_times=run_times,
                        input_class=input_class,
                        start_time=start_time,
                        duration=duration,
                        rate=rate,
                        seed=12345)
     spikes = synfire_run.get_output_pop_spikes_numpy()
     self.assertIsNotNone(spikes, "must have some spikes")
     # Check spikes increase in second half by at least a factor of ten
     hist = numpy.histogram(spikes[:, 1], bins=[0, 5000, 10000])
     self.assertIsNotNone(hist, "must have a histogram")
     # Did we build the report file like we asked for in config file?
     self.assertIn(EnergyReport._SUMMARY_FILENAME,
                   os.listdir(report_default_directory()))
     # Did we output power provenance data, as requested?
     num_chips = None
     for row in self.query_provenance(
             "SELECT the_value FROM provenance_view "
             "WHERE source_name = 'power_provenance' "
             "AND description_name = 'num_chips' LIMIT 1"):
         num_chips = row["the_value"]
     self.assertIsNotNone(num_chips, "power provenance was not written")
def redundant_packet_count_report():
    """

    :return:
    """
    file_name = os.path.join(report_default_directory(), _FILE_NAME)

    try:
        _create_views()
        with open(file_name, "w") as f:
            _write_report(f)
    except Exception as e:  # pylint: disable=broad-except
        logger.exception(f"Error {e} doing redundant_packet_count_report"
                         f" {file_name}:")
    def __call__(self, provenance_items):
        """
        :param provenance_items:
        :type provenance_items:
            list(~spinn_front_end_common.utilities.utility_objs.ProvenanceDataItem)
        """
        file_name = os.path.join(report_default_directory(), self._FILE_NAME)

        try:
            with open(file_name, "w") as f:
                self._write_report(f, provenance_items)
        except Exception:  # pylint: disable=broad-except
            logger.exception("Generate_placement_reports: Can't open file"
                             " {} for writing.", self._FILE_NAME)
    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()
    def __call__(self, connection_holder, dsg_targets):
        """ Convert synaptic matrix for every application edge.

        :param connection_holder: where the synaptic matrices are stored
            (possibly after retrieval from the machine)
        :type connection_holder:
            dict(tuple(ProjectionApplicationEdge, SynapseInformation),
            ConnectionHolder)
        :param dsg_targets: used to check if connection holders are populated
        """

        # Update the print options to display everything
        print_opts = numpy.get_printoptions()
        numpy.set_printoptions(threshold=numpy.nan)

        if dsg_targets is None:
            raise SynapticConfigurationException(
                "dsg_targets should not be none, used as a check for "
                "connection holder data to be generated")

        # generate folder for synaptic reports
        top_level_folder = os.path.join(report_default_directory(), _DIRNAME)
        if not os.path.exists(top_level_folder):
            os.mkdir(top_level_folder)

        # create progress bar
        progress = ProgressBar(connection_holder.keys(),
                               "Generating synaptic matrix reports")

        # for each application edge, write matrix in new file
        for edge, _ in progress.over(connection_holder.keys()):
            # only write matrix's for edges which have matrix's
            if isinstance(edge, ProjectionApplicationEdge):
                # figure new file name
                file_name = os.path.join(top_level_folder,
                                         _TMPL_FILENAME.format(edge.label))
                self._write_file(file_name, connection_holder, edge)

        # Reset the print options
        numpy.set_printoptions(**print_opts)
Beispiel #7
0
    def debug(self):
        reports = [
            # write_energy_report does not happen on a virtual machine
            # "Detailed_energy_report.rpt",
            # "energy_summary_report.rpt",
            # write_text_specs = False
            "data_spec_text_files",
            # write_router_reports
            reports_names._ROUTING_FILENAME,
            # write_partitioner_reports
            reports_names._PARTITIONING_FILENAME,
            # write_application_graph_placer_report
            reports_names._PLACEMENT_VTX_GRAPH_FILENAME,
            reports_names._PLACEMENT_CORE_GRAPH_FILENAME,
            reports_names._SDRAM_FILENAME,
            # write_machine_graph_placer_report
            reports_names._PLACEMENT_VTX_SIMPLE_FILENAME,
            reports_names._PLACEMENT_CORE_SIMPLE_FILENAME,
            # repeats reports_names._SDRAM_FILENAME,
            # write_router_info_report
            reports_names._VIRTKEY_FILENAME,
            # write_routing_table_reports not on a virtual boad
            # reports_names._ROUTING_TABLE_DIR,
            # reports_names._C_ROUTING_TABLE_DIR,
            # reports_names._COMPARED_FILENAME,
            # write_routing_compression_checker_report not on a virtual board
            # "routing_compression_checker_report.rpt",
            # write_routing_tables_from_machine_report not on a virtual board
            # routing_tables_from_machine_report,
            # write_memory_map_report
            # ??? used by MachineExecuteDataSpecification but not called ???
            # write_network_specification_report
            network_specification_file_name,
            # write_provenance_data
            "provenance_data",
            # write_tag_allocation_reports
            reports_names._TAGS_FILENAME,
            # write_algorithm_timings
            # "provenance_data/pacman.xml"  = different test
            # write_board_chip_report not on a virtual board
            # BoardChipReport.AREA_CODE_REPORT_NAME,
            # write_data_speed_up_report not on a virtual board
            # DataSpeedUpPacketGatherMachineVertex.REPORT_NAME
            _GRAPH_NAME,
            # TODO why svg when default is png
            _GRAPH_NAME + ".svg",
            ]
        sim.setup(1.0)
        pop = sim.Population(100, sim.IF_curr_exp, {}, label="pop")
        pop.record("v")
        inp = sim.Population(1, sim.SpikeSourceArray(
            spike_times=[0]), label="input")
        sim.Projection(inp, pop, sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5))
        sim.run(1000)
        pop.get_data("v")
        sim.end()

        found = os.listdir(report_default_directory())
        print(found)
        for report in reports:
            self.assertIn(report, found)
    def debug(self, run_zero):
        # pylint: disable=protected-access
        reports = [
            # write_energy_report
            # EnergyReport._DETAILED_FILENAME,
            # EnergyReport._SUMMARY_FILENAME,
            # write_text_specs = False
            "data_spec_text_files",
            # write_router_reports
            reports_names._ROUTING_FILENAME,
            # write_partitioner_reports
            reports_names._PARTITIONING_FILENAME,
            # write_application_graph_placer_report
            reports_names._PLACEMENT_VTX_GRAPH_FILENAME,
            reports_names._PLACEMENT_CORE_GRAPH_FILENAME,
            reports_names._SDRAM_FILENAME,
            # write_machine_graph_placer_report
            reports_names._PLACEMENT_VTX_SIMPLE_FILENAME,
            reports_names._PLACEMENT_CORE_SIMPLE_FILENAME,
            # repeats reports_names._SDRAM_FILENAME,
            # write_router_info_report
            reports_names._VIRTKEY_FILENAME,
            # write_routing_table_reports
            reports_names._ROUTING_TABLE_DIR,
            reports_names._C_ROUTING_TABLE_DIR,
            reports_names._COMPARED_FILENAME,
            # write_routing_tables_from_machine_report
            routing_tables_from_machine_report,
            # write_memory_map_report
            memory_map_on_host_report,
            # write_network_specification_report
            network_specification_file_name,
            # write_provenance_data
            "provenance_data",
            # write_tag_allocation_reports
            reports_names._TAGS_FILENAME,
            # write_algorithm_timings
            # "provenance_data/pacman.xml"  = different test
            # write_board_chip_report
            AREA_CODE_REPORT_NAME,
            _GRAPH_NAME,
            _GRAPH_NAME + "." + _GRAPH_FORMAT,
        ]

        sim.setup(1.0)
        if (get_config_bool("Machine", "enable_advanced_monitor_support")
                and not get_config_bool("Java", "use_java")):
            # write_data_speed_up_report
            reports.append(
                DataSpeedUpPacketGatherMachineVertex.OUT_REPORT_NAME)
            reports.append(DataSpeedUpPacketGatherMachineVertex.IN_REPORT_NAME)
        pop = sim.Population(100, sim.IF_curr_exp, {}, label="pop")
        pop.record("v")
        inp = sim.Population(1,
                             sim.SpikeSourceArray(spike_times=[0]),
                             label="input")
        sim.Projection(inp,
                       pop,
                       sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5))
        if run_zero:
            sim.run(0)
        sim.run(1000)
        pop.get_data("v")
        sim.end()

        report_directory = globals_variables.report_default_directory()
        found = os.listdir(report_directory)
        for report in reports:
            self.assertIn(report, found)