Beispiel #1
0
count = 4
lookahead = minDelay

def exponential(mean):
    return -math.log(random.random())/mean

class Node(simianEngine.Entity):
    def __init__(self, baseInfo, *args):
        super(Node, self).__init__(baseInfo)

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

        self.out.write("Time "
                + str(self.engine.now)
                + ": Waking " + str(targetId)
                + " at " + str(offset) + " from now\n")

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

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

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

simianEngine.run()
simianEngine.exit()
Beispiel #2
0
count = 4
lookahead = minDelay


def exponential(mean):
    return -math.log(random.random()) / mean


class Node(simianEngine.Entity):
    def __init__(self, baseInfo, *args):
        super(Node, self).__init__(baseInfo)

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

        self.out.write("Time " + str(self.engine.now) + ": Waking " +
                       str(targetId) + " at " + str(offset) + " from now\n")

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


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

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

simianEngine.run()
simianEngine.exit()
Beispiel #3
0
        data = random.randrange(100)

        self.out.write(str(self) + ": Time "
                    + str(self.engine.now)
                    + ": Sending " + str(data) + " to "
                    + target["entity"] + "[" + str(targetId) + "]\n")

        self.reqService(10, target["service"], data, target["entity"], targetId)
        self.reqService(25, "generate", None, None, None)

    def sqrt(self, data, tx, txId):
        self.reqService(10, "result", math.sqrt(data), tx, txId)

    def result(self, data, tx, txId):
        self.out.write(str(self) + ": Time "
                    + str(self.engine.now)
                    + ": Got " + str(data)
                    + " from " + tx + "[" + str(txId) + "]\n")

for i in xrange(count):
    simianEngine.addEntity("Alice", Alice, i) #Additional arguments, if given are passed to Alice.__init__()
    simianEngine.addEntity("Bob", Bob, i)

for i in xrange(count):
    simianEngine.schedService(0, "generate", None, "Alice", i)
    simianEngine.schedService(50, "generate", None, "Bob", i)

simianEngine.run()
simianEngine.exit()
Beispiel #4
0
        self.out.write(
            str(self) + ": Time " + str(self.engine.now) + ": Sending " +
            str(data) + " to " + target["entity"] + "[" + str(targetId) +
            "]\n")

        self.reqService(10, target["service"], data, target["entity"],
                        targetId)
        self.reqService(25, "generate", None, None, None)

    def sqrt(self, data, tx, txId):
        self.reqService(10, "result", math.sqrt(data), tx, txId)

    def result(self, data, tx, txId):
        self.out.write(
            str(self) + ": Time " + str(self.engine.now) + ": Got " +
            str(data) + " from " + tx + "[" + str(txId) + "]\n")


for i in xrange(count):
    simianEngine.addEntity(
        "Alice", Alice,
        i)  #Additional arguments, if given are passed to Alice.__init__()
    simianEngine.addEntity("Bob", Bob, i)

for i in xrange(count):
    simianEngine.schedService(0, "generate", None, "Alice", i)
    simianEngine.schedService(50, "generate", None, "Bob", i)

simianEngine.run()
simianEngine.exit()

simianEngine.attachService(nodes.Node, "appService", appService)
simianEngine.attachService(nodes.Node, "statServiceNode", statServiceNode)
simianEngine.attachService(router.Router, "statServiceRouter", statServiceRouter)
simianEngine.attachService(interface.Interface, "statServiceInterface", statServiceInterface)
simianEngine.attachService(nodes.Node, "appService_2", appService_2)
simianEngine.attachService(nodes.Node, "mpiService", mpiService)
simianEngine.attachService(nodes.Node, "mpiServiceRecv", mpiServiceRecv)
simianEngine.attachService(nodes.Node, "mpiServiceBcast", mpiServiceBcast)
simianEngine.attachService(nodes.Node, "mpiServiceBarrier", mpiServiceBarrier)
simianEngine.attachService(nodes.Node, "mpiServiceBcast_2", mpiServiceBcast_2)

source_node_id = 1
simianEngine.schedService(
    0, "mpiService", source_node_id, "Node", source_node_id
)  # TODO: check the last parameter: 1... may be this value would have to be changed

# destination node:
dest_node_id = 1
simianEngine.schedService(
    0, "mpiServiceRecv", dest_node_id, "Node", dest_node_id
)  # TODO: check the last parameter: 1... may be this value would have to be changed


# The followings are for MPI_Bcast
"""
end_time = endTime
source_node_id = 1
BcastObj = MPIBcastData(source_node_id, end_time)
simianEngine.schedService(50, "mpiServiceBcast", BcastObj, "Node", source_node_id)