# Call tree/profiler

**URL:** <https://openmc.discourse.group/t/call-tree-profiler/650>\
**Category:** User Support\
**Created:** [July 21, 2020, 1:21pm UTC](https://openmc.discourse.group/t/call-tree-profiler/650 "2020-07-21T13:21:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Echlin](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@Mike\_Echlin](https://openmc.discourse.group/u/Mike_Echlin)\
**Post date:** [July 21, 2020, 1:21pm UTC](https://openmc.discourse.group/t/call-tree-profiler/650/1 "2020-07-21T13:21:14Z")

</div>

Hi,

I am trying to create a call tree for openmc, I am trying to use a profiler to do it so I have 2 questions, does someone already have a call tree for both the c++ and python sides and is anyone using a profiler, gprof, prof or forge? I keep telling cmake to build using gprof but it keeps ignoring my directives. I’m not a cmake expert so i’m obviously doing it wrong.

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 21, 2020, 3:09pm UTC](https://openmc.discourse.group/t/call-tree-profiler/650/2 "2020-07-21T15:09:25Z")

</div>

Hi Mike,

In our CMakeLists.txt file, there is a “profile” option that adds flags necessary for doing profiling (if using gcc). When you’re running cmake, add -Dprofile=on to make sure you get these flags. I believe gprof doesn’t work well for us currently because most of OpenMC is built as a shared library. If you changed it to build libopenmc as a static library, you might be able to get gprof to work. Generally I use the Linux perf profiler for OpenMC, so the workflow looks something like:

cmake -Dprofile=on …  
make  
cd \<directory\_with\_inputs\>  
perf record -g openmc  
perf report

I know myself and others have also used Intel VTune with success, if that’s an option for you.

Best regards,  
Paul

---

<div class="post-metadata">

**Author:** ![Mike\_Echlin](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@Mike\_Echlin](https://openmc.discourse.group/u/Mike_Echlin)\
**Post date:** [July 27, 2020, 1:04pm UTC](https://openmc.discourse.group/t/call-tree-profiler/650/3 "2020-07-27T13:04:23Z")

</div>

Hi,

Thank you Paul, perf is working out well, for the c++ code. perf script \> scr.out then gprof2dot gives a nice (huge) call tree.  
For python I settled on cProfile (python -m cProfile -o output.pstats run\_depletion.py) and then gprof2dot gives a somewhat smaller tree (but still huge.)

Thanks again,

Mike
