def printExecutionUnits(self): busy = lambda fus: filter(lambda fu: fu.isOccupied(self.STATE), fus) print "Busy - ALU: %s" % toString(busy(self.STATE.ALUs)) print "Busy - ALU: %s" % toString(busy(self.STATE.MUs)) print "Busy - ALU: %s" % toString(busy(self.STATE.DUs)) print "Busy - LSU: %s" % toString(busy(self.STATE.LSUs)) print "Busy - BU: %s" % toString(busy(self.STATE.BUs))
def runCycle(): global STATE print("PC: %d" % STATE.PC) should_exit = commit() writeback() execute() dispatch() issue() decode() fetch() if should_exit: print "Stack: %s" % toString(STATE.STACK) print "Register File: %s" % toString(STATE.REGISTER_FILE) print "Vector Register File: %s" % toString(STATE.VECTOR_REGISTER_FILE) print("Program Returned Successfully") print("STATE.RETIRED_INSTRUCTIONS = %d" % STATE.RETIRED_INSTRUCTIONS) print("STATE.TOTAL_CYCLES = %d" % STATE.TOTAL_CYCLES) print("IPC = %f" % (float(STATE.RETIRED_INSTRUCTIONS) / STATE.TOTAL_CYCLES)) return True STATE.TOTAL_CYCLES += 1 if not STATE.PIPELINE_STALLED: STATE.PC += STATE.INCREMENT STATE.INCREMENT = STATE.N_WAY_SUPERSCALAR return False
def test_toString(self): # we check several things here self.assertEqual( util.toString(self.ione), "Int: 1") self.assertEqual( util.toString(self.fone), "Float: 1.0") self.assertEqual( util.toString(self.lsimple), "List: [1, 2, 3, 4, 5]") # the odd case of None type self.assertEqual( util.toString(None), "None: None" )
def __str__(self): busy_entries = "" if self.EMPTY: busy_entries = "ROB is Empty\n" if self.FULL: busy_entries = "ROB is Full\n" + toString(self.entries[self.commit_ptr: self.size] + self.entries[:self.issue_ptr]) if self.issue_ptr > self.commit_ptr: busy_entries = toString(self.entries[self.commit_ptr: self.issue_ptr]) if self.issue_ptr < self.commit_ptr: busy_entries = toString(self.entries[self.commit_ptr: self.size] + self.entries[:self.issue_ptr]) return busy_entries
def printStack(self, cmd_args): if cmd_args is not None: if len(cmd_args) == 1: [ind] = cmd_args print "Stack[%d]: %s" % (ind, toString(self.STATE.STACK[ind])) if len(cmd_args) == 2: [start, end] = cmd_args print "Stack[%d:%d]: %s" % ( start, end, toString(self.STATE.STACK[start:end])) else: print "Stack: %s" % toString(self.STATE.STACK)
def __str__(self): return toString({ # "OCCUPIED": self.isOccupied(None), "FINISHED": self.isFinished(), "CYCLES_PER_OPERATION": self.CYCLES_PER_OPERATION, "output": self.output })
def printExecute(self): print "========= Execute ========" print "### Executed instructions that aren't finished are retained in the EXECUTION UNITS" self.printExecutionUnits() print "### Instructions that finish this cycle are placed in the PIPELINE" print "Writeback Instruction: %s" % toString( self.STATE.PIPELINE["writeback"]) print "### Update branch history and pattern table"
def __str__(self): return toString({ "inst_seq_id": self.inst_seq_id, "pc": self.pc, "busy": self.Busy, "op": self.Op, "values": self.Values, "tags": self.Tags })
def appQuery(appInfo, appRecord, values): query = 'insert into data(appName, packageName, path, tableName, ' for i in values: query = query + i + ", " query = query[:-2] + ") values('%s', '%s', '%s', '%s', " % (appInfo['appName'], appInfo['packageName'], appInfo['path'], appInfo['tableName']) for i in appRecord: query = query + "'%s'," % util.toString(i).replace(u'\'', u'') query = query[:-1] + ');' return query
def __str__(self): return toString({ "inst_seq_id": self.inst_seq_id, "pc": self.pc, "op_type": self.op_type, "valid": self.Valid, "value": self.Value, "Areg": self.Areg })
def __str__(self): return toString({ "inst_seq_id": self.inst_seq_id, "pc": self.pc, "store": self.Store, "load_dest": self.load_dest, "address": self.Address, "valid_address": self.ValidA, "value": self.Value, "valid_value": self.ValidV })
def __str__(self): busy_entries = None if self.EMPTY: busy_entries = "LSQ is Empty" if self.FULL: busy_entries = "LSQ is Full" if self.issue_ptr > self.commit_ptr: busy_entries = self.entries[self.commit_ptr: self.issue_ptr] if self.issue_ptr < self.commit_ptr: busy_entries = self.entries[self.commit_ptr: self.size] + self.entries[:self.issue_ptr] return toString(busy_entries)
def run(self): recvAckThread = threading.Thread(target=self.receiveAcks, args=(self.sockRAck, )) recvAckThreadH = threading.Thread(target=self.receiveAcks, args=(self.sockRAckH, )) recvAckThread.start() recvAckThreadH.start() print "Server started" while True: try: fileName, addr = self.sockR.recvfrom( 1024) # buffer size is 1024 bytes except socket.timeout: #print "Timeout" # Temp continue fileName = util.toString(fileName) #fileName = fileName[:-1] # Remove \n fileName = fileName.strip("\n") print "requested file: ", fileName self.fileBlocks = util.getFileChunks(fileName) #print("blocks") #print(self.fileBlocks) self.fileLength = len(self.fileBlocks) self.fileBlockReceived = [False] * self.fileLength # Use plain string for simplicity here self.sockS.sendto("Ack " + str(self.fileLength), (self.remoteIP, self.recvPort)) # Wait for RTT time.sleep(0.3) # temporary print "Sending file" #send file with multithread on multiple link sendFileThreadH = threading.Thread(target=self.sendFileChunksH, args=()) sendFileThreadH.start() sendFileThread = threading.Thread(target=self.sendFileChunks, args=()) sendFileThread.start() sendFileThread.join() sendFileThreadH.join() print "Send file completed"
def main(): parser = OptionParser() parser.add_option("-i", "--in_reply_to_status_id", dest="reply", help="in_reply_to_status_id") parser.add_option("--lat", dest="lat", help="latitude") parser.add_option("--long", dest="long", help="longitude") (options, args) = parser.parse_args() auth = tweepy.OAuthHandler(config.consumer_key, config.consumer_secret) auth.set_access_token(config.access_key, config.access_secret) api = tweepy.API(auth) arg = {} arg["status"] = " ".join(args) if options.lat: arg["lat"] = options.lat if options.long: arg["long"] = options.long print util.toString(api.update_status(**arg))
def __str__(self): return toString(self.entries.items())
def printBHB(self): print("BHB: %s" % toString(self.STATE.BHB))
def printBTIAC(self): print("BTIC: %s" % toString(self.STATE.BTIC)) print("BTAC: %s" % toString(self.STATE.BTAC))
def __str__(self): return toString({ "valid": self.Valid, "pending": self.Pending, "inst_seq_id": self.inst_seq_id })
def __str__(self): invalid_entries = filter(lambda (key, val): not val.Valid, self.entries.items() + self.vector_entries.items()) return toString(invalid_entries)
def printLoadStoreBuffer(self): print "LSQ: %s" % toString(self.STATE.LSQ)
def __str__(self): busy = lambda rs_entries: filter(lambda rs_entry: rs_entry.Busy, rs_entries) return toString(busy(self.RSEntries))
# for label, insts in program.iteritems(): program = map(toInstruction, lines) program = map(transformPseudoInstructions, program) # def appendNOOPsRec(inst): # if isinstance(inst, dict) and inst["opcode"] in UNCOND_JUMP_OPCODES + ["jr", "syscall"] + COND_BRANCH_OPCODES: # return [inst, {"opcode": "noop", "arg1": -1, "arg2": -1, "arg3": -1}] # else: # return [inst] # temp = map(lambda inst: appendNOOPsRec(inst), program) # program = list(itertools.chain.from_iterable(temp)) # Collect Labels def toLabelRec(acc, tup): (idx, inst) = tup if not isinstance(inst, dict): acc[inst[:-1]] = idx return acc labels = reduce(toLabelRec, enumerate(program), {}) program = map(resolveLabels, program) return program if __name__ == '__main__': program = readProgram(sys.argv[1]) print(toString(program))
def printRegisters(self): print "Register File: %s" % toString(self.STATE.REGISTER_FILE) print "Vector Register File: %s" % toString( self.STATE.VECTOR_REGISTER_FILE)
def printInstructionQueue(self): print "Instruction Queue: %s" % toString(self.STATE.INSTRUCTION_QUEUE)
def printPHT(self): print("PHT: %s" % toString(self.STATE.PHT)) pass
def printFetch(self): print "========= Fetch =========" print "### Fetches instruction placed in PIPELINE" print "Fetch Instruction: %s" % toString(self.STATE.PIPELINE["decode"]) print "### Speculatively takes/doesnt-taken branch"
def printRegisterAliasTable(self): print "RAT: %s" % toString(self.STATE.RAT)
def __str__(self): return toString(self.instruction_queue)
def printReservationStations(self): print "Busy - ALU RS: %s" % toString(self.STATE.ALU_RS) print "Busy - ALU RS: %s" % toString(self.STATE.MU_RS) print "Busy - ALU RS: %s" % toString(self.STATE.DU_RS) print "Busy - LSU RS: %s" % toString(self.STATE.LSU_RS) print "Busy - BU RS: %s" % toString(self.STATE.BU_RS)
def printReorderBuffer(self): print "ROB: %s" % toString(self.STATE.ROB)