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-2012. The SimGrid Team.
11 # This file is part of the SimGrid project. This is free software:
12 # You can redistribute and/or modify it under the terms of the
13 # GNU LGPL (v2.1) licence.
19 simgrid_update_xml - updates simgrid XML files to latest version
23 B<simgrid_update_xml> I<xml_file>
27 simgrid_update_xml updates the simgrid XML file passed as argument. The file
28 is modified in place, without any kind of backup. You may want to save a copy
29 before running the script.
31 In SimGrid XML files, the standard version is indicated in the version
32 attribute of the platform tag. Current version is 3. Here is a list of major
33 changes in each version.
37 =item B<Version 0:> Used before SimGrid 3.3
39 =item B<Version 1:> Introduced in SimGrid 3.3
45 The version attribute of platform were added to allow file versionning.
49 The link bandwidth changed from Mb/s to b/s; and the CPU power were changed
50 from MFlop/s to Flop/s
54 =item B<Version 2:> Introduced in SimGrid 3.4
60 Several tags were renamed:
64 ROUTE_ELEMENT -> LINK_CTN
65 PLATFORM_DESCRIPTION -> PLATFORM
69 =item B<Version 3:> Introduced in SimGrid 3.5 (this is the current version)
75 The AS tag were introduced. Every plaform should now contain an englobing AS
80 Routes are now symmetric by default.
84 Several tags were renamed (for sake of XML sanity):
87 TRACE:CONNECT -> TRACE_CONNECT
95 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
97 =head1 COPYRIGHT AND LICENSE
99 Copyright (c) 2006-2012. The SimGrid Team. All rights reserved.
101 This program is free software; you may redistribute it and/or modify it
102 under the terms of GNU LGPL (v2.1) license.
114 $ARGV[0] or die "simgrid_update_xml.pl <platform.xml>\n";
115 open INPUT, "$ARGV[0]" or die "Cannot open input file $ARGV[0]: $!\n";
117 $output_string = "<?xml version='1.0'?>\n".
118 "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n".
119 "<platform version=\"$toversion\">\n";
125 while (defined($line = <INPUT>)) {
127 # eat the header, whatever form it has
128 next if ($line =~ s/<\?xml[^>]*>// && ! $line =~ /\S/); # just in case several tags are on the same line
129 next if ($line =~ s/<!DOCTYPE[^>]*>// && ! $line =~ /\S/);
131 if ($line =~ s/<platform(_description)? *>//) {
134 next if !$line =~ /\S/;
135 } elsif ($line =~ s/<platform.*version=["]*([0-9.])["]*>//) {
137 print "version $fromversion\n";
138 if ($fromversion == $toversion) {
139 die "Input platform file version is already $fromversion. This should be a no-op.\n";
141 if ($fromversion > $toversion) {
142 die "Input platform file version is more recent than this script (file version: $fromversion; script version: $toversion)\n";
144 next if !$line =~ /\S/;
147 if ($fromversion == 0) {
148 while ($line =~ m|^(.*?)<cpu(.*?)power="([^"]*)"(.*)$|) {
149 $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
151 while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*)$/) {
152 $line = "$1<cpu${2}power=\"$3\"$4";
154 while ($line =~ m|^(.*?)<network_link(.*?)bandwidth="([^"]*)"(.*?)$|) {
155 $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
157 while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)$/) {
158 $line = "$1<network_link${2}bandwidth=\"$3\"$4";
162 if ($fromversion < 2) {
163 # The renamings (\b=zero-width word boundary check)
164 $line =~ s/\bplatform_description\b/platform/g;
165 $line =~ s/\bname\b/id/g;
166 $line =~ s/\bcpu\b/host/g;
167 $line =~ s/\bnetwork_link\b/link/g;
168 $line =~ s/\broute_element\b/link:ctn/g;
171 if ($fromversion < 3) {
172 $line =~ s/\blink:ctn\b/link_ctn/g;
173 $line =~ s/\btrace:connect\b/trace_connect/g;
175 if($AS_opened && (($line=~ /<\/platform>/) || ($line=~ /<process/))) {
176 $output_string .= "</AS>\n";
180 if( (!$AS_opened) && (
181 ($line =~ /<host/) ||
182 ($line =~ /<link/) ||
183 ($line =~ /<cluster/) ||
186 $output_string .= " <AS id=\"AS0\" routing=\"Full\">\n";
191 if($line=~/<route /){$line =~ s/\<route/\<route symmetrical=\"NO\"/g;}
192 $output_string .= "$line\n";
197 if ($fromversion == -1) {
198 die "Cannot retrieve the platform version\n";
201 open OUTPUT, "> $ARGV[0]";
202 print OUTPUT $output_string;