Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix power monitor buffer extraction #977

Merged
merged 10 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spinn_front_end_common/interface/abstract_spinnaker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
from spinn_front_end_common.data import FecTimer
from spinn_front_end_common.interface.config_handler import ConfigHandler
from spinn_front_end_common.interface.interface_functions import (
application_finisher, application_runner, buffer_extractor,
application_finisher, application_runner,
buffer_manager_creator, chip_io_buf_clearer, chip_io_buf_extractor,
chip_provenance_updater, chip_runtime_updater, compute_energy_used,
create_notification_protocol, database_interface,
Expand Down Expand Up @@ -2112,7 +2112,8 @@ def _execute_buffer_extractor(self):
with FecTimer(RUN_LOOP, "Buffer extractor") as timer:
if timer.skip_if_virtual_board():
return
buffer_extractor()
bm = self._data_writer.get_buffer_manager()
bm.get_placement_data()

def _do_extract_from_machine(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,33 +529,47 @@ def stop(self):
with self._thread_lock_buffer_out:
self._finished = True

def get_data_for_placements(self, recording_placements, progress=None):
def __count_regions(self):
"""
:param ~pacman.model.placements.Placements recording_placements:
Where to get the data from. May not be all placements
:param progress: How to measure/display the progress.
:type progress: ~spinn_utilities.progress_bar.ProgressBar or None
:rtype: tuple(int, list(~.Placement))
"""
if self._java_caller is not None:
self._java_caller.set_placements(recording_placements)
# Count the regions to be read
n_regions_to_read = 0
recording_placements = list()
for placement in FecDataView.iterate_placements_by_vertex_type(
AbstractReceiveBuffersToHost):
vertex = placement.vertex
n_regions_to_read += len(vertex.get_recorded_region_ids())
recording_placements.append(placement)
return n_regions_to_read, recording_placements

def get_placement_data(self):
timer = Timer()
with timer:
with self._thread_lock_buffer_out:
if self._java_caller is not None:
self._java_caller.get_all_data()
if progress:
progress.end()
elif get_config_bool(
"Machine", "enable_advanced_monitor_support"):
self.__old_get_data_for_placements_with_monitors(
recording_placements, progress)
self.__get_data_for_placements_using_java()
else:
self.__old_get_data_for_placements(
recording_placements, progress)
n_regions, recording_placements = self.__count_regions()
progress = ProgressBar(
n_regions, "Extracting buffers from the last run")
if get_config_bool(
"Machine", "enable_advanced_monitor_support"):
self.__old_get_data_for_placements_with_monitors(
recording_placements, progress)
else:
self.__old_get_data_for_placements(
recording_placements, progress)
with ProvenanceWriter() as db:
db.insert_category_timing(BUFFER, timer.measured_interval, None)

def __get_data_for_placements_using_java(self):
logger.info("Starting buffer extraction using Java")
self._java_caller.set_placements(
FecDataView.iterate_placements_by_vertex_type(
AbstractReceiveBuffersToHost))
self._java_caller.get_all_data()

def __old_get_data_for_placements_with_monitors(
self, recording_placements, progress):
"""
Expand Down Expand Up @@ -589,8 +603,7 @@ def __old_get_data_for_placements(self, recording_placements, progress):
vertex = placement.vertex
for recording_region_id in vertex.get_recorded_region_ids():
self._retreive_by_placement(placement, recording_region_id)
if progress is not None:
progress.update()
progress.update()

def get_data_by_placement(self, placement, recording_region_id):
""" Get the data container for all the data retrieved\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from .application_finisher import application_finisher
from .application_runner import application_runner
from .buffer_extractor import buffer_extractor
from .chip_iobuf_clearer import chip_io_buf_clearer
from .chip_iobuf_extractor import chip_io_buf_extractor
from .buffer_manager_creator import buffer_manager_creator
Expand Down Expand Up @@ -63,8 +62,7 @@


__all__ = [
"application_finisher",
"application_runner", "buffer_extractor",
"application_finisher", "application_runner",
"buffer_manager_creator", "chip_io_buf_clearer",
"chip_io_buf_extractor", "chip_provenance_updater",
"chip_runtime_updater", "create_notification_protocol",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def _compute_energy_consumption(

def __find_monitor_placements():
return [placement
for placement in FecDataView.iterate_placemements()
if isinstance(placement.vertex, ChipPowerMonitorMachineVertex)]
for placement in FecDataView.iterate_placements_by_vertex_type(
ChipPowerMonitorMachineVertex)]


_COST_PER_TYPE = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def get_bit_field_sdram_base_addresses(self, chip_x, chip_y):
# pylint: disable=too-many-arguments, unused-argument
# locate the bitfields in a chip level scope
base_addresses = dict()
for placement in FecDataView.iterate_placements_with_vertex_type(
for placement in FecDataView.iterate_placements_by_xy_and_type(
chip_x, chip_y, AbstractSupportsBitFieldRoutingCompression):
vertex = placement.vertex
base_addresses[placement.p] = vertex.bit_field_base_address(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from spinn_utilities.progress_bar import ProgressBar
from spinn_machine import CoreSubsets
from spinn_front_end_common.abstract_models import AbstractHasAssociatedBinary
from spinn_front_end_common.data import FecDataView
Expand All @@ -27,19 +26,16 @@ def locate_executable_start_type():
"""
binary_start_types = dict()

progress = ProgressBar(
FecDataView.get_n_placements(), "Finding executable start types")
for placement in progress.over(FecDataView.iterate_placemements()):
for placement in FecDataView.iterate_placements_by_vertex_type(
AbstractHasAssociatedBinary):
bin_type = placement.vertex.get_binary_start_type()
# update core subset with location of the vertex on the
# machine
if bin_type not in binary_start_types:
binary_start_types[bin_type] = CoreSubsets()

if isinstance(placement.vertex, AbstractHasAssociatedBinary):
bin_type = placement.vertex.get_binary_start_type()
# update core subset with location of the vertex on the
# machine
if bin_type not in binary_start_types:
binary_start_types[bin_type] = CoreSubsets()

__add_vertex_to_subset(
placement, binary_start_types[bin_type])
__add_vertex_to_subset(
placement, binary_start_types[bin_type])

# only got apps with no binary, such as external devices.
# return no app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,10 @@ def _write_detailed_report(self, power_used, f):

# sort what to report by chip
active_chips = defaultdict(dict)
for placement in FecDataView.iterate_placemements():
vertex = placement.vertex
if not isinstance(vertex, ChipPowerMonitorMachineVertex):
labels = active_chips[placement.x, placement.y]
labels[placement.p] = vertex.label
for placement in FecDataView.iterate_placements_by_vertex_type(
ChipPowerMonitorMachineVertex):
labels = active_chips[placement.x, placement.y]
labels[placement.p] = placement.vertex.label
for xy in active_chips:
self._write_chips_active_cost(
xy, active_chips[xy], runtime_total_ms, power_used, f)
Expand Down