TubeTK/Code Optimization in Linux: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The following script demonstrates profiling on linux using oprofile
= Valgrind (KCacheGrind) =
 
<pre>
valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes program arguments
</pre>
 
== Links ==
* http://valgrind.org/docs/manual/cl-manual.html
* http://matt.eifelle.com/2009/04/07/profiling-with-valgrind/
* http://www.slac.stanford.edu/BFROOT/www/Computing/Optimization/genprof.html
* http://wiki.eclipse.org/Linux_Tools_Project/Valgrind/User_Guide


OProfile Web Page: http://oprofile.sourceforge.net/about/
= OProfile =


You can download the following script from this link: [[file:TubeTK_OProfileExampleScript.sh | TubeTK_OProfileExampleScript.sh]]
The following script demonstrates profiling on linux using oprofile
* OProfile Web Page: http://oprofile.sourceforge.net/about/
* Compiling:
** To see see function names, you need to compile with debug.
** To see callgraphs, you need to compile with frame pointers (-fno-omit-frame-pointer).
* You can download the following script from this link: [[file:TubeTK_OProfileExampleScript.txt‎ | TubeTK_OProfileExampleScript.txt‎]]


<pre>
<pre>
Line 57: Line 72:
opcontrol --shutdown
opcontrol --shutdown
</pre>
</pre>
[[Category:TubeTK|Code Optimization in Linux]]

Latest revision as of 18:39, 26 July 2013

Valgrind (KCacheGrind)

valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes program arguments

Links

OProfile

The following script demonstrates profiling on linux using oprofile


#! /bin/bash

# notes:
# opcontrol: controls data collection
# opreport: retrieves profile data
# opannotate: produce notated source code

# configure
opcontrol --no-vmlinux
opcontrol --callgraph=6
#opcontrol --event=CPU_CLK_UNHALTED:100000:0:1:1
#opcontrol --event=CPU_CLK_UNHALTED:1000:0:1:1
opcontrol --event=default

# TODO: could potentially increase count = number of samples to take

# start opcontrol
opcontrol --reset
opcontrol --start

# run the test
/home/dpace/TubeTKRepo/daniellepace-tubetk-debug/TubeTK-Build/lib/TubeTK/Plugins/tubeAnisotropicDiffusiveDeformableRegistration /home/dpace/TubeTKRepo/daniellepace-tubetk/Data/tubeAnisotropicDiffusiveSphereRegistration_origFixedImage.mhd /home/dpace/TubeTKRepo/daniellepace-tubetk/Data/tubeAnisotropicDiffusiveSphereRegistration_origMovingImage.mhd -n /home/dpace/TubeTKRepo/daniellepace-tubetk/Data/tubeAnisotropicDiffusiveSphereRegistration_normalVectorImage.mhd -w /home/dpace/TubeTKRepo/daniellepace-tubetk/Data/tubeAnisotropicDiffusiveSphereRegistration_weightImage.mhd -d /home/dpace/TubeTKRepo/daniellepace-tubetk-debug/TubeTK-Build/Temporary/tubeAnisotropicDiffusiveSphereRegistration_anisotropic_resultingMotionField.mhd -o /home/dpace/TubeTKRepo/daniellepace-tubetk-debug/TubeTK-Build/Temporary/tubeAnisotropicDiffusiveSphereRegistration_anisotropic_transformedMovingImage.mhd -i 500 -s 0.125 -l -0.1 > anisotropicTestOutput.txt

# dump the profiler results
opcontrol --dump

opcontrol --stop

# get the report

# Get an overview report of all images - not super helpful, but might as well save it out
opreport > completeOverview.txt

# Get a report on the samples for all individual binary images (libraries + applications) used by the tubeAnisotropicDiffusiveDeformableRegistration image
opreport image:/home/dpace/TubeTKRepo/daniellepace-tubetk-debug/TubeTK-Build/lib/TubeTK/Plugins/tubeAnisotropicDiffusiveDeformableRegistration > anisotropicOverview.txt

# Get a symbol report for the tubeAnisotropicDiffusiveDeformableRegistration image
opreport -l image:/home/dpace/TubeTKRepo/daniellepace-tubetk-debug/TubeTK-Build/lib/TubeTK/Plugins/tubeAnisotropicDiffusiveDeformableRegistration --demangle smart --debug-info > anisotropicSymbols.txt

# Get code annotations
opannotate --source --output-dir=annotated --demangle smart

# Get callgraph information
opreport -l image:/home/dpace/TubeTKRepo/daniellepace-tubetk-debug/TubeTK-Build/lib/TubeTK/Plugins/tubeAnisotropicDiffusiveDeformableRegistration --demangle smart --callgraph > callgraph.txt

# TODO oparchive for comparison to changed code

# stop the profiler
opcontrol --shutdown