Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use a user level mallocator on the task content
[simgrid.git] / examples / gras / replay / do_simulation.pl
1 #! /usr/bin/perl
2
3 use strict;
4
5 my $platfile = $ARGV[0] || die "Usage: $0 platfile daxfile\n";
6 my $daxfile = $ARGV[1] || die "Usage: $0 platfile daxfile\n";
7
8 sub title {
9     my $l = "XXXX $0: $_[0] XXXX";
10     my $l2 = $l;
11     $l2 =~ s/./X/g;
12     print STDERR "\n\n$l2\n$l\n$l2\n";
13 }
14
15 title("relaunching make");
16 system qw(make -C ../../../src libsimgrid.la) and die "XXXX $0: make library failed: $?\n";  
17 system qw(make -C ../../simdag dax/dax_test) and die "XXXX $0: make dax_test failed.\n";
18 system qw(make replay_simulator) and die "XXXX $0: make replay_simulator failed.\n";
19
20 ###################################################
21 my $tracefile = "$daxfile";
22 $tracefile =~ s/\.xml$//;
23 $tracefile .= ".trace";
24 title("Regenerating the trace '$tracefile'");
25 my @args = ("../../simdag/dax/dax_test", "$platfile", "$daxfile","$tracefile");
26 system @args and die "XXXX $0: cannot regenerate the trace '$tracefile': $?\n";
27
28
29 ###################################################
30 my $deployfile = "deploy_$platfile";
31 $deployfile =~ s/\.xml$//;
32 $deployfile .= "_".$daxfile;
33 title("Generate a deployment file '$deployfile'");
34 my %hosts;
35
36 print STDERR  "$0: parsing the trace file '$tracefile'\n";
37 open TRACE,"$tracefile" || die "$0: cannot open tracefile $tracefile: $!\n";
38 while (<TRACE>) {
39     #    print "Seen $_";
40     next unless /compute/;
41     m/^\[.*?\] ([^ ]*) .*$/ || die "unparsable line: $_";
42     if (defined $hosts{$1}) {
43         $hosts{$1}+=1;
44     } else {
45         $hosts{$1}++;
46     }
47
48 close TRACE;
49 my @hostnames = sort keys %hosts;
50 my $master = $hostnames[0];
51
52 foreach my $host (@hostnames) {
53     if ($host ne $master && $hosts{$host} > 1) {
54         print STDERR "$host computes $hosts{$host} times!\n";
55     }
56 }
57
58 print STDERR  "$0: Generating the xml deployment file\n";
59 open DEPLOY,">$deployfile";
60 print DEPLOY "<?xml version='1.0'?>\n";
61 print DEPLOY "<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n\n";
62 print DEPLOY "<!-- File generated by \"$0 $tracefile\" at ".(localtime())." -->\n\n";
63 print DEPLOY "<platform version=\"2\">\n";
64
65 print DEPLOY "  <process host=\"$master\" function=\"master\">\n";
66 print DEPLOY "    <argument value=\"$tracefile\" /> <!-- trace file -->\n";
67 print DEPLOY "    <argument value=\"4500\"/>            <!-- port number -->\n";
68 print DEPLOY "  </process>\n";
69
70 foreach my $host (@hostnames) {
71     print DEPLOY "  <process host=\"$host\" function=\"worker\">";
72     print DEPLOY "<argument value=\"$master:4500\" />";
73     print DEPLOY "</process>\n";
74 }
75
76 print DEPLOY "</platform>\n";
77 close DEPLOY;
78 print STDERR  "$0: Xml deployment file generated\n";
79
80 ###################################################
81 title("Replay this trace onto the simulator");
82 system ("./replay_simulator","$platfile","$deployfile")
83   and die "Cannot replay the trace. Command was:\n./replay_simulator $platfile $deployfile\n";
84
85
86