for i in range(time_bins): self.gtime_sends[i] += msg[6][i] str_out = str(msg[0]) + " " + str(msg[1]) + " " + str( msg[2]) + " " + str(msg[3]) + " " + str(msg[4]) + " " + str( msg[5]) + " " + str(msg[6]) + " " #self.out.write(str_out) if self.stats_received == n_ent: # We can write out global stats #self.out.write("===================== LANL PDES BENCHMARK Collected Stats from All Ranks =======================\n") header = "#Entities, #sends, #receives Ops(min, avg, max), Time Bin Sends" #self.out.write(header) str_out = "test" #self.out.write(str(n_ent)+" "+str(self.gsend_count)+" "+str(self.greceive_count)) #self.out.write("=================================================================================================\n") ################################ # "MAIN" ################################ for i in range(n_ent): simianEngine.addEntity("PDES_LANL_Node", PDES_LANL_Node, i) # 5. Run simx simianEngine.run() for i in range(n_ent): node = simianEngine.getEntity("PDES_LANL_Node", i) #print node.num simianEngine.exit()
def result(self, data, tx, txId): self.out.write("Time " + str(self.engine.now) + ": Got " + str(data) + " from " + tx + "[" + str(txId) + "]\n") def sqrt(self, data, tx, txId): self.reqService(10, "result", math.sqrt(data), tx, txId) for i in xrange(count): simianEngine.addEntity( "Alice", Alice, i) #Additional arguments, if given are passed to Alice.__init__() simianEngine.addEntity("Bob", Bob, i) #Example showing how to attach services to klasses and instances at runtime simianEngine.attachService( Alice, "square", square) #Attach square service at runtime to klass Alice for i in xrange(count): #Attach sqrt service at runtime to all Bob instances entity = simianEngine.getEntity("Bob", i) if entity: entity.attachService("sqrt", sqrt) for i in xrange(count): simianEngine.schedService(0, "generate", None, "Alice", i) simianEngine.schedService(50, "generate", None, "Bob", i) simianEngine.run() simianEngine.exit()