OpenPAT
Original author(s) | Simon Spacey |
---|---|
Initial release | 2006 |
Stable release | 3.0.0 (r1) |
Platform | Cross-platform |
Type | Dynamic program analysis |
License | Free (with some registration and redistribution restrictions) |
Website |
www |
OpenPAT (the Open Performance Analysis Toolkit) is a dynamic trace analysis system that can be used to identify performance bottlenecks,[1] monitor memory usage,[2] for Search-Based Software Engineering[3] and to visualize and model the performance of new High-Performance Computing architectures[4][5][6] and distributed communication methods.[7]
OpenPAT integrates with platform specific compiler chain tools which allows it to remain simple with a core toolkit code base of less than 1000 lines and also to provide cross platform analysis for programs written in any compilable language including native languages like C, C++ and Fortran and languages that compile to bytecodes like Java and C#.[8][9]
History
OpenPAT was created by Simon Spacey in 2006 at Imperial College London and Cambridge University where it was originally called the Spacey Stream Splitter (3S).[10]
3S was renamed OpenPAT in 2011 to coincide with the release of version 3 which was a complete re-write of the code from Python/C to Perl/C to support new features that allowed the software to run on multiple architectures, operating systems and to analyze programs written in a wider range of languages.[8] OpenPAT is now maintained by the OpenPAT.org project and the toolkit is used around the world.[6][9][11][12][13][14][15][16]
Method
The OpenPAT instrumentation process statically inserts stubs at key places in the assembly of a program and then compiles the assembly along with a runtime and a tool to produce an instrumented executable. When the program executes an instrumented section, the inserted stub calls a tool with information about the part of the program being executed. The tool then analyzes the dynamic trace information to produce its reports.
The OpenPAT process is summarized in the diagram and provides the benefits of:
- Simplicity as OpenPAT can offload the work of creating assembly to external programs like GCC or LLVM/Clang and does not require an integrated disassembler like Valgrind and Pin or an AST compiler like SUIF,[17]
- Accuracy because OpenPAT provides real runtime information for the actual dynamic trace the program takes unlike static analysis systems such as SUIF and
- Efficiency as OpenPAT has only a single instrumentation overhead no matter how many times a program is executed unlike dynamic recompilation toolkits such as Valgrind and Pin.
However the basic OpenPAT process has the drawback of being unsuitable for instrumenting some special programs such as viruses and high performance FFT implementations, which can include self-modifying code, and the process requires external libraries to be explicitly instrumented if they are to be analyzed at a fine grained level (note however that OpenPAT does track external interactions at a coarse grained level without explicit library instrumentation).
Features
The OpenPAT introduction presentation[8] lists the following key features for various versions of OpenPAT:
Feature | v0 | v1 | v2 | v3 |
---|---|---|---|---|
Block Traces | ||||
Block Tools | ||||
CPU Timestamp Timings | ||||
Instruction Level DFG Tools (Integer) | ||||
Instruction Level DFG Tools (x87 FPU) | ||||
Static Memory Instrumentation | ||||
Assembly Aspect-oriented programming | ||||
Ranged Instrumentations | ||||
Granularity Features | ||||
Threading Features |
However, the OpenPAT modules that support some of the instruction level features above are currently undergoing internal testing and review and are not publicly available at this time.[18]
Example usage
The OpenPAT distribution comes as a packaged set of source directories including example benchmarks in the ./benchmarks
directory and a set of core tools in the ./tools/core
directory.
To instrument the OpenPAT matrix.c
benchmark with the hotspot
tool you can issue a command like this:
./OpenPAT.pl –t hotspot -o matrix ./benchmarks/matrix.c
which will create an instrumented version of the matrix benchmark called matrix
with the –t
option setting the analysis tool and –o
the name of the instrumented output file (use –h
to list all the OpenPAT command options).
Running the instrumented benchmark with:
./matrix 10
executes the original benchmark program which will multiply two 10x10 matrices for the above command line and a file called hotspot.op
will be created in the current directory with the hotspot analysis results when the benchmark completes.
Example tool
OpenPAT aims to make tool creation simple so that businesses and researchers can focus on tool creation rather than learning a complex toolkit.[8][15]
The tool below (based on the core OpenPAT hotspot
tool) is a simple big O program analysis tool which consists of only six lines of C after boilerplate code.
#define _OP_STUB symbols // set instrumentation stub #include "../../_/runtime/OpenPAT.h" // include the OpenPAT data structures and utilities // Structure for symbol measurements for this tool accessed through _OP_<GET|SET|ADD>_M() typedef struct { uint64_t entries; // number of times a block has been executed } _OP_MEASUREMENT_T; // Called by the OpenPAT runtime once at program initialization void _OP_TOOL_INITIALIZE(int argc, char *argv[], char *env[]) { _OP_INITIALIZE(); // get a measurement slot for this tool from the runtime } // Called with an _OP structure initialized by the stub as code sections execute void _OP_TOOL_ANALYZE(_OP_t *_OP) { _OP_ADD_M(entries, 1); // increment entries for the block just executed } // Called by the OpenPAT runtime on program exit void _OP_TOOL_REPORT(void) { uint64_t max_entries = (uint64_t)0; // a local to be set to the max entries _OP_FOR_CHAIN() { // an OpenPAT macro to loop through measurements max_entries = (_OP_GET_M(entries) > max_entries ? _OP_GET_M(entries) : max_entries); } printf("\nbig-O: %llu\n\n", max_entries); // print max_entries to stdout }
To use the tool we can initialise a new OpenPAT ./tools
directory with the command line cp -r ./tools/core/none/code ./tools/big_O
and paste the above code into the ./tools/big_O/tool.c
file. Then we can instrument the matrix.c
benchmark with the command line:
./OpenPAT.pl -t big_O -o matrix ./benchmarks/matrix.c
and execute the instrumented program with different inputs to obtain maximum code section entry (i.e. loop count) data for a big O implementation complexity analysis. The result of running the instrumented benchmark to multiply two 10x10 matrices with:
./matrix 10
would be the standard matrix.c
benchmark output followed by:
big-O: 1000
because the OpenPAT matrix.c
benchmark implementation is of n3 complexity.
Standard tools
There are a range of free tools that come with the core OpenPAT distribution including:
Tool | Feature Demonstrated | Description |
---|---|---|
hotspot | CPU Timestamp Timings | Reports CPU cycle timing and Valgrind style Instruction Requests for program code sections |
control_flow | Trace Analysis | Shows the internal control flow of a program with a text report and an image created using Graphviz |
coverage | Block Tools | Reports QA test coverage at the basic block level |
override | Assembly Aspect-Oriented Programming | Overrides prints to stdout and stderr so they automatically flush and rings a system bell on writes to stderr |
none | A starting template for creating new tools |
With other key features such as Retargeting and Ranged Instrumentation being demonstrated through included configuration files and benchmarks. Additionally, a number of more advanced tools including trace, data flow and memory analysis tools have been discussed in the literature[2][19] and new tools are being created.[20]
Supported hardware, operating systems and languages
OpenPAT can run the same tools on different hardware, operating systems and program languages making it a Write once, analyze anywhere system. To support this feature, OpenPAT has a set of configuration files for each target environment. The configuration files currently distributed with OpenPAT allow the same tools to analyze programs on the x86 and x86-64 CPUs, the Linux, FreeBSD and OSX operating systems written in any language compiling with GCC or Clang.
Creating new OpenPAT configurations requires writing assembly stubs and regular expressions that map source assembly to OpenPAT instrumentation routines.
The configurations are written in a special format called "parameterized assembly" or .pasm
files and creating new configurations requires knowledge of OpenPAT, regex's, the underlying assembly and calling conventions/ABI.
Several projects exist to create new OpenPAT configurations.[9][20]
License
OpenPAT is free and its source code is provided along with the software for unrestricted internal review and modification. However the license includes a non-redistribution and a registration clause[21] which were added to ensure a standard simple version of OpenPAT remains available for new users and clear contribution attribution is possible.[19]
User created tools can be freely distributed under a user selected license and toolkit feature changes can be distributed as patches if required[19] or through the OpenPAT.org website which is currently being updated to facilitate community communication, tool sharing and knowledge transfer.[13][14][15][16]
See also
References
- ↑ Spacey, S.; Luk, W.; Kuhn, D.; Kelly, P.H.J. (2013). "Parallel Partitioning for Distributed Systems using Sequential Assignment" (PDF). Journal of Parallel and Distributed Computing 73 (2): 207–219. doi:10.1016/j.jpdc.2012.09.019.
- ↑ 2.0 2.1 Spacey, S. (2009). Computational Partitioning for Heterogeneous Systems (Ph.D.). Imperial College London.
- ↑ Mayo, M.; Spacey, S. (2013). Predicting Regression Test Failures Using Genetic Algorithm-Selected Dynamic Performance Analysis Metrics (PDF). Proceedings of the 5th International Symposium on Search-Based Software Engineering (SSBSE) 8084: 158–171.
- ↑ Spacey, S.; Wiesmann, W.; Kuhn, D.; Luk, W. (2012). "Robust Software Partitioning with Multiple Instantiation" (PDF). INFORMS Journal on Computing 24 (3): 500–515. doi:10.1287/ijoc.1110.0467.
- ↑ Schumacher, T. (2011). Performance Modeling and Analysis in High-Performance Reconfigurable Computing (PDF) (Report). The University of Paderborn.
- ↑ 6.0 6.1 Zaidi, A. (2006). Acceleration of Compute Intensive Applications using Compute Unified Device Architecture (CUDA) (PDF) (Report). Imperial College London.
- ↑ Spacey, S.; Luk, W.; Kelly, P.H.J.; Kuhn, D. (2012). "Improving Communication Latency with the Write-Only Architecture" (PDF). Journal of Parallel and Distributed Computing 72 (12): 1617–1627. doi:10.1016/j.jpdc.2012.08.007.
- ↑ 8.0 8.1 8.2 8.3 OpenPAT: Analysing Programs the Easy Way Retrieved 2013-11-05.
- ↑ 9.0 9.1 9.2 Boris Pfahringer. OpenPAT Java Bytecode Retargeting Project Retrieved 2013-11-05.
- ↑ Spacey, S. (2006a). 3S: Program Instrumentation and Characterisation Framework (PDF) (Report). Imperial College London.
- ↑ Countries Using OpenPAT Retrieved 2013-11-06.
- ↑ OpenPAT on the home page of Waikato University's CS Department Retrieved 2013-11-05.
- ↑ 13.0 13.1 OpenPAT lecture at Moscow State University Retrieved 2013-11-05.
- ↑ 14.0 14.1 OpenPAT lecture at the National University of Singapore Retrieved 2013-11-05.
- ↑ 15.0 15.1 15.2 OpenPAT lecture at the University of Helsinki Retrieved 2013-11-05.
- ↑ 16.0 16.1 OpenPAT lecture at Victoria University of Wellington Retrieved 2013-11-05.
- ↑ Aigner, G.; Diwan, A.; Heine, D.; Lam, M.; Moore, D.; Murphy, B.; Sapuntzakis, C. (2000). Performance Modeling and Analysis in High-Performance Reconfigurable Computing (Report). Stanford University.
- ↑ OpenPAT registration e-mail. Retrieved 2013-11-05.
- ↑ 19.0 19.1 19.2 Spacey, S. (2009). 3S Quick Start Guide (PDF) (Report). Imperial College London.
- ↑ 20.0 20.1 OpenPAT projects Retrieved 2013-11-05.
- ↑ The OpenPAT license Retrieved 2013-11-05.