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.
6 from argparse import ArgumentParser
8 from simgrid import Engine, Task, ExecTask, IoTask, IoOpType
11 parser = ArgumentParser()
16 help='path to the platform description'
18 return parser.parse_args()
21 print(f'[{Engine.clock}] {t} finished ({t.count})')
23 if __name__ == '__main__':
26 e.load_platform(args.platform)
29 bob = e.host_by_name('bob')
30 carl = e.host_by_name('carl')
33 exec1 = ExecTask.init("exec1", 1e9, bob)
34 exec2 = ExecTask.init("exec2", 1e9, carl)
35 write = IoTask.init("write", 1e7, bob.disks[0], IoOpType.WRITE)
36 read = IoTask.init("read", 1e7, carl.disks[0], IoOpType.READ)
38 # Create the graph by defining dependencies between tasks
39 exec1.add_successor(write)
40 write.add_successor(read)
41 read.add_successor(exec2)
43 # Add a function to be called when tasks end for log purpose
44 Task.on_completion_cb(callback)
46 # Enqueue two firings for task exec1
47 exec1.enqueue_firings(2)