darshan-job-summary.pl 19.9 KB
Newer Older
1
#!/usr/bin/perl -w
2 3 4 5 6
#
#  (C) 2009 by Argonne National Laboratory.
#      See COPYRIGHT in top-level directory.
#

7 8
use FindBin;
use lib "$FindBin::Bin/../lib/";
9 10
use TeX::Encode;
use Encode;
11 12
use File::Temp qw/ tempdir /;
use Cwd;
13 14
use Getopt::Long;
use English;
15 16 17 18

my $gnuplot = "";

my $tmp_dir = tempdir( CLEANUP => 1 );
19 20 21
#my $tmp_dir = tempdir( CLEANUP => 0 );
#print "tmp dir: $tmp_dir\n";

22
my $orig_dir = getcwd;
23 24
my $output_file = "summary.pdf";
my $input_file = "";
25 26
my %access_hash = ();
my @access_size = ();
27

28 29 30
process_args();

open(TRACE, $input_file) || die("can't open $input_file for processing: $!\n");
31 32
open(FA_READ, ">$tmp_dir/file-access-read.dat") || die("error opening output file: $!\n");
open(FA_WRITE, ">$tmp_dir/file-access-write.dat") || die("error opening output file: $!\n");
33 34
open(FA_READ_SH, ">$tmp_dir/file-access-read-sh.dat") || die("error opening output file: $!\n");
open(FA_WRITE_SH, ">$tmp_dir/file-access-write-sh.dat") || die("error opening output file: $!\n");
35 36 37

my $last_read_start = 0;
my $last_write_start = 0;
38

39 40 41 42 43 44 45 46 47 48 49 50
my $cumul_read_indep = 0;
my $cumul_read_bytes_indep = 0;

my $cumul_write_indep = 0;
my $cumul_write_bytes_indep = 0;

my $cumul_read_shared = 0;
my $cumul_read_bytes_shared = 0;

my $cumul_write_shared = 0;
my $cumul_write_bytes_shared = 0;

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
while ($line = <TRACE>) {
    chop($line);
    
    if ($line =~ /^\s*$/) {
        # ignore blank lines
    }
    elsif ($line =~ /^#/) {
	if ($line =~ /^# exe: /) {
	    ($junk, $cmdline) = split(':', $line, 2);
            # add escape characters if needed for special characters in
            # command line
            $cmdline = encode('latex', $cmdline);
	}
	if ($line =~ /^# nprocs: /) {
	    ($junk, $nprocs) = split(':', $line, 2);
	    $procreads[$nprocs] = 0;
	}
	if ($line =~ /^# run time: /) {
	    ($junk, $runtime) = split(':', $line, 2);
	}
	if ($line =~ /^# start_time: /) {
	    ($junk, $starttime) = split(':', $line, 2);
	}
	if ($line =~ /^# uid: /) {
	    ($junk, $uid) = split(':', $line, 2);
	}
    }
    else {
	@fields = split(/[\t ]+/, $line);
	$summary{$fields[2]} += $fields[3];

	# record per-process POSIX read count
	if ($fields[2] eq "CP_POSIX_READS") {
	    if ($fields[0] == -1) {
		$procreads[$nprocs] += $fields[3];
	    }
	    else {
		$procreads[$fields[0]] += $fields[3];
	    }
	}

	# record per-proces POSIX write count
	if ($fields[2] eq "CP_POSIX_WRITES") {
	    if ($fields[0] == -1) {
		$procwrites[$nprocs] += $fields[3];
	    }
	    else {
		$procwrites[$fields[0]] += $fields[3];
	    }
	}

102
        # seperate accumulators for independent and shared reads and writes
Philip Carns's avatar
Philip Carns committed
103
        if ($fields[2] eq "CP_F_POSIX_READ_TIME" && $fields[0] == -1){
104 105
            $cumul_read_shared += $fields[3];
        }
Philip Carns's avatar
Philip Carns committed
106
        if ($fields[2] eq "CP_F_POSIX_READ_TIME" && $fields[0] != -1){
107 108
            $cumul_read_indep += $fields[3];
        }
Philip Carns's avatar
Philip Carns committed
109
        if ($fields[2] eq "CP_F_POSIX_WRITE_TIME" && $fields[0] == -1){
110 111
            $cumul_write_shared += $fields[3];
        }
Philip Carns's avatar
Philip Carns committed
112
        if ($fields[2] eq "CP_F_POSIX_WRITE_TIME" && $fields[0] != -1){
113 114 115
            $cumul_write_indep += $fields[3];
        }

Philip Carns's avatar
Philip Carns committed
116
        if ($fields[2] eq "CP_BYTES_READ" && $fields[0] == -1){
117 118
            $cumul_read_bytes_shared += $fields[3];
        }
Philip Carns's avatar
Philip Carns committed
119
        if ($fields[2] eq "CP_BYTES_READ" && $fields[0] != -1){
120 121
            $cumul_read_bytes_indep += $fields[3];
        }
Philip Carns's avatar
Philip Carns committed
122
        if ($fields[2] eq "CP_BYTES_WRITTEN" && $fields[0] == -1){
123 124
            $cumul_write_bytes_shared += $fields[3];
        }
Philip Carns's avatar
Philip Carns committed
125
        if ($fields[2] eq "CP_BYTES_WRITTEN" && $fields[0] != -1){
126 127 128
            $cumul_write_bytes_indep += $fields[3];
        }

129 130 131 132 133 134 135 136 137 138 139 140 141 142
        # record start and end of reads and writes

        if ($fields[2] eq "CP_F_READ_START_TIMESTAMP") {
            # store until we find the end
            # adjust for systems that give absolute time stamps
            $last_read_start = $fields[3];
        }
        if ($fields[2] eq "CP_F_READ_END_TIMESTAMP" && $fields[3] != 0) {
            # assume we got the read start already 
            my $xdelta = $fields[3] - $last_read_start;
            # adjust for systems that have absolute time stamps 
            if($last_read_start > $starttime) {
                $last_read_start -= $starttime;
            }
143 144 145 146 147 148
            if($fields[0] == -1){
                print FA_READ_SH "$last_read_start\t0\t$xdelta\t0\n";
            }
            else{
                print FA_READ "$last_read_start\t$fields[0]\t$xdelta\t0\n";
            }
149 150 151 152 153 154 155 156 157 158 159 160
        }
        if ($fields[2] eq "CP_F_WRITE_START_TIMESTAMP") {
            # store until we find the end
            $last_write_start = $fields[3];
        }
        if ($fields[2] eq "CP_F_WRITE_END_TIMESTAMP" && $fields[3] != 0) {
            # assume we got the write start already 
            my $xdelta = $fields[3] - $last_write_start;
            # adjust for systems that have absolute time stamps 
            if($last_write_start > $starttime) {
                $last_write_start -= $starttime;
            }
161 162 163 164 165 166
            if($fields[0] == -1){
                print FA_WRITE_SH "$last_write_start\t0\t$xdelta\t0\n";
            }
            else{
                print FA_WRITE "$last_write_start\t$fields[0]\t$xdelta\t0\n";
            }
167 168
        }

169 170
        if ($fields[2] =~ /^CP_ACCESS(.)_ACCESS/) {
            $access_size[$1] = $fields[3];
171
        }
172 173 174 175
        if ($fields[2] =~ /^CP_ACCESS(.)_COUNT/) {
            my $tmp_access_size = $access_size[$1];
            if(defined $access_hash{$tmp_access_size}){
                $access_hash{$tmp_access_size} += $fields[3];
176
            }
177 178
            else{
                $access_hash{$tmp_access_size} = $fields[3];
179 180 181 182 183
            }
        }
    }
}

184 185 186 187
# Fudge one point at the end to make xrange match in read and write plots.
# For some reason I can't get the xrange command to work.  -Phil
print FA_READ "$runtime\t-1\t0\t0\n";
print FA_WRITE "$runtime\t-1\t0\t0\n";
188 189
print FA_READ_SH "$runtime\t0\t0\t0\n";
print FA_WRITE_SH "$runtime\t0\t0\t0\n";
190 191
close(FA_READ);
close(FA_WRITE);
192 193
close(FA_READ_SH);
close(FA_WRITE_SH);
194

195
# counts of operations
196
open(COUNTS, ">$tmp_dir/counts.dat") || die("error opening output file: $!\n");
197 198
print COUNTS "# P=POSIX, MI=MPI-IO indep., MC=MPI-IO coll., R=read, W=write\n";
print COUNTS "# PR, MIR, MCR, PW, MIW, MCW, Popen, Pseek, Pstat\n";
199
my $total_syncs = $summary{CP_POSIX_FSYNCS} + $summary{CP_POSIX_FDSYNCS};
200 201 202 203 204 205 206 207
print COUNTS "Read, ", $summary{CP_POSIX_READS}, ", ",
    $summary{CP_INDEP_READS}, ", ", $summary{CP_COLL_READS}, "\n",
    "Write, ", $summary{CP_POSIX_WRITES}, ", ", 
    $summary{CP_INDEP_WRITES}, ", ", $summary{CP_COLL_WRITES}, "\n",
    "Open, ", $summary{CP_POSIX_OPENS}, ", ", $summary{CP_INDEP_OPENS},", ",
    $summary{CP_COLL_OPENS}, "\n",
    "Stat, ", $summary{CP_POSIX_STATS}, ", 0, 0\n",
    "Seek, ", $summary{CP_POSIX_SEEKS}, ", 0, 0\n",
208 209
    "Mmap, ", $summary{CP_POSIX_MMAPS}, ", 0, 0\n",
    "Fsync, ", $total_syncs, ", 0, 0\n";
210 211 212
close COUNTS;

# histograms of reads and writes
213
open (HIST, ">$tmp_dir/hist.dat") || die("error opening output file: $!\n");
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
print HIST "# size_range read write\n";
print HIST "0-100, ", $summary{CP_SIZE_READ_0_100}, ", ",
                 $summary{CP_SIZE_WRITE_0_100}, "\n";
print HIST "101-1K, ", $summary{CP_SIZE_READ_100_1K}, ", ",
                 $summary{CP_SIZE_WRITE_100_1K}, "\n";
print HIST "1K-10K, ", $summary{CP_SIZE_READ_1K_10K}, ", ",
                 $summary{CP_SIZE_WRITE_1K_10K}, "\n";
print HIST "10K-100K, ", $summary{CP_SIZE_READ_10K_100K}, ", ",
                 $summary{CP_SIZE_WRITE_10K_100K}, "\n";
print HIST "100K-1M, ", $summary{CP_SIZE_READ_100K_1M}, ", ",
                 $summary{CP_SIZE_WRITE_100K_1M}, "\n";
print HIST "1M-4M, ", $summary{CP_SIZE_READ_1M_4M}, ", ",
                 $summary{CP_SIZE_WRITE_1M_4M}, "\n";
print HIST "4M-10M, ", $summary{CP_SIZE_READ_4M_10M}, ", ",
                 $summary{CP_SIZE_WRITE_4M_10M}, "\n";
print HIST "10M-100M, ", $summary{CP_SIZE_READ_10M_100M}, ", ",
                 $summary{CP_SIZE_WRITE_10M_100M}, "\n";
print HIST "100M-1G, ", $summary{CP_SIZE_READ_100M_1G}, ", ",
                 $summary{CP_SIZE_WRITE_100M_1G}, "\n";
print HIST "1G+, ", $summary{CP_SIZE_READ_1G_PLUS}, ", ",
                 $summary{CP_SIZE_WRITE_1G_PLUS}, "\n";
close HIST;

# sequential and consecutive accesses
238
open (PATTERN, ">$tmp_dir/pattern.dat") || die("error opening output file: $!\n");
239 240 241 242 243 244 245 246
print PATTERN "# op total sequential consecutive\n";
print PATTERN "Read, ", $summary{CP_POSIX_READS}, ", ",
    $summary{CP_SEQ_READS}, ", ", $summary{CP_CONSEC_READS}, "\n";
print PATTERN "Write, ", $summary{CP_POSIX_WRITES}, ", ",
    $summary{CP_SEQ_WRITES}, ", ", $summary{CP_CONSEC_WRITES}, "\n";
close PATTERN;

# aligned I/O
247
open (ALIGN, ">$tmp_dir/align.dat") || die("error opening output file: $!\n");
248 249 250 251 252 253
print ALIGN "# total unaligned_mem unaligned_file align_mem align_file\n";
print ALIGN $summary{CP_POSIX_READS} + $summary{CP_POSIX_WRITES}, ", ",
    $summary{CP_MEM_NOT_ALIGNED}, ", ", $summary{CP_FILE_NOT_ALIGNED}, "\n";
close ALIGN;

# MPI types
254
open (TYPES, ">$tmp_dir/types.dat") || die("error opening output file: $!\n");
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
print TYPES "# type use_count\n";
print TYPES "Named, ", $summary{CP_COMBINER_NAMED}, "\n";
print TYPES "Dup, ", $summary{CP_COMBINER_DUP}, "\n";
print TYPES "Contig, ", $summary{CP_COMBINER_CONTIGUOUS}, "\n";
print TYPES "Vector, ", $summary{CP_COMBINER_VECTOR}, "\n";
print TYPES "HvecInt, ", $summary{CP_COMBINER_HVECTOR_INTEGER}, "\n";
print TYPES "Hvector, ", $summary{CP_COMBINER_HVECTOR}, "\n";
print TYPES "Indexed, ", $summary{CP_COMBINER_INDEXED}, "\n";
print TYPES "HindInt, ", $summary{CP_COMBINER_HINDEXED_INTEGER}, "\n";
print TYPES "Hindexed, ", $summary{CP_COMBINER_HINDEXED}, "\n";
print TYPES "IndBlk, ", $summary{CP_COMBINER_INDEXED_BLOCK}, "\n";
print TYPES "StructInt, ", $summary{CP_COMBINER_STRUCT_INTEGER}, "\n";
print TYPES "Struct, ", $summary{CP_COMBINER_STRUCT}, "\n";
print TYPES "Subarray, ", $summary{CP_COMBINER_SUBARRAY}, "\n";
print TYPES "Darray, ", $summary{CP_COMBINER_DARRAY}, "\n";
print TYPES "F90Real, ", $summary{CP_COMBINER_F90_REAL}, "\n";
print TYPES "F90Complex, ", $summary{CP_COMBINER_F90_COMPLEX}, "\n";
print TYPES "F90Int, ", $summary{CP_COMBINER_F90_INTEGER}, "\n";
print TYPES "Resized, ", $summary{CP_COMBINER_RESIZED}, "\n";
close TYPES;

# generate histogram of process I/O counts
#
# NOTE: NEED TO FILL IN ACTUAL WRITE DATA!!!
#
$minprocread = (defined $procreads[0]) ? $procreads[0] : 0;
$maxprocread = (defined $procreads[0]) ? $procreads[0] : 0;
for ($i=1; $i < $nprocs; $i++) {
    $rdi = (defined $procreads[$i]) ? $procreads[$i] : 0;
    $minprocread = ($rdi > $minprocread) ? $minprocread : $rdi;
    $maxprocread = ($rdi < $maxprocread) ? $maxprocread : $rdi;
}
$minprocread += $procreads[$nprocs];
$maxprocread += $procreads[$nprocs];
# print "$minprocread $maxprocread\n";

@bucket = ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );

for ($i=0; $i < $nprocs; $i++) {
    $mysize = ((defined $procreads[$i]) ? $procreads[$i] : 0) +
	$procreads[$nprocs];
    $mysize -= $minprocread;
    $mybucket = ($mysize > 0) ?
	(($mysize * 10) / ($maxprocread - $minprocread)) : 0;
    $bucket[$mybucket]++;
}

302
open(IODIST, ">$tmp_dir/iodist.dat") || die("error opening output file: $!\n");
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
print IODIST "# bucket n_procs_rd n_procs_wr\n";
print IODIST "# NOTE: WRITES ARE A COPY OF READS FOR NOW!!!\n";

$bucketsize = $maxprocread - $minprocread / 10;
# TODO: do writes also, is dropping a 0 in for now
for ($i=0; $i < 10; $i++) {
    print IODIST $bucketsize * $i + $minprocread, "-",
    $bucketsize * ($i+1) + $minprocread, ", ", $bucket[$i], ", 0\n";
}
close IODIST;

# generate title for summary
($executable, $junk) = split(' ', $cmdline, 2);
@parts = split('/', $executable);
$cmd = $parts[$#parts];

@timearray = localtime($starttime);
$year = $timearray[5] + 1900;
$mon = $timearray[4] + 1;
$mday = $timearray[3];

324
open(TITLE, ">$tmp_dir/title.tex") || die("error opening output file:$!\n");
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
print TITLE "
\\rhead{\\thepage\\ of \\pageref{LastPage}}
\\chead[
\\large $cmd ($mon/$mday/$year)
]
{
\\large $cmd ($mon/$mday/$year)
}
\\cfoot[
\\scriptsize{$cmdline}
]
{
\\scriptsize{$cmdline}
}
";
close TITLE;

342
open(TABLES, ">$tmp_dir/job-table.tex") || die("error opening output file:$!\n");
343 344 345 346 347 348 349 350 351
print TABLES "
\\begin{tabular}{|p{.63\\columnwidth}|p{.63\\columnwidth}|p{.63\\columnwidth}|}
\\hline
uid: $uid \& nprocs: $nprocs \& runtime: $runtime seconds\\\\
\\hline
\\end{tabular}
";
close TABLES;

352
open(TABLES, ">$tmp_dir/access-table.tex") || die("error opening output file:$!\n");
353
print TABLES "
Philip Carns's avatar
Philip Carns committed
354
\\begin{tabular}{r|r}
355
\\multicolumn{2}{c}{Most Common Access Sizes} \\\\
356 357 358
\\hline
access size \& count \\\\
\\hline
Philip Carns's avatar
Philip Carns committed
359
\\hline
360 361
";

362 363
# sort access sizes (descending)
my $i = 0;
364 365
foreach $value (sort {$access_hash{$b} <=> $access_hash{$a} } keys %access_hash) {
    if($i == 4) {
366 367 368 369 370 371 372 373 374
        last;
    }
    if($access_hash{$value} == 0) {
        last;
    }
    print TABLES "$value \& $access_hash{$value} \\\\\n";
    $i++;
}

375 376 377 378 379 380
print TABLES "
\\hline
\\end{tabular}
";
close TABLES;

381
open(TIME, ">$tmp_dir/time-summary.dat") || die("error opening output file:$!\n");
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
print TIME "# <type>, <app time>, <read>, <write>, <meta>\n";
print TIME "POSIX, ", ((($runtime * $nprocs - $summary{CP_F_POSIX_READ_TIME} -
    $summary{CP_F_POSIX_WRITE_TIME} -
    $summary{CP_F_POSIX_META_TIME})/($runtime * $nprocs)) * 100);
print TIME ", ", (($summary{CP_F_POSIX_READ_TIME}/($runtime * $nprocs))*100);
print TIME ", ", (($summary{CP_F_POSIX_WRITE_TIME}/($runtime * $nprocs))*100);
print TIME ", ", (($summary{CP_F_POSIX_META_TIME}/($runtime * $nprocs))*100), "\n";
print TIME "MPI-IO, ", ((($runtime * $nprocs - $summary{CP_F_MPI_READ_TIME} -
    $summary{CP_F_MPI_WRITE_TIME} -
    $summary{CP_F_MPI_META_TIME})/($runtime * $nprocs)) * 100);
print TIME ", ", (($summary{CP_F_MPI_READ_TIME}/($runtime * $nprocs))*100);
print TIME ", ", (($summary{CP_F_MPI_WRITE_TIME}/($runtime * $nprocs))*100);
print TIME ", ", (($summary{CP_F_MPI_META_TIME}/($runtime * $nprocs))*100), "\n";
close TIME;

397
# copy template files to tmp tmp_dir
Philip Carns's avatar
Philip Carns committed
398 399
system "cp $FindBin::Bin/../share/*.gplt $tmp_dir/";
system "cp $FindBin::Bin/../share/*.tex $tmp_dir/";
400

401 402 403 404 405 406 407
# generate template for file access plot (we have to set range)
my $ymax = $nprocs + 1;
open(FILEACC, ">$tmp_dir/file-access-read-eps.gplt") || die("error opening output file:$!\n");
print FILEACC "#!/usr/bin/gnuplot -persist

set terminal postscript eps color solid font \"Helvetica\" 18 size 10in,2.5in
set output \"file-access-read.eps\"
408 409
set ylabel \"MPI rank\"
set xlabel \"hours:minutes:seconds\"
410 411 412
set xdata time
set timefmt \"%s\"
set format x \"%H:%M:%S\"
413
set yrange [-1:$ymax]
Philip Carns's avatar
Philip Carns committed
414
set title \"Timespan from first to last read access on independent files\"
415 416 417
# the xrange doesn't work for some reason
#set xrange [0:$runtime]
#set ytics -1,1
418
set lmargin 4
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437

# color blindness work around
set style line 2 lc 3
set style line 3 lc 4
set style line 4 lc 5
set style line 5 lc 2
set style increment user

# lw 3 to make lines thicker...
# note that writes are slightly offset for better visibility
plot \"file-access-read.dat\" using 1:2:3:4 with vectors nohead filled notitle
";
close FILEACC;

open(FILEACC, ">$tmp_dir/file-access-write-eps.gplt") || die("error opening output file:$!\n");
print FILEACC "#!/usr/bin/gnuplot -persist

set terminal postscript eps color solid font \"Helvetica\" 18 size 10in,2.5in
set output \"file-access-write.eps\"
438 439
set ylabel \"MPI rank\"
set xlabel \"hours:minutes:seconds\"
440 441 442
set xdata time
set timefmt \"%s\"
set format x \"%H:%M:%S\"
Philip Carns's avatar
Philip Carns committed
443
set title \"Timespan from first to last write access on independent files\"
444
set yrange [-1:$ymax]
445 446 447
# the xrange doesn't work for some reason
# set xrange [0:$runtime]
#set ytics -1,1
448
set lmargin 4
449 450 451 452 453 454 455 456 457 458 459 460 461

# color blindness work around
set style line 2 lc 3
set style line 3 lc 4
set style line 4 lc 5
set style line 5 lc 2
set style increment user

# lw 3 to make lines thicker...
plot \"file-access-write.dat\" using 1:2:3:4 with vectors nohead filled lt 2 notitle
";
close FILEACC;

462 463 464 465 466 467 468 469 470 471
open(FILEACC, ">$tmp_dir/file-access-shared-eps.gplt") || die("error opening output file:$!\n");
print FILEACC "#!/usr/bin/gnuplot -persist

set terminal postscript eps color solid font \"Helvetica\" 18 size 10in,2.5in
set output \"file-access-shared.eps\"
set xlabel \"hours:minutes:seconds\"
set xdata time
set timefmt \"%s\"
set format x \"%H:%M:%S\"
unset ytics
472
set ylabel \"All processes\"
473 474 475
# the xrange doesn't work for some reason
# set xrange [0:$runtime]
set yrange [-1:1]
Philip Carns's avatar
Philip Carns committed
476
set title \"Timespan from first to last access on files shared by all processes\"
477
set lmargin 4
478 479 480 481 482 483 484 485 486 487 488 489 490

# color blindness work around
set style line 2 lc 3
set style line 3 lc 4
set style line 4 lc 5
set style line 5 lc 2
set style increment user

plot \"file-access-read-sh.dat\" using 1:2:3:4 with vectors nohead filled lw 10 title \"read\", \\
\"file-access-write-sh.dat\" using 1:((\$2)-.2):3:4 with vectors nohead filled lw 10 title \"write\"
";
close FILEACC;

491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
$cumul_read_indep /= $nprocs;
$cumul_read_bytes_indep /= $nprocs;
$cumul_read_bytes_indep /= 1048576.0;

$cumul_write_indep /= $nprocs;
$cumul_write_bytes_indep /= $nprocs;
$cumul_write_bytes_indep /= 1048576.0;

$cumul_read_shared /= $nprocs;
$cumul_read_bytes_shared /= $nprocs;
$cumul_read_bytes_shared /= 1048576.0;

$cumul_write_shared /= $nprocs;
$cumul_write_bytes_shared /= $nprocs;
$cumul_write_bytes_shared /= 1048576.0;

open(FILEACC, ">$tmp_dir/file-access-table.tex") || die("error opening output file:$!\n");
508
print FILEACC "
Philip Carns's avatar
Philip Carns committed
509 510 511 512
\\begin{tabular}{l|p{1.7in}r}
\\multicolumn{3}{c}{Average I/O per process} \\\\
\\hline
 \& Cumulative time spent in I/O functions (seconds) \& Amount of I/O (MB) \\\\
513 514
\\hline
\\hline
Philip Carns's avatar
Philip Carns committed
515 516
";

Philip Carns's avatar
Philip Carns committed
517 518 519 520 521 522 523 524 525
# printf to get consistent precision in output
printf(FILEACC "Independent reads \& \\multicolumn{1}{r}{%f} \& \\multicolumn{1}{r}{%f} \\\\", 
    $cumul_read_indep, $cumul_read_bytes_indep);
printf(FILEACC "Independent writes \& \\multicolumn{1}{r}{%f} \& \\multicolumn{1}{r}{%f} \\\\", 
    $cumul_write_indep, $cumul_write_bytes_indep);
printf(FILEACC "Shared reads \& \\multicolumn{1}{r}{%f} \& \\multicolumn{1}{r}{%f} \\\\", 
    $cumul_read_shared, $cumul_read_bytes_shared);
printf(FILEACC "Shared writes \& \\multicolumn{1}{r}{%f} \& \\multicolumn{1}{r}{%f} \\\\", 
    $cumul_write_shared, $cumul_write_bytes_shared);
Philip Carns's avatar
Philip Carns committed
526 527

print FILEACC "
528 529 530
\\hline
\\end{tabular}
";
531 532
close(FILEACC);

533 534 535 536 537 538 539 540 541 542 543 544
if(-x "$FindBin::Bin/gnuplot")
{
    $gnuplot = "$FindBin::Bin/gnuplot";
}
else
{
    $gnuplot = "gnuplot";
}

# move to tmp_dir
chdir $tmp_dir;

545
# execute gnuplot scripts
546
system "$gnuplot counts-eps.gplt";
547
system "epstopdf counts.eps";
548
system "$gnuplot hist-eps.gplt";
549
system "epstopdf hist.eps";
550
system "$gnuplot pattern-eps.gplt";
551
system "epstopdf pattern.eps";
552
system "$gnuplot time-summary-eps.gplt";
553
system "epstopdf time-summary.eps";
554 555 556 557
system "$gnuplot file-access-read-eps.gplt";
system "epstopdf file-access-read.eps";
system "$gnuplot file-access-write-eps.gplt";
system "epstopdf file-access-write.eps";
558 559
system "$gnuplot file-access-shared-eps.gplt";
system "epstopdf file-access-shared.eps";
560

561 562 563 564
#system "gnuplot align-pdf.gplt";
#system "gnuplot iodist-pdf.gplt";
#system "gnuplot types-pdf.gplt";

565 566 567 568
# generate summary PDF
system "pdflatex -halt-on-error summary.tex > latex.output";
system "pdflatex -halt-on-error summary.tex > latex.output2";

569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
# get back out of tmp dir and grab results
chdir $orig_dir;
system "mv $tmp_dir/summary.pdf $output_file";

sub process_args
{
    use vars qw( $opt_help $opt_output );

    Getopt::Long::Configure("no_ignore_case", "bundling");
    GetOptions( "help",
        "output=s");

    if($opt_help)
    {
        print_help();
        exit(0);
    }

    if($opt_output)
    {
        $output_file = $opt_output;
    }

    # there should only be one remaining argument: the input file 
    if($#ARGV != 0)
    {
        print "Error: invalid arguments.\n";
        print_help();
        exit(1);
    }
    $input_file = $ARGV[0];

    return;
}

sub print_help
{
    print <<EOF;

Usage: $PROGRAM_NAME <options> input_file

    --help          Prints this help message
    --output        Specifies a file to write pdf output to
                    (defaults to ./summary.pdf)
Purpose:

    This script reads a Darshan output file in text format (as 
    produced by the darshan-parser utility) and generates a pdf file 
    summarizing job behavior.

EOF
    return;
}