user_guide:extend:profiling

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revisionBoth sides next revision
user_guide:extend:profiling [2019/01/29 21:46] – external edit 127.0.0.1user_guide:extend:profiling [2019/01/30 14:44] – deleted artefact from move operation (i think). current page at user_guide:extend:profiling oroehrig
Line 1: Line 1:
-===== Profiling  ===== 
- 
-This page describes two different ways how you can analyze and profile your code in ''polymake''. 
- 
- 
-==== using valgrind ==== 
- 
-Using the tool [[http://valgrind.org/|valgrind]] is an easy way to get many pieces of information about your code. 
-Once valgrind is installed on your system you are able to use many analyzing tools, as callgrind and cachegrind. 
-You will find more details in the [[http://valgrind.org/docs/manual/manual.html|manual]]. 
- 
-You can run ''polymake'' and your code with valgrind via the command 
-<code> 
-valgrind --tool=callgrind perl/polymake 
-</code> 
-or your corresponding path to ''polymake''. 
- 
-''polymake'' will start and you can execute your code, while valgrind is collecting data. 
-But be aware that this will slow down your program, such that you should just test your code with very small examples. 
- 
-A typical shell output looks like this: 
- 
-<code> 
-==30738== Callgrind, a call-graph generating cache profiler 
-==30738== Copyright (C) 2002-2009, and GNU GPL'd, by Josef Weidendorfer et al. 
-==30738== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info 
-==30738== Command: perl/polymake 
- 
-==30738== 
-==30738== For interactive control, run 'callgrind_control -h'. 
-Welcome to polymake version 2.12.3, rev. 11104 [DEVELOPER MODE] 
-Copyright (c) 1997-2012 
-Ewgenij Gawrilow, Michael Joswig (TU Darmstadt) 
-http://www.polymake.org 
- 
-This is free software licensed under GPL; see the source for copying conditions. 
-There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- 
-Press F1 or enter 'help;' for basic instructions. 
- 
-Application polytope currently uses following third-party software packages: 
-cddlib, geomview, graphviz, jreality, lrslib, nauty, normaliz2, permlib, povray, qhull, sketch, sympol, tosimplex 
-For more details:  show_credits; 
-polytope > script("my_script.pl"); 
-polytope > exit; 
-==30738== 
-==30738== Events    : Ir 
-==30738== Collected : 2091660153168 
-==30738== 
-==30738== I   refs:      2,091,660,153,168 
-</code> 
- 
-After closing ''polymake'' you will find files called callgrind.out.*, where * is a session number. The file stores all information about the run, in the above example callgrind.out.30738. You can open the file using kcachegrind. 
- 
-Picture1 
- 
-In our example you can see from this file, that mostly called is the interior function ''_gmpz_mul'', as subroutine of ''dd_LPSolve_gmp''. 
-This gives the hint that many Linear Programs will be solved that nearly all time is needed for that. 
-   
- 
-Another useful tool is cachegrind. You can run your code similar to the above via the command 
-<code> 
-valgrind --tool=cachegrind perl/polymake 
-</code> 
-you will produce a file called cachegrind.out.* and also the shell output is similar. 
-The data you will get tells you about the cach misses in your Program. 
- 
-A weak point of this methode is that also other information than your code is analyzed, as recompiling and the files which where execute by the start of 
-''polymake''. You can start your code as [[:callable|Callable Library]] to reduces this. 
- 
- 
- 
-==== using gprof ==== 
-Another way is using [[http://sourceware.org/binutils/docs/gprof/|gprof]]. To run this we start our code as [[:callable|Callable Library]] and have to install ''polymake'' again, this time compiling under the flags '-g', '-pg' and '-O2'. 
- 
-You can change compiler flags in the file '/build.x86_64/conf.make'. 
-It should look like this (with your corresponding paths): 
-<code> 
-... 
-Cflags := -march=native -g -pg -Wall -I/.../mpfr/include 
-CXXflags := -march=native -g -pg -ftemplate-depth-200 -Wall -Wno-strict-aliasing -Wno-parentheses -fno-inline-functions-called-once -I/.../mpfr/include 
-... 
-CXXOPT := -O2 
-... 
-LDflags :=  -g -pg -L/.../mpfr/lib -Wl,-rpath,/.../mpfr/lib 
-LDsharedFlags := -shared -O2 -g -pg -L/usr/local/lib -fstack-protector 
-LDcallableFlags := -shared -O2 -g -pg -L/usr/local/lib -fstack-protector  -fstack-protector -L/usr/local/lib 
-... 
-</code> 
- 
-For this version of ''polymake'' we execute our code as [[:callable|Callable Library]] also compiled under the flags '-g' and '-pg'. Therefore you can use the makefile from the [[http://polymake.org/lib/exe/fetch.php/callable.tbz|example]]. We execute our c++ program 'test' via the command 
-<code> 
-./test 
-</code> 
-This takes a while and produces the file 'gmon.out' which stores all profling data and can convert to a readable file via the command 
-<code> 
-gprof [executable file] [> Outfile]  
-</code> 
- 
- 
  
  • user_guide/extend/profiling.txt
  • Last modified: 2019/01/30 14:44
  • by oroehrig