def test_run_too_long(): s.setup(model_binary_folder=os.path.dirname(__file__)) s.add_machine_vertex_instance( TestRunVertex("test_run_too_long.aplx", ExecutableType.USES_SIMULATION_INTERFACE)) with pytest.raises(SpinnmanTimeoutException): s.run(1000)
def setup(self): sim.setup(model_binary_module=common, time_scale_factor=5) vertex_1 = SimpleTestVertex(12, fixed_sdram_value=20) vertex_1.splitter = SDRAMSplitter(SourceSegmentedSDRAMMachinePartition) sim.add_vertex_instance(vertex_1) sim.run(100) sim.stop()
def test_rte_at_start(): globals_variables.unset_simulator() s.setup(model_binary_folder=os.path.dirname(__file__)) s.add_machine_vertex_instance( RunVertex("test_rte_start.aplx", ExecutableType.USES_SIMULATION_INTERFACE)) with pytest.raises(SpinnmanException): s.run(1000)
def setup(self): sim.setup(model_binary_module=common) vertex_1 = SimpleTestVertex(10, fixed_sdram_value=20) vertex_1.splitter = SDRAMSplitterInternal( ConstantSDRAMMachinePartition) sim.add_vertex_instance(vertex_1) sim.run(100) sim.stop()
def setup(self): sim.setup(model_binary_module=common) vertex_1 = SdramTestVertex(12, fixed_sdram_value=20) vertex_1.splitter = SDRAMSplitter( DestinationSegmentedSDRAMMachinePartition) sim.add_vertex_instance(vertex_1) sim.run(100) sim.stop()
def run(self, mbs): # setup system sim.setup(model_binary_module=test_extra_monitor_core_data_extraction, n_chips_required=2) # build verts writer = SDRAMWriter(mbs) # add verts to graph sim.add_machine_vertex_instance(writer) sim.run(12) # get placements for extraction placements = sim.placements() machine = sim.machine() writer_placement = placements.get_placement_of_vertex(writer) writer_chip = \ machine.get_chip_at(writer_placement.x, writer_placement.y) writer_nearest_ethernet = machine.get_chip_at( writer_chip.nearest_ethernet_x, writer_chip.nearest_ethernet_y) extra_monitor_vertices = sim.globals_variables.\ get_simulator()._last_run_outputs['MemoryExtraMonitorVertices'] extra_monitor_gatherers = sim.globals_variables.\ get_simulator()._last_run_outputs[ 'MemoryMCGatherVertexToEthernetConnectedChipMapping'] receiver = None gatherer = extra_monitor_gatherers[(writer_nearest_ethernet.x, writer_nearest_ethernet.y)] for vertex in extra_monitor_vertices: placement = placements.get_placement_of_vertex(vertex) if (placement.x == writer_placement.x and placement.y == writer_placement.y): receiver = vertex start = float(time.time()) gatherer.set_cores_for_data_extraction(sim.transceiver(), extra_monitor_vertices, placements) data = gatherer.get_data( sim.transceiver(), placements.get_placement_of_vertex(receiver), self._get_data_region_address(sim.transceiver(), writer_placement), writer.mbs_in_bytes) gatherer.unset_cores_for_data_extraction(sim.transceiver(), extra_monitor_vertices, placements) end = float(time.time()) print("time taken to extract {} MB is {}. MBS of {}".format( mbs, end - start, (mbs * 8) / (end - start))) self._check_data(data)
def test_rte_during_run_forever(): s.setup(model_binary_folder=os.path.dirname(__file__)) s.add_machine_vertex_instance( TestRunVertex("test_rte_during_run.aplx", ExecutableType.USES_SIMULATION_INTERFACE)) s.run(None) sleep(2.0) with pytest.raises(ExecutableFailedToStopException): s.stop()
def test_rte_during_run(): s.setup(model_binary_folder=os.path.dirname(__file__)) s.add_machine_vertex_instance( RunVertex("test_rte_during_run.aplx", ExecutableType.USES_SIMULATION_INTERFACE)) with pytest.raises(SpinnmanException): try: s.run(1000) except Exception: traceback.print_exc() raise
def test_rte_during_run_forever(): globals_variables.unset_simulator() s.setup(model_binary_folder=os.path.dirname(__file__)) s.add_machine_vertex_instance( RunVertex("test_rte_during_run.aplx", ExecutableType.USES_SIMULATION_INTERFACE)) s.add_socket_address(None, "localhost", conn.local_port) s.run(None) conn.close() with pytest.raises(ExecutableFailedToStopException): s.stop()
def run (self): """ run the application graph """ # cannot run unless weights file exists if self._weights_file is None: print "run aborted: weights file not given" return # may need to reload initial weights file if # application graph was modified after load if not self._weights_loaded: if not self.read_Lens_weights_file (self._weights_file): print "run aborted: error reading weights file" # cannot run unless example set exists if self._ex_set is None: print "run aborted: no example set" return # cannot run unless examples have been loaded if not self._ex_set.examples_loaded: print "run aborted: examples not loaded" return # generate summary set, example and event data self._num_examples = self._ex_set.compile (self) if self._num_examples == 0: print "run aborted: error compiling example set" return # generate machine graph self.generate_machine_graph () # run application based on the machine graph g.run (None) # wait for the application to finish print "running: waiting for application to finish" _txrx = g.transceiver () _app_id = globals_variables.get_simulator ()._app_id #lap _running = _txrx.get_core_state_count (_app_id, CPUState.RUNNING) _finished = _txrx.get_core_state_count (_app_id, CPUState.FINISHED) while _finished < self._num_vertices: time.sleep (0.5) _error = _txrx.get_core_state_count\ (_app_id, CPUState.RUN_TIME_EXCEPTION) _wdog = _txrx.get_core_state_count (_app_id, CPUState.WATCHDOG) if _error > 0 or _wdog > 0: print "application stopped: cores failed ({}\ RTE, {} WDOG)".format (_error, _wdog) break #lap _running = _txrx.get_core_state_count (_app_id, CPUState.RUNNING) _finished = _txrx.get_core_state_count (_app_id, CPUState.FINISHED)
def setup(self): sim.setup(model_binary_module=common) vertex_1 = SdramTestVertex(12, fixed_sdram_value=20) vertex_1.splitter = BasicSDRAMSplitter() vertex_2 = SdramTestVertex(12, fixed_sdram_value=20) vertex_2.splitter = SDRAMSplitter( SourceSegmentedSDRAMMachinePartition, vertex_1.splitter) sim.add_vertex_instance(vertex_1) sim.add_vertex_instance(vertex_2) sim.add_application_edge_instance( ApplicationEdge(vertex_1, vertex_2), "sdram") sim.run(100) sim.stop()
def setup(self): sim.setup(model_binary_module=common) vertex_1 = SdramTestVertex(2, fixed_sdram_value=200 * 1024 * 1024) vertex_1.splitter = SDRAMSplitterExternal( ConstantSDRAMMachinePartition) vertex_2 = SdramTestVertex(2, fixed_sdram_value=200 * 1024 * 1024) vertex_2.splitter = SDRAMSplitterExternal( ConstantSDRAMMachinePartition) sim.add_vertex_instance(vertex_1) sim.add_vertex_instance(vertex_2) sim.add_application_edge_instance(ApplicationEdge(vertex_1, vertex_2), "sdram") with self.assertRaises(PacmanValueError): sim.run(100)
def setup(self): sim.setup(model_binary_module=common) vertex_1 = SdramTestVertex(2, fixed_sdram_value=20) vertex_1.splitter = SDRAMSplitterExternal( ConstantSDRAMMachinePartition) vertex_2 = SdramTestVertex(2, fixed_sdram_value=20) vertex_2.splitter = SDRAMSplitterExternal( ConstantSDRAMMachinePartition) sim.add_vertex_instance(vertex_1) sim.add_vertex_instance(vertex_2) sim.add_application_edge_instance( ApplicationEdge(vertex_1, vertex_2), "sdram") sim.run(100) sim.stop()
def _do_run(reader, receiver, mbs): # run forever (to allow better speed testing) sim.run() # get placements for extraction placements = sim.placements() sim.transceiver().set_watch_dog(False) # set time outs using new interface ( # clunky, but will be hidden in interface at later date) extra_monitor_vertices = sim.globals_variables. \ get_simulator()._last_run_outputs['MemoryExtraMonitorVertices'] try: print("starting data gathering") start = float(time.time()) data, lost_seq_data = receiver.get_data( sim.transceiver(), placements.get_placement_of_vertex(reader), extra_monitor_vertices, placements) end = float(time.time()) # end sim sim.stop() # check data is correct here ints = struct.unpack("<{}I".format(len(data) // 4), data) start_value = 0 for value in ints: if value != start_value: print("should be getting {}, but got {}".format( start_value, value)) start_value = value + 1 else: start_value += 1 # print data seconds = float(end - start) speed = (mbs * 8) / seconds print("Read {} MB in {} seconds ({} Mb/s)".format( mbs, seconds, speed)) del data return speed, True, False, "", lost_seq_data except Exception as e: # if boomed. end so that we can get iobuf traceback.print_exc() sim.stop() return None, True, True, str(e), 0
def test_hello_world(self): front_end.setup(n_chips_required=1, model_binary_folder=os.path.dirname(__file__)) # Put HelloWorldVertex onto 16 cores total_number_of_cores = 16 for x in range(total_number_of_cores): front_end.add_machine_vertex_instance( HelloWorldVertex(n_hellos=10, label=f"Hello World at {x}")) front_end.run(10) front_end.run(10) front_end.stop()
def test_rte_during_run_forever(): def start(): sleep(3.0) s.stop_run() conn = DatabaseConnection(start, local_port=None) s.setup(model_binary_folder=os.path.dirname(__file__)) s.add_machine_vertex_instance( RunVertex("test_rte_during_run.aplx", ExecutableType.USES_SIMULATION_INTERFACE)) s.add_socket_address(None, "localhost", conn.local_port) s.run(None) with pytest.raises(ExecutableFailedToStopException): s.stop() conn.close()
def check_extra_monitor(self): mbs = _TRANSFER_SIZE_MEGABYTES # setup system globals_variables.unset_simulator() sim.setup(model_binary_folder=os.path.dirname(__file__), n_chips_required=2) # build verts writer_vertex = SDRAMWriter(mbs) # add verts to graph sim.add_machine_vertex_instance(writer_vertex) sim.run(12) writer_placement = sim.placements().get_placement_of_vertex( writer_vertex) # pylint: disable=protected-access outputs = sim.globals_variables.get_simulator()._last_run_outputs monitor_vertices = outputs[_MONITOR_VERTICES] receiver_plt = _get_monitor_placement(monitor_vertices, writer_placement) gatherers, gatherer = _get_gatherer_for_monitor(writer_vertex) start = float(time.time()) data = _do_transfer(gatherer, gatherers, monitor_vertices, receiver_plt, writer_placement, writer_vertex) end = float(time.time()) print( "time taken to extract {} MB is {}. Transfer rate: {} Mb/s".format( mbs, end - start, (mbs * 8) / (end - start))) check_data(data) sim.stop()
def check_extra_monitor(self): mbs = _TRANSFER_SIZE_MEGABYTES # setup system sim.setup(model_binary_folder=os.path.dirname(__file__), n_chips_required=2) # build verts writer_vertex = SDRAMWriter(mbs) # add verts to graph sim.add_machine_vertex_instance(writer_vertex) sim.run(12) writer_placement = sim.placements().get_placement_of_vertex( writer_vertex) # pylint: disable=protected-access monitor_vertices = sim.globals_variables.get_simulator().\ _extra_monitor_to_chip_mapping receiver_plt = _get_monitor_placement(monitor_vertices, writer_placement) gatherers, gatherer = _get_gatherer_for_monitor(writer_vertex) start = float(time.time()) data = _do_transfer(gatherer, gatherers, monitor_vertices, receiver_plt, writer_placement, writer_vertex) end = float(time.time()) print(f"time taken to extract {mbs} MB is {end - start}. " f"Transfer rate: {(mbs * 8) / (end - start)} Mb/s") check_data(data) sim.stop()
from pacman.model.graphs.machine import MachineEdge from pkt_injector_vertex import Pkt_Injector_Vertex from pkt_extractor_vertex import Pkt_Extractor_Vertex NUM_INJECTORS = 9 gfe.setup(machine_time_step=1000000, n_chips_required=1, model_binary_folder=os.path.dirname(__file__)) # instantiate injector vertices injectors = [] for i in range(NUM_INJECTORS): iv = Pkt_Injector_Vertex(i) gfe.add_machine_vertex_instance(iv) injectors.append(iv) # instantiate extractor vertices ev = Pkt_Extractor_Vertex() gfe.add_machine_vertex_instance(ev) # create links from injectors to extractor for iv in injectors: gfe.add_machine_edge_instance(MachineEdge(iv, ev), iv.inj_lnk) gfe.run(10000) gfe.stop()
import spinnaker_graph_front_end as front_end # set up the front end and ask for the detected machines dimensions front_end.setup() front_end.run() front_end.stop()
logger = logging.getLogger(__name__) front_end.setup( n_chips_required=None, model_binary_folder=os.path.dirname(__file__)) ''' calculate total number of 'free' cores for the given board (i.e. does not include those busy with SARK or reinjection)''' total_number_of_cores = \ front_end.get_number_of_available_cores_on_machine() #param1: data #param2: number of chips used #param3: what columns to use #param4: how many string columns exist? #param5: function id load_data_onto_vertices(raw_data, 1, [0], 1, 2) front_end.run(10000) placements = front_end.placements() buffer_manager = front_end.buffer_manager() #write_unique_ids_to_csv(getData,1,len(raw_data)) #display_linked_list_size() #display_results_function_one() #display_results_function_two() display_results_function_three() front_end.stop()
# Copyright (c) 2017-2019 The University of Manchester # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import spinnaker_graph_front_end as front_end from spinnaker_graph_front_end.examples.Conways.no_edges_examples.\ conways_basic_cell import ( ConwayBasicCell) # set up the front end and ask for the detected machines dimensions front_end.setup() for count in range(0, 60): front_end.add_machine_vertex_instance( ConwayBasicCell("cell{}".format(count))) front_end.run(1) front_end.stop()
def run_broken(): machine_time_step = 1000 time_scale_factor = 1 # machine_port = 11111 machine_receive_port = 22222 machine_host = "0.0.0.0" live_gatherer_label = "LiveHeatGatherer" notify_port = 19999 database_listen_port = 19998 # set up the front end and ask for the detected machines dimensions front_end.setup( graph_label="heat_demo_graph", model_binary_module=sys.modules[__name__], database_socket_addresses={SocketAddress( "127.0.0.1", notify_port, database_listen_port)}) machine = front_end.machine() # create a live gatherer vertex for each board default_gatherer = None live_gatherers = dict() used_cores = set() for chip in machine.ethernet_connected_chips: # Try to use core 17 if one is available as it is outside the grid processor = chip.get_processor_with_id(17) if processor is None or processor.is_monitor: processor = chip.get_first_none_monitor_processor() if processor is not None: live_gatherer = front_end.add_machine_vertex( LivePacketGatherMachineVertex, { 'label': live_gatherer_label, 'ip_address': machine_host, 'port': machine_receive_port, 'payload_as_time_stamps': False, 'use_payload_prefix': False, 'strip_sdp': True, 'message_type': EIEIOType.KEY_PAYLOAD_32_BIT } ) live_gatherers[chip.x, chip.y] = live_gatherer used_cores.add((chip.x, chip.y, processor.processor_id)) if default_gatherer is None: default_gatherer = live_gatherer # Create a list of lists of vertices (x * 4) by (y * 4) # (for 16 cores on a chip - missing cores will have missing vertices) max_x_element_id = (machine.max_chip_x + 1) * 4 max_y_element_id = (machine.max_chip_y + 1) * 4 vertices = [ [None for _ in range(max_y_element_id)] for _ in range(max_x_element_id) ] receive_labels = list() for x in range(0, max_x_element_id): for y in range(0, max_y_element_id): chip_x = x / 4 chip_y = y / 4 core_x = x % 4 core_y = y % 4 core_p = ((core_x * 4) + core_y) + 1 # Add an element if the chip and core exists chip = machine.get_chip_at(chip_x, chip_y) if chip is not None: core = chip.get_processor_with_id(core_p) if (core is not None and not core.is_monitor and (chip_x, chip_y, core_p) not in used_cores): element = front_end.add_machine_vertex( HeatDemoVertex, { 'machine_time_step': machine_time_step, 'time_scale_factor': time_scale_factor }, label="Heat Element {}, {}".format( x, y)) vertices[x][y] = element vertices[x][y].add_constraint( ChipAndCoreConstraint(chip_x, chip_y, core_p)) # add a link from the heat element to the live packet # gatherer live_gatherer = live_gatherers.get( (chip.nearest_ethernet_x, chip.nearest_ethernet_y), default_gatherer) front_end.add_machine_edge( MachineEdge, { 'pre_vertex': vertices[x][y], 'post_vertex': live_gatherer }, label="Live output from {}, {}".format(x, y), semantic_label="TRANSMISSION") receive_labels.append(vertices[x][y].label) # build edges for x in range(0, max_x_element_id): for y in range(0, max_y_element_id): if vertices[x][y] is not None: # Add a north link if not at the top if y+1 < max_y_element_id and vertices[x][y+1] is not None: front_end.add_machine_edge( HeatDemoEdge, { 'pre_vertex': vertices[x][y], 'post_vertex': vertices[x][y + 1], 'direction': HeatDemoEdge.DIRECTIONS.SOUTH }, label="North Edge from {}, {} to {}, {}".format( x, y, x + 1, y), semantic_label="TRANSMISSION") # Add an east link if not at the right if x+1 < max_y_element_id and vertices[x+1][y] is not None: front_end.add_machine_edge( HeatDemoEdge, { 'pre_vertex': vertices[x][y], 'post_vertex': vertices[x + 1][y], 'direction': HeatDemoEdge.DIRECTIONS.WEST }, label="East Edge from {}, {} to {}, {}".format( x, y, x + 1, y), semantic_label="TRANSMISSION") # Add a south link if not at the bottom if (y - 1) >= 0 and vertices[x][y - 1] is not None: front_end.add_machine_edge( HeatDemoEdge, { 'pre_vertex': vertices[x][y], 'post_vertex': vertices[x][y - 1], 'direction': HeatDemoEdge.DIRECTIONS.NORTH }, label="South Edge from {}, {} to {}, {}".format( x, y, x, y - 1), semantic_label="TRANSMISSION") # check for the likely hood for a W link if (x - 1) >= 0 and vertices[x - 1][y] is not None: front_end.add_machine_edge( HeatDemoEdge, { 'pre_vertex': vertices[x][y], 'post_vertex': vertices[x - 1][y], 'direction': HeatDemoEdge.DIRECTIONS.EAST }, label="West Edge from {}, {} to {}, {}".format( x, y, x - 1, y), semantic_label="TRANSMISSION") # Set up the live connection for receiving heat elements live_heat_connection = LiveEventConnection( live_gatherer_label, receive_labels=receive_labels, local_port=notify_port, machine_vertices=True) heat_values = defaultdict(list) condition = Condition() def receive_heat(label, atom, value): with condition: print "{}: {}".format(label, value / 65536.0) # Set up callbacks to occur when spikes are received for label in receive_labels: live_heat_connection.add_receive_callback(label, receive_heat) front_end.run(1000) front_end.stop() for label in receive_labels: print "{}: {}".format( label, ["{:05.2f}".format(value) for value in heat_values[label]])
def run_model(data, n_chips=None, n_ihcan=0, fs=44100, resample_factor=1): # Set up the simulation g.setup(n_chips_required=n_chips, model_binary_module=model_binaries) # Get the number of cores available for use n_cores = 0 machine = g.machine() # Create a OME for each chip boards = dict() #changed to lists to ensure data is read back in the same order that verticies are instantiated ihcans = list() cf_index = 0 count = 0 for chip in machine.chips: if count >= n_chips: break else: boards[chip.x, chip.y] = chip.ip_address for j in range(n_ihcan): ihcan = IHCANVertex(data[j][:], fs, resample_factor) g.add_machine_vertex_instance(ihcan) # constrain placement to local chip ihcan.add_constraint(ChipAndCoreConstraint(chip.x, chip.y)) #ihcans[chip.x, chip.y,j] = ihcan ihcans.append(ihcan) count = count + 1 # Run the simulation g.run(None) # Wait for the application to finish txrx = g.transceiver() app_id = globals_variables.get_simulator()._app_id #logger.info("Running {} worker cores".format(n_workers)) logger.info("Waiting for application to finish...") running = txrx.get_core_state_count(app_id, CPUState.RUNNING) while running > 0: time.sleep(0.5) error = txrx.get_core_state_count(app_id, CPUState.RUN_TIME_EXCEPTION) watchdog = txrx.get_core_state_count(app_id, CPUState.WATCHDOG) if error > 0 or watchdog > 0: error_msg = "Some cores have failed ({} RTE, {} WDOG)".format( error, watchdog) raise Exception(error_msg) running = txrx.get_core_state_count(app_id, CPUState.RUNNING) # Get the data back samples = list() progress = ProgressBar(len(ihcans), "Reading results") for ihcan in ihcans: samples.append(ihcan.read_samples(g.buffer_manager())) progress.update() progress.end() samples = numpy.hstack(samples) # Close the machine g.stop() print "channels running: ", len(ihcans) / 5.0 print "output data: {} fibres with length {}".format( len(ihcans) * 2, len(samples)) #if(len(samples) != len(ihcans)*2*numpy.floor(len(data[0][0])/100)*100*(1.0/resample_factor)): if (len(samples) != len(ihcans) * 2 * numpy.floor(len(data[0][0]) / 96) * 96): #print "samples length {} isn't expected size {}".format(len(samples),len(ihcans)*2*numpy.floor(len(data[0][0])/100)*100*(1.0/resample_factor)) print "samples length {} isn't expected size {}".format( len(samples), len(ihcans) * 2 * numpy.floor(len(data[0][0]) / 96) * 96) return samples
for y in range(0, n_particles): if (x == y): continue front_end.add_machine_edge_instance( MachineEdge(particle_list[x], particle_list[y], label="Edge P{} to P{}".format(x, y)), constants.EDGE_PARTITION_PARTICLE_TO_PARTICLE) # EDGES from main_particle to output front_end.add_machine_edge_instance( MachineEdge(the_main_particle, output_vertex, label="Final Result Edge"), constants.EDGE_PARTITION_TARGET_POSITION) if (run_online): front_end.run(None) time.sleep(0.5) print 'Experiment Started with',constants.PARTICLES,'particles and',\ constants.MAX_BATCH_SIZE,'batch size.' raw_input("Press Enter to stop operation...") else: front_end.run(operation_time) # used with test data placements = front_end.placements() buffer_manager = front_end.buffer_manager() placement = placements.get_placement_of_vertex(the_main_particle) data = the_main_particle.get_data(buffer_manager, placement) print "The simulation recorded {} steps".format(len(data)) #processAndPlot(video_sequence, data)
def run(time=None): front_end.run(time)
def run(self, mbs, number_of_repeats): # setup system sim.setup(model_binary_module=( test_extra_monitor_core_data_extraction_multiple_locations), n_chips_required=49 * 2) # build vertices locs = [(0, 0), (2, 2), (7, 7), (3, 0), (1, 0), (0, 1), (3, 3), (4, 4), (5, 5), (3, 5), (4, 0), (7, 4), (8, 4), (4, 8), (11, 11), (11, 0), (0, 11), (6, 3), (0, 6)] writers = list() for chip_x, chip_y in locs: writer = SDRAMWriter(mbs, constraint=ChipAndCoreConstraint( chip_x, chip_y)) # add vertices to graph sim.add_machine_vertex_instance(writer) writers.append(writer) sim.run(12) # get placements for extraction placements = sim.placements() machine = sim.machine() extra_monitor_vertices = sim.globals_variables. \ get_simulator()._last_run_outputs[ 'MemoryExtraMonitorVertices'] extra_monitor_gatherers = sim.globals_variables. \ get_simulator()._last_run_outputs[ 'MemoryMCGatherVertexToEthernetConnectedChipMapping'] time_out_setter = extra_monitor_gatherers[(0, 0)] time_out_setter.set_cores_for_data_extraction(sim.transceiver(), extra_monitor_vertices, placements) for _ in range(0, number_of_repeats): for writer in writers: writer_placement = placements.get_placement_of_vertex(writer) writer_chip = \ machine.get_chip_at(writer_placement.x, writer_placement.y) writer_nearest_ethernet = machine.get_chip_at( writer_chip.nearest_ethernet_x, writer_chip.nearest_ethernet_y) receiver = None gatherer = extra_monitor_gatherers[(writer_nearest_ethernet.x, writer_nearest_ethernet.y)] for vertex in extra_monitor_vertices: placement = placements.get_placement_of_vertex(vertex) if (placement.x == writer_placement.x and placement.y == writer_placement.y): receiver = vertex start = float(time.time()) data = gatherer.get_data( sim.transceiver(), placements.get_placement_of_vertex(receiver), self._get_data_region_address(sim.transceiver(), writer_placement), writer.mbs_in_bytes) end = float(time.time()) print("time taken to extract {} MB is {}. MBS of {}".format( mbs, end - start, (mbs * 8) / (end - start))) self._check_data(data) time_out_setter.unset_cores_for_data_extraction( sim.transceiver(), extra_monitor_vertices, placements)
(y - 1) % MAX_Y_SIZE_OF_FABRIC, "SE"), (x, (y - 1) % MAX_Y_SIZE_OF_FABRIC, "S"), ((x - 1) % MAX_X_SIZE_OF_FABRIC, (y - 1) % MAX_Y_SIZE_OF_FABRIC, "SW"), ((x - 1) % MAX_X_SIZE_OF_FABRIC, y, "W"), ((x - 1) % MAX_X_SIZE_OF_FABRIC, (y + 1) % MAX_Y_SIZE_OF_FABRIC, "NW")] for (dest_x, dest_y, compass) in positions: front_end.add_machine_edge_instance( MachineEdge(vertices[x][y], vertices[dest_x][dest_y], label=compass), ConwayBasicCell.PARTITION_ID) # run the simulation front_end.run(runtime) # get recorded data recorded_data = dict() # get the data per vertex for x in range(0, MAX_X_SIZE_OF_FABRIC): for y in range(0, MAX_Y_SIZE_OF_FABRIC): recorded_data[(x, y)] = vertices[x][y].get_data( front_end.buffer_manager(), front_end.placements().get_placement_of_vertex(vertices[x][y])) # visualise it in text form (bad but no vis this time) for time in range(0, runtime): print "at time {}".format(time) output = ""
from spinnaker_graph_front_end.examples.speed_test_solo.\ packet_gatherer_cheat import PacketGathererCheat mbs = 1.0 # setup system sim.setup(model_binary_module=speed_test_solo) # build verts receiver = PacketGathererCheat(mbs, 1) # add verts to graph sim.add_machine_vertex_instance(receiver) # run forever (to allow better speed testing) sim.run() # get placements for extraction placements = sim.placements() # try getting data via mc transmission start = None end = None data = None sim.transceiver().set_watch_dog(False) try: print("starting data gathering") start = float(time.time()) data = receiver.get_data(