Collection Controls to Minimize Analysis Overhead
Issue
Running your target application with the
can take substantially longer than running your target application without the
.
Intel® Advisor
Intel Advisor
Depending on an accuracy level and analyses you choose for a perspective, different overhead is added to your application execution time.
For example:
Runtime Overhead / Analysis
| Survey
| Characterization
| Dependencies
| MAP
|
---|---|---|---|---|
Target application runtime with
Intel® Advisor compared to runtime without
Intel® Advisor | 1.1x longer
| 2 - 55x longer
| 5 - 100x longer
| 5 - 20x longer
|
Solutions
Use the following techniques to skip
uninteresting
parts of your target application, such as the initialization phase, and analyze only
interesting
parts.
Pause Collection/Resume Collection Using Annotations
Minimize collection overhead.
Applicable analyses: Survey, Dependencies.
Some analysis types recognize the structural annotations typically used in the
workflow.
Threading
perspectiveUse when:
- Modifying/recompiling your target application is not an issue.
- You do not want to analyze one or more uninteresting parts of your target application.
- The interesting parts of your target application involve large workloads (because Pause/Resume API call frequency is about 1 Hz, and the operations pause and resume data collection in all processes in the analysis run, with the corresponding collection state notification to the GUI).
To pause collection, add the following annotation to your code:
- C++:ANNOTATE_DISABLE_COLLECTION_PUSH
- Fortran:call annotate_disable_collection_push()
- C#:Annotate.DisableCollectionPush();
To resume collection, add the following annotation to your code:
- C++:ANNOTATE_DISABLE_COLLECTION_POP
- Fortran:call annotate_disable_collection_pop()
- C#:Annotate.DisableCollectionPop();
C# and .NET support is deprecated starting
Intel® Advisor
2021.1.
See
Pause Collection and Resume Collection Annotations for more information.
Pause Collection/Resume Collection Using API Methods
Minimize collection overhead using the Intel® Instrumentation and Tracing Technology (ITT) API.
For MPI applications, you can also use a standard MPI-specific function
MPI_Pcontrol(
to pause and resume data collection. This function requires no changes in the application building process, unlike the ITT API calls, which require linking of a static ITT API library. See
Control Collection with an MPI_Pcontrol Function.
<N>
)Applicable analyses:
Survey,
Characterization with Trip Counts or FLOP collection enabled
.
Use when:
- Modifying/recompiling your target application is not an issue.
- You do not want to analyze one or more uninteresting parts of your target application.
- The interesting parts of your target application involve large workloads (because Pause/Resume API call frequency is about 1 Hz, and the operations pause and resume data collection in all processes in the analysis run, with the corresponding collection state notification to the GUI).
Prerequisites:
- Add the following statements to every source file you want to instrument:
- C/C++:ittnotify.h
- Fortran:USE ITTNOTIFY
- Theittnotifyheader file contains definitions of ITT API routines and important macros that provide the correct logic of API invocation from an application.
- The ITT API is designed to incur almost zero overhead when tracing is disabled. If you need completely zero overhead, you can compile out all ITT API calls from an application by defining theINTEL_NO_ITTNOTIFY_APImacro in your project at compile time, either on the compiler command line or in your source file prior to including theittnotifyheader file.
- Configure your build system to reach ITT API header file and libraries, where<install-dir>is theIntel Advisorinstallation directory.
- Add the appropriate entry to your INCLUDE path:
- C++:<install-dir>/sdk/include
- Fortran:<install-dir>/sdk/include/lib32or<install-dir>/sdk/include/lib64
- Microsoft Visual Studio* IDE:.
- Add<install-dir>/sdk/lib32or<install-dir>/sdk/lib64to your LIBRARIES path.Visual Studio IDE:.
The ITT API headers, static libraries, and Fortran modules previously located at<install-dir>/includeand<install-dir>/[lib32 | lib64]folders were moved to the<install-dir>/sdk/includeand<install-dir>/sdk/[lib32 | lib64]folder. Copies of these files are retained at their old locations for backward compatibility and these copies should not be used for new projects. - Link your target application to the static librarylibittnotify.a(Linux* OS) orlibittnotify.lib(Windows* OS) by passing-littnotifyto your compiler. If tracing is enabled, this static library loads the ITT API implementation and forwards ITT API instrument data to theIntel Advisor. If tracing is disabled, the static library ignores ITT API calls, providing nearly zero instrumentation overhead.Visual Studio IDE:
- Insert_itt_pause(C/C++) orCALL ITT_PAUSE(Fortran) before uninteresting parts of your target application and the_itt_resume(C/C++) orCALL ITT_RESUME(Fortran) before interesting parts of your target application.Example 1: The following snippet plus the standard run control collects analysis data twice - at the beginning and the middle of the snippet:#include <ittnotify.h> int main(int argc, char* argv[]) { // Do work here __itt_pause(); // Do uninteresting work here __itt_resume(); // Do work here __itt_pause(); // Do uninteresting work here return 0; }Example 2: The following snippet plus the standard run control collects analysis data only once - in the middle of the snippet:#include <ittnotify.h> int main(int argc, char* argv[]) { __itt_pause(); // Do uninteresting work here __itt_resume(); // Do work here __itt_pause(); // Do uninteresting work here return 0; }Example 3: The following snippet plus the standard run control collects analysis data only once - at the end of the snippet:#include <ittnotify.h> int main(int argc, char* argv[]) { __itt_pause(); // Do uninteresting work here __itt_resume(); // Do work here return 0; }Example 4: The following snippet plus theStart Pausedcontrol collects analysis data only once - at the end of the snippet:#include <ittnotify.h> int main(int argc, char* argv[]) { // Do uninteresting work here __itt_resume(); // Do work here return 0; }
After
performing the prerequisites and recompiling, do one of the following:
Note
: In the commands below, make sure to replace the
myApplication
with your application executable path and name
before
executing a command. If your application requires additional command line options, add them
after
the executable name.- Click the standard run control or theStart Pausedcontrol on theAnalysis Workflowpane to run the desired analysis.
- Use theadvisorCLI action--collectwith or without the CLI action option to run the desired analysis. For example:advisor --collect=survey --project-dir=./advi_results -- ./myApplication
To attach ITT APIs to a launched application, that is, to collect API data on an application that is already launched, point the target application to the
ittnotify_collector
library using an environment variable:
- Windows* OS:set INTEL_LIBITTNOTIFY32=<install_dir>\bin32\runtime\ittnotify_collector.dllset INTEL_LIBITTNOTIFY64=<install_dir>\bin64\runtime\ittnotify_collector.dll
- Linux* OS:export INTEL_LIBITTNOTIFY32=<install_dir>/lib32/runtime/libittnotify_collector.soexport INTEL_LIBITTNOTIFY64=<install_dir>/lib64/runtime/libittnotify_collector.so
Use the full path to the library without quotations marks.
After you complete configuration, start the instrumented application in the correct environment.
collects API data even if the application is launched before the
is launched.
Intel® Advisor
Intel® Advisor
You can find the
ITT API documentation
at
https://github.com/intel/ittapi.
Start Target Application With Collection Paused
Minimize collection overhead.
Applicable analyses: Survey,
Characterization with Trip Counts and FLOP collection enabled
.
Use when you do not want to analyze the early phase(s) of your target application, such as the initialization phase, but you want analysis in
ready mode
.
Note
: In the commands below, make sure to replace the
myApplication
with your application executable path and name
before
executing a command. If your application requires additional command line options, add them
after
the executable name.To implement, do one of the following:
- Click the associated
control on the
Analysis Workflowpane to run the desired analysis. - Use theadvisorCLI action option when you run the desired analysis. For example:advisor --collect=survey --start-paused --project-dir=./advi_results -- ./myApplication
You can use different techniques to resume collection. The most common is
__itt_resume
.
Start Target Application With Collection Paused/Resume Collection After N Seconds
Minimize collection overhead.
Applicable analyses: Survey,
Characterization with Trip Counts and FLOP collection enabled
.
Use when...
- You do not want to modify/recompile your target application.
- You do not want to analyze the initialization phase of your target application.
- You have a good idea of the time interval of interest, but pinpointing the exact beginning of the interesting part of your target application is not important.
- The interesting part of your target application is more than a few loops.
Note
: In the commands below, make sure to replace the
myApplication
with your application executable path and name
before
executing a command. If your application requires additional command line options, add them
after
the executable name.To implement, do one of the following:
- Enable thecheckbox and supply the desired value, where.[Name]is Survey or Trip Counts and FLOPClick the standard run control on theAnalysis Workflowpane to run the desired analysis. (Collection automatically starts in the paused state.)
- Use theadvisorCLI action option--resume-after=<integer>when your run the desired analysis. For example:advisor --collect=survey --resume-after=30 --project-dir=./advi_results -- ./myApplication
Use a value representing seconds in the GUI field and milliseconds in the integer argument.
Stop Collection After N Seconds
Minimize collection overhead.
Applicable analyses:
Survey,
Characterization with Trip Counts and FLOP collection enabled
, Dependencies, Memory Access Patterns.
This is the flip side of the
Start target application with collection paused
technique. Use when...
- You do not want to modify/recompile your target application.
- You do not want to analyze the end of your target application.
- You have a good idea of the time interval of interest, but pinpointing the exact end of the interesting part of your target application is not important.
- The interesting part of your target application is more than a few loops.
To implement, enable
checkbox and supply the desired value, where
.
[Name]
is Survey or Trip Counts and FLOPClick the standard run control on the
Analysis Workflow
pane to run the desired analysis.
Use a value representing seconds in both the GUI field and integer argument.
Stop Collection
Minimize collection overhead.
Applicable analyses:
Survey,
Characterization with Trip Counts and FLOP collection enabled
, Dependencies, Memory Access Patterns.
Use when...
- You do not want to modify/recompile your target application.
- You do not want to analyze the end of your target application.
- You can detect the time interval of interest based on target application output.
- The interesting part of your target application is more than a few loops.
To implement, do one of the following:
- Click the associated
control on the
Analysis Workflowpane when running the desired analysis.If running a Dependencies or Memory Access Patterns analysis, use theSite Coveragebar to determine when all marked loops are analyzed at least once: - Use theadvisorCLI action--command=stopwhen you run the desired analysis. For example:advisor --command=stop --result-dir=./myAdvisorResult
Manually Pause Collection/Manually Resume Collection
Minimize collection overhead.
Applicable analyses: Survey,
Characterization with Trip Counts and FLOP collection enabled
.
Use when...
- You can detect the time interval of interest based on target application output.
- Your need to pause or resume is unplanned and spontaneous.
To implement, do one of the following to pause analysis data collection (the target application continues running, but analysis data collection stops):
- Click the associated
control on the
Analysis Workflowpane when running the desired analysis. - Use theadvisorCLI action--command=pausewhen you run the desired analysis. For example:advisor --command=pause --result-dir=./myAdvisorResult
Do one of the following to resume analysis data collection:
- Click the associated
control on the
Analysis Workflowpane. - Use theadvisorCLI action--command=resume. For example:advisor --command=resume --result-dir=./myAdvisorResult
Attach to Process/Detach from Process
Minimize collection overhead.
Applicable analyses: Survey,
Characterization with Trip Counts and FLOP collection enabled
without call stacks.
This technique is similar to the
Start target application with collection paused
technique, except you can attach to an already running process. This is particularly beneficial if:
- The process is a service that runs forever.
- The launching infrastructure is relatively complicated, such as a sequence of scripts that must be modified to embed alaunch collectioncommand.
GUI:
- Choose> Launch Applicationdrop-down list> Attach to Process, where.[Name]is Survey or Trip Counts and FLOP
- Disable theInherit settings from Survey Hotspots Analysis Typecheckbox.
- Choose theProcess nameorPIDoption and identify a process.
- Supply other information as desired and close theProject Propertiesdialog box.
- Click the standard run control on theAnalysis Workflowpane to run the desired analysis.
CLI: Use the
advisor
CLI action option
--target-pid=<unsigned integer>
or
--target-process=<string>
to attach to a process when running the desired analysis. For example:
advisor --collect=survey --project-dir=./advi_results --result-dir=./myAdvisorResult --target-process=myProcess
Do one of the following to stop collecting analysis data on a process (the process continues running but analysis data collection stops):
- Click the associated
control on the
Analysis Workflowpane. - Use theadvisorCLI action--command=detach. For example:advisor --command=detach --result-dir=./myAdvisorResult
- Ensure call stacks are disabled (which is the default setting) if you run theCharacterization with Trip Counts and FLOP collection enabledanalysis:
- Using theadvisorCLI action--command=stopkills the process (which also stops analysis data collection).