Beispiel #1
0
def estimate_bw(disk: Disk, n_flows: int, read: bool):
    """ Calculates the bandwidth for disk doing async operations """
    size = 100000
    cur_time = Engine.get_clock()
    activities = [
        disk.read_async(size) if read else disk.write_async(size)
        for _ in range(n_flows)
    ]

    for act in activities:
        act.wait()

    elapsed_time = Engine.get_clock() - cur_time
    estimated_bw = float(size * n_flows) / elapsed_time
    this_actor.info(
        "Disk: %s, concurrent %s: %d, estimated bandwidth: %f" %
        (disk.name, "read" if read else "write", n_flows, estimated_bw))
Beispiel #2
0
    def __call__(self):
        workload = 100E6
        host = this_actor.get_host()

        nb = host.get_pstate_count()
        this_actor.info("Count of Processor states={:d}".format(nb))

        this_actor.info("Current power peak={:f}".format(host.speed))

        # Run a task
        this_actor.execute(workload)

        task_time = Engine.get_clock()
        this_actor.info("Task1 duration: {:.2f}".format(task_time))

        # Change power peak
        new_pstate = 2

        this_actor.info(
            "Changing power peak value to {:f} (at index {:d})".format(
                host.get_pstate_speed(new_pstate), new_pstate))

        host.pstate = new_pstate

        this_actor.info("Changed power peak={:f}".format(host.speed))

        # Run a second task
        this_actor.execute(workload)

        task_time = Engine.get_clock() - task_time
        this_actor.info("Task2 duration: {:.2f}".format(task_time))

        # Verify that the default pstate is set to 0
        host2 = Host.by_name("MyHost2")
        this_actor.info("Count of Processor states={:d}".format(
            host2.get_pstate_count()))

        this_actor.info("Final power peak={:f}".format(host2.speed))
Beispiel #3
0
    this_actor.info("Join the 3rd sleeper (timeout 2)")
    actor.join(2)

    this_actor.info("Start 4th sleeper")
    actor = Actor.create("4th sleeper from master", Host.current(), sleeper)
    this_actor.info("Waiting 4")
    this_actor.sleep_for(4)
    this_actor.info("Join the 4th sleeper after its end (timeout 1)")
    actor.join(1)

    this_actor.info("Goodbye now!")

    this_actor.sleep_for(1)

    this_actor.info("Goodbye now!")


if __name__ == '__main__':
    e = Engine(sys.argv)
    if len(sys.argv) < 2:
        raise AssertionError(
            "Usage: actor-join.py platform_file [other parameters]")

    e.load_platform(sys.argv[1])

    Actor.create("master", Host.by_name("Tremblay"), master)

    e.run()

    this_actor.info("Simulation time {}".format(Engine.get_clock()))
Beispiel #4
0
def create_sata_disk(host: Host, disk_name: str):
    """ Same for a SATA disk, only read operation follows a non-linear resource sharing """
    disk = host.create_disk(disk_name, "68MBps", "50MBps")
    disk.set_sharing_policy(Disk.Operation.READ, Disk.SharingPolicy.NONLINEAR,
                            functools.partial(sata_dynamic_sharing, disk))
    # this is the default behavior, expliciting only to make it clearer
    disk.set_sharing_policy(Disk.Operation.WRITE, Disk.SharingPolicy.LINEAR)
    disk.set_sharing_policy(Disk.Operation.READWRITE,
                            Disk.SharingPolicy.LINEAR)


if __name__ == '__main__':
    e = Engine(sys.argv)
    # simple platform containing 1 host and 2 disk
    zone = NetZone.create_full_zone("bob_zone")
    bob = zone.create_host("bob", 1e6)
    create_ssd_disk(bob, "Edel (SSD)")
    create_sata_disk(bob, "Griffon (SATA II)")
    zone.seal()

    Actor.create("runner", bob, host)

    e.run()
    this_actor.info("Simulated time: %g" % Engine.get_clock())

    # explicitly deleting Engine object to avoid segfault during cleanup phase.
    # During Engine destruction, the cleanup of std::function linked to non_linear callback is called.
    # If we let the cleanup by itself, it fails trying on its destruction because the python main program
    # has already freed its variables
    del (e)