- nx.draw_networkx_labels(G, pos)
- plt.legend(scatterpoints = 1)
-
-
-def generate_svg(platform_csv):
- G = load_graph(platform_csv)
- plot_graph(G, label=False, groups=['router', 'link', 'cpu', '_node', 'supernode', 'cluster'])
- img = platform_csv.replace('.csv', '.svg')
- plt.savefig(img)
- print(f'Generated file {img}')
+ nx.draw_networkx_labels(graph, pos)
+ plt.legend(scatterpoints=1)
+
+
+def generate_svg(platform_csv, output_file, simplify_graph):
+ graph = load_graph(platform_csv, simplify_graph)
+ plot_graph(graph, label=False, groups=['router', 'link', 'cpu', '_node', 'supernode', 'cluster'])
+ plt.savefig(output_file)
+ print(f'Generated file {output_file}')
+
+
+def main():
+ parser = argparse.ArgumentParser(description='Visualization of topologies for SimGrid C++ platforms')
+ parser.add_argument('input', type=str, help='SimGrid C++ platform file name (input)')
+ parser.add_argument('output', type=str, help='File name of the output image')
+ parser.add_argument('--simplify', action='store_true', help='Simplify the topology (removing link vertices)')
+ args = parser.parse_args()
+ if not args.input.endswith('.cpp'):
+ parser.error(f'SimGrid platform must be a C++ file (with .cpp extension), got {args.input}')
+ if not os.path.isfile(args.input):
+ parser.error(f'File {args.input} not found')
+ output_dir = os.path.dirname(args.output)
+ if output_dir != '' and not os.path.isdir(output_dir):
+ parser.error(f'Not a directory: {output_dir}')
+ with tempfile.TemporaryDirectory() as tmpdirname:
+ platform_cpp = args.input
+ platform_csv = os.path.join(tmpdirname, 'platform.csv')
+ platform_so = os.path.join(tmpdirname, 'platform.so')
+ compile_platform(platform_cpp, platform_so)
+ dump_csv(platform_so, platform_csv)
+ generate_svg(platform_csv, args.output, args.simplify)