def getRouterNameForId(self, rtr_id): num_levels = len(self._start_ids) # Check to make sure the index is in range level = num_levels - 1 if rtr_id >= (self._start_ids[level] + self._routers_per_level[level]) or rtr_id < 0: print( "ERROR: topoFattree.getRouterNameForId: rtr_id not found: %d" % rtr_id) sst.exit() # Find the level for x in range(num_levels - 1, 0, -1): if rtr_id >= self._start_ids[x]: break level = level - 1 # Find the group remainder = rtr_id - self._start_ids[level] routers_per_group = self._routers_per_level[ level] // self._groups_per_level[level] group = remainder // routers_per_group router = remainder % routers_per_group return self.getRouterNameForLocation((level, group, router))
def _allocate_indexed(available_nodes, num_nodes, nids): if len(nids) != num_nodes: print( "ERROR: in call to _allocate_indexed length of index list does not equal number of endpoints to allocate" ) sst.exit() nid_list = [] available_nodes.sort() count = 0 try: # Get the indexed nids for i in nids: nid_list.append(available_nodes[i]) except IndexError as e: print( "ERROR: call to _allocate_indexed caused index to exceed nid array bounds, check index list" ) raise n = nids[:] n.sort(reverse=True) for i in n: available_nodes.pop(i) return nid_list, available_nodes
def build(self, nID, extraKeys): if self.groupInfo.isDone(self.config): self.next_group_id += 1 self.groupInfo = self.GroupInfo(self.next_group_id) sst.pushNamePrefix("g%d" % self.groupInfo.groupNum) nodeType = self.groupInfo.nextItem(self.config) if nodeType == EndpointCreator._CORE: ret = self.buildCore(nID) elif nodeType == EndpointCreator._L3: ret = self.buildL3(nID) elif nodeType == EndpointCreator._MEMORY: ret = self.buildMemory(nID) else: print("Unknown Next item type: ", nodeType) sst.exit(1) sst.popNamePrefix() return ret
sst.setProgramOption('timebase', timebase.text.strip()) if None != cfg: processConfig(cfg) if None != graph: buildGraph(graph) xmlFile = sys.argv[1] with open(xmlFile, 'r') as f: data = f.read() + "\n</sdl>" # Perform manipulations data = sdlRE.sub("<sdl\\1 >", data) data = commentRE.sub("", data) count = 1 while count > 0: (data, count) = eqRE.subn(r'\1="\2"', data) data = namespaceRE.sub("<\\1 xmlns:\\2=\"\\2\"", data) data = data.strip() # Parse XML root = ET.fromstring(data) # Process if root.tag == 'sdl': #printTree(0, root) build(root) else: print("Unknown format") sst.exit(1)
def __setattr__(self, key, value): if key in self._in_dict: return object.__setattr__(self, key, value) var = None callback = None if key in self._vars: var = self._vars[key] if var.locked: raise LockedWriteError( "attribute %s of class %r has been marked read only" % (key, self.__class__.__name__)) else: # Check to see if there is a formatted var that matches for match in self._format_vars: if re.match(match, key): obj = self._format_vars[match] # Create a "real" variable for this and copy over # the dictionaries list if key in self._vars: # This shouldn't happen. After it's called # once it should use the normal path print( "ERROR: logic error in __settattr__ for class _AttributeManager" ) sst.exit() self._vars[key] = _member_info(self._name + "." + key) var = self._vars[key] var.dictionaries = copy.copy(obj.dictionaries) callback = obj.call_back break # Process the variable if not var: # Variable not found, see if there is a passthrough # If there's a passthrough target, send this write to it if self._passthrough_target: return self._passthrough_target.__setattr__(key, value) else: raise KeyError("%r has no attribute %r" % (self.__getErrorReportClass(), self.__getErrorReportName(key))) # Set the value var.value = value # Put the value in the specified param dictionaries with # their corresponding prefixes for (d, p) in var.dictionaries: # Apply the prefix for this dictionary mykey = key if p: mykey = p + mykey if value is None: # If set to None, remove from dictionary d.pop(mykey, None) else: d[mykey] = value # If there's a callback, call it. It can either be a # callback for a formatted variable (callback will not be # None, or it could be a regular callback if callback: callback(var.fullname, value) elif var.call_back: var.call_back(var.fullname, value)
processConfig(cfg) if None != graph: buildGraph(graph) xmlFile = sys.argv[1] with open(xmlFile, 'r') as f: data = f.read() + "\n</sdl>" # Perform manipulations data = sdlRE.sub("<sdl\\1 >", data) data = commentRE.sub("", data) count = 1 while count > 0: (data, count) = eqRE.subn(r'\1="\2"', data) data = namespaceRE.sub("<\\1 xmlns:\\2=\"\\2\"", data) data = data.strip() # Parse XML root = ET.fromstring(data) # Process if root.tag == 'sdl': #printTree(0, root) build(root) else: print "Unknown format" sst.exit(1)