~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to utils/parallel/RTS2gran.pl

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/local/bin/perl
 
2
##############################################################################
 
3
# Time-stamp: <Mon May 20 1996 17:22:45 Stardate: [-31]7533.41 hwloidl>
 
4
#
 
5
# Usage: RTS2gran <RTS-file>
 
6
#
 
7
# Options:
 
8
#  -t <file>   ... use <file> as template file (<,> global <.> local template)
 
9
#  -p <file>   ... use <file> as gnuplot .gp file (default: gran.gp)
 
10
#  -x <x-size> ... of gnuplot graph
 
11
#  -y <y-size> ... of gnuplot graph
 
12
#  -n <n>      ... use <n> as number of PEs in title 
 
13
#  -h          ... help; print this text.
 
14
#  -v          ... verbose mode.
 
15
#
 
16
##############################################################################
 
17
 
 
18
# ----------------------------------------------------------------------------
 
19
# Command line processing and initialization
 
20
# ----------------------------------------------------------------------------
 
21
 
 
22
$gran_dir = $ENV{'GRANDIR'};
 
23
if ( $gran_dir eq "" ) {
 
24
    print STDERR "RTS2gran: Warning: Env variable GRANDIR is undefined\n";
 
25
}
 
26
 
 
27
push(@INC, $gran_dir, $gran_dir . "/bin");
 
28
# print STDERR "INC: " . join(':',@INC) . "\n";
 
29
 
 
30
require "getopts.pl";
 
31
require "template.pl";      # contains read_template for parsing template file
 
32
require "stats.pl";          # statistics package with corr and friends
 
33
 
 
34
&Getopts('hvt:p:x:y:n:Y:Z:');  
 
35
 
 
36
$OPEN_INT = 1;
 
37
$CLOSED_INT = 0;
 
38
 
 
39
do process_options();
 
40
 
 
41
if ( $opt_v ) {
 
42
    do print_verbose_message ();
 
43
}
 
44
 
 
45
# ----------------------------------------------------------------------------
 
46
# The real thing
 
47
# ----------------------------------------------------------------------------
 
48
 
 
49
$max_y = &pre_process($input);
 
50
 
 
51
open(INPUT,"<$input") || die "Couldn't open input file $input";
 
52
open(OUT_CUMU,">$cumulat_rts_file_name") || die "Couldn't open output file $cumulat_rts_file_name";
 
53
open(OUT_CUMU0,">$cumulat0_rts_file_name") || die "Couldn't open output file $cumulat0_rts_file_name";
 
54
 
 
55
#do skip_header();
 
56
 
 
57
$tot_total_rt = 0;
 
58
$tot_rt = 0;
 
59
$count = 0;
 
60
$last_rt = 0;
 
61
$last_x = 0;
 
62
$last_y = ($logscale{"'g'"} ne "") ? 1 : 0;
 
63
 
 
64
$line_no = 0;
 
65
while (<INPUT>) {
 
66
    $line_no++;
 
67
    next                     if /^--/;     # Comment lines start with --
 
68
    next                     if /^\s*$/;   # Skip empty lines
 
69
    $rt = $1                 if /^(\d+)/;
 
70
    $count++;
 
71
 
 
72
    if ( $opt_D ) {
 
73
        print STDERR "Error @ line $line_no: RTS file not sorted!\n";
 
74
    }
 
75
 
 
76
    #push(@all_rts,$rt);
 
77
    $sum_rt += $rt;
 
78
 
 
79
    $index = do get_index_open_int($rt,@exec_times);
 
80
    $exec_class[$index]++;
 
81
 
 
82
    if ( $last_rt != $rt ) { 
 
83
        print OUT_CUMU "$rt \t" . int($last_y/$max_y) . "\n";
 
84
        print OUT_CUMU0 "$rt \t$last_y\n";
 
85
        print OUT_CUMU "$rt \t" . int($count/$max_y) . "\n";
 
86
        print OUT_CUMU0 "$rt \t$count\n";
 
87
        $last_x = $rt;
 
88
        $last_y = $count;
 
89
    }
 
90
 
 
91
    $last_rt = $rt;
 
92
}
 
93
print OUT_CUMU "$rt \t" . int($last_y/$max_y) . "\n";
 
94
print OUT_CUMU0 "$rt \t$last_y\n";
 
95
print OUT_CUMU "$rt \t" . int($count/$max_y) . "\n";
 
96
print OUT_CUMU0 "$rt \t$count\n";
 
97
 
 
98
close OUT_CUMU;
 
99
close OUT_CUMU0;
 
100
 
 
101
$tot_tasks = $count;         # this is y-max in cumulat graph
 
102
$max_rt = $rt;               # this is x-max in cumulat graph
 
103
 
 
104
$max_rt_class = &list_max(@exec_class);
 
105
 
 
106
do write_data($gran_file_name, $OPEN_INT, $logscale{"'g'"}, $#exec_times+1,
 
107
              @exec_times, @exec_class);
 
108
 
 
109
# ----------------------------------------------------------------------------
 
110
# Run GNUPLOT over the data files and create figures
 
111
# ----------------------------------------------------------------------------
 
112
 
 
113
do gnu_plotify($gp_file_name); 
 
114
 
 
115
# ----------------------------------------------------------------------------
 
116
 
 
117
if ( $max_y != $tot_tasks ) {
 
118
    if ( $pedantic ) {
 
119
        die "ERROR: pre-processed number of tasks ($max_y) does not match computed one ($tot_tasks)\n";
 
120
    } else {
 
121
        print STDERR "Warning: pre-processed number of tasks ($max_y) does not match computed one ($tot_tasks)\n" if $opt_v;
 
122
    }
 
123
}
 
124
 
 
125
exit 0;
 
126
 
 
127
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
128
# ToDo: Put these routines into an own package
 
129
# ----------------------------------------------------------------------------
 
130
# Basic Operations on the intervals
 
131
# ----------------------------------------------------------------------------
 
132
 
 
133
sub get_index_open_int {
 
134
    local ($value,@list) = @_;
 
135
    local ($index,$right);
 
136
 
 
137
    # print "get_index: searching for index of" . $value;
 
138
    # print " in " . join(':',@list);
 
139
 
 
140
      $index = 0;
 
141
      $right = $list[$index];
 
142
      while ( ($value >= $right) && ($index < $#list) ) {
 
143
        $index++;
 
144
        $right = $list[$index];
 
145
      }
 
146
    
 
147
      return ( ($index == $#list) && ($value > $right) ) ? $index+1 : $index;
 
148
}
 
149
 
 
150
# ----------------------------------------------------------------------------
 
151
 
 
152
sub get_index_closed_int {
 
153
    local ($value,@list) = @_;
 
154
    local ($index,$right);
 
155
 
 
156
      if ( ($value < $list[0]) || ($value > $list[$#list]) ) {
 
157
          return ( -1 );
 
158
      }
 
159
 
 
160
      $index = 0;
 
161
      $left = $list[$index];
 
162
      while ( ($left <= $value) && ($index < $#list) ) {
 
163
        $index++;
 
164
        $left = $list[$index];
 
165
      }
 
166
      return ( $index-1 );
 
167
}
 
168
 
 
169
# ----------------------------------------------------------------------------
 
170
# Write operations
 
171
# ----------------------------------------------------------------------------
 
172
 
 
173
sub write_data {
 
174
    local ($file_name, $open_int, $logaxes, $n, @rest) = @_;
 
175
    local (@times) = splice(@rest,0,$n);
 
176
    local (@class) = @rest;
 
177
 
 
178
    open(GRAN,">$file_name") || die "Couldn't open file $file_name for output";
 
179
 
 
180
    if ( $open_int == $OPEN_INT ) {
 
181
 
 
182
      for ($i=0, 
 
183
           $left = ( index($logaxes,"x") != -1 ? int($times[0]/2) : 0 ), 
 
184
           $right = 0; 
 
185
           $i < $n; 
 
186
           $i++, $left = $right) {
 
187
         $right = $times[$i];
 
188
         print GRAN int(($left+$right)/2) . "  " . 
 
189
                    ($class[$i] eq "" ? "0" : $class[$i]) . "\n"; 
 
190
      }
 
191
      print GRAN $times[$n-1]+(($times[$n-1]-$times[$n-2])/2) . "  " . 
 
192
                 ($class[$n] eq "" ? "0" : $class[$n]) . "\n";
 
193
 
 
194
     } else {
 
195
 
 
196
      print GRAN ( (index($logaxes,"x") != -1) && ($times[0] == 0 ? int($times[1]/2) : ($times[$1] + $times[0])/2 ) .  "  " . $class[0] . "\n");
 
197
      for ($i=1; $i < $n-2; $i++) {
 
198
         $left = $times[$i];
 
199
         $right = $times[$i+1];
 
200
         print(GRAN ($left+$right)/2 . "  " . 
 
201
                    ($class[$i] eq "" ? "0" : $class[$i]) . "\n"); 
 
202
      }
 
203
      print GRAN ($times[$n-1]+$times[$n-2])/2 . "  " . $class[$n-2]  if $n >= 2;
 
204
    }
 
205
 
 
206
    close(GRAN);
 
207
}
 
208
 
 
209
# ----------------------------------------------------------------------------
 
210
 
 
211
sub write_array {
 
212
    local ($file_name,$n,@list) = @_;
 
213
 
 
214
    open(FILE,">$file_name") || die "$file_name: $!";
 
215
    for ($i=0; $i<=$#list; $i++) {
 
216
        print FILE $i . "  " .  ( $list[$i] eq "" ? "0" : $list[$i] ) . "\n";
 
217
    }
 
218
 
 
219
    if ( $opt_D ) {
 
220
        print "write_array: (" . join(", ",1 .. $#list) . ")\n for file $file_name returns: \n (0, $#list, &list_max(@list)\n";
 
221
    } 
 
222
 
 
223
    return ( (0, $#list, &list_max(@list), 
 
224
              "(" . join(", ",1 .. $#list) . ")\n") );
 
225
}
 
226
 
 
227
# ----------------------------------------------------------------------------
 
228
 
 
229
sub gnu_plotify {
 
230
  local ($gp_file_name) = @_;
 
231
 
 
232
  @open_xrange = &range($OPEN_INT,$logscale{"'g'"},@exec_times);
 
233
 
 
234
  $exec_xtics = $opt_T ? &get_xtics($OPEN_INT,@exec_times) : "" ;
 
235
 
 
236
  open(GP_FILE,">$gp_file_name") || 
 
237
      die "Couldn't open gnuplot file $gp_file_name for output\n";
 
238
 
 
239
  print GP_FILE "set term postscript \"Roman\" 20\n";
 
240
  do write_gp_record(GP_FILE,
 
241
                     $gran_file_name, &dat2ps_name($gran_file_name),
 
242
                     "Granularity (pure exec. time)", "Number of threads", 
 
243
                     $logscale{"'g'"},
 
244
                     @open_xrange,$max_rt_class,$exec_xtics);
 
245
 
 
246
  do write_gp_lines_record(GP_FILE,
 
247
                           $cumulat_rts_file_name, &dat2ps_name($cumulat_rts_file_name),
 
248
                           "Cumulative pure exec. times","% of threads",
 
249
                           "",
 
250
                           $max_rt, 100, ""); 
 
251
                           # $xtics_cluster_rts as last arg?
 
252
  
 
253
  do write_gp_lines_record(GP_FILE,
 
254
                           $cumulat0_rts_file_name, &dat2ps_name($cumulat0_rts_file_name),
 
255
                           "Cumulative pure exec. times","Number of threads",
 
256
                           $logscale{"'Cg'"},
 
257
                           $max_rt, $tot_tasks, ""); 
 
258
                           # $xtics_cluster_rts as last arg?
 
259
 
 
260
  close GP_FILE;
 
261
 
 
262
  print "Gnu plotting figures ...\n";
 
263
  system "gnuplot $gp_file_name";
 
264
 
 
265
  print "Extending thickness of impulses ...\n";
 
266
  do gp_ext($gran_file_name);
 
267
}
 
268
 
 
269
# ----------------------------------------------------------------------------
 
270
 
 
271
sub gp_ext {
 
272
    local (@file_names) = @_;
 
273
    local ($file_name);
 
274
    local ($ps_file_name);
 
275
    local ($prg);
 
276
 
 
277
    #$prg = system "which gp-ext-imp";
 
278
    #print "  Using script $prg for impuls extension\n";
 
279
    $prg = $ENV{GRANDIR} ? $ENV{GRANDIR} . "/bin/gp-ext-imp" 
 
280
                         : $ENV{HOME} . "/bin/gp-ext-imp" ;
 
281
    if ( $opt_v ) {
 
282
        print "    (using script $prg)\n";
 
283
    }
 
284
 
 
285
    foreach $file_name (@file_names) {
 
286
        $ps_file_name = &dat2ps_name($file_name);
 
287
        system "$prg -w $ext_size -g $gray " . 
 
288
               $ps_file_name  . " " . 
 
289
               $ps_file_name . "2" ;
 
290
        system "mv " . $ps_file_name . "2 " . $ps_file_name;
 
291
    }
 
292
}
 
293
 
 
294
# ----------------------------------------------------------------------------
 
295
 
 
296
sub write_gp_record {
 
297
    local ($file,$in_file,$out_file,$xlabel,$ylabel,$logaxes,
 
298
           $xstart,$xend,$ymax,$xtics) = @_;
 
299
 
 
300
    if ( $xstart >= $xend ) {
 
301
        print ("WARNING: empty xrange [$xstart:$xend] changed to [$xstart:" . $xstart+1 . "]\n")        if ( $pedantic || $opt_v );
 
302
        $xend = $xstart + 1;    
 
303
    }
 
304
 
 
305
    if ( $ymax <=0 ) {
 
306
        $ymax = 2;
 
307
        print "WARNING: empty yrange changed to [0:$ymax]\n"   if ( $pedantic || $opt_v );
 
308
    }
 
309
 
 
310
    $str = "set size " . $xsize . "," . $ysize . "\n" .
 
311
           "set xlabel \"" . $xlabel . "\"\n" .
 
312
           "set ylabel \"" . $ylabel . "\"\n" .
 
313
           ($xstart eq "" ? "" 
 
314
                          : "set xrange [" . int($xstart) .":" . int($xend) . "]\n") .
 
315
           ($opt_Y ? 
 
316
              ("set yrange [" . (index($logaxes,"y") != -1 ? 1 : 0) . ":$opt_Y]\n") :
 
317
              ($ymax eq "" ? "" 
 
318
                        : "set yrange [" . (index($logaxes,"y") != -1 ? 1 : 0) . 
 
319
                          ":" . &list_max(2,int($ymax+$ymax/5)) . "]\n")) .
 
320
           ($xtics ne "" ? "set xtics $xtics" : "") . 
 
321
           "set tics out\n" .
 
322
           "set border\n" .
 
323
           ( $nPEs!=0 ? "set title \"$nPEs PEs\"\n" : "" ) .
 
324
           "set nokey \n" .
 
325
           "set nozeroaxis\n" .
 
326
           "set format xy \"%8.8g\"\n" .
 
327
           (index($logaxes,"x") != -1 ? 
 
328
               "set logscale x\n" : 
 
329
               "set nologscale x\n") .
 
330
           (index($logaxes,"y") != -1 ? 
 
331
               "set logscale y\n" : 
 
332
               "set nologscale y\n") .
 
333
           "set output \"" . $out_file . "\"\n" .
 
334
           "plot \"" . $in_file . "\" with impulses\n\n";
 
335
    print $file $str;
 
336
}
 
337
 
 
338
# ----------------------------------------------------------------------------
 
339
 
 
340
sub write_gp_lines_record {
 
341
    local ($file,$in_file,$out_file,$xlabel,$ylabel,$logaxes,
 
342
           $xend,$yend,$xtics) = @_;
 
343
 
 
344
    local ($str);
 
345
 
 
346
    $str = "set xlabel \"" . $xlabel . "\"\n" .
 
347
           "set ylabel \"" . $ylabel . "\"\n" .
 
348
           "set xrange [" . ( index($logaxes,"x") != -1 ? 1 : 0 ) . ":$xend]\n" .
 
349
           "set yrange [" . ( index($logaxes,"y") != -1 ? 1 : 0 ) . 
 
350
               ($yend!=100 && $opt_Z ? ":$opt_Z]\n" : ":$yend]\n") .
 
351
           "set border\n" .
 
352
           "set nokey\n" .
 
353
           ( $xtics ne "" ? "set xtics $xtics" : "" ) .
 
354
           (index($logaxes,"x") != -1 ? 
 
355
               "set logscale x\n" : 
 
356
               "set nologscale x\n") .
 
357
           (index($logaxes,"y") != -1 ? 
 
358
               "set logscale y\n" : 
 
359
               "set nologscale y\n") .
 
360
           "set nozeroaxis\n" .
 
361
           "set format xy \"%8.8g\"\n" .
 
362
           "set output \"" . $out_file . "\"\n" .
 
363
           "plot \"" . $in_file . "\" with lines\n\n";
 
364
    print $file $str;
 
365
}
 
366
 
 
367
 
 
368
# ----------------------------------------------------------------------------
 
369
 
 
370
sub write_gp_simple_record {
 
371
    local ($file,$in_file,$out_file,$xlabel,$ylabel,$logaxes,
 
372
           $xstart,$xend,$ymax,$xtics) = @_;
 
373
 
 
374
    $str = "set size " . $xsize . "," . $ysize . "\n" .
 
375
           "set xlabel \"" . $xlabel . "\"\n" .
 
376
           "set ylabel \"" . $ylabel . "\"\n" .
 
377
           ($xstart eq "" ? "" 
 
378
                          : "set xrange [" . int($xstart) .":" . int($xend) . "]\n") .
 
379
           ($ymax eq "" ? "" 
 
380
                        : "set yrange [" . (index($logaxes,"y") != -1 ? 1 : 0) . 
 
381
                          ":" . &list_max(2,int($ymax+$ymax/5)) . "]\n") .
 
382
           ($xtics ne "" ? "set xtics $xtics" : "") . 
 
383
           "set border\n" .
 
384
           "set nokey\n" .
 
385
           "set tics out\n" .
 
386
           "set nozeroaxis\n" .
 
387
           "set format xy \"%8.8g\"\n" .
 
388
           (index($logaxes,"x") != -1 ? 
 
389
               "set logscale x\n" : 
 
390
               "set nologscale x\n") .
 
391
           (index($logaxes,"y") != -1 ? 
 
392
               "set logscale y\n" : 
 
393
               "set nologscale y\n") .
 
394
           "set output \"" . $out_file . "\"\n" .
 
395
           "plot \"" . $in_file . "\" with impulses\n\n";
 
396
    print $file $str;
 
397
}
 
398
 
 
399
# ----------------------------------------------------------------------------
 
400
 
 
401
sub range {
 
402
    local ($open_int, $logaxes, @ints) = @_;
 
403
 
 
404
    local ($range, $left_margin, $right_margin);
 
405
 
 
406
    $range = $ints[$#ints]-$ints[0];
 
407
    $left_margin = 0; # $range/10;
 
408
    $right_margin = 0; # $range/10;
 
409
 
 
410
    if ( $opt_D ) {
 
411
       print "\n==> Range: logaxes are $logaxes i.e. " . 
 
412
           (index($logaxes,"x") != -1 ? "matches x axis\n" 
 
413
                                      : "DOESN'T match x axis\n"); 
 
414
    }
 
415
    if ( index($logaxes,"x") != -1 ) {
 
416
        if ( $open_int == $OPEN_INT ) {
 
417
            return ( ($ints[0]/2-$left_margin, 
 
418
                      $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
 
419
        } else {
 
420
            return ( ( &list_max(1,$ints[0]-$left_margin), 
 
421
                       $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
 
422
        }
 
423
    } else {
 
424
        if ( $open_int == $OPEN_INT ) {
 
425
            return ( ($ints[0]/2-$left_margin, 
 
426
                      $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
 
427
        } else {
 
428
            return ( ($ints[0]-$left_margin, 
 
429
                      $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
 
430
        }
 
431
    }
 
432
}
 
433
 
 
434
# ----------------------------------------------------------------------------
 
435
 
 
436
# ----------------------------------------------------------------------------
 
437
 
 
438
sub process_options {
 
439
    if ( $opt_h ) {                      
 
440
        open(ME,$0) || die "Can't open myself ($0)";
 
441
        $n = 0;
 
442
        while (<ME>) {
 
443
            last if $_ =~ /^$/;
 
444
            print $_;
 
445
            $n++;
 
446
        }
 
447
        close(ME);
 
448
        
 
449
        # system "cat $0 | awk 'BEGIN { n = 0; } \
 
450
        #                             /^$/ { print n; \
 
451
        #                                    exit; } \
 
452
        #                                  { n++; }'"
 
453
        exit ;
 
454
    }
 
455
 
 
456
    $input = $#ARGV == -1 ? "-" : $ARGV[0] ;
 
457
    
 
458
    if ( $#ARGV != 0 ) {
 
459
        #print "Usage: gran-extr [options] <sim-file>\n";
 
460
        #print "Use -h option to get details\n";
 
461
        #exit 1;
 
462
        
 
463
    }
 
464
 
 
465
    # Default settings:
 
466
    $gp_file_name = "gran.gp";
 
467
    $gran_file_name = "gran.dat";
 
468
    $cumulat_rts_file_name = "cumu-rts.dat";
 
469
    $cumulat0_rts_file_name = "cumu-rts0.dat";
 
470
    $xsize = 1;
 
471
    $ysize = 1;
 
472
 
 
473
    if ( $opt_p ) {
 
474
        $gp_file_name = $opt_p;
 
475
    } else {
 
476
        $gp_file_name = "gran.gp";
 
477
    }
 
478
 
 
479
    #if ( $opt_s ) {
 
480
    #   $gp_file_name =~ s|\.|${opt_s}.|;
 
481
    #   $gran_file_name =~ s|\.|${opt_s}.|;
 
482
    #   $cumulat_rts_file_name =~ s|\.|${opt_s}.|;
 
483
    #   $cumulat0_rts_file_name =~ s|\.|${opt_s}.|;
 
484
    #}
 
485
    
 
486
    if ( $opt_x ) {
 
487
        $xsize = $opt_x;
 
488
    } else {
 
489
        $xsize = 1;
 
490
    }
 
491
    
 
492
    if ( $opt_y ) {
 
493
        $ysize = $opt_y;
 
494
    } else {
 
495
        $ysize = 1;
 
496
    }
 
497
    
 
498
    if ( $opt_t ) {
 
499
        do read_template($opt_t,$input);
 
500
    }
 
501
    
 
502
}
 
503
 
 
504
# ----------------------------------------------------------------------------
 
505
 
 
506
sub print_verbose_message { 
 
507
 
 
508
    print "-" x 70 . "\n";
 
509
    print "Setup: \n";
 
510
    print "-" x 70 . "\n";
 
511
    print "\nFilenames: \n";
 
512
    print "  Input file: $input\n";
 
513
    print "  Gran files: $gran_file_name $gran_global_file_name $gran_local_file_name\n"; 
 
514
    print "  Comm files: $comm_file_name $comm_global_file_name $comm_local_file_name\n";
 
515
    print "  Sparked threads file: $spark_file_name $spark_local_file_name $spark_global_file_name\n";
 
516
    print "  Heap file: $ha_file_name\n";
 
517
    print "  GNUPLOT file name: $gp_file_name   Correlation file name: $corr_file_name\n";
 
518
    print "  Cumulative RT file name: $cumulat_rts_file_name ($cumulat0_rts_file_name)   \n  Cumulative HA file name: $cumulat_has_file_name\n";
 
519
    print "  Cluster RT file name: $clust_rts_file_name   \n  Cluster HA file name: $clust_has_file_name\n";
 
520
    print "  Cumulative runtimes file name:    $cumulat_rts_file_name\n";
 
521
    print "  Cumulative heap allocations file name   $cumulat_has_file_name\n";
 
522
    print "  Cluster run times file name:    $clust_rts_file_name\n";
 
523
    print "  Cluster heap allocations file name:    $clust_has_file_name\n";
 
524
    print "  PE load file name:    $pe_file_name\n";
 
525
    print "  Site size file name:    $sn_file_name\n";
 
526
    print "\nBoundaries: \n";
 
527
    print "  Gran boundaries: (" . join(',',@exec_times) . ")\n";
 
528
    print "  Comm boundaries: (" . join(',',@comm_percs) . ")\n";
 
529
    print "  Sparked threads boundaries: (" . join(',',@sparks) . ")\n";
 
530
    print "  Heap boundaries: (" . join(',',@has) .")\n";
 
531
    print "\nOther pars: \n";
 
532
    print "  Left margin: $left_margin  Right margin: $right_margin\n";
 
533
    print "  GP-extension: $ext_size  GP xsize: $xsize  GP ysize: $ysize\n";
 
534
    print "  Gray scale: $gray  Smart x-tics is " . ($opt_T ? "ON" : "OFF") .
 
535
          "  Percentage y-axis is " . ($opt_P ? "ON" : "OFF") . "\n";
 
536
    print "  Log. scaling assoc list: ";
 
537
    while (($key,$value) = each %logscale) {
 
538
        print "$key: $value, ";
 
539
    }
 
540
    print "\n";
 
541
    print "  Active template file: $templ_file\n"              if $opt_t;  
 
542
    print "-" x 70 . "\n";
 
543
}
 
544
 
 
545
# ----------------------------------------------------------------------------
 
546
 
 
547
sub pre_process {
 
548
    local ($file) = @_;
 
549
 
 
550
    open(PIPE,"wc -l $input |") || die "Couldn't open pipe";
 
551
 
 
552
    while (<PIPE>) {            
 
553
        if (/^\s*(\d+)/) {
 
554
            $res = $1; 
 
555
        } else {
 
556
            die "Error in pre-processing: Last line of $file does not match RTS!\n";
 
557
        }
 
558
    }
 
559
    close(PIPE);
 
560
 
 
561
    return ($res-1);
 
562
}
 
563
 
 
564
# ----------------------------------------------------------------------------
 
565
 
 
566
 
 
567
# ----------------------------------------------------------------------------
 
568
#
 
569
# Old version (eventually delete it)
 
570
# New version is in template.pl
 
571
 
572
# sub read_template {
 
573
#     local ($f);
 
574
 
575
#     if ( $opt_v ) {
 
576
#       print "Reading template file $templ_file_name ...\n";
 
577
#     }
 
578
 
579
#     ($f = ($input eq "-" ? "stdin" : $input)) =~ s/.rts//;
 
580
 
581
#     open(TEMPLATE,"cat $templ_file_name | sed -e 's/\$0/$f/' |") 
 
582
#       || die "Couldn't open file $templ_file_name";
 
583
 
584
#     while (<TEMPLATE>) {
 
585
#       next if /^\s*$/ || /^--/;
 
586
#       if (/^\s*G[:,;.\s]+([^\n]+)$/) {
 
587
#         $list_str = $1;
 
588
#           $list_str =~ s/[\(\)\[\]]//g;
 
589
#           @exec_times = split(/[,;. ]+/, $list_str);
 
590
#       } elsif (/^\s*F[:,;.\s]+([^\n]+)$/) {
 
591
#         $list_str = $1;
 
592
#           $list_str =~ s/[\(\)\[\]]//g;
 
593
#           @fetch_times = split(/[,;. ]+/, $list_str);
 
594
#       } elsif (/^\s*A[:,;.\s]+([^\n]+)$/) {
 
595
#         $list_str = $1;
 
596
#           $list_str =~ s/[\(\)\[\]]//g;
 
597
#           @has = split(/[,;. ]+/, $list_str);
 
598
#       } elsif (/^\s*C[:,;.\s]+([^\n]+)$/) {
 
599
#         $list_str = $1;
 
600
#           $list_str =~ s/[\(\)\[\]]//g;
 
601
#           @comm_percs = split(/[,;. ]+/, $list_str);
 
602
#       } elsif (/^\s*S[:,;.\s]+([^\n]+)$/) {
 
603
#         $list_str = $1;
 
604
#           $list_str =~ s/[\(\)\[\]]//g;
 
605
#           @sparks = split(/[,;. ]+/, $list_str);
 
606
#       } elsif (/^\s*g[:,;.\s]+([\S]+)$/) {
 
607
#          ($gran_file_name,$gran_global_file_name, $gran_local_file_name) = 
 
608
#            &mk_global_local_names($1);
 
609
#       } elsif (/^\s*f[:,;.\s]+([\S]+)$/) {
 
610
#          ($ft_file_name,$ft_global_file_name, $ft_local_file_name) = 
 
611
#            &mk_global_local_names($1);
 
612
#       } elsif (/^\s*c[:,;.\s]+([\S]+)$/) {
 
613
#          ($comm_file_name, $comm_global_file_name, $comm_local_file_name) = 
 
614
#            &mk_global_local_names($1);
 
615
#       } elsif (/^\s*s[:,;.\s]+([\S]+)$/) {
 
616
#          ($spark_file_name, $spark_global_file_name, $spark_local_file_name) = 
 
617
#            &mk_global_local_names($1);
 
618
#       } elsif (/^\s*a[:,;.\s]+([\S]+)$/) {
 
619
#          ($ha_file_name, $ha_global_file_name, $ha_local_file_name) = 
 
620
#            &mk_global_local_names($1);
 
621
#       } elsif (/^\s*p[:,;.\s]+([\S]+)$/) {
 
622
#          $gp_file_name = $1;
 
623
#        $ps_file_name = &dat2ps_name($gp_file_name);
 
624
 
625
#       } elsif (/^\s*Xcorr[:,;.\s]+([\S]+)$/) {
 
626
#          $corr_file_name = $1;
 
627
#       } elsif (/^\s*Xcumulat-rts[:,;.\s]+([\S]+)$/) {
 
628
#          $cumulat_rts_file_name = $1;
 
629
#        ($cumulat0_rts_file_name = $1) =~ s/\./0./;
 
630
#       } elsif (/^\s*Xcumulat-has[:,;.\s]+([\S]+)$/) {
 
631
#          $cumulat_has_file_name = $1;
 
632
#       } elsif (/^\s*Xcumulat-fts[:,;.\s]+([\S]+)$/) {
 
633
#          $cumulat_fts_file_name = $1;
 
634
#       } elsif (/^\s*Xcumulat-cps[:,;.\s]+([\S]+)$/) {
 
635
#          $cumulat_cps_file_name = $1;
 
636
#       } elsif (/^\s*Xclust-rts[:,;.\s]+([\S]+)$/) {
 
637
#          $clust_rts_file_name = $1;
 
638
#       } elsif (/^\s*Xclust-has[:,;.\s]+([\S]+)$/) {
 
639
#          $clust_has_file_name = $1;
 
640
#       } elsif (/^\s*Xclust-fts[:,;.\s]+([\S]+)$/) {
 
641
#          $clust_fts_file_name = $1;
 
642
#       } elsif (/^\s*Xclust-cps[:,;.\s]+([\S]+)$/) {
 
643
#          $clust_cps_file_name = $1;
 
644
#       } elsif (/^\s*Xpe[:,;.\s]+([\S]+)$/) {
 
645
#          $pe_file_name = $1;
 
646
#       } elsif (/^\s*Xsn[:,;.\s]+([\S]+)$/) {
 
647
#          $sn_file_name = $1;
 
648
 
649
#       } elsif (/^\s*XRTS[:,;.\s]+([\S]+)$/) {
 
650
#         $rts_file_name = $1;
 
651
#       } elsif (/^\s*XHAS[:,;.\s]+([\S]+)$/) {
 
652
#         $has_file_name = $1;
 
653
#       } elsif (/^\s*XFTS[:,;.\s]+([\S]+)$/) {
 
654
#         $fts_file_name = $1;
 
655
#       } elsif (/^\s*XLSPS[:,;.\s]+([\S]+)$/) {
 
656
#         $lsps_file_name = $1;
 
657
#       } elsif (/^\s*XGSPS[:,;.\s]+([\S]+)$/) {
 
658
#         $gsps_file_name = $1;
 
659
#       } elsif (/^\s*XCPS[:,;.\s]+([\S]+)$/) {
 
660
#         $cps_file_name = $1;
 
661
#       } elsif (/^\s*XCCPS[:,;.\s]+([\S]+)$/) {
 
662
#         $ccps_file_name = $1;
 
663
 
664
#       } elsif (/^\s*\-[:,;.\s]+([\S]+)$/) {
 
665
#          $input = $1;
 
666
#       } elsif (/^\s*L[:,;\s]+(.*)$/) {
 
667
#        $str = $1;
 
668
#        %logscale = ('g',"xy",'a',"xy",'Cg',"xy",'Ca',"xy",'Yp',"y",'Ys',"y") , next  if $str eq ".";
 
669
#          $str =~ s/[\(\)\[\]]//g;
 
670
#          %logscale = split(/[,;. ]+/, $str);
 
671
#       } elsif (/^\s*i[:,;.\s]+([\S]+)$/) {
 
672
#        $gray = $1;
 
673
#       } elsif (/^\s*k[:,;.\s]+([\S]+)$/) {
 
674
#        $no_of_clusters = $1;
 
675
#       } elsif (/^\s*e[:,;.\s]+([\S]+)$/) {
 
676
#        $ext_size = $1;
 
677
#       } elsif (/^\s*v.*$/) {
 
678
#        $verbose = 1;
 
679
#       } elsif (/^\s*T.*$/) {
 
680
#        $opt_T = 1;
 
681
#      }
 
682
#   }
 
683
#   close(TEMPLATE);
 
684
# }