2 ##############################################################################
3 # Last modified: Time-stamp: <Sat Oct 28 1995 23:49:48 Stardate: [-31]6509.75 hwloidl>
4 # (C) Hans Wolfgang Loidl
6 # Usage: gran-extr [options] [<sim-file>]
8 # Takes a file <sim-file> generated by running the GrAnSim simulator and
9 # produces data files that should be used as input for gnuplot.
10 # This script produces figures for:
12 # percentage of communication
14 # number of created sparks
15 # cumulative no. of tasks over runtime
16 # Furthermore, it computes the correlation between runtime and heap allocation.
19 # -g <file> ... filename of granularity file to be produced; should end with
20 # .dat; -global and -local will be automatically inserted for
22 # -c <file> ... filename of communication file to be produced; should end with
23 # .dat; -global and -local will be automatically inserted for
25 # -s <file> ... filename of sparked-threads file to be produced; should end w/
26 # .dat; -global and -local will be automatically inserted for
28 # -a <file> ... filename of heap alloc. file to be produced; should end with
30 # -f <file> ... filename of communication time file to be produced;
31 # should end with .dat;
32 # -p <file> ... filename of GNUPLOT file that is prouced and executed.
33 # -G <LIST> ... provide a list of boundaries for the Intervals used in the
34 # granularity figure; must be a Perl list e.g. (10, 20, 50)
35 # this is interpreted as being open to left and right.
36 # -C <LIST> ... provide a list of boundaries for the Intervals used in the
37 # communication figure; must be a Perl list e.g. (10, 20, 50)
38 # this is interpreted as being closed to left and right.
39 # -S <LIST> ... provide a list of boundaries for the Intervals used in the
40 # sparked-threads figure; must be a Perl list e.g. (10, 20, 50)
41 # this is interpreted as being closed to left and right.
42 # -A <LIST> ... provide a list of boundaries for the Intervals used in the
43 # heap alloc figure; must be a Perl list e.g. (10, 20, 50)
44 # this is interpreted as being closed to left and right.
45 # -F <LIST> ... provide a list of boundaries for the Intervals used in the
46 # comm. time figure; must be a Perl list e.g. (10, 20, 50)
47 # this is interpreted as being open to left and right.
48 # -l <int> ... left margin in the produced figures.
49 # -r <int> ... right margin in the produced figures.
50 # -x <int> ... enlargement of figure along x-axis.
51 # -y <int> ... enlargement of figure along y-axis.
52 # -e <int> ... thickness of impulses in figure.
53 # -i <rat> ... set the gray level of the impulses to <rat>; <rat> must be
54 # between 0 and 1 with 0 meaning black.
55 # -k <n> ... number of klusters (oops, clusters, I mean ;)
56 # -P ... print percentage of threads rather than absolute number of
57 # threads on the y axis
58 # -t <file> ... use template <file> for interval settings and file names
59 # Syntax of a line in the template file:
61 # -T ... use smart xtics rather than GNUPLOT default x-axis naming.
62 # -L ... use logarithmic scale for all figures.
63 # -W ... print warnings
64 # -m ... generate monchrome output
65 # -h ... help; print this text.
66 # -v ... verbose mode.
68 ##############################################################################
70 # ----------------------------------------------------------------------------
71 # Command line processing and initialization
72 # ----------------------------------------------------------------------------
76 &Getopts('hvWTPDmt:L:g:f:c:s:a:p:G:F:C:S:A:l:r:x:y:e:i:k:');
84 do print_verbose_message ();
87 # ----------------------------------------------------------------------------
89 # ----------------------------------------------------------------------------
91 open(INPUT,"<$input") || die "Couldn't open input file $input";
104 next if /^--/; # Comment lines start with --
105 next if /^\s*$/; # Skip empty lines
107 @fields = split(/[:,]/,$_);
110 foreach $elem (@fields) {
112 $pe = $1, $end = $2 , last foo if $elem =~ /^\s*PE\s+(\d+)\s+\[(\d+)\].*$/;
113 $tn = $1, $has_end = 1 , last foo if $elem =~ /^\s*END\s+(\w+).*$/;
114 # $tn = $1 , last foo if $elem =~ /^\s*TN\s+(\w+).*$/;
115 $sn = $1 , last foo if $elem =~ /^\s*SN\s+(\d+).*$/;
116 $start = $1 , last foo if $elem =~ /^\s*ST\s+(\d+).*$/;
117 $is_global = $1 , last foo if $elem =~ /^\s*EXP\s+(T|F).*$/;
118 $bbs = $1 , last foo if $elem =~ /^\s*BB\s+(\d+).*$/;
119 $ha = $1 , last foo if $elem =~ /^\s*HA\s+(\d+).*$/;
120 $rt = $1 , last foo if $elem =~ /^\s*RT\s+(\d+).*$/;
121 $bt = $1, $bc = $2 , last foo if $elem =~ /^\s*BT\s+(\d+)\s+\((\d+)\).*$/;
122 $ft = $1, $fc = $2 , last foo if $elem =~ /^\s*FT\s+(\d+)\s+\((\d+)\).*$/;
123 $lsp = $1 , last foo if $elem =~ /^\s*LS\s+(\d+).*$/;
124 $gsp = $1 , last foo if $elem =~ /^\s*GS\s+(\d+).*$/;
125 $my = $1 , last foo if $elem =~ /^\s*MY\s+(T|F).*$/;
129 next unless $has_end == 1;
131 $total_rt = $end - $start;
132 $ready_time = $total_rt - $rt - $bt - $ft;
134 # ------------------------------------------------------------------------
135 # Accumulate runtime, block time, fetch time and ready time over all threads
136 # ------------------------------------------------------------------------
138 $tot_total_rt += $total_rt;
142 $tot_it += $ready_time;
144 # ------------------------------------------------------------------------
145 # Gather statistics about `load' on the PEs
146 # ------------------------------------------------------------------------
148 print "WARNING: ready time of thread is <0: $ready_time\n" if $pedantic && ($ready_time <0);
149 $pe_load[$pe] += $ready_time;
152 print "Adding $ready_time to the load time of PE no. $pe yielding $pe_load[$pe]\n";
155 # ------------------------------------------------------------------------
156 # Gather statistics about the size of a spark site
157 # ------------------------------------------------------------------------
159 $site_size[$sn] += $rt;
162 print "Adding $rt to the size of site $sn yielding $site_size[$sn]\n";
165 # ------------------------------------------------------------------------
166 # Gather statistics about pure exec time
167 # ------------------------------------------------------------------------
171 $max_rt = $rt if $rt > $max_rt;
173 $index = do get_index_open_int($rt,@exec_times);
174 $exec_class[$index]++;
176 if ( $is_global eq 'T' ) {
177 $exec_global_class[$index]++;
179 $exec_local_class[$index]++;
182 # ------------------------------------------------------------------------
183 # Gather statistics about communication time (absolute time rather than %)
184 # ------------------------------------------------------------------------
186 # Note: Communicatin time is fetch time
190 $max_ft = $ft if $ft > $max_ft;
192 $index = do get_index_open_int($ft,@fetch_times);
193 $fetch_class[$index]++;
195 if ( $is_global eq 'T' ) {
196 $fetch_global_class[$index]++;
198 $fetch_local_class[$index]++;
201 # ------------------------------------------------------------------------
202 # Gather statistics about communication percentage
203 # ------------------------------------------------------------------------
205 $comm_perc = ( $total_rt == 0 ? 100 : (100 * $ft)/$total_rt );
207 push(@all_comm_percs,$comm_perc);
208 $sum_comm_perc += $comm_perc;
209 $max_comm_perc = $comm_perc if $comm_perc > $max_comm_perc;
211 $index = do get_index_closed_int( $comm_perc, @comm_percs );
212 if ( $index != -1 ) {
213 $comm_class[$index]++;
215 print "WARNING: value " . $comm_perc . " not in range (t_rt=$total_rt; ft=$ft)\n" if $pedantic;
219 if ( $is_global eq 'T' ) {
220 if ( $index != -1 ) {
221 $comm_global_class[$index]++;
226 if ( $index != -1 ) {
227 $comm_local_class[$index]++;
233 # ------------------------------------------------------------------------
234 # Gather statistics about locally sparked threads
235 # ------------------------------------------------------------------------
237 push(@all_local_sparks,$lsp);
238 $sum_local_sp += $lsp;
239 $max_local_sp = $lsp if $lsp > $max_local_sp;
241 $index = do get_index_open_int($lsp,@sparks);
242 $spark_local_class[$index]++;
244 # ------------------------------------------------------------------------
245 # Gather statistics about globally sparked threads
246 # ------------------------------------------------------------------------
248 push(@all_global_sparks,$gsp);
249 $sum_global_sp += $gsp;
250 $max_global_sp = $gsp if $gsp > $max_global_sp;
252 $index = do get_index_open_int($gsp,@sparks);
253 $spark_global_class[$index]++;
255 # ------------------------------------------------------------------------
256 # Add the above two entries to get the total number of sparks
257 # ------------------------------------------------------------------------
261 push(@all_sparks,$sp);
263 $max_sp = $sp if $sp > $max_sp;
265 $index = do get_index_open_int($sp,@sparks);
266 $spark_class[$index]++;
268 # ------------------------------------------------------------------------
269 # Gather statistics about heap allocations
270 # ------------------------------------------------------------------------
274 $max_ha = $ha if $ha > $max_ha;
276 $index = do get_index_open_int($ha,@has);
279 # do print_line($start,$end,$is_global,$bbs,$ha,$rt,$bt,$bc,$ft,$fc,$my);
282 print STDERR "You don't want to engage me for a file with just $line_no lines, do you?(N)\n" , exit (-1) if $line_no <= 1;
284 # ----------------------------------------------------------------------------
286 do write_pie_chart();
288 # ----------------------------------------------------------------------------
290 # ----------------------------------------------------------------------------
294 " all_rts: $#all_rts;\n" .
295 " all_comm_percs: $#all_comm_percs;\n" .
296 " all_sparks: $#all_sparks; \n" .
297 " all_local_sparks: $#all_local_sparks; \n" .
298 " all_global_sparks: $#all_global_sparks; \n" .
299 " all_has: $#all_has\n" .
300 " all_fts: $#all_fts;\n";
303 print "No of elems in all_rts: $#all_rts with sum $sum_rt\n";
304 print "No of elems in all_comm_percs: $#all_rts with sum $sum_comm_perc\n";
305 print "No of elems in all_has: $#all_has with sum $sum_ha\n";
306 print "No of elems in all_fts: $#all_fts with sum $sum_ft\n";
310 do do_statistics($line_no);
316 open(FILE,">LOG") || die "Couldn't open file LOG\n";
317 printf FILE "All total runtimes (\@all_rts:)\n";
319 printf FILE join(", ",@all_rts);
321 printf FILE " Mean, std. dev: $mean_rt, $std_dev_rt\n";
322 printf FILE 70 x "-" . "\n";
323 printf FILE "All communication times (\@all_fts:)\n";
325 printf FILE join(", ",@all_fts);
327 printf FILE " Mean, std. dev: $mean_ft, $std_dev_ft\n";
328 printf FILE 70 x "-" . "\n";
329 printf FILE "All communication percentages (\@all_comm_percs:)\n";
331 printf FILE join(", ",@all_comm_percs);
333 printf FILE " Mean, std. dev: $mean_comm_perc,$std_dev_comm_perc\n";
334 printf FILE 70 x "-" . "\n";
335 printf FILE "All sparks (\@all_sparks:)\n";
337 printf FILE join(", ",@all_sparks);
339 printf FILE " Mean, std. dev: $mean_spark,$std_dev_spark\n";
340 printf FILE 70 x "-" . "\n";
341 printf FILE "All local sparks (\@all_local_sparks:)\n";
343 printf FILE join(", ",@all_local_sparks);
345 printf FILE " Mean, std. dev: $mean_local_spark,$std_dev_local_spark\n";
346 printf FILE 70 x "-" . "\n";
347 printf FILE "All global sparks (\@all_global_sparks:)\n";
349 printf FILE join(", ",@all_global_sparks);
351 printf FILE " Mean, std. dev: $mean_global_spark,$std_dev_global_spark\n";
352 printf FILE 70 x "-" . "\n";
353 printf FILE "All local sparks (\@all_has:)\n";
355 printf FILE join(", ",@all_has);
357 printf FILE " Mean, std. dev: $mean_ha,$std_dev_ha\n";
358 printf FILE 70 x "-" . "\n";
361 printf FILE ("CORR of runtime and heap alloc: %f\n",$c_exec_ha);
362 printf FILE ("CORR of runtime and no. of sparks: %f\n",$c_exec_sp);
363 printf FILE ("CORR of heap alloc and no. sparks: %f\n",$c_ha_sp);
364 printf FILE ("CORR of runtime and local sparks: %f\n",$c_exec_lsp);
365 printf FILE ("CORR of runtime and global sparks: %f\n",$c_exec_gsp);
366 printf FILE ("CORR of heap alloc and local sparks: %f\n",$c_ha_lsp);
367 printf FILE ("CORR of heap alloc and global sparks: %f\n",$c_ha_gsp);
368 printf FILE ("CORR of runtime and communication time: %f\n",$c_exec_ft);
369 printf FILE ("CORR of heap alloc and communication time: %f\n",$c_ha_ft);
370 printf FILE ("CORR of local sparks and communication time: %f\n",$c_lsp_ft);
371 printf FILE ("CORR of global_sparks and communication time: %f\n",$c_gsp_ft);
376 do percentify($line_no,*exec_class);
377 do percentify($line_no,*exec_global_class);
378 do percentify($line_no,*exec_local_class);
379 do percentify($line_no,*comm_class);
380 do percentify($line_no,*comm_global_class);
381 do percentify($line_no,*comm_local_class);
382 do percentify($line_no,*spark_local_class);
383 do percentify($line_no,*spark_global_class);
384 do percentify($line_no,*ha_class);
385 do percentify($line_no,*ft_class);
388 # Produce cumulative RT graph and other (more or less) nice graphs
389 # ................................................................
393 # ----------------------------------------------------------------------------
395 open(IV,">INTERVALS") || die "Couldn't open file INTERVALS\n";
396 do write_interval(IV, 'G', &guess_interval(@all_rts));
397 do write_interval(IV, 'C', 0, int($mean_comm_perc),
398 int($mean_comm_perc+$std_dev_comm_perc), 50);
399 do write_interval(IV, 'S', &guess_interval(@all_sparks));
400 do write_interval(IV, 'A', &guess_interval(@all_has));
403 # ----------------------------------------------------------------------------
404 # Print results to STDOUT (mainly for testing)
405 # ----------------------------------------------------------------------------
408 do print_general_info();
411 # ----------------------------------------------------------------------------
412 # Write results to data files to be processed by GNUPLOT
413 # ----------------------------------------------------------------------------
415 do write_data($gran_file_name, $OPEN_INT, $logscale{'g'}, $#exec_times+1,
416 @exec_times, @exec_class);
418 do write_data($gran_global_file_name, $OPEN_INT, $logscale{'g'}, $#exec_times+1,
419 @exec_times, @exec_global_class);
421 do write_data($gran_local_file_name, $OPEN_INT, $logscale{'g'}, $#exec_times+1,
422 @exec_times, @exec_local_class);
424 do write_data($comm_file_name, $CLOSED_INT, $logscale{'c'}, $#comm_percs+1,
425 @comm_percs, @comm_class);
427 do write_data($comm_global_file_name, $CLOSED_INT, $logscale{'c'}, $#comm_percs+1,
428 @comm_percs, @comm_global_class);
430 do write_data($comm_local_file_name, $CLOSED_INT, $logscale{'c'}, $#comm_percs+1,
431 @comm_percs, @comm_local_class);
433 do write_data($spark_file_name, $OPEN_INT, $logscale{'s'}, $#sparks+1,
434 @sparks, @spark_class);
436 do write_data($spark_local_file_name, $OPEN_INT, $logscale{'s'}, $#sparks+1,
437 @sparks, @spark_local_class);
439 do write_data($spark_global_file_name, $OPEN_INT, $logscale{'s'}, $#sparks+1,
440 @sparks, @spark_global_class);
442 do write_data($ha_file_name, $OPEN_INT, $logscale{'a'}, $#has+1,
445 do write_data($ft_file_name, $OPEN_INT, $logscale{'g'}, $#fetch_times+1,
446 @fetch_times, @fetch_class);
449 # ----------------------------------------------------------------------------
450 # Run GNUPLOT over the data files and create figures
451 # ----------------------------------------------------------------------------
453 do gnu_plotify($gp_file_name);
455 print "Script finished successfully!\n";
459 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
461 # ----------------------------------------------------------------------------
462 # Basic Operations on the intervals
463 # ----------------------------------------------------------------------------
465 sub get_index_open_int {
466 local ($value,@list) = @_;
467 local ($index,$right);
469 # print "get_index: searching for index of" . $value;
470 # print " in " . join(':',@list);
473 $right = $list[$index];
474 while ( ($value >= $right) && ($index < $#list) ) {
476 $right = $list[$index];
479 return ( ($index == $#list) && ($value > $right) ) ? $index+1 : $index;
482 # ----------------------------------------------------------------------------
484 sub get_index_closed_int {
485 local ($value,@list) = @_;
486 local ($index,$right);
488 if ( ($value < $list[0]) || ($value > $list[$#list]) ) {
493 $left = $list[$index];
494 while ( ($left <= $value) && ($index < $#list) ) {
496 $left = $list[$index];
501 # ----------------------------------------------------------------------------
503 # ----------------------------------------------------------------------------
506 local ($file_name, $open_int, $logaxes, $n, @rest) = @_;
507 local (@times) = splice(@rest,0,$n);
508 local (@class) = @rest;
510 open(GRAN,">$file_name") || die "Couldn't open file $file_name for output";
512 if ( $open_int == $OPEN_INT ) {
515 $left = ( index($logaxes,"x") != -1 ? int($times[0]/2) : 0 ),
518 $i++, $left = $right) {
520 print GRAN int(($left+$right)/2) . " " .
521 ($class[$i] eq "" ? "0" : $class[$i]) . "\n";
523 print GRAN $times[$n-1]+(($times[$n-1]-$times[$n-2])/2) . " " .
524 ($class[$n] eq "" ? "0" : $class[$n]) . "\n";
528 print GRAN ( (index($logaxes,"x") != -1) && ($times[0] == 0 ? int($times[1]/2) : ($times[$1] + $times[0])/2 ) . " " . $class[0] . "\n");
529 for ($i=1; $i < $n-2; $i++) {
531 $right = $times[$i+1];
532 print(GRAN ($left+$right)/2 . " " .
533 ($class[$i] eq "" ? "0" : $class[$i]) . "\n");
535 print GRAN ($times[$n-1]+$times[$n-2])/2 . " " . $class[$n-2] if $n >= 2;
541 # ----------------------------------------------------------------------------
544 local ($file_name,$n,@list) = @_;
546 open(FILE,">$file_name") || die "$file_name: $!";
547 for ($i=0; $i<=$#list; $i++) {
548 print FILE $i . " " . ( $list[$i] eq "" ? "0" : $list[$i] ) . "\n";
552 print "write_array: (" . join(", ",1 .. $#list) . ")\n for file $file_name returns: \n (0, $#list, &list_max(@list)\n";
555 return ( (0, $#list, &list_max(@list),
556 "(" . join(", ",1 .. $#list) . ")\n") );
559 # ----------------------------------------------------------------------------
561 sub write_cumulative_data {
562 local ($file_name1,$file_name2,@list) = @_;
563 local (@ns, @elems, @xtics, $i, $j, $n, $elem, $max_clust, $xtics_str,
564 $xstart, $xend, $file_name0);
565 local ($CLUST_SZ) = $no_of_clusters;
569 $file_name0 = $file_name1;
570 $file_name0 =~ s/\.dat$//;
571 $file_name0 .= "0.dat";
572 open(CUMM,">$file_name1") || die "Couldn't open file $file_name1 (error $!)\n";
573 open(CUMM0,">$file_name0") || die "Couldn't open file $file_name0 (error $!)\n";
575 print CUMM "1 0\n" unless $list[0] <= 1;
576 print CUMM0 "1 0\n" unless $list[0] <= 1;;
578 for ($i=0; $i <= $#list; $i++) {
580 print CUMM ($elem) . " " . int( (100 * ($i)) / ($#list+1) ) . "\n" unless $elem == 0;
581 print CUMM0 ($elem) . " " . $i . "\n" unless $elem == 0;;
582 for ($n=1; $i < $#list && $list[$i+1] == $elem; $i++, $n++) { }
584 print CUMM "$elem " . int( (100 * ($i+1)) / ($#list+1) ) . "\n";
585 print CUMM0 "$elem " . ($i+1) . "\n";
589 print "\n--> Insert: n: $n (elem $elem) in the above lists yields: \n ";
592 # inlined version of do insert_elem($elem, $n, $#exs, @exs, @ns)
593 for ($j=0; $j<=$#ns && $ns[$j]>$n; $j++) { }
598 splice(@ns,$j,0,$n); # insert $n at pos $j and move the
599 splice(@elems,$j,0,$elem); # rest of the array to the right
603 print "[" . join(", ",@ns) . "]" . "\n and \n" .
604 "[" . join(", ",@elems) . "]\n";
612 open(CLUSTERS_ALL,">" . (&dirname($file_name2)) . "CL-" .
613 &basename($file_name2))
614 || die "Couldn't open file CL-$file_name2 (error $!)\n";
615 for ($i=0; $i <= $#ns; $i++) {
616 print CLUSTERS_ALL "$elems[$i] $ns[$i]\n";
620 # Interesting are only the first parts of the list (clusters!)
621 splice(@elems, $CLUST_SZ);
622 splice(@ns, $CLUST_SZ);
624 open(CLUSTERS,">$file_name2") || die "Couldn't open file $file_name2 (error $!)\n";
626 $xstart = &list_min(@elems);
627 $xend = &list_max(@elems);
628 $step = ($xend - $xstart) / ( $CLUST_SZ == 1 ? 1 : ($CLUST_SZ-1));
631 for ($i=0, $x=$xstart; $i <= $#ns; $i++, $x+=$step) {
632 print CLUSTERS "$x $ns[$i]\n";
633 push(@xtics,"\"$elems[$i]\" $x");
638 $xtics_str = "(" . join(", ",@xtics) . ")\n";
640 return ( ($xstart, $xend, $max_clust, $xtics_str) );
643 # ----------------------------------------------------------------------------
646 local ($open_int, @list) = @_;
650 if ( $open_int == $OPEN_INT ) {
654 $str .= ", \">$x\" $x";
656 $str .= ", \"Large\" $last)\n";
658 $left = shift(@list);
659 $right = shift(@list) if $#list >= 0;
660 $last = pop(@list) if $#list >= 0;
661 $str = "( \"$left-$right\" " . $left;
663 foreach $right (@list) {
664 $str .= ", \"$left-$right\" " . ($left+$right)/2;
667 $str .= ", \"$left-$last\" " . $last .")\n" unless $last eq "";
672 # ----------------------------------------------------------------------------
675 local ($start,$end,$is_global,$bbs,$ha,$rt,$bt,$bc,$ft,$fc,$my) = @_;
677 printf("START: %u, END: %u ==> tot_exec: %u\n",
678 $start,$end,$end-$start);
679 printf(" BASIC_BLOCKS: %u, HEAP_ALLOCATIONS: %u \n",$bbs,$ha);
680 printf(" TOT_EXEC: %u = RUN_TIME %u + BLOCK_TIME %u + FETCH_TIME %u\n",
681 $end-$start,$rt,$bt,$ft);
682 printf(" BLOCK_TIME %u / BLOCK_COUNT %u; FETCH_TIME %u / FETCH_COUNT %u\n",
685 $is_global eq 'T' ? "GLOBAL" : "LOCAL",
686 $my eq 'T' ? "MANDATORY" : "NOT MANDATORY");
689 # ----------------------------------------------------------------------------
692 local ($gp_file_name) = @_;
694 local (@open_xrange,@closed_xrang,@spark_xrange,@ha_xrange, @ft_range,
695 $exec_xtics,$comm_perc_xtics,$spark_xtics,$has_xtics,
696 $cumu0_rts_file, $cumu0_has_file, $cumu0_fts_file);
698 $cumu0_rts_file = $cumulat_rts_file_name;
699 $cumu0_rts_file =~ s/\.dat$//;
700 $cumu0_rts_file .= "0.dat";
702 $cumu0_has_file = $cumulat_has_file_name;
703 $cumu0_has_file =~ s/\.dat$//;
704 $cumu0_has_file .= "0.dat";
706 $cumu0_fts_file = $cumulat_fts_file_name;
707 $cumu0_fts_file =~ s/\.dat$//;
708 $cumu0_fts_file .= "0.dat";
710 $cumu0_cps_file = $cumulat_cps_file_name;
711 $cumu0_cps_file =~ s/\.dat$//;
712 $cumu0_cps_file .= "0.dat";
714 @open_xrange = &range($OPEN_INT,$logscale{'g'},@exec_times);
715 @closed_xrange = &range($CLOSED_INT,$logscale{'c'},@comm_percs);
716 @spark_xrange = &range($OPEN_INT,$logscale{'s'},@sparks);
717 @ha_xrange = &range($OPEN_INT,$logscale{'a'},@has);
718 @ft_xrange = &range($OPEN_INT,$logscale{'f'},@fts);
720 $exec_xtics = $opt_T ? &get_xtics($OPEN_INT,@exec_times) : "" ;
721 $comm_perc_xtics = $opt_T ? &get_xtics($CLOSED_INT,@comm_percs) : "";
722 $spark_xtics = $opt_T ? &get_xtics($OPEN_INT,@sparks) : "";
723 $has_xtics = $opt_T ? &get_xtics($OPEN_INT,@has) : "";
724 $fts_xtics = $opt_T ? &get_xtics($OPEN_INT,@fts) : "";
726 open(GP_FILE,">$gp_file_name") ||
727 die "Couldn't open gnuplot file $gp_file_name for output\n";
730 print GP_FILE "set term postscript \"Roman\" 20\n";
732 print GP_FILE "set term postscript color \"Roman\" 20\n";
735 do write_gp_record(GP_FILE,
736 $gran_file_name, &dat2ps_name($gran_file_name),
737 "Granularity (pure exec. time)", $ylabel, $logscale{'g'},
738 @open_xrange,$max_rt_class,$exec_xtics);
739 do write_gp_record(GP_FILE,
740 $gran_global_file_name, &dat2ps_name($gran_global_file_name),
741 "Granularity (pure exec. time) of exported threads",
742 $ylabel, $logscale{'g'},
743 @open_xrange,$max_rt_global_class,$exec_xtics);
744 do write_gp_record(GP_FILE,
745 $gran_local_file_name, &dat2ps_name($gran_local_file_name),
746 "Granularity (pure exec. time) of not exported threads",
747 $ylabel,$logscale{'g'},
748 @open_xrange,$max_rt_local_class,$exec_xtics);
750 do write_gp_record(GP_FILE,
751 $comm_file_name, &dat2ps_name($comm_file_name),
752 "% of communication",$ylabel,$logscale{'c'},
753 @closed_xrange,$max_comm_perc_class,$comm_perc_xtics);
754 do write_gp_record(GP_FILE,
755 $comm_global_file_name, &dat2ps_name($comm_global_file_name),
756 "% of communication of exported threads",$ylabel,$logscale{'c'},
757 @closed_xrange,$max_comm_perc_global_class,$comm_perc_xtics);
758 do write_gp_record(GP_FILE,
759 $comm_local_file_name, &dat2ps_name($comm_local_file_name),
760 "% of communication of not exported threads",$ylabel,$logscale{'c'},
761 @closed_xrange,$max_comm_perc_local_class,$comm_perc_xtics);
762 do write_gp_record(GP_FILE,
763 $ft_file_name, &dat2ps_name($ft_file_name),
764 "Communication time", $ylabel, $logscale{'g'},
765 @open_xrange,$max_ft_class,$fts_xtics);
768 do write_gp_record(GP_FILE,
769 $spark_file_name, &dat2ps_name($spark_file_name),
770 "No. of sparks created", $ylabel, $logscale{'s'},
771 @spark_xrange,$max_spark_class,$spark_xtics);
773 do write_gp_record(GP_FILE,
774 $spark_local_file_name, &dat2ps_name($spark_local_file_name),
775 "No. of sparks created (parLocal)", $ylabel, $logscale{'s'},
776 @spark_xrange,$max_spark_local_class,$spark_xtics);
778 do write_gp_record(GP_FILE,
779 $spark_global_file_name, &dat2ps_name($spark_global_file_name),
780 "No. of sparks created (parGlobal)", $ylabel, $logscale{'s'},
781 @spark_xrange,$max_spark_global_class,$spark_xtics);
783 do write_gp_record(GP_FILE,
784 $ha_file_name, &dat2ps_name($ha_file_name),
785 "Heap Allocations (words)", $ylabel, $logscale{'a'},
786 @ha_xrange,$max_ha_class,$has_xtics);
788 do write_gp_lines_record(GP_FILE,
789 $cumulat_rts_file_name, &dat2ps_name($cumulat_rts_file_name),
790 "Cumulative pure exec. times","% of threads",
792 $xend_cum_rts, $yend_cum_rts,"");
793 # $xtics_cluster_rts as last arg?
795 do write_gp_lines_record(GP_FILE,
796 $cumulat_has_file_name, &dat2ps_name($cumulat_has_file_name),
797 "Cumulative heap allocations","% of threads",
799 $xend_cum_has, $yend_cum_has,"");
800 # $xtics_cluster_has as last arg?
802 do write_gp_lines_record(GP_FILE,
803 $cumu0_rts_file, &dat2ps_name($cumu0_rts_file),
804 "Cumulative pure exec. times","Number of threads",
806 $xend_cum_rts, $yend_cum0_rts,"");
807 # $xtics_cluster_rts as last arg?
809 do write_gp_lines_record(GP_FILE,
810 $cumu0_has_file, &dat2ps_name($cumu0_has_file),
811 "Cumulative heap allocations","Number of threads",
813 $xend_cum_has, $yend_cum0_has,"");
814 # $xtics_cluster_has as last arg?
816 do write_gp_lines_record(GP_FILE,
817 $cumulat_fts_file_name, &dat2ps_name($cumulat_fts_file_name),
818 "Cumulative communication times","% of threads",
820 $xend_cum_fts, $yend_cum_fts,"");
821 # $xtics_cluster_rts as last arg?
823 do write_gp_lines_record(GP_FILE,
824 $cumu0_fts_file, &dat2ps_name($cumu0_fts_file),
825 "Cumulative communication times","Number of threads",
827 $xend_cum_fts, $yend_cum0_fts,"");
828 # $xtics_cluster_rts as last arg?
830 do write_gp_lines_record(GP_FILE,
831 $cumulat_cps_file_name, &dat2ps_name($cumulat_cps_file_name),
832 "Cumulative communication percentages","% of threads",
833 "", # No logscale here !
834 $xend_cum_cps, $yend_cum_cps,"");
835 # $xtics_cluster_rts as last arg?
837 do write_gp_lines_record(GP_FILE,
838 $cumu0_cps_file, &dat2ps_name($cumu0_cps_file),
839 "Cumulative communication percentages","Number of threads",
840 "", # No logscale here !
841 $xend_cum_cps, $yend_cum0_cps,"");
842 # $xtics_cluster_rts as last arg?
844 do write_gp_record(GP_FILE,
845 $clust_rts_file_name, &dat2ps_name($clust_rts_file_name),
846 "Pure exec. time", "No. of threads", $logscale{'CG'},
847 $xstart_cluster_rts,$xend_cluster_rts,$max_cluster_rts,$xtics_cluster_rts);
849 do write_gp_record(GP_FILE,
850 $clust_has_file_name, &dat2ps_name($clust_has_file_name),
851 "Pure exec. time", "No. of threads", $logscale{'CA'},
852 $xstart_cluster_has,$xend_cluster_has,$max_cluster_has,$xtics_cluster_has);
854 do write_gp_record(GP_FILE,
855 $clust_fts_file_name, &dat2ps_name($clust_fts_file_name),
856 "Communication time", "No. of threads", $logscale{'CG'},
857 $xstart_cluster_fts,$xend_cluster_fts,$max_cluster_fts,$xtics_cluster_rts);
860 do write_gp_simple_record(GP_FILE,
861 $pe_file_name, &dat2ps_name($pe_file_name),
862 "Processing Elements (PEs)", "Ready Time (not running)",
863 $logscale{'Yp'},$xstart_pe,$xend_pe,$max_pe,$xtics_pe);
865 do write_gp_simple_record(GP_FILE,
866 $sn_file_name, &dat2ps_name($sn_file_name),
867 "Spark sites", "Pure exec. time",
868 $logscale{'Ys'},$xstart_sn,$xend_sn,$max_sn,$xtics_sn);
872 print "Gnu plotting figures ...\n";
873 system "gnuplot $gp_file_name";
875 print "Extending thickness of impulses ...\n";
876 do gp_ext($gran_file_name,
877 $gran_global_file_name,
878 $gran_local_file_name,
880 $comm_global_file_name,
881 $comm_local_file_name,
883 $spark_local_file_name,
884 $spark_global_file_name,
887 $clust_fts_file_name,
888 $clust_rts_file_name,
889 $clust_has_file_name,
897 # ----------------------------------------------------------------------------
900 local (@file_names) = @_;
902 local ($ps_file_name);
905 #$prg = system "which gp-ext-imp";
906 #print " Using script $prg for impuls extension\n";
907 $prg = $ENV{GRANDIR} ? $ENV{GRANDIR} . "/bin/gp-ext-imp"
908 : $ENV{HOME} . "/bin/gp-ext-imp" ;
910 print " (using script $prg)\n";
913 foreach $file_name (@file_names) {
914 $ps_file_name = &dat2ps_name($file_name);
915 system "$prg -w $ext_size -g $gray " .
916 $ps_file_name . " " .
917 $ps_file_name . "2" ;
918 system "mv " . $ps_file_name . "2 " . $ps_file_name;
922 # ----------------------------------------------------------------------------
924 sub write_gp_record {
925 local ($file,$in_file,$out_file,$xlabel,$ylabel,$logaxes,
926 $xstart,$xend,$ymax,$xtics) = @_;
928 if ( $xstart >= $xend ) {
929 print ("WARNING: empty xrange [$xstart:$xend] changed to [$xstart:" . $xstart+1 . "]\n") if ( $pedantic || $opt_v );
935 print "WARNING: empty yrange changed to [0:$ymax]\n" if ( $pedantic || $opt_v );
938 $str = "set size " . $xsize . "," . $ysize . "\n" .
939 "set xlabel \"" . $xlabel . "\"\n" .
940 "set ylabel \"" . $ylabel . "\"\n" .
942 : "set xrange [" . int($xstart) .":" . int($xend) . "]\n") .
944 : "set yrange [" . (index($logaxes,"y") != -1 ? 1 : 0) .
945 ":" . &list_max(2,int($ymax+$ymax/5)) . "]\n") .
946 ($xtics ne "" ? "set xtics $xtics" : "") .
949 "set title \"$nPEs PEs\"\n" .
952 "set format xy \"%g\"\n" .
953 (index($logaxes,"x") != -1 ?
955 "set nologscale x\n") .
956 (index($logaxes,"y") != -1 ?
958 "set nologscale y\n") .
959 "set output \"" . $out_file . "\"\n" .
960 "plot \"" . $in_file . "\" with impulses\n\n";
964 # ----------------------------------------------------------------------------
966 sub write_gp_lines_record {
967 local ($file,$in_file,$out_file,$xlabel,$ylabel,$logaxes,
968 $xend,$yend,$xtics) = @_;
972 $str = "set xlabel \"" . $xlabel . "\"\n" .
973 "set ylabel \"" . $ylabel . "\"\n" .
974 "set xrange [" . ( index($logaxes,"x") != -1 ? 1 : 0 ) . ":$xend]\n" .
975 "set yrange [" . ( index($logaxes,"y") != -1 ? 1 : 0 ) . ":$yend]\n" .
978 ( $xtics ne "" ? "set xtics $xtics" : "" ) .
979 (index($logaxes,"x") != -1 ?
981 "set nologscale x\n") .
982 (index($logaxes,"y") != -1 ?
984 "set nologscale y\n") .
986 "set format xy \"%g\"\n" .
987 "set output \"" . $out_file . "\"\n" .
988 "plot \"" . $in_file . "\" with lines\n\n";
993 # ----------------------------------------------------------------------------
995 sub write_gp_simple_record {
996 local ($file,$in_file,$out_file,$xlabel,$ylabel,$logaxes,
997 $xstart,$xend,$ymax,$xtics) = @_;
999 $str = "set size " . $xsize . "," . $ysize . "\n" .
1000 "set xlabel \"" . $xlabel . "\"\n" .
1001 "set ylabel \"" . $ylabel . "\"\n" .
1003 : "set xrange [" . int($xstart) .":" . int($xend) . "]\n") .
1005 : "set yrange [" . (index($logaxes,"y") != -1 ? 1 : 0) .
1006 ":" . &list_max(2,int($ymax+$ymax/5)) . "]\n") .
1007 ($xtics ne "" ? "set xtics $xtics" : "") .
1011 "set nozeroaxis\n" .
1012 "set format xy \"%g\"\n" .
1013 (index($logaxes,"x") != -1 ?
1014 "set logscale x\n" :
1015 "set nologscale x\n") .
1016 (index($logaxes,"y") != -1 ?
1017 "set logscale y\n" :
1018 "set nologscale y\n") .
1019 "set output \"" . $out_file . "\"\n" .
1020 "plot \"" . $in_file . "\" with impulses\n\n";
1024 # ----------------------------------------------------------------------------
1027 local ($dat_name) = @_;
1029 $dat_name =~ s/\.dat$/\.ps/;
1033 # ----------------------------------------------------------------------------
1036 local ($open_int, $logaxes, @ints) = @_;
1038 local ($range, $left_margin, $right_margin);
1040 $range = $ints[$#ints]-$ints[0];
1041 $left_margin = 0; # $range/10;
1042 $right_margin = 0; # $range/10;
1045 print "\n==> Range: logaxes are $logaxes i.e. " .
1046 (index($logaxes,"x") != -1 ? "matches x axis\n"
1047 : "DOESN'T match x axis\n");
1049 if ( index($logaxes,"x") != -1 ) {
1050 if ( $open_int == $OPEN_INT ) {
1051 return ( ($ints[0]/2-$left_margin,
1052 $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
1054 return ( ( &list_max(1,$ints[0]-$left_margin),
1055 $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
1058 if ( $open_int == $OPEN_INT ) {
1059 return ( ($ints[0]/2-$left_margin,
1060 $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
1062 return ( ($ints[0]-$left_margin,
1063 $ints[$#ints]+($ints[$#ints]-$ints[$#ints-1])/2+$right_margin) );
1068 # ----------------------------------------------------------------------------
1071 local ($sum,*classes) = @_;
1073 for ($i=0; $i<=$#classes; $i++) {
1074 $classes[$i] = (100 * $classes[$i]) / $sum;
1078 # ----------------------------------------------------------------------------
1079 # ToDo: get these statistics functions from "stat.pl"
1080 # ----------------------------------------------------------------------------
1083 local ($sum,@list) = @_;
1085 local ($n, $s, $s_);
1087 #print "\nmean_std_dev: sum is $sum ; list has length $#list";
1090 $mean_value = $sum/$n;
1093 foreach $x (@list) {
1095 $s += ($mean_value - $x) ** 2;
1097 if ( $sum != $s_ ) {
1098 print "ERROR in mean_std_dev: provided sum is wrong " .
1099 "(provided: $sum; computed: $s_)\n";
1100 print " list_sum: " . &list_sum(@list) . "\n";
1104 return ( ($mean_value, sqrt($s / ($n - 1)) ) );
1107 # ----------------------------------------------------------------------------
1110 return ( &mean_std_dev(&list_sum(@_), @_) );
1113 # ----------------------------------------------------------------------------
1114 # Compute covariance of 2 vectors, having their sums precomputed.
1115 # Input: $n ... number of all elements in @list_1 as well as in @list_2
1116 # (i.e. $n = $#list_1+1 = $#list_2+1).
1117 # $mean_1 ... mean value of all elements in @list_1
1118 # @list_1 ... list of integers; first vector
1119 # $mean_2 ... mean value of all elements in @list_2
1120 # @list_2 ... list of integers; first vector
1121 # Output: covariance of @list_1 and @list_2
1122 # ----------------------------------------------------------------------------
1125 local ($n, $mean_1, @rest) = @_;
1126 local (@list_1) = splice(@rest,0,$n);
1127 local ($mean_2, @list_2) = @rest;
1129 local ($i,$s,$s_1,$s_2);
1131 for ($i=0; $i<$n; $i++) {
1132 $s_1 += $list_1[$i];
1133 $s_2 += $list_2[$i];
1134 $s += ($mean_1 - $list_1[$i]) * ($mean_2 - $list_2[$i]);
1136 if ( $mean_1 != ($s_1/$n) ) {
1137 print "ERROR in cov: provided mean value is wrong " .
1138 "(provided: $mean_1; computed: " . ($s_1/$n) . ")\n";
1141 if ( $mean_2 != ($s_2/$n) ) {
1142 print "ERROR in cov: provided mean value is wrong " .
1143 "(provided: $mean_2; computed: " . ($s_2/$n) . ")\n";
1146 return ( $s / ($n - 1) ) ;
1149 # ----------------------------------------------------------------------------
1150 # Compute correlation of 2 vectors, having their sums precomputed.
1151 # Input: $n ... number of all elements in @list_1 as well as in @list_2
1152 # (i.e. $n = $#list_1+1 = $#list_2+1).
1153 # $sum_1 ... sum of all elements in @list_1
1154 # @list_1 ... list of integers; first vector
1155 # $sum_2 ... sum of all elements in @list_2
1156 # @list_2 ... list of integers; first vector
1157 # Output: correlation of @list_1 and @list_2
1158 # ----------------------------------------------------------------------------
1161 local ($n, $sum_1, @rest) = @_;
1162 local (@list_1) = splice(@rest,0,$n);
1163 local ($sum_2, @list_2) = @rest;
1165 local ($mean_1,$mean_2,$std_dev_1,$std_dev_2);
1168 print "\ncorr: n=$n sum_1=$sum_1 sum_2=$sum_2\n";
1169 print " list_sum of list_1=" . &list_sum(@list_1) .
1170 " list_sum of list_2=" . &list_sum(@list_2) . "\n";
1171 print " len of list_1=$#list_1 len of list_2=$#list_2\n";
1174 ($mean_1, $std_dev_1) = &mean_std_dev($sum_1,@list_1);
1175 ($mean_2, $std_dev_2) = &mean_std_dev($sum_2,@list_2);
1178 print "corr: $mean_1, $std_dev_1; $mean_2, $std_dev_2\n";
1181 return ( ($std_dev_1 * $std_dev_2) == 0 ?
1183 &cov($n, $mean_1, @list_1, $mean_2, @list_2) /
1184 ( $std_dev_1 * $std_dev_2 ) );
1187 # ----------------------------------------------------------------------------
1194 foreach $x (@list) {
1201 # ----------------------------------------------------------------------------
1206 local ($max) = shift;
1208 foreach $x (@list) {
1209 $max = $x if $x > $max;
1215 # ----------------------------------------------------------------------------
1220 local ($min) = shift;
1222 foreach $x (@list) {
1223 $min = $x if $x < $min;
1229 # ----------------------------------------------------------------------------
1231 sub guess_interval {
1232 local (@list) = @_ ;
1234 local ($min,$max,$sum,$mean,$std_dev,@intervals);
1236 $min = &list_min(@list);
1237 $max = &list_max(@list);
1238 $sum = &list_sum(@list);
1239 ($mean, $std_dev) = &mean_std_dev($sum,@list);
1241 @intervals = (int($mean-$std_dev),int($mean-$std_dev/2),int($mean),
1242 int($mean+$std_dev/2),int($mean+$std_dev));
1244 while ($#intervals>=0 && $intervals[0]<0) {
1248 return (@intervals);
1251 # ----------------------------------------------------------------------------
1253 sub write_interval {
1254 local ($file,$flag,@intervals) = @_;
1256 printf $file "$flag: (" . join(", ",@intervals) . ")\n";
1259 # ----------------------------------------------------------------------------
1264 print "Reading settings from template file $templ_file_name ...\n";
1267 open(TEMPLATE,$templ_file_name) || die "Couldn't open file $templ_file_name";
1268 while (<TEMPLATE>) {
1269 next if /^\s*$/ || /^--/;
1270 if (/^\s*G[:,;.\s]+([^\n]+)$/) {
1272 $list_str =~ s/[\(\)\[\]]//g;
1273 @exec_times = split(/[,;. ]+/, $list_str);
1274 } elsif (/^\s*F[:,;.\s]+([^\n]+)$/) {
1276 $list_str =~ s/[\(\)\[\]]//g;
1277 @fetch_times = split(/[,;. ]+/, $list_str);
1278 } elsif (/^\s*A[:,;.\s]+([^\n]+)$/) {
1280 $list_str =~ s/[\(\)\[\]]//g;
1281 @has = split(/[,;. ]+/, $list_str);
1282 } elsif (/^\s*C[:,;.\s]+([^\n]+)$/) {
1284 $list_str =~ s/[\(\)\[\]]//g;
1285 @comm_percs = split(/[,;. ]+/, $list_str);
1286 } elsif (/^\s*S[:,;.\s]+([^\n]+)$/) {
1288 $list_str =~ s/[\(\)\[\]]//g;
1289 @sparks = split(/[,;. ]+/, $list_str);
1290 } elsif (/^\s*g[:,;.\s]+([\S]+)$/) {
1291 ($gran_file_name,$gran_global_file_name, $gran_local_file_name) =
1292 &mk_global_local_names($1);
1293 } elsif (/^\s*f[:,;.\s]+([\S]+)$/) {
1294 ($ft_file_name,$ft_global_file_name, $ft_local_file_name) =
1295 &mk_global_local_names($1);
1296 } elsif (/^\s*c[:,;.\s]+([\S]+)$/) {
1297 ($comm_file_name, $comm_global_file_name, $comm_local_file_name) =
1298 &mk_global_local_names($1);
1299 } elsif (/^\s*s[:,;.\s]+([\S]+)$/) {
1300 ($spark_file_name, $spark_global_file_name, $spark_local_file_name) =
1301 &mk_global_local_names($1);
1302 } elsif (/^\s*a[:,;.\s]+([\S]+)$/) {
1303 ($ha_file_name, $ha_global_file_name, $ha_local_file_name) =
1304 &mk_global_local_names($1);
1305 } elsif (/^\s*p[:,;.\s]+([\S]+)$/) {
1307 $ps_file_name = &dat2ps_name($gp_file_name);
1309 } elsif (/^\s*Xcorr[:,;.\s]+([\S]+)$/) {
1310 $corr_file_name = $1;
1311 } elsif (/^\s*Xcumulat-rts[:,;.\s]+([\S]+)$/) {
1312 $cumulat_rts_file_name = $1;
1313 } elsif (/^\s*Xcumulat-has[:,;.\s]+([\S]+)$/) {
1314 $cumulat_has_file_name = $1;
1315 } elsif (/^\s*Xcumulat-fts[:,;.\s]+([\S]+)$/) {
1316 $cumulat_fts_file_name = $1;
1317 } elsif (/^\s*Xcumulat-cps[:,;.\s]+([\S]+)$/) {
1318 $cumulat_cps_file_name = $1;
1319 } elsif (/^\s*Xclust-rts[:,;.\s]+([\S]+)$/) {
1320 $clust_rts_file_name = $1;
1321 } elsif (/^\s*Xclust-has[:,;.\s]+([\S]+)$/) {
1322 $clust_has_file_name = $1;
1323 } elsif (/^\s*Xclust-fts[:,;.\s]+([\S]+)$/) {
1324 $clust_fts_file_name = $1;
1325 } elsif (/^\s*Xclust-cps[:,;.\s]+([\S]+)$/) {
1326 $clust_cps_file_name = $1;
1327 } elsif (/^\s*Xpe[:,;.\s]+([\S]+)$/) {
1329 } elsif (/^\s*Xsn[:,;.\s]+([\S]+)$/) {
1332 } elsif (/^\s*XRTS[:,;.\s]+([\S]+)$/) {
1333 $rts_file_name = $1;
1334 } elsif (/^\s*XHAS[:,;.\s]+([\S]+)$/) {
1335 $has_file_name = $1;
1336 } elsif (/^\s*XFTS[:,;.\s]+([\S]+)$/) {
1337 $fts_file_name = $1;
1338 } elsif (/^\s*XLSPS[:,;.\s]+([\S]+)$/) {
1339 $lsps_file_name = $1;
1340 } elsif (/^\s*XGSPS[:,;.\s]+([\S]+)$/) {
1341 $gsps_file_name = $1;
1342 } elsif (/^\s*XCPS[:,;.\s]+([\S]+)$/) {
1343 $cps_file_name = $1;
1344 } elsif (/^\s*XCCPS[:,;.\s]+([\S]+)$/) {
1345 $ccps_file_name = $1;
1347 } elsif (/^\s*\-[:,;.\s]+([\S]+)$/) {
1349 } elsif (/^\s*L[:,;\s]+(.*)$/) {
1351 %logscale = ('g',"xy",'a',"xy",'Cg',"xy",'Ca',"xy",'Yp',"y",'Ys',"y") , next if $str eq ".";
1352 $str =~ s/[\(\)\[\]]//g;
1353 %logscale = split(/[,;. ]+/, $str);
1354 } elsif (/^\s*i[:,;.\s]+([\S]+)$/) {
1356 } elsif (/^\s*k[:,;.\s]+([\S]+)$/) {
1357 $no_of_clusters = $1;
1358 } elsif (/^\s*e[:,;.\s]+([\S]+)$/) {
1360 } elsif (/^\s*v.*$/) {
1362 } elsif (/^\s*T.*$/) {
1364 } elsif (/^\s*m.*$/) {
1371 # ----------------------------------------------------------------------------
1373 sub mk_global_local_names {
1374 local ($file_name) = @_;
1376 $file_name .= ".dat" unless $file_name =~ /\.dat$/;
1377 $global_file_name = $file_name;
1378 $global_file_name =~ s/\.dat/\-global\.dat/ ;
1379 $local_file_name = $file_name;
1380 $local_file_name =~ s/\.dat/\-local\.dat/ ;
1382 return ( ($file_name, $global_file_name, $local_file_name) );
1385 # ----------------------------------------------------------------------------
1387 # ----------------------------------------------------------------------------
1390 local ($lines) = @_;
1392 local (@all_rts, @all_comm_percs, @all_sparks, @all_local_sparks,
1393 @all_global_sparks, @all_has, @fields,
1394 $line_no, $elem, $total_rt, $comm_perc,
1395 $pe, $start, $end, $is_global, $bbs, $ha, $rt, $bt, $ft,
1399 print "Preprocessing file $input ... \n";
1402 open(INPUT,"<$input") || die "Couldn't open input file $input";
1409 last if $line_no > $lines;
1411 @fields = split(/,/,$_);
1413 foreach $elem (@fields) {
1415 $pe = $1 , last foo if $elem =~ /^\s*PE\s+(\d+).*$/;
1416 $start = $1 , last foo if $elem =~ /^\s*ST\s+(\d+).*$/;
1417 $end = $1 , last foo if $elem =~ /^\s*END\s+(\d+).*$/;
1418 $is_global = $1 , last foo if $elem =~ /^\s*GBL\s+(T|F).*$/;
1419 $bbs = $1 , last foo if $elem =~ /^\s*BB\s+(\d+).*$/;
1420 $ha = $1 , last foo if $elem =~ /^\s*HA\s+(\d+).*$/;
1421 $rt = $1 , last foo if $elem =~ /^\s*RT\s+(\d+).*$/;
1422 $bt = $1, $bc = $2 , last foo if $elem =~ /^\s*BT\s+(\d+)\s+\((\d+)\).*$/;
1423 $ft = $1, $fc = $2 , last foo if $elem =~ /^\s*FT\s+(\d+)\s+\((\d+)\).*$/;
1424 $lsp = $1 , last foo if $elem =~ /^\s*LS\s+(\d+).*$/;
1425 $gsp = $1 , last foo if $elem =~ /^\s*GS\s+(\d+).*$/;
1426 $my = $1 , last foo if $elem =~ /^\s*MY\s+(T|F).*$/;
1430 $total_rt = $end - $start;
1431 $comm_perc = ( $total_rt == 0 ? 100 : (100 * $ft)/$total_rt );
1436 push(@all_comm_percs,$comm_perc);
1438 push(@all_sparks,$sp);
1439 push(@all_local_sparks,$lsp);
1440 push(@all_global_sparks,$gsp);
1447 @exec_times = &guess_interval(@all_rts);
1448 @sparks = &guess_interval(@all_sparks);
1449 @has = &guess_interval(@all_has);
1451 ($m,$std_dev) = &_mean_std_dev(@all_comm_percs);
1452 @comm_percs = (0, int($m), int($std_dev), 100) unless int($m) == 0;
1453 @comm_percs = (0, 1, 2, 5, 10, 50, 100) if int($m) == 0;
1456 # ----------------------------------------------------------------------------
1458 sub process_options {
1460 open(ME,$0) || die "Can't open myself ($0)";
1469 # system "cat $0 | awk 'BEGIN { n = 0; } \
1482 $input = $#ARGV == -1 ? "-" : $ARGV[0] ;
1484 if ( $#ARGV != 0 ) {
1485 #print "Usage: gran-extr [options] <sim-file>\n";
1486 #print "Use -h option to get details\n";
1497 ($gran_file_name, $gran_global_file_name, $gran_local_file_name) =
1498 do mk_global_local_names($opt_g);
1500 $gran_file_name = "gran.dat";
1501 $gran_global_file_name = "gran-global.dat";
1502 $gran_local_file_name = "gran-local.dat";
1506 ($comm_file_name, $comm_global_file_name, $comm_local_file_name) =
1507 do mk_global_local_names($opt_c);
1509 $comm_file_name = "comm.dat";
1510 $comm_global_file_name = "comm-global.dat";
1511 $comm_local_file_name = "comm-local.dat";
1515 ($ft_file_name, $ft_global_file_name, $ft_local_file_name) =
1516 do mk_global_local_names($opt_c);
1518 $ft_file_name = "ft.dat";
1519 $ft_global_file_name = "ft-global.dat";
1520 $ft_local_file_name = "ft-local.dat";
1524 ($spark_file_name, $spark_global_file_name, $spark_local_file_name) =
1525 do mk_global_local_names($opt_s);
1527 $spark_file_name = "spark.dat";
1528 $spark_global_file_name = "spark-global.dat";
1529 $spark_local_file_name = "spark-local.dat";
1533 ($ha_file_name, $ha_global_file_name, $ha_local_file_name) =
1534 do mk_global_local_names($opt_a);
1536 $ha_file_name = "ha.dat";
1540 $gp_file_name = $opt_p;
1542 $gp_file_name = "gran.gp";
1545 $ps_file_name = &dat2ps_name($gp_file_name);
1547 $corr_file_name = "CORR";
1548 $cumulat_rts_file_name = "cumulative-rts.dat";
1549 $cumulat_has_file_name = "cumulative-has.dat";
1550 $cumulat_fts_file_name = "cumulative-fts.dat";
1551 $cumulat_cps_file_name = "cumulative-cps.dat";
1552 $clust_rts_file_name = "clusters-rts.dat";
1553 $clust_has_file_name = "clusters-has.dat";
1554 $clust_fts_file_name = "clusters-fts.dat";
1555 $clust_cps_file_name = "clusters-cps.dat";
1556 $pe_file_name = "pe.dat";
1557 $sn_file_name = "sn.dat";
1559 $pie_file_name = "Pie.ps";
1561 $cps_file_name = "CPS";
1562 $fts_file_name = "FTS";
1563 $rts_file_name = "RTS";
1564 $has_file_name = "HAS";
1565 $lsps_file_name = "LSPS";
1566 $gsps_file_name = "GSPS";
1567 $ccps_file_name = "CCPS";
1570 $left_margin = $opt_l;
1574 $left_perc_margin = 0;
1577 $right_margin = $opt_r;
1581 $right_perc_margin = 0;
1608 $no_of_clusters = $opt_k;
1610 $no_of_clusters = 5;
1615 $str =~ s/[\(\)\[\]]//g;
1616 %logscale = split(/[,;. ]+/, $str);
1617 # $logscale = $opt_L;
1619 %logscale = (); # ('g',"xy",'a',"xy",'Cg',"xy",'Ca',"xy");
1622 # $delta = do compute_delta(@exec_times);
1623 # $no_of_exec_times = $#exec_times;
1626 $opt_G =~ s/[\(\)\[\]]//g;
1627 @exec_times = split(/[,;. ]+/, $opt_G);
1628 # @exec_times = split(/[,;. ]+/, ($opt_G =~ s/[\(\)]//g));
1630 # @exec_times = (50, 100, 200, 300, 400, 500, 700);
1634 $opt_F =~ s/[\(\)\[\]]//g;
1635 @fetch_times = split(/[,;. ]+/, $opt_F);
1636 # @fetch_times = split(/[,;. ]+/, ($opt_F =~ s/[\(\)]//g));
1638 # @fetch_times = (50, 100, 200, 300, 400, 500, 700);
1642 $opt_C =~ s/[\(\)\[\]]//g;
1643 @comm_percs = split(/[,;. ]+/, $opt_C);
1645 # @comm_percs = (0,10,20,30,50,100);
1649 $opt_S =~ s/[\(\)\[\]]//g;
1650 @sparks = split(/[,;. ]+/, $opt_S);
1652 # @sparks = (0,5,10,50);
1655 # $delta_comm = do compute_delta(@comm_percs);
1658 $opt_A =~ s/[\(\)\[\]]//g;
1659 @has = split(/[,;. ]+/, $opt_A);
1661 # @has = (10, 100, 200, 300, 500, 1000);
1665 $templ_file_name = ( $opt_t eq '.' ? "TEMPL" # default file name
1666 : $opt_t eq ',' ? "/users/fp/hwloidl/grasp/GrAn/bin/TEMPL" # global master template
1667 : $opt_t eq '/' ? "/users/fp/hwloidl/grasp/GrAn/bin/T0" # template, that throws away most of the info
1670 # see RTS2gran for use of template-package
1673 $ylabel = $opt_P ? "% of threads" : "No. of threads";
1676 # ----------------------------------------------------------------------------
1678 sub print_verbose_message {
1680 print "-" x 70 . "\n";
1682 print "-" x 70 . "\n";
1683 print "\nFilenames: \n";
1684 print " Input file: $input\n";
1685 print " Gran files: $gran_file_name $gran_global_file_name $gran_local_file_name\n";
1686 print " Comm files: $comm_file_name $comm_global_file_name $comm_local_file_name\n";
1687 print " Sparked threads file: $spark_file_name $spark_local_file_name $spark_global_file_name\n";
1688 print " Heap file: $ha_file_name\n";
1689 print " GNUPLOT file name: $gp_file_name Correlation file name: $corr_file_name\n";
1690 print " Cumulative RT file name: $cumulat_rts_file_name \n Cumulative HA file name: $cumulat_has_file_name\n";
1691 print " Cluster RT file name: $clust_rts_file_name \n Cluster HA file name: $clust_has_file_name\n";
1692 print " Cumulative runtimes file name: $cumulat_rts_file_name\n";
1693 print " Cumulative heap allocations file name $cumulat_has_file_name\n";
1694 print " Cluster run times file name: $clust_rts_file_name\n";
1695 print " Cluster heap allocations file name: $clust_has_file_name\n";
1696 print " PE load file name: $pe_file_name\n";
1697 print " Site size file name: $sn_file_name\n";
1698 print "\nBoundaries: \n";
1699 print " Gran boundaries: @exec_times\n";
1700 print " Comm boundaries: @comm_percs\n";
1701 print " Sparked threads boundaries: @sparks\n";
1702 print " Heap boundaries: @has\n";
1703 print "\nOther pars: \n";
1704 print " Left margin: $left_margin Right margin: $right_margin\n";
1705 print " GP-extension: $ext_size GP xsize: $xsize GP ysize: $ysize\n";
1706 print " Gray scale: $gray Smart x-tics is " . ($opt_T ? "ON" : "OFF") .
1707 " Percentage y-axis is " . ($opt_P ? "ON" : "OFF") . "\n";
1708 print " Log. scaling assoc list: ";
1709 while (($key,$value) = each %logscale) {
1710 print "$key: $value, ";
1713 print " Active template file: $templ_file\n" if $opt_t;
1714 print "-" x 70 . "\n";
1717 # ----------------------------------------------------------------------------
1721 @sorted_rts = sort {$a <=> $b} @all_rts;
1723 ($xstart_cluster_rts,$xend_cluster_rts,$max_cluster_rts,$xtics_cluster_rts) =
1724 &write_cumulative_data($cumulat_rts_file_name,$clust_rts_file_name,@sorted_rts);
1726 $xend_cum_rts = pop(@sorted_rts);
1727 $yend_cum_rts = 100;
1728 $yend_cum0_rts = $#sorted_rts+1; # unpercentified cum graph
1730 open(RTS,">$rts_file_name") || die "$rts_file_name: $!";
1731 print RTS "Sorted list of all runtimes:\n";
1732 print RTS join("\n",@sorted_rts);
1735 @sorted_has = sort {$a <=> $b} @all_has;
1737 ($xstart_cluster_has,$xend_cluster_has,$max_cluster_has,$xtics_cluster_has) =
1738 &write_cumulative_data($cumulat_has_file_name,$clust_has_file_name,@sorted_has);
1740 $xend_cum_has = pop(@sorted_has);
1741 $yend_cum_has = 100;
1742 $yend_cum0_has = $#sorted_has+1; # unpercentified cum graph
1744 open(HAS,">$has_file_name") || die "$has_file_name: $!";
1745 print HAS "Sorted list of all heap allocations:\n";
1746 print HAS join("\n",@sorted_has);
1749 @sorted_lsps = sort {$a <=> $b} @all_local_sparks;
1751 open(LSPS,">$lsps_file_name") || die "$lsps_file_name: $!";
1752 print LSPS "Sorted list of all local sparks:\n";
1753 print LSPS join("\n",@sorted_lsps);
1756 @sorted_gsps = sort {$a <=> $b} @all_global_sparks;
1758 open(GSPS,">$gsps_file_name") || die "$gsps_file_name: $!";
1759 print GSPS "Sorted list of all global sparks:\n";
1760 print GSPS join("\n",@sorted_gsps);
1763 @sorted_fts = sort {$a <=> $b} @all_fts;
1765 ($xstart_cluster_fts,$xend_cluster_fts,$max_cluster_fts,$xtics_cluster_fts) =
1766 &write_cumulative_data($cumulat_fts_file_name,$clust_fts_file_name,@sorted_fts);
1768 $xend_cum_fts = pop(@sorted_fts);
1769 $yend_cum_fts = 100;
1770 $yend_cum0_fts = $#sorted_fts+1; # unpercentified cum graph
1772 open(FTS,">$fts_file_name") || die "$FTS_file_name: $!";
1773 print FTS "Sorted list of all communication times:\n";
1774 print FTS join("\n",@sorted_fts);
1777 @sorted_comm_percs = sort {$a <=> $b} @all_comm_percs;
1779 ($xstart_cluster_cps,$xend_cluster_cps,$max_cluster_cps,$xtics_cluster_cps) =
1780 &write_cumulative_data($cumulat_cps_file_name,$clust_cps_file_name,@sorted_comm_percs);
1782 $xend_cum_cps = 100; # pop(@sorted_comm_percs);
1783 $yend_cum_cps = 100;
1784 $yend_cum0_cps = $#sorted_comm_percs+1; # unpercentified cum graph
1786 open(CCPS,">$ccps_file_name") || die "$ccps_file_name: $!";
1787 print CCPS "Sorted list of all communication percentages:\n";
1788 print CCPS join("\n",@sorted_comm_percs);
1791 ($xstart_pe,$xend_pe,$max_pe,$xtics_pe) =
1792 &write_array($pe_file_name,$#pe_load,@pe_load);
1794 ($xstart_sn,$xend_sn,$max_sn,$xtics_sn) =
1795 &write_array($sn_file_name,$#site_size,@site_size);
1798 print "After write_array: xstart, xend, max _sn: $xstart_sn,$xend_sn,$max_sn,$xtics_sn\n";
1802 # ----------------------------------------------------------------------------
1803 # Compute statistical values (like mean, std_dev and especially corr coeff).
1804 # Write the important info to a file.
1805 # ----------------------------------------------------------------------------
1811 print "Sorry, no statistics for just $n threads\n";
1815 # Compute mean values and std deviations
1816 # ......................................
1818 ($mean_rt,$std_dev_rt) = &mean_std_dev($sum_rt,@all_rts);
1819 ($mean_comm_perc,$std_dev_comm_perc) = &mean_std_dev($sum_comm_perc,@all_comm_percs);
1820 ($mean_spark,$std_dev_spark) = &mean_std_dev($sum_sp,@all_sparks);
1821 ($mean_local_spark,$std_dev_local_spark) = &mean_std_dev($sum_local_sp,@all_local_sparks);
1822 ($mean_global_spark,$std_dev_global_spark) = &mean_std_dev($sum_global_sp,@all_global_sparks);
1823 ($mean_ha,$std_dev_ha) = &mean_std_dev($sum_ha,@all_has);
1824 ($mean_ft,$std_dev_ft) = &mean_std_dev($sum_ft,@all_fts);
1826 # Compute correlation coefficients
1827 # ................................
1829 $c_exec_ha = &corr($#all_rts+1,$sum_rt,@all_rts,$sum_ha,@all_has);
1830 $c_exec_sp = &corr($#all_rts+1,$sum_rt,@all_rts,$sum_sp,@all_sparks);
1831 $c_exec_lsp = &corr($#all_rts+1,$sum_rt,@all_rts,$sum_local_sp,@all_local_sparks);
1832 $c_exec_gsp = &corr($#all_rts+1,$sum_rt,@all_rts,$sum_global_sp,@all_global_sparks);
1833 $c_ha_sp = &corr($#all_has+1,$sum_ha,@all_has,$sum_sp,@all_sparks);
1834 $c_ha_lsp = &corr($#all_has+1,$sum_ha,@all_has,$sum_local_sp,@all_local_sparks);
1835 $c_ha_gsp = &corr($#all_has+1,$sum_ha,@all_has,$sum_global_sp,@all_global_sparks);
1836 $c_exec_ft = &corr($#all_rts+1,$sum_rt,@all_rts,$sum_ft,@all_fts);
1837 $c_ha_ft = &corr($#all_has+1,$sum_ha,@all_has,$sum_ft,@all_fts);
1838 $c_lsp_ft = &corr($#all_local_sparks+1,$sum_local_sp,@all_local_sparks,$sum_ft,@all_fts);
1839 $c_gsp_ft = &corr($#all_global_sparks+1,$sum_global_sp,@all_global_sparks,$sum_ft,@all_fts);
1841 # Write corr coeffs into a file
1842 # .............................
1844 open(CORR,">$corr_file_name") || die "Couldn't open file $corr_file_name\n";
1845 #printf CORR ("%f\n%f\n%f\n%f\n%f",$c_exec_ha,$c_exec_lsp,$c_exec_gsp,$c_ha_lsp,$c_ha_gsp) ;
1846 printf CORR ("CORR of runtime and heap alloc: %f\n",$c_exec_ha);
1847 printf CORR ("CORR of runtime and no. of sparks: %f\n",$c_exec_sp);
1848 printf CORR ("CORR of heap alloc and no. sparks: %f\n",$c_ha_sp);
1849 printf CORR ("CORR of runtime and no. of local sparks: %f\n",$c_exec_lsp);
1850 printf CORR ("CORR of runtime and no. of global sparks: %f\n",$c_exec_gsp);
1851 printf CORR ("CORR of heap alloc and no. local sparks: %f\n",$c_ha_lsp);
1852 printf CORR ("CORR of heap alloc and no. global sparks: %f\n",$c_ha_gsp);
1853 printf CORR ("CORR of runtime and communication time: %f\n",$c_exec_ft);
1854 printf CORR ("CORR of heap alloc and communication time: %f\n",$c_ha_ft);
1855 printf CORR ("CORR of no. of local sparks and communication time: %f\n",$c_lsp_ft);
1856 printf CORR ("CORR of no. of global sparks and communication time: %f\n",$c_gsp_ft);
1859 # These are needed later in the GNUPLOT files
1860 # ...........................................
1862 $max_rt_class = &list_max(@exec_class);
1863 $max_rt_global_class = &list_max(@exec_global_class);
1864 $max_rt_local_class = &list_max(@exec_local_class);
1865 $max_comm_perc_class = &list_max(@comm_class);
1866 $max_comm_perc_global_class = &list_max(@comm_global_class);
1867 $max_comm_perc_local_class = &list_max(@comm_local_class);
1868 $max_spark_class = &list_max(@spark_class);
1869 $max_spark_local_class = &list_max(@spark_local_class);
1870 $max_spark_global_class = &list_max(@spark_global_class);
1871 $max_ha_class = &list_max(@ha_class);
1872 $max_ft_class = &list_max(@fetch_class);
1876 # ----------------------------------------------------------------------------
1877 # This is written to STDOUT at the end of the file processing (before
1878 # gnuplotting and such) if the verbose option is given.
1879 # ----------------------------------------------------------------------------
1881 sub print_general_info {
1883 printf("\nTotal number of lines: %d\n", $line_no);
1885 print "\nDistribution of execution times: \n";
1886 print " Intervals: " . join('|',@exec_times) . "\n";
1887 print " Total: " . join('|',@exec_class) . "\n";
1888 print " Global: " . join('|',@exec_global_class) . "\n";
1889 print " Local: " . join('|',@exec_local_class) . "\n";
1891 $total=0; foreach $i (@exec_class) { $total += $i ; }
1892 $global=0; foreach $i (@exec_global_class) { $global += $i ; }
1893 $local=0; foreach $i (@exec_local_class) { $local += $i ; }
1895 print " Sum of classes (should be " . $line_no . "): " . $total .
1896 " (global/local)=(" . $global . "/" . $local . ")\n";
1897 print " Mean value: $mean_rt Std dev: $std_dev_rt\n";
1899 print "\nPercentage of communication: \n";
1900 print " Intervals: " . join('|',@comm_percs) . "\n";
1901 print " Total: " . join('|',@comm_class) . "\n";
1902 print " Global: " . join('|',@comm_global_class) . "\n";
1903 print " Local: " . join('|',@comm_local_class) . "\n";
1904 print " Values outside closed int: Total: " . $outside .
1905 " Global: " . $outside_global . " Local: " . $outside_local . "\n";
1907 $total=0; foreach $i (@comm_class) { $total += $i ; }
1908 $global=0; foreach $i (@comm_global_class) { $global += $i ; }
1909 $local=0; foreach $i (@comm_local_class) { $local += $i ; }
1911 print " Sum of classes (should be " . $line_no . "): " . $total .
1912 " (global/local)=(" . $global . "/" . $local . ")\n";
1913 print " Mean value: $mean_comm_perc Std dev: $std_dev_comm_perc\n";
1915 print "\nSparked threads: \n";
1916 print " Intervals: " . join('|',@sparks) . "\n";
1917 print " Total allocs: " . join('|',@spark_class) . "\n";
1919 $total=0; foreach $i (@spark_class) { $total += $i ; }
1921 print " Sum of classes (should be " . $line_no . "): " . $total . "\n";
1922 print " Mean value: $mean_spark Std dev: $std_dev_spark\n";
1924 print "\nHeap Allcoations: \n";
1925 print " Intervals: " . join('|',@has) . "\n";
1926 print " Total allocs: " . join('|',@ha_class) . "\n";
1928 $total=0; foreach $i (@ha_class) { $total += $i ; }
1930 print " Sum of classes (should be " . $line_no . "): " . $total . "\n";
1931 print " Mean value: $mean_ha Std dev: $std_dev_ha\n";
1933 print "CORRELATION between runtimes and heap allocations: $c_exec_ha \n";
1934 print "CORRELATION between runtime and no. of sparks: $c_exec_sp \n";
1935 print "CORRELATION between heap alloc and no. sparks: $c_ha_sp \n";
1936 print "CORRELATION between runtimes and locally sparked threads: $c_exec_lsp \n";
1937 print "CORRELATION between runtimes and globally sparked threads: $c_exec_gsp \n";
1938 print "CORRELATION between heap allocations and locally sparked threads: $c_ha_lsp \n";
1939 print "CORRELATION between heap allocations and globally sparked threads: $c_ha_gsp \n";
1940 print "CORRELATION between runtime and communication time: $c_exec_ft\n";
1941 print "CORRELATION between heap alloc and communication time: $c_ha_ft\n";
1942 print "CORRELATION between no. of local sparks and communication time: $c_lsp_ft\n";
1943 print "CORRELATION between no. of global sparks and communication time: $c_gsp_ft\n";
1948 # ----------------------------------------------------------------------------
1949 # Old (obsolete) stuff
1950 # ----------------------------------------------------------------------------
1953 # $index <= &list_max($#spark_local_class,$#spark_local_class);
1955 # $spark_class[$index] = $spark_local_class[$index] + $spark_global_class[$index];
1958 #for ($index=0, $sum_sp=0;
1959 # $index <= &list_max($#all_local_sparks,$#all_global_sparks);
1961 # $all_sparks[$index] = $all_local_sparks[$index] + $all_global_sparks[$index];
1962 # $sum_sp += $all_sparks[$index];
1965 # ----------------------------------------------------------------------------
1967 #sub compute_delta {
1968 # local (@times) = @_;
1970 # return ($times[$#times] - $times[$#times-1]);
1973 # ----------------------------------------------------------------------------
1976 local ($elem,$val,$n,*list1,*list2) = @_;
1977 local (@small_part, $i, $len);
1980 print "Inserting val $val (with elem $elem) in the following list: \n" .
1981 @list . "\n yields the lists: \n ";
1984 for ($i=0; $i<=$#list2 && $list2[$i]>$val; $i++) { }
1985 $len = $#list2 - $i + 1;
1990 splice(@list1,$i,0,$elem);
1991 splice(@list2,$i,0,$val);
1995 print @list1 . "\n and \n" . @list2;
2000 # ----------------------------------------------------------------------------
2007 if ( $in_header = 9 ) {
2012 $pars = "-b??????"; #
2015 return ($prg, $pars, $nPEs, $lat);
2022 $prg = $1, $pars = $2 if /^Granularity Simulation for\s+(\w+)\s+(.*)$/;
2023 $nPEs = $1 if /^PEs\s+(\d+)/;
2024 $lat = $1, $fetch = $2 if /^Latency\s+(\d+)[^F]+Fetch\s+(\d+)/;
2026 last if /^\+\+\+\+\+/;
2030 # ----------------------------------------------------------------------------
2032 sub write_pie_chart {
2033 local ($rt_perc, $bt_perc, $ft_perc, $it_perc);
2034 local ($title, $title_sz, $label_sz, $x_center, $y_center, $radius);
2036 $PieChart = "/users/fp/hwloidl/grasp/GrAn/bin/PieChart.ps";
2038 $title = "Original Glaswegian Communication Pie (tm)";
2045 open(PIE,">$pie_file_name") || die "$pie_file_name: $!";
2047 print PIE "%!PS-Adobe-2.0\n";
2048 print PIE "%%Title: Pie Chart\n";
2049 print PIE "%%Creator: gran-extr\n";
2050 print PIE "%%CreationDate: Ides of March 44 B.C.\n";
2051 print PIE "%%EndComments\n";
2053 print PIE "% Def of PieChart is taken from:\n";
2054 print PIE "% ($PieChart) run\n";
2057 open(PIE_CHART,"<$PieChart") || die "$PieChart: $!";
2058 while (<PIE_CHART>){
2064 $rt_perc = $tot_rt / $tot_total_rt;
2065 $bt_perc = $tot_bt / $tot_total_rt;
2066 $ft_perc = $tot_ft / $tot_total_rt;
2067 $it_perc = $tot_it / $tot_total_rt;
2069 print PIE "($title) $title_sz $label_sz % Title, title size and label size\n" .
2070 "[ % PS Array of (descrition, percentage [0, .., 1])\n" .
2071 "[(Run Time) $rt_perc]\n" .
2072 "[(Block Time) $bt_perc]\n" .
2073 "[(Fetch Time) $ft_perc]\n" .
2074 "[(Ready Time) $it_perc]\n" .
2075 "] $x_center $y_center $radius DrawPieChart\n";
2076 print PIE "showpage\n";
2081 # ----------------------------------------------------------------------------
2084 local ($in_str) = @_;
2087 $i = rindex($in_str,"/");
2091 $str = substr($in_str,$i+1) ;
2097 # ----------------------------------------------------------------------------
2100 local ($in_str) = @_;
2103 $i = rindex($in_str,"/");
2107 $str = substr($in_str,0,$i+1) ;
2113 # ----------------------------------------------------------------------------