How to use simgrid - 10 common examples

To help you get started, we’ve selected a few simgrid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simgrid / simgrid / examples / python / exec-remote / exec-remote.py View on Github external
ginette = Host.by_name("Ginette")
        boivin = Host.by_name("Boivin")

        this_actor.info("I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!")
        activity = this_actor.exec_init(48.492e6)
        activity.host = ginette
        activity.start()
        this_actor.info("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).")

        this_actor.sleep_for(0.1)
        this_actor.info("Loads in flops/s: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(boivin.load, fafard.load,
                                                                                                ginette.load))
        activity.wait()
        this_actor.info("Done!")

        this_actor.info("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec")
        activity = this_actor.exec_init(73293500)
        activity.host = ginette
        activity.start()

        this_actor.sleep_for(0.5)
        this_actor.info(
            "Loads before the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
                boivin.load,
                fafard.load,
                ginette.load))

        activity.host = boivin

        this_actor.sleep_for(0.1)
        this_actor.info(
            "Loads after the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
github simgrid / simgrid / examples / python / exec-async / exec-async.py View on Github external
def __call__(self):
        computation_amount = this_actor.get_host().speed
        this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
        activity = this_actor.exec_init(computation_amount).start()

        while not activity.test():
            this_actor.info("Remaining amount of flops: {:.0f} ({:.0f}%)".format(
                activity.remaining, 100 * activity.remaining_ratio))
            this_actor.sleep_for(0.3)
        activity.wait()

        this_actor.info("Goodbye now!")
github simgrid / simgrid / examples / python / async-wait / async-wait.py View on Github external
mbox = mboxes[i % self.receivers_count]

            this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))

            # Create a communication representing the ongoing communication, and store it in pending_comms
            comm = mbox.put_async(content, self.msg_size)
            pending_comms.append(comm)

        # Start sending messages to let the workers know that they should stop
        for i in range(0, self.receivers_count):
            mbox = mboxes[i]
            this_actor.info("Send 'finalize' to '{:s}'".format(str(mbox)))
            comm = mbox.put_async("finalize", 0)
            pending_comms.append(comm)

        this_actor.info("Done dispatching all messages")

        # Now that all message exchanges were initiated, wait for their completion, in order of creation.
        for comm in pending_comms:
            comm.wait()
        this_actor.info("Goodbye now!")
github simgrid / simgrid / examples / python / actor-lifetime / actor-lifetime.py View on Github external
def __init__(self, *args):
        # sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed)."))
        this_actor.on_exit(lambda: print("BAAA"))
github simgrid / simgrid / examples / python / actor-kill / actor-kill.py View on Github external
def victim_a_fun():
    this_actor.on_exit(lambda: this_actor.info("I have been killed!"))
    this_actor.info("Hello!")
    this_actor.info("Suspending myself")
    this_actor.suspend()                        # - Start by suspending itself
    # - Then is resumed and start to execute a task
    this_actor.info("OK, OK. Let's work")
    this_actor.execute(1e9)
    # - But will never reach the end of it
    this_actor.info("Bye!")
github simgrid / simgrid / examples / python / exec-remote / exec-remote.py View on Github external
def __call__(self):

        fafard = Host.by_name("Fafard")
        ginette = Host.by_name("Ginette")
        boivin = Host.by_name("Boivin")

        this_actor.info("I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!")
        activity = this_actor.exec_init(48.492e6)
        activity.host = ginette
        activity.start()
        this_actor.info("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).")

        this_actor.sleep_for(0.1)
        this_actor.info("Loads in flops/s: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(boivin.load, fafard.load,
                                                                                                ginette.load))
        activity.wait()
        this_actor.info("Done!")

        this_actor.info("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec")
        activity = this_actor.exec_init(73293500)
        activity.host = ginette
        activity.start()

        this_actor.sleep_for(0.5)
        this_actor.info(
            "Loads before the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
                boivin.load,
                fafard.load,
                ginette.load))
github simgrid / simgrid / examples / python / exec-async / exec-async.py View on Github external
def __call__(self):
        computation_amount = this_actor.get_host().speed
        this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
        activity = this_actor.exec_init(computation_amount)
        activity.start()
        activity.wait()

        this_actor.info("Goodbye now!")
github simgrid / simgrid / examples / python / actor-kill / actor-kill.py View on Github external
victim_a.resume()
    this_actor.sleep_for(2)

    this_actor.info("Kill the victim A")   # - and then kill it
    Actor.by_pid(victim_a.pid).kill()       # You can retrieve an actor from its PID (and then kill it)

    this_actor.sleep_for(1)

    # that's a no-op, there is no zombies in SimGrid
    this_actor.info("Kill victim B, even if it's already dead")
    victim_b.kill()

    this_actor.sleep_for(1)

    this_actor.info("Start a new actor, and kill it right away")
    victim_c = Actor.create("victim C", Host.by_name("Jupiter"), victim_a_fun)
    victim_c.kill()

    this_actor.sleep_for(1)

    this_actor.info("Killing everybody but myself")
    Actor.kill_all()

    this_actor.info("OK, goodbye now. I commit a suicide.")
    this_actor.exit()

    this_actor.info(
        "This line never gets displayed: I'm already dead since the previous line.")
github simgrid / simgrid / examples / python / exec-remote / exec-remote.py View on Github external
def __call__(self):

        fafard = Host.by_name("Fafard")
        ginette = Host.by_name("Ginette")
        boivin = Host.by_name("Boivin")

        this_actor.info("I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!")
        activity = this_actor.exec_init(48.492e6)
        activity.host = ginette
        activity.start()
        this_actor.info("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).")

        this_actor.sleep_for(0.1)
        this_actor.info("Loads in flops/s: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(boivin.load, fafard.load,
                                                                                                ginette.load))
        activity.wait()
        this_actor.info("Done!")

        this_actor.info("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec")
        activity = this_actor.exec_init(73293500)
        activity.host = ginette
github simgrid / simgrid / examples / python / exec-remote / exec-remote.py View on Github external
def __call__(self):

        fafard = Host.by_name("Fafard")
        ginette = Host.by_name("Ginette")
        boivin = Host.by_name("Boivin")

        this_actor.info("I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!")
        activity = this_actor.exec_init(48.492e6)
        activity.host = ginette
        activity.start()
        this_actor.info("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).")

        this_actor.sleep_for(0.1)
        this_actor.info("Loads in flops/s: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(boivin.load, fafard.load,
                                                                                                ginette.load))
        activity.wait()
        this_actor.info("Done!")

        this_actor.info("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec")
        activity = this_actor.exec_init(73293500)