diff --git a/CMakeLists.txt b/CMakeLists.txt index ef88c82c18e2e6f3ee973c8d305f8bf35dfb23df..110afbe1083260ecdcac72835a94b000d60a4bf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,12 @@ if(ENABLE_CONTRACTS) add_compile_definitions(ENABLE_CONTRACTS) endif() +# Chioce of profiling with callgrind +option(CALLGRIND_PROFILE "Set Callgrind macros around sequence" OFF) +if(CALLGRIND_PROFILE) + add_compile_definitions(CALLGRIND_PROFILE) +endif() + # Deal with device target architecture if(NOT STANDALONE) message(STATUS "Configured Gaudi build") diff --git a/stream/sequence/src/Stream.cpp b/stream/sequence/src/Stream.cpp index 3367dd34be4fe6f061f2c31d0ee2cb256a337697..3ad5ef630775eda8c9e4089b856776293736dcd3 100644 --- a/stream/sequence/src/Stream.cpp +++ b/stream/sequence/src/Stream.cpp @@ -5,6 +5,10 @@ #include "StreamWrapper.cuh" #include "ValidationAlgorithm.cuh" +#ifdef CALLGRIND_PROFILE +#include <valgrind/callgrind.h> +#endif + StreamWrapper::StreamWrapper() {} void StreamWrapper::initialize_streams( @@ -102,6 +106,10 @@ void Stream::set_host_buffer_manager(HostBuffersManager* buffers_manager) Allen::error Stream::run_sequence(const unsigned buf_idx, const RuntimeOptions& runtime_options) { +#ifdef CALLGRIND_PROFILE + CALLGRIND_START_INSTRUMENTATION; +#endif + host_buffers = host_buffers_manager->getBuffers(buf_idx); // The sequence is only run if there are events to run on auto event_start = std::get<0>(runtime_options.event_interval); @@ -142,5 +150,10 @@ Allen::error Stream::run_sequence(const unsigned buf_idx, const RuntimeOptions& } } +#ifdef CALLGRIND_PROFILE + CALLGRIND_STOP_INSTRUMENTATION; + CALLGRIND_DUMP_STATS; +#endif + return Allen::error::success; }