Use VTuneAPI in Intel® Parallel Amplifier for selective code profiling

VTuneAPI is a set of APIs from VTuneTMPerformance Analyzer - the user can ignore (don't collect) the profiling data when the application is running on non-interest of code, e.g. 3rd-party libraries. VTuneAPI  has Pause API and Resume API to set profiling control in user's C/C++ program, also there are other APIs to configure sampling / call graph data collection, and generate final result, etc. See An Introduction to Sampling and Time, page 8 in detail.


Dump VTuneAPI all export functions:

1 000012F4 VTBindSamplingResults

2 0000126C VTNameThread

3 00001234  VTPause

4 0000135C VTunePauseCounterMonitor

5 00001324 VTunePauseSampling

6 00001250 VTResume

7 00001378 VTuneResumeCounter Monitor

8 00001340 VTuneResumeSampling

9 00001294 VTStartSampling

10 000012C4 VTStopSampling


Fortunately Intel® Parallel Amplifier includes this feature in the product. Simply the user can use VTPause/VTResume to control data profiling. There is no necessary to use VTStartSampling/VTStopSampling since the user can do it on the Parallel Amplifier's user interface.

a)       Include file - VtuneApi.h under Parallel Studio\Amplifier\include

b)       Lib file - VtuneApi.dllunder Parallel Studion\Amplifer\bin32\runtime, or Parallel Studion\Amplifer\bin64\runtime


Here are steps to use VTuneAPI to control data collection.

  1. Set new path for Vtuneapi.h in Include Directories, Microsoft* Visual Studio* ->Tools->Options->VC++ Directories->Include files
  2. Copy VtuneApi.dll to Project's Release directory which includes generated application.
  3. In Microsoft* Visual Studio, right-click on the project -> Intel Parallel Amplifier->Project Properties->check on "Start data collection paused" & check off "Resume collection after sec."
  4. vtuneapi.bmp
  5. Insert VTuneAPI code in user's source such as below example, then rebuild the project

      #include "Vtuneapi.h"


       typedef void (*VTFUNC)(void);

       HMODULE hMod;

       VTFUNC vtResume, vtPause;

       hMod = LoadLibrary("VtuneApi.dll");


       vtResume = (VTFUNC) GetProcAddress(hMod, "VTResume");

       vtPause = (VTFUNC) GetProcAddress(hMod, "VTPause");



       // code section 1 - collecting data


       // code section 2 - not collecting data


      // code section 3 - collecting data


Finally run the Parallel amplifier to get expected result

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.