예제 #1
0
        self.createProcess("App", appProcess)  #Shows how to create "App"
        self.startProcess("App", 78783, {
            "two": 2
        })  #Shows how to start "App" process with arbitrary number of data

    def generate(self, *args):
        targetId = random.randrange(count)
        offset = exponential(1) + lookahead

        #Shows how to log outputs
        self.out.write("Time " + str(self.engine.now) + ": Waking " +
                       str(targetId) + " at " + str(offset) + " from now\n")

        self.reqService(offset, "generate", None, "Node", targetId)

    def wakeMe(self, name, rx=None, rxId=None):
        #This example is just a simple wrapper around the generic wakeProcess, but it could be more elaborate
        self.out.write("Explicit wake-up from hibernation through an event")
        self.wakeProcess(name)


for i in range(count):
    simianEngine.addEntity("Node", Node, i)

for i in range(count):
    simianEngine.schedService(0, "generate", None, "Node", i)

simianEngine.run()
simianEngine.exit()
예제 #2
0
        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()
예제 #3
0
파일: ppt.py 프로젝트: garyson/PPT
        hw.pipelinethroughputs['load'] = B_eff / hw.clockspeed
        #print("L_eff, B_eff for load ops and Phits:", L_eff, B_eff, phits)

        ######
        # 3. Compute run times of each block in task graph
        ######
        #simName, startTime, endTime, minDelay, useMPI = "ppt", 0.0, 100000000000.0, 0.1, False
        simName = "ppt"
        bb_times, counts = {}, 0
        for bbName, bb_graph in task_graph.items():
            if bbName in bb_id_map:
                #print("INFO:", bbName, "in task_graph also in bb_id_map") #NOTE: Nandu: These are the good BBs
                bb_id = bb_id_map[bbName]
                #print("before dropCore with bbName, bb_graph: ", bbName, bb_id, len(task_graph.items()))
                simEngine = Simian(simName, silent=True)
                simEngine.addEntity('dropCore', dropCore, 0, bb_graph)
                simEngine.run()
                simEngine.exit()
                # By convention, dropEngine added an element to the taskgraph with the time
                # it took to complete it. Every instruction vertex in the taskgraph also has an
                # attribute 'time_done' that lists when that instruction was completed.
                bb_times[bb_id] = bb_graph["totalBBTime"]
                #NOTE: Nandu: Otherwise taskgraph traversal in pipeline simulator (for future input settings) gets confused by this extra node
                del bb_graph["totalBBTime"]
                counts += 1
            else:
                pass
                #print("WARNING:", bbName, "in task_graph but not in bb_id_map") #NOTE: Nandu: Need to investigate these warnings further

        ######
        # 4. Calculate sum of basic block functions
예제 #4
0
        self.reqService(10, target["service"], data, target["entity"],
                        targetId)
        self.reqService(25, "generate", None, None, None)

    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)
예제 #5
0
# "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()
예제 #6
0
    this.sleep(1)
    entity = this.entity
    for evt_time in xrange(1, int(endTime/2-1)):
        hello_rcvr = random.choice(xrange(num_entities))
        reply_rcvr = random.choice(xrange(num_entities))
        #print evt_time,hello_rcvr,reply_rcvr
        entity.reqService(evt_time,"recv_hello",
                          HelloMessage(reply_rcvr),
                          "Person", hello_rcvr)

        if (evt_time % 10 == 0):
            #raw_input()
            this.sleep(evt_time - this.entity.engine.now)
            
        
        
class dummyNode(simianEngine.Entity):
    def __init__(self, baseInfo, *args):
        super(dummyNode, self).__init__(baseInfo)
        self.createProcess("MessageGen",MessageGenProcess)
        self.startProcess("MessageGen")

            
for i in xrange(num_entities):
    simianEngine.addEntity("Person",Person,i,i)

simianEngine.addEntity("dummyNode",dummyNode,0)

simianEngine.run()
simianEngine.exit()