Analyzers
Community support for Analyzers (Intel VTune™ Profiler, Intel Advisor, Intel Inspector)
4969 Discussions

Run VTune for a function that runs thousands of times

code_code
Beginner
1,267 Views

Hi,

I am profiling a piece of code with VTune. The code takes less than a minute to run without using VTune, and when I run VTune on it, it still runs in less than a minute if I don't use ITT pause and resume commands. The problem is when I use pause and resume functions before and after one of the functions that repeats thousands of times. I interrupted the execution after 30 minutes of running. In this case, when I run VTune (in command line mode) on my program, it starts writing to a log folder that gets bigger and bigger, in the range of GBs, and also the profiling overhead is significant. Is there any option or mode that can reduce the overhead, for identifying hotspots?

I am using VTune 2021.4 and running the following command:

vtune -collect hotspots -start-paused -q -data-limit=800 -discard-raw-data <target>
 
Using or not using data-limit and discard-raw-data did not help.
0 Kudos
9 Replies
AbhijeetJ_Intel
Moderator
1,231 Views

Hi,

Could you please try out following step:

1.    Try updating Vtune to latest version and again see if the issue persists.

Download link: https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html#gs.j9amtm

 

2.    Could you please share your OS version, a reproducer script, and steps you followed to run the script so that we may try to reproduce your issue from our end.

 

Regards

Abhijeet


0 Kudos
code_code
Beginner
1,202 Views

Hi,

 

Thanks for the help.

  1. I have upgraded to the latest, using the apt package manager. It is now version 2021.9. 
  2. I'm using Ubuntu 2018.04.5.
  3. I have prepared a simple code to reproduce the issue, attached at the end.
  4. The command I use to run: vtune -collect hotspots -mrte-mode=native -q -start-paused ./vtune001

I'm passing "mrte-mode=native", because I get the following warning if I use the default:

vtune: Warning: Pause command is not supported for managed code profiling. Runtime overhead is still possible. Data size limit may be exceeded.

I'm passing "start-paused" since I want to only profile part of the code. The attached example is very basic and is not meaningful. My original code is completely different but with the same situation, which is profiling part of the code that repeats many times.

 

I ran this example twice. It froze once after printing 7000 and the second time after 72000. The log folder in the second case is almost 1GB and I believe it mostly consists of similar commands for pausing and resuming. Is there anyway to avoid writing the log folder? Maybe that fixes the freezing problem and also the overhead, because it is writing a large log file.

 

I paste the code here:

#include <vector>
#include <iostream>
#include <ittnotify.h>
using namespace std;

int main(){
    const int sz = 200000;
    vector<int> a(sz, 3);
    for(int i = 0; i < sz; ++i){
        if(i % 1000 == 0)
            cout << i << ' ' << flush;

        __itt_resume();
        for(int j = 0; j < sz; ++j){
            a[i] = a[i] * 2 + 2;
        }
        __itt_pause();

        for(int k = 0; k < sz; ++k){
            a[i] = a[i] * 3 + a[i] * 2;
        }
    }
    cout << endl;
    return 0;
}

And, this is the cmake file:

cmake_minimum_required(VERSION 3.10)
project(vtune001)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

set(ITT_INCLUDE_DIRS "/opt/intel/oneapi/vtune/latest/sdk/include")
set(ITT_LIBS "/opt/intel/oneapi/vtune/latest/sdk/lib64/libittnotify.a")

include_directories(${ITT_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} main.cpp)

# On Linux* systems, you have to link the dl and pthread libraries to enable
# ITT API functionality. Not linking these libraries will not prevent your
# application from running, but no ITT API data will be collected.
target_link_libraries(${PROJECT_NAME} ${ITT_LIBS} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})

 

0 Kudos
AbhijeetJ_Intel
Moderator
1,147 Views

Hi,

We are investigating your issue at our end and will soon be back with an update.

Regards


0 Kudos
coder_profiler
Beginner
1,042 Views

Hi,

Thanks! I just wanted to give you an update, that I upgraded to the 2022 version, and I still have the issue.

Best

 

0 Kudos
AbhijeetJ_Intel
Moderator
993 Views

Hi,

We were able to reproduce your issue from our end, and we are working on it.

We will get back to you soon.

Regards

Abhijeet

 

0 Kudos
Maria_N_Intel
Employee
911 Views

Hi,
Unfortunately, the provided case of usage Pause/Resume API is not the best one and should be reworked:

    for(int i = 0; i < sz; ++i){
        if(i % 1000 == 0)
            cout << i << ' ' << flush;

        __itt_resume();
        for(int j = 0; j < sz; ++j){
            a[i] = a[i] * 2 + 2;
        }
        __itt_pause();


Current implementation of the Pause/Resume API is asynchronous. It's call frequency is about 1Hz. That's why we would not recommend to use this API on a frequent basis for small workloads.

Could you please try to use Frame APIs in your workload instead?

0 Kudos
AbhijeetJ_Intel
Moderator
815 Views

Hi,

 

We tried to use Pause/Resume API in other code and that works fine for us.

Could you please try to use mentioned suggestions in your workload and tell us if it works for you?

 

Regards

Abhijeet


0 Kudos
code_code
Beginner
791 Views

Hi,

 

This task has recently been cancelled for our product. Really appreciate your help anyway!

0 Kudos
AbhijeetJ_Intel
Moderator
782 Views

Hi,

 

Thank you for the clarification.

If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.

 

Regards

Abhijeet


0 Kudos
Reply