TubeTK/Code Optimization in Linux

From KitwarePublic
Jump to navigationJump to search

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