2 eval 'exec perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
5 # This script updates the simgrid XML file passed as argument (modification in place)
6 # It is built to do the conversion incrementally.
8 # Copyright (c) 2006-2018. The SimGrid Team.
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms of the license (GNU LGPL) which comes with this package.
18 simgrid_update_xml - updates simgrid XML files to latest version
22 B<simgrid_update_xml> I<xml_file>
26 simgrid_update_xml updates the simgrid XML file passed as argument. The file
27 is modified in place, without any kind of backup. You may want to save a copy
28 before running the script.
30 In SimGrid XML files, the standard version is indicated in the version
31 attribute of the platform tag. Current version is 4. Here is a list of major
32 changes in each version.
36 =item B<Version 0:> Used before SimGrid 3.3
38 =item B<Version 1:> Introduced in SimGrid 3.3
44 The version attribute of platform were added to allow file versioning.
48 The link bandwidth changed from Mb/s to b/s; and the CPU power were changed
49 from MFlop/s to Flop/s
53 =item B<Version 2:> Introduced in SimGrid 3.4
59 Several tags were renamed:
63 ROUTE_ELEMENT -> LINK_CTN
64 PLATFORM_DESCRIPTION -> PLATFORM
68 =item B<Version 3:> Introduced in SimGrid 3.5
74 The AS tag were introduced. Every platform should now contain an englobing AS
79 Routes are now symmetric by default.
83 Several tags were renamed (for sake of XML sanity):
86 TRACE:CONNECT -> TRACE_CONNECT
90 =item B<Version 4:> Introduced in SimGrid 3.13
96 Rename the attributes describing the amount of flop that a host / peer / cluster / cabinet can deliver per second.
98 <host power=...> -> <host speed=...>
102 In <trace_connect>, attribute kind="POWER" is now kind="SPEED".
106 The DOCTYPE points to the right URL: http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd
110 Units are now mandatory in attributes. USE THE SCRIPT sg_xml_unit_converter.py TO CONVERT THIS
112 - speed. Old default: 'f' or 'flops'. Also defined:
113 'Yf', 'Zf', 'Ef', 'Pf', 'Tf', 'Gf', 'Mf', 'kf'
114 'yottaflops', 'zettaflops', 'exaflops', 'petaflops', 'teraflops', 'gigaflops', 'megaflops', 'kiloflops'
116 - bandwidth. Old default: 'Bps' bytes per second (or 'bps' but 1 Bps = 8 bps)
117 Also defined in bytes: 'TiBps', 'GiBps', 'MiBps', 'KiBps', 'TBps', 'GBps', 'MBps', 'kBps', 'Bps'
118 And the same in bits: 'Tibps', 'Gibps', 'Mibps', 'Kibps', 'Tbps', 'Gbps', 'Mbps', 'kbps', 'bps'
120 - latency. Old default: 's' second. Also defined:
121 'w' week, 'd' day, 'h' hour, 'm' minute, 'ms' millisecond, 'us' microsecond, 'ns' nanosecond, 'ps' picosecond
126 =item B<Version 4.1:> Introduced in SimGrid 3.16 (this is the current version)
132 Rename a few tags, but in a backward-compatible manner: the old names are still accepted.
136 bypassAsRoute -> bypassZoneRoute
141 =item Other backward-compatible changes (old syntax is still accepted) for which we did not bump the DTD version:
147 Rename the FULLDUPLEX sharing into SPLITDUPLEX.
155 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
157 =head1 COPYRIGHT AND LICENSE
159 Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.
161 This program is free software; you may redistribute it and/or modify it
162 under the terms of GNU LGPL (v2.1) license.
172 my $filename = $ARGV[0] or die "Usage: simgrid_update_xml.pl file_to_convert.xml\nPlease provide an XML to convert as a parameter.\n";
173 open INPUT, "$filename" or die "Cannot open input file $filename: $!\n";
175 my $output_string = "<?xml version='1.0'?>\n".
176 "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n".
177 "<platform version=\"$toversion\">\n";
182 while (defined($line = <INPUT>)) {
184 # eat the header, whatever form it has
185 next if ($line =~ s/<\?xml[^>]*>// && ! $line =~ /\S/); # just in case several tags are on the same line
186 next if ($line =~ s/<!DOCTYPE[^>]*>// && ! $line =~ /\S/);
188 if ($line =~ s/<platform(_description)? *>//) {
190 print "$filename was using version 0\n";
191 next if !$line =~ /\S/;
192 } elsif ($line =~ s/<platform.*version=["']*([0-9.]*)["']*>//) {
194 if ($fromversion == $toversion) {
195 warn "Input platform file $filename is already conformant to version $fromversion. This should be a no-op.\n";
197 if ($fromversion > $toversion) {
198 die "Input platform file $filename is more recent than this script (file version: $fromversion; script version: $toversion)\n";
200 next if !$line =~ /\S/;
201 print "$filename was using version $fromversion\n";
204 if ($fromversion == 0) {
205 while ($line =~ m|^(.*?)<cpu(.*?)power="([^"]*)"(.*)$|) {
206 $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
208 while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*)$/) {
209 $line = "$1<cpu${2}power=\"$3\"$4";
211 while ($line =~ m|^(.*?)<network_link(.*?)bandwidth="([^"]*)"(.*?)$|) {
212 $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
214 while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)$/) {
215 $line = "$1<network_link${2}bandwidth=\"$3\"$4";
219 if ($fromversion < 2) {
220 # The renamings (\b=zero-width word boundary check)
221 $line =~ s/\bplatform_description\b/platform/g;
222 $line =~ s/\bname\b/id/g;
223 $line =~ s/\bcpu\b/host/g;
224 $line =~ s/\bnetwork_link\b/link/g;
225 $line =~ s/\broute_element\b/link:ctn/g;
228 if ($fromversion < 3) {
229 $line =~ s/\blink:ctn\b/link_ctn/g;
230 $line =~ s/\btrace:connect\b/trace_connect/g;
232 if($AS_opened && (($line=~ /<\/platform>/) || ($line=~ /<process/))) {
233 $output_string .= "</AS>\n";
237 if( (!$AS_opened) && (
238 ($line =~ /<host/) ||
239 ($line =~ /<link/) ||
240 ($line =~ /<cluster/) ||
243 $output_string .= " <AS id=\"AS0\" routing=\"Full\">\n";
247 if($line=~/<route /){$line =~ s/\<route/\<route symmetrical=\"NO\"/g;}
249 if ($fromversion < 4) {
250 $line =~ s/\bpower\b/speed/g;
251 $line =~ s/\bkind="POWER"/kind="SPEED"/g;
253 if ($fromversion < 4.1) {
254 $line =~ s/\bAS\b/zone/g;
255 $line =~ s/\bASroute\b/zoneRoute/g;
256 $line =~ s/\bbypassAsRoute\b/bypassZoneRoute/g;
257 $line =~ s/\bprocess\b/actor/g;
259 $line =~ s/\bFULLDUPLEX\b/SPLITDUPLEX/g;
261 $output_string .= "$line\n";
266 if ($fromversion == -1) {
267 die "Cannot retrieve the platform version of $filename\n";
270 open OUTPUT, "> $filename";
271 print OUTPUT $output_string;