1 # Copyright (c) 2006-2023. The SimGrid Team. All rights reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the license (GNU LGPL) which comes with this package.
7 This example demonstrates basic use of the task plugin.
8 We model the following graph:
10 exec1 -> comm -> exec2
12 exec1 and exec2 are execution tasks.
13 comm is a communication task.
16 from argparse import ArgumentParser
18 from simgrid import Engine, Task, CommTask, ExecTask
21 parser = ArgumentParser()
26 help='path to the platform description'
28 return parser.parse_args()
31 print(f'[{Engine.clock}] {t} finished ({t.count})')
33 if __name__ == '__main__':
36 e.load_platform(args.platform)
40 tremblay = e.host_by_name('Tremblay')
41 jupiter = e.host_by_name('Jupiter')
44 exec1 = ExecTask.init("exec1", 1e9, tremblay)
45 exec2 = ExecTask.init("exec2", 1e9, jupiter)
46 comm = CommTask.init("comm", 1e7, tremblay, jupiter)
48 # Create the graph by defining dependencies between tasks
49 exec1.add_successor(comm)
50 comm.add_successor(exec2)
52 # Add a function to be called when tasks end for log purpose
53 Task.on_end_cb(callback)
55 # Enqueue two executions for task exec1
56 exec1.enqueue_execs(2)