# "MAIN" ############################################################################### # 1. Choose and instantiate the Cluster that we want to simulate print "\nSNAPSim run with Simian PDES Engine\nVersion =", version #cluster = clusters.MiniTrinity(simianEngine) cluster = clusters.SingleCielo(simianEngine) # determine number of cores on each node and the total number of cores cores = cluster.cores # Is a dictionary {node_id: number of cores} total_cores = 0 for node_id in cores: total_cores += cores[node_id] # print the computational resources used print "\nNodes =", cluster.num_nodes, "\nCores =", total_cores, "\n" \ "Cores per node =", cores, "\n\n", \ "Begin SNAPSim loops\n--------------------------------" # 2. Create a Snap Handler Service on each node simianEngine.attachService(nodes.Node, "SNAP_CN_Handler", SNAP_CN_Handler) # 3. Create Master Node # This in turn creates and starts the main process snapsim_master_process simianEngine.addEntity("Master", MasterNode, 0) # 4. Run simx simianEngine.run() 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()
print "Computed time is ", time this.sleep(time) print "PolyBench app", simName, ", Input n_x, n_y, n_z: ", n_x, n_y, n_z, \ " Cluster Mustang, serial run, predicted runtime (s): ", simianEngine.now ############################################################################### def os_handler(self, arg, *args): self.createProcess("Twomm", TwommSim) self.startProcess("Twomm", TwommSim, arg) ############################################################################### ############################################################################### # "MAIN" ############################################################################### # 1. Choose and instantiate the Cluster that we want to simulate cluster = clusters.Mustang(simianEngine, 1) # Single node Mustang # 2. Create a OS Service Service on each node simianEngine.attachService(nodes.Node, "os_handler", os_handler) # 3. Schedule OS Handler with arguments for PolyBench app arg = [0, N_X, N_Y, N_Z] # Node id 0 simianEngine.schedService(0.0, "os_handler", arg, "Node", 0) # 4. Run simx simianEngine.run() simianEngine.exit()