instr (1158309), страница 2
Текст из файла (страница 2)
The argument specifies whatfunctions are instrumented (include) and which are not (exclude). The argument hasD R A F T 0.26Instrumenting pC++September 8, 1993basically two forms: Either it is “file”, “class”, or “function” followed by a nameor it is a qualified name. “file” and “class” can be used to exclude/include allfunctions declared in one file or class. Name can be either a fixed identifier or a regularexpression in angle brackets (see regexp(3)).QualifiedName:Name“:”Name“::”NameFIGURE 6. Syntax Diagram for “QualifiedName”A qualified name can be used to specify complex combinations.
It consists of a file namepart followed by a colon, a class name part followed by a double colon, and a functionname part. Each part of the qualified name can be empty. Also, like above, fixed identifiersor regular expressions in angle brackets can be used for each name part. Lets discuss someexamples:# exclude all functions in filenames ending with “.h”exclude file <\.h$># exclude all member functions declared in classes# Note that an empty regular expression matches alwaysexclude class <># exclude all functions which represent operators# i.e., name doesn’t start with a letterexclude function <^[^A-Za-z]># include all functions of class “kernel”# which contain “local” in their nameinclude kernel::<local># exclude all functions starting with a capitol letter# declared in C++ filesexclude <(\.C|\.cc)$>:<^[A-Z]>FIGURE 7.
Examples of Instrumentation CommandsThe order of the instrumentation commands in the file doesn’t matter. First of all, theinstrumentor determines the start set of functions to instrument by processing all includecommands. If there are no include commands, all functions in the source files areincluded.
Next, the exclude commands are evaluated against the start set. The remainingfunctions are finally instrumented using the profiling approach described above.D R A F T 0.27Instrumenting pC++3.3September 8, 1993Instrumentor Command Line SwitchesThe instrumentor is implemented as a stand-alone program and can be invoked by typing“instr” followed by the name of a .dep file. The .dep files can be generated by invoking“pc++ –deponly sourcefiles”. The instrumentor recognizes the followingoptions, which can be used to alter the default behavior:-h or -helpPrint help information (long version of usage information includingexplanation)-u or -usagePrint usage information-v or -verboseTurn on verbose mode-debugPrint useful debugging information-p or -profileInsert special code for direct profiling instead of instrumenting fortrace-based profiling(-c or -commands) comfileRead instrumentation command file comfile.
Thisoption can be used repeatedly to specify more than one commandfile. It is recommended to use “.prf” as suffix for instrumentationcommand files.(-t or -tdl) tdlfile Generate TDL description file tdlfile. It is recommended to usethe suffix “.tdl” for TDL description files.(-e or -edf) edffile Generate event description file edffile. It is recommended touse the suffix “.edf” for event description files.(-o or -output) outfile Output the modified (instrumented) syntax tree into the.dep file named outfile. By default, instr overwrites the original .depinput file.The resulting modified .dep file can be unparsed to C++ using “dep2C++” or“unparse”. In general, the instrumentor will be called automatically from the pC++compiler (see next subsection).3.4Integration into the pC++ EnvironmentThis subsection describes the commands and tools which can be used to run directprofiling or trace-based profiling versions of pC++ programs.3.4.1 pc++If the pC++ compiler pc++ is called with the -profile or -trace option, itautomatically calls the instrumentor with the right flags to do all the necessary direct ortrace-based function profiling instrumentation.
Pc++ uses a system and a userinstrumentation command file. The system instrumentation command file is located at“$(SAGEROOT)/target/include/sysinstr.prf”. It may be empty. If there isa file with the same filename as the pC++ source program, but with the suffix “.prf”instead of “.pc”, it is assumed that it is a user level instrumentation command file andalso passed to the instrumentor.D R A F T 0.28Instrumenting pC++September 8, 1993Also, pc++ includes the necessary header files (“profiler.h” for profiling or“se_event.h” and “tracer.h” for tracing) automatically in the pC++ sourceprogram.
Finally, it invokes the instrumentor which performs all necessaryinstrumentations and also generates a function symbol file or a TDL and EDF descriptionfile respectively. The function symbol file is named “profile.ftab“. The TDL andEDF files will have the same basename as the pC++ input source file but with the suffix“.tdl” and “.edf” respectively.3.4.2 MAKEThe MAKE utility provides an user-friendly and convenient way of compiling pC++programs.
It can be used by typing MAKE <MachineName>. If the MachineName isprefixed with “prf-” or “trc-” profiling or tracing versions of the program aregenerated respectively. The following MachineNames are supported:• Profiling: uniproc, symmetry, tc2000, ksr, paragon, cm5• Tracing: uniproc, symmetry, tc2000, ksrMAKE calls first pc++ with the necessary options, then uses the target’s machine C++compiler to generate the executable.
There are also instrumented versions of the pC++Kernel files and runtime system, both for direct and trace-based profiling. In addition tothe instrumentation of user level functions, they provide profiling of runtime systemfunctions1 and collection access. In using MAKE, these special kernels are used in thelinking phase.3.4.3 pprofPprof is the parallel profile printing tool for pC++ profile datafiles.The output of pprof issimilar to the normal UNIX prof tool. In addition, it prints a function profile for each nodeand also some collection data access statistics.
Also, it prints a function profile summary(mean and sum) and collection data access summary for the whole parallel execution. Thecolumns of the function profile table have the following meaning:%timemsectotal msec#callsusec/callname1.The percentage of the total running time of the main program(Processor_Main) used by this function (on the specified node).The number of milliseconds accounted for by this function alone.A running sum of the number of milliseconds accounted for by thisfunction and all its childs (functions which are called within thecurrent function).The number of times this function was invoked.The average number of microseconds spent in this function per call.The name of the function.At the moment, only the Barrier runtime function is profiled.
Future versions will include more routines.D R A F T 0.29Instrumenting pC++September 8, 1993Figure 8 shows the output of pprof of the UNIX uniprocessor version of the pC++ Simplebenchmark:NODE 0:-----------------------------------------------------totalusec/%time msec msec #callcall name-----------------------------------------------------100.0571861 186694 Processor_Main69.055128642014 MyCollection::phello39.37373641148 MyElement::hello0.000318 Barrier0.000116 MyCollection::MyColl.localaccesses320remoteaccesses0collectionnumname0XCOLLECTION SUMMARY:-----------------------------------------------------MyCollection<MyElement> X, collection #064 elements of size 16, 1-dimensional320 local / 0 remote accessesFIGURE 8.
Examples of pprof outputIf a pC++ program compiled with the profiling option is executed, there will be a profiledata file for each node the program was executed on. The profile data files will have namesof the form profile.<NodeId>. If pprof is called without a parameter, it will lookfor all profile data files in the current directory and print profiles for all of them. But it isalso possible to restrict the printing by specifying a list of node identifications.
In additionto the normal parameters, pprof supports the following command line options:-c | -m | -t-r-s-n numThe mutually exclusive options c, m, and t determine the type ofsorting of the output lines of the function profile. Sort by decreasingnumber of calls (-c), by decreasing time in milliseconds (-m), or bydecreasing percentage of total time (-t) is supported. Sort by totaltime is the default.Reverse the order of sort to get reverse (ascending) order orsmallest value first.Print only the summary profile information.Print only the first num functions.D R A F T 0.210Instrumenting pC++September 8, 19933.4.4 Trace AnalysisCurrently, tracing of pC++ programs is restricted to pC++ ports to shared-memory parallelcomputer systems (Sequent Symmetry, BBN Butterfly, Kendall Square KSR-1) and theuniprocessor UNIX version.
The port of the event tracing package to distributed memorymachines is under way. Also, the pC++ programming environment does not yet containany performance analysis or visualization tools. However, there are already some utilitytools available that allow to analyze the resulting event traces with the help of externallyavailable event trace analysis tools. Trace analysis involves several steps:(1)Merging: If a pC++ program compiled with the tracing option is executed, there willbe an event trace for each node the program was executed on. The trace files willhave names of the form <MachineName>.<NodeId>.trc. These single nodetraces have to be merged into one global event trace, i.e., all event records have to beordered according to increasing timestamps.