def test_generate_router_report(self): # Write a temporary router dat file # (assumption is that the filename ends with .dat) (routeFile, routeFileName) = tempfile.mkstemp(".dat") routeFile = os.fdopen(routeFile, "wb") print "Test writing route file to %s" % (routeFileName) # Write some random routes route_id = 0 no_routes = 35 for i in range(0, no_routes): compiled = route_id | (no_routes << 16) routeValue = randint(0, 0x3F) | (randint(1, 16) << 6) maskedkey = (randint(0, 7) << 24 | randint(0, 7) << 16 | randint(0, 16) << 11) mask = 0xFFFFFC00 output_me = array('I', [compiled, routeValue, maskedkey, mask]) output_me.tofile(routeFile) route_id += 1 compiled=mykey=mymask=myroute=0xFFFFFFFF output_me = array('I', [compiled, mykey, mymask, myroute]) output_me.tofile(routeFile) routeFile.close() dao = DAO(None, hostname="amu12") chip = Chip(dao.machine, 0, 0, None, 16) print "Running read of generated route" reports.generate_router_report(routeFileName, chip, dao) os.remove(routeFileName)
def test_generate_router_report(self): # Write a temporary router dat file # (assumption is that the filename ends with .dat) (routeFile, routeFileName) = tempfile.mkstemp(".dat") routeFile = os.fdopen(routeFile, "wb") print "Test writing route file to %s" % (routeFileName) # Write some random routes route_id = 0 no_routes = 35 for i in range(0, no_routes): compiled = route_id | (no_routes << 16) routeValue = randint(0, 0x3F) | (randint(1, 16) << 6) maskedkey = (randint(0, 7) << 24 | randint(0, 7) << 16 | randint(0, 16) << 11) mask = 0xFFFFFC00 output_me = array('I', [compiled, routeValue, maskedkey, mask]) output_me.tofile(routeFile) route_id += 1 compiled = mykey = mymask = myroute = 0xFFFFFFFF output_me = array('I', [compiled, mykey, mymask, myroute]) output_me.tofile(routeFile) routeFile.close() dao = DAO(None, hostname="amu12") chip = Chip(dao.machine, 0, 0, None, 16) print "Running read of generated route" reports.generate_router_report(routeFileName, chip, dao) os.remove(routeFileName)
def generate_output_raw(dao): """ The nitty gritty. Generates load targets and executable targets comprising the simulation, and for when individual memory locations are to be written, generates memWrites. This is now largely finished. Data structures are generated for edges and the data structure generation for vertices is merely a prototype. *Side effects*: writes data structures for the load targets to files in the binaries directories :returns: Nothing """ executable_targets, load_targets, mem_write_targets = list(), list(), list( ) chipsUsed = set() progress_bar = ProgressBar(len(dao.placements)) # If we have host-side Spec Execution, execute all Data Specs now: try: dao.useHostBasedSpecExecutor = \ conf.config.getboolean( "SpecExecution", "specExecOnHost" ) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): raise Exception("SpecExecutor could not find config information" " indicating where Spec Execution should occur.") chips = None if dao.useHostBasedSpecExecutor == True: chips = dict() for placement in dao.placements: (x, y, p) = placement.processor.get_coordinates() key = "{}:{}".format(x, y) if not key in chips: chips[key] = data_spec_executor.Chip(x, y) for placement in dao.placements: if not placement.subvertex.vertex.is_virtual(): start_addr = None if dao.useHostBasedSpecExecutor == True: dao.spec_executor = data_spec_executor.SpecExecutor() (x, y, p) = placement.processor.get_coordinates() key = "{}:{}".format(x, y) chip = chips[key] start_addr = chip.sdram_used + \ data_spec_constants.SDRAM_BASE_ADDR dao.spec_executor.setup(chip) subvertex = placement.subvertex myExecTargets, myLoadTargets, myMemWriteTargets = \ subvertex.generateDataSpec(placement.processor, dao) # Add this core to the list of targets if myExecTargets is not None: executable_targets.append(myExecTargets) # Append the new dataSpec file to the list of load targets: if myLoadTargets is not None and len(myLoadTargets) > 0: load_targets.extend(myLoadTargets) # Add required memory writes to the list of writes: if myMemWriteTargets is not None and len(myMemWriteTargets) > 0: mem_write_targets.extend(myMemWriteTargets) x, y, p = placement.processor.get_coordinates() chipsUsed.add((x, y)) hostname = dao.machine.hostname if dao.useHostBasedSpecExecutor == True: (x, y, p) = placement.processor.get_coordinates() f_out = os.path.join( dao.get_binaries_directory(), "%s_appData_%d_%d_%d.dat" % (hostname, x, y, p)) dao.spec_executor.finish(f_out) # TODO: Bring the following in line / neaten # ---------------------------------------------- # Keep information on the memory region locations # for later report generation: index = "%d %d %d" % (x, y, p) dao.memMaps[index] = [ [i, s.wr_ptr_aligned, s.wr_ptr_offset, s.size, \ s.memory, s.unfilled] \ if s is not None else [i, 0, 0, 0, [], False] for (i, s) in enumerate(dao.spec_executor.memory_slots) ] # Add the files produced by the Spec Executor to the # list of files to load: load_targets.append( lib_map.LoadTarget(f_out, x, y, p, start_addr)) mem_write_targets.append( lib_map.MemWriteTarget(x, y, p, 0xe5007000 + 128 * p + 112, start_addr)) progress_bar.update() # populate the DAO with executable, load and memory writing requirements dao.set_executable_targets(executable_targets) dao.set_load_targets(load_targets) dao.set_mem_write_targets(mem_write_targets) # Generate core map and routing table binaries for each chip for coord in dao.machine.get_coords_of_all_chips(): x, y = coord['x'], coord['y'] chip = dao.machine.get_chip(x, y) routeCount = get_route_count(chip) if (routeCount > 0 or (x, y) in chipsUsed) and not chip.is_virtual(): fileName = generate_routing_table(chip, routeCount, dao) if (conf.config.getboolean("Reports", "reportsEnabled") and conf.config.getboolean("Reports", "writeRouterReports") and conf.config.getboolean("Reports", "writeRouterDatReport")): reports.generate_router_report(fileName, chip, dao) # Place in the list of targets to load at 119.5MB depth in the SDRAM if not chip.virtual: load_targets.insert( 0, lib_map.LoadTarget( fileName, chip.x, chip.y, 0, data_spec_constants.ROUTING_TABLE_ADDRESS)) progress_bar.end()
def generate_output_raw(dao): """ The nitty gritty. Generates load targets and executable targets comprising the simulation, and for when individual memory locations are to be written, generates memWrites. This is now largely finished. Data structures are generated for edges and the data structure generation for vertices is merely a prototype. *Side effects*: writes data structures for the load targets to files in the binaries directories :returns: Nothing """ executable_targets, load_targets, mem_write_targets = list(), list(), list() chipsUsed = set() progress_bar = ProgressBar(len(dao.placements)) # If we have host-side Spec Execution, execute all Data Specs now: try: dao.useHostBasedSpecExecutor = \ conf.config.getboolean( "SpecExecution", "specExecOnHost" ) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): raise Exception( "SpecExecutor could not find config information" " indicating where Spec Execution should occur." ) chips = None if dao.useHostBasedSpecExecutor == True: chips = dict() for placement in dao.placements: (x, y, p) = placement.processor.get_coordinates() key = "{}:{}".format(x, y) if not key in chips: chips[key] = data_spec_executor.Chip(x, y) for placement in dao.placements: if not placement.subvertex.vertex.is_virtual(): start_addr = None if dao.useHostBasedSpecExecutor == True: dao.spec_executor = data_spec_executor.SpecExecutor() (x, y, p) = placement.processor.get_coordinates() key = "{}:{}".format(x, y) chip = chips[key] start_addr = chip.sdram_used + \ data_spec_constants.SDRAM_BASE_ADDR dao.spec_executor.setup(chip) subvertex = placement.subvertex myExecTargets, myLoadTargets, myMemWriteTargets = \ subvertex.generateDataSpec(placement.processor, dao) # Add this core to the list of targets if myExecTargets is not None: executable_targets.append(myExecTargets) # Append the new dataSpec file to the list of load targets: if myLoadTargets is not None and len(myLoadTargets) > 0: load_targets.extend(myLoadTargets) # Add required memory writes to the list of writes: if myMemWriteTargets is not None and len(myMemWriteTargets) > 0: mem_write_targets.extend(myMemWriteTargets) x, y, p = placement.processor.get_coordinates() chipsUsed.add((x, y)) hostname = dao.machine.hostname if dao.useHostBasedSpecExecutor == True: (x, y, p) = placement.processor.get_coordinates() f_out = os.path.join( dao.get_binaries_directory(), "%s_appData_%d_%d_%d.dat" % (hostname, x, y, p) ) dao.spec_executor.finish(f_out) # TODO: Bring the following in line / neaten # ---------------------------------------------- # Keep information on the memory region locations # for later report generation: index = "%d %d %d" % (x, y, p) dao.memMaps[index] = [ [i, s.wr_ptr_aligned, s.wr_ptr_offset, s.size, \ s.memory, s.unfilled] \ if s is not None else [i, 0, 0, 0, [], False] for (i, s) in enumerate(dao.spec_executor.memory_slots) ] # Add the files produced by the Spec Executor to the # list of files to load: load_targets.append(lib_map.LoadTarget( f_out, x, y, p, start_addr)) mem_write_targets.append(lib_map.MemWriteTarget( x, y, p, 0xe5007000 + 128*p + 112, start_addr)) progress_bar.update() # populate the DAO with executable, load and memory writing requirements dao.set_executable_targets(executable_targets) dao.set_load_targets(load_targets) dao.set_mem_write_targets(mem_write_targets) # Generate core map and routing table binaries for each chip for coord in dao.machine.get_coords_of_all_chips(): x, y = coord['x'], coord['y'] chip = dao.machine.get_chip(x, y) routeCount = get_route_count(chip) if (routeCount > 0 or (x, y) in chipsUsed) and not chip.is_virtual(): fileName = generate_routing_table(chip, routeCount, dao) if (conf.config.getboolean("Reports", "reportsEnabled") and conf.config.getboolean("Reports", "writeRouterReports") and conf.config.getboolean("Reports", "writeRouterDatReport")): reports.generate_router_report(fileName, chip, dao) # Place in the list of targets to load at 119.5MB depth in the SDRAM if not chip.virtual: load_targets.insert( 0, lib_map.LoadTarget( fileName, chip.x, chip.y, 0, data_spec_constants.ROUTING_TABLE_ADDRESS ) ) progress_bar.end()