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-2011. The SimGrid team. All rights reserved.
10 # This file is part of the SimGrid project. This is free software:
11 # You can redistribute and/or modify it under the terms of the
12 # GNU LGPL (v2.1) licence.
18 simgrid_update_xml - updates simgrid XML files to lastest 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 3. 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 versionning.
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 (this is the current version)
74 The AS tag were introduced. Every plaform 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
94 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
96 =head1 COPYRIGHT AND LICENSE
98 Copyright 2006-2011. The SimGrid team. All rights reserved.
100 This program is free software; you may redistribute it and/or modify it
101 under the terms of GNU LGPL (v2.1) license.
113 $ARGV[0] or die "simgrid_update_xml.pl <platform.xml>\n";
114 open INPUT, "$ARGV[0]" or die "Cannot open input file $ARGV[0]: $!\n";
116 $output_string = "<?xml version='1.0'?>\n".
117 "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n".
118 "<platform version=\"$toversion\">\n";
124 while (defined($line = <INPUT>)) {
126 # eat the header, whatever form it has
127 next if ($line =~ s/<\?xml[^>]*>// && ! $line =~ /\S/); # just in case several tags are on the same line
128 next if ($line =~ s/<!DOCTYPE[^>]*>// && ! $line =~ /\S/);
130 if ($line =~ s/<platform(_description)? *>//) {
133 next if !$line =~ /\S/;
134 } elsif ($line =~ s/<platform.*version=["]*([0-9.])["]*>//) {
136 print "version $fromversion\n";
137 if ($fromversion == $toversion) {
138 die "Input platform file version is already $fromversion. This should be a no-op.\n";
140 if ($fromversion > $toversion) {
141 die "Input platform file version is more recent than this script (file version: $fromversion; script version: $toversion)\n";
143 next if !$line =~ /\S/;
146 if ($fromversion == 0) {
147 while ($line =~ m|^(.*?)<cpu(.*?)power="([^"]*)"(.*)$|) {
148 $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
150 while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*)$/) {
151 $line = "$1<cpu${2}power=\"$3\"$4";
153 while ($line =~ m|^(.*?)<network_link(.*?)bandwidth="([^"]*)"(.*?)$|) {
154 $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
156 while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)$/) {
157 $line = "$1<network_link${2}bandwidth=\"$3\"$4";
161 if ($fromversion < 2) {
162 # The renamings (\b=zero-width word boundary check)
163 $line =~ s/\bplatform_description\b/platform/g;
164 $line =~ s/\bname\b/id/g;
165 $line =~ s/\bcpu\b/host/g;
166 $line =~ s/\bnetwork_link\b/link/g;
167 $line =~ s/\broute_element\b/link:ctn/g;
170 if ($fromversion < 3) {
171 $line =~ s/\blink:ctn\b/link_ctn/g;
172 $line =~ s/\btrace:connect\b/trace_connect/g;
174 if($AS_opened && (($line=~ /<\/platform>/) || ($line=~ /<process/))) {
175 $output_string .= "</AS>\n";
179 if( (!$AS_opened) && (
180 ($line =~ /<host/) ||
181 ($line =~ /<link/) ||
182 ($line =~ /<cluster/) ||
185 $output_string .= " <AS id=\"AS0\" routing=\"Full\">\n";
190 if($line=~/<route /){$line =~ s/\<route/\<route symmetrical=\"NO\"/g;}
191 $output_string .= "$line\n";
196 if ($fromversion == -1) {
197 die "Cannot retrieve the platform version\n";
200 open OUTPUT, "> $ARGV[0]";
201 print OUTPUT $output_string;