File: aggregate_profile.pl

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (72 lines) | stat: -rwxr-xr-x 1,887 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -w

#
# Copyright (c) 2013-2015 The University of Tennessee and The University
#                         of Tennessee Research Foundation.  All rights
#                         reserved.
# Copyright (c) 2013-2015 Inria.  All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

#
# Author Emmanuel Jeannot <emmanuel.jeannot@inria.fr>
#
# This script aggregates the profiles generated by the flush_monitoring function.
# The files need to be in in given format: name_<phase_id>_<process_id>
# They are then aggregated by phases.
# If one needs the profile of all the phases he can concatenate the different files,
# or use the output of the monitoring system done at MPI_Finalize
# in the example it should be call as:
# ./aggregate_profile.pl prof/phase to generate
# prof/phase_1.prof
# prof/phase_2.prof
#
# ensure that this script as the executable right: chmod +x ...
#

die "$0 <name of the  profile>\n\tProfile files should be of the form  \"name_phaseid_processesid.prof\"\n\tFor instance if you saved the monitoring into phase_0.0.prof, phase_0.1.prof, ..., phase_1.0.prof etc you should call: $0 phase\n" if ($#ARGV!=0);

$name = $ARGV[0];

@files = glob ($name."*");

%phaseid = ();


# Detect the different phases
foreach $file (@files) {
  ($id)=($file =~ m/$name\_(\d+)\.\d+/);
  $phaseid{$id} = 1 if ($id);
}

# for each phases aggregate the files
foreach $id (sort {$a <=> $b} keys %phaseid) {
  aggregate($name."_".$id);
}




sub aggregate{
  $phase = $_[0];
 #Aggregating all files of given phase in files array.This should be done
 # before creating $phase.prof to avoid adding $phase.prof to files array
  @files = glob ($phase."*");
  print "Building $phase.prof\n";

  open OUT,">$phase.prof";


  foreach $file ( @files) {
    open IN,$file;
    while (<IN>) {
      print OUT;
    }
    close IN;
  }
  close OUT;
}