Make TcGenDeriv warning-free
[ghc-hetmet.git] / utils / parallel / AVG.pl
1 #!/usr/local/bin/perl
2 #                                       (C) Hans Wolfgang Loidl, October 1995
3 #############################################################################
4 # Time-stamp: <Thu Oct 26 1995 18:30:54 Stardate: [-31]6498.64 hwloidl>
5 #
6 # Usage: AVG [options] <gr-file>
7 #
8 # A quich hack to get avg runtimes of different spark sites. Similar to SPLIT.
9 #
10 # Options:
11 #  -s <list> ... a perl list of spark names; the given <gr-file> is scanned 
12 #                for each given name in turn and granularity graphs are 
13 #                generated for each of these sparks  
14 #  -O        ... use gr2RTS and RTS2gran instead of gran-extr;
15 #                this generates fewer output files (only granularity graphs)
16 #                but should be faster and far less memory consuming
17 #  -h        ... help; print this text.
18 #  -v        ... verbose mode.
19 #
20 #############################################################################
21
22 require "getopts.pl";
23
24 &Getopts('hvOs:');  
25
26 do process_options();
27
28 if ( $opt_v ) { do print_verbose_message(); }
29
30 # ---------------------------------------------------------------------------
31 # Init
32 # ---------------------------------------------------------------------------
33
34 foreach $s (@sparks) {
35     # extract END events for this spark-site
36     open (GET,"cat $input | tf -s $s | avg-RTS") || die "!$\n";
37 }
38
39 exit 0;
40
41 exit 0;
42
43 # -----------------------------------------------------------------------------
44
45 sub process_options {
46
47     if ( $opt_h ) {                      
48         open(ME,$0) || die "Can't open myself ($0): $!\n";
49         $n = 0;
50         while (<ME>) {
51             last if $_ =~ /^$/;
52             print $_;
53             $n++;
54         }
55         close(ME);
56         exit ;
57     }
58     
59     if ( $opt_s ) {
60         $opt_s =~ s/[\(\)\[\]]//g;
61         @sparks = split(/[,;. ]+/, $opt_s);
62     } else {
63         @sparks = ( 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15);
64     }
65
66     if ( $#ARGV != 0 ) {
67         print "Usage: $0 [options] <gr-file>\n;";
68         print "Use -h option to get details\n";
69         exit 1;
70     }
71
72     $gr_file = $ARGV[0];
73     ($basename = $gr_file) =~ s/\.gr//;
74     $rts_file = $basename . ".rts";        # "RTS";
75     $gran_file = "g.ps"; # $basename . ".ps";
76     #$rts_file = $gr_file;
77     #$rts_file =~ s/\.gr/.rts/g;
78
79     if ( $opt_o ) {
80         $va_file = $opt_o;
81         $va_dvi_file = $va_file;
82         $va_dvi_file =~ s/\.tex/.dvi/g; 
83         $va_ps_file = $va_file;
84         $va_ps_file =~ s/\.tex/.ps/g; 
85     } else {
86         $va_file = "va.tex";
87         $va_dvi_file = "va.dvi";
88         $va_ps_file = "va.ps";
89     }
90     
91     if ( $opt_t ) {
92         $template_file = $opt_t;
93     } else {
94         $template_file = "TEMPL";
95     }
96
97     $tmp_file = ",t";
98 }
99
100 # -----------------------------------------------------------------------------
101
102 sub print_verbose_message {
103     print "Sparks: (" . join(',',@sparks) . ")\n";
104     print "Files: .gr " . $gr_file . "  template " . $template_file .
105             " va " . $va_file . "\n";
106 }
107
108 # -----------------------------------------------------------------------------