Skip to content

Commit

Permalink
cmake: Switchable valgrind/callgrind instrumentation for the main loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
fweik committed Feb 13, 2016
1 parent 069c19d commit eaf057f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Expand Up @@ -43,6 +43,7 @@ option(WITH_TCL "Build tcl interface" ON)
option(WITH_CUDA "Build with GPU support" ON)
option(WITH_TESTS "Enable tests" ON)
option(WITH_SCAFACOS "Build with Scafacos support" ON)
option(WITH_VALGRIND_INSTRUMENTATION "Build with valgrind instrumentation markers" OFF)

# choose the name of the config file
set(MYCONFIG_NAME "myconfig.hpp"
Expand Down Expand Up @@ -101,6 +102,16 @@ if(WITH_SCAFACOS)
endif(SCAFACOS_FOUND)
endif(WITH_SCAFACOS)

if(WITH_VALGRIND_INSTRUMENTATION)
find_package(PkgConfig)
pkg_check_modules(VALGRIND valgrind)
if(VALGRIND_FOUND)
set(VALGRIND_INSTRUMENTATION 1)
message(STATUS ${VALGRIND_INCLUDE_DIRS})
include_directories(${VALGRIND_INCLUDE_DIRS})
endif(VALGRIND_FOUND)
endif(WITH_VALGRIND_INSTRUMENTATION)

include(RequireCXX11)

#######################################################################
Expand Down
2 changes: 2 additions & 0 deletions cmake/cmake_config.cmakein
Expand Up @@ -17,6 +17,8 @@

#cmakedefine SCAFACOS

#cmakedefine VALGRIND_INSTRUMENTATION

#define PACKAGE_NAME "${PROJECT_NAME}"

#define __PRETTYFUNC__ "n/a"
12 changes: 12 additions & 0 deletions src/core/integrate.cpp
Expand Up @@ -64,6 +64,10 @@
#include "immersed_boundary/ibm_volume_conservation.hpp"
#include "minimize_energy.hpp"

#ifdef VALGRIND_INSTRUMENTATION
#include <callgrind.h>
#endif

/************************************************
* DEFINES
************************************************/
Expand Down Expand Up @@ -325,6 +329,10 @@ void integrate_vv(int n_steps, int reuse_forces)

n_verlet_updates = 0;

#ifdef VALGRIND_INSTRUMENTATION
CALLGRIND_START_INSTRUMENTATION;
#endif

/* Integration loop */
for (int step=0; step<n_steps; step++) {
INTEG_TRACE(fprintf(stderr,"%d: STEP %d\n", this_node, step));
Expand Down Expand Up @@ -550,6 +558,10 @@ void integrate_vv(int n_steps, int reuse_forces)
#endif
}

#ifdef VALGRIND_INSTRUMENTATION
CALLGRIND_STOP_INSTRUMENTATION;
#endif

/* verlet list statistics */
if(n_verlet_updates>0) verlet_reuse = n_steps/(double) n_verlet_updates;
else verlet_reuse = 0;
Expand Down

0 comments on commit eaf057f

Please sign in to comment.