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 operation plugin.
8 We model the following graph:
10 exec1 -> comm -> exec2
12 exec1 and exec2 are execution operations.
13 comm is a communication operation.
16 from argparse import ArgumentParser
18 from simgrid import Engine, Operation, CommOp, ExecOp
21 parser = ArgumentParser()
26 help='path to the platform description'
28 return parser.parse_args()
31 print(f'[{Engine.clock}] Operation {op} finished ({op.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 = ExecOp.init("exec1", 1e9, tremblay)
45 exec2 = ExecOp.init("exec2", 1e9, jupiter)
46 comm = CommOp.init("comm", 1e7, tremblay, jupiter)
48 # Create the graph by defining dependencies between operations
49 exec1.add_successor(comm)
50 comm.add_successor(exec2)
52 # Add a function to be called when operations end for log purpose
53 Operation.on_end_cb(callback)
55 # Enqueue two executions for operation exec1
56 exec1.enqueue_execs(2)