Repository navigation
doc: add Formatted Metadata API documentation #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4a8ce8
initial add of formatted metadata api documentation
alexey-kireev 378915a
add formatted metadata reference to task api page
alexey-kireev 5f04836
small naming fix
alexey-kireev 242676b
Update docs/src/ittapi/formatted-metadata-api.rst
alexey-kireev 6efda73
add documentation for formatted metadata in overlapped tasks
alexey-kireev 1b8f59b
Merge branch 'master' into fm_docs
alexey-kireev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| .. _formatted-metadata-api: | ||
|
|
||
| Formatted Metadata API | ||
| ====================== | ||
|
|
||
|
|
||
| Use the Formatted Metadata API to attach formatted string data to tasks with efficient string | ||
| formatting capabilities. This API extends the basic Metadata API by providing printf-style formatting functionality. | ||
|
|
||
| The Formatted Metadata API is a per-thread function that works in the resumed profiling state only. | ||
|
|
||
|
|
||
| API Functions | ||
| ------------- | ||
|
|
||
| **To add formatted metadata to the current task, use the following primitive:** | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| void __itt_formatted_metadata_add(const __itt_domain *domain, | ||
| __itt_string_handle *format_handle, | ||
| ...); | ||
|
|
||
|
|
||
| **Parameters of the primitive:** | ||
|
|
||
| +--------+------------------------------+----------------------------------------------------+ | ||
| | Type | Parameter | Description | | ||
| +========+==============================+====================================================+ | ||
| | [in] | .. code-block:: cpp | Metadata domain | | ||
| | | | | | ||
| | | __itt_domain* domain | | | ||
| +--------+------------------------------+----------------------------------------------------+ | ||
| | [in] | .. code-block:: cpp | String handle containing the format string with | | ||
| | | | printf-style format specifiers | | ||
| | | __itt_string_handle* | | | ||
| | | format_handle | | | ||
| +--------+------------------------------+----------------------------------------------------+ | ||
| | [in] | .. code-block:: cpp | Variable arguments corresponding to format | | ||
| | | | specifiers in the format string | | ||
| | | ... | | | ||
| +--------+------------------------------+----------------------------------------------------+ | ||
|
|
||
|
|
||
| Metadata Visualization and Analysis in VTune | ||
| -------------------------------------------- | ||
|
|
||
| Formatted metadata provides several benefits for visualization and analysis in Intel® VTune™ Profiler: | ||
|
|
||
| - **Timeline tooltips**: Metadata appears in tooltips when hovering over tasks in the timeline view, | ||
| providing contextual runtime information. | ||
| - **Bottom-up view grouping**: Formatted metadata can be used as a grouping criteria in the bottom-up view, | ||
| allowing you to organize and analyze tasks based on their metadata values. | ||
| - **Custom grouping**: Users can group tasks by their metadata values to identify patterns and performance | ||
| characteristics across different execution contexts. | ||
| - **Square bracket notation for format specifiers**: When you include format specifiers in square brackets | ||
| (e.g., ``[%s]``) within your format string, VTune treats these as special grouping identifiers. | ||
|
|
||
|
|
||
| Usage Example | ||
| ------------- | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| #include "ittnotify.h" | ||
|
|
||
| __itt_domain* domain = __itt_domain_create("FileProcessor"); | ||
| __itt_string_handle* operation_format = __itt_string_handle_create("Operation: [%s] on file %s"); | ||
| __itt_string_handle* performance_format = __itt_string_handle_create("Performance: %d bytes in %.2f ms"); | ||
|
|
||
| void process_file(const char* filename) { | ||
| __itt_task_begin(domain, __itt_null, __itt_null, __itt_string_handle_create("process_file")); | ||
|
|
||
| __itt_formatted_metadata_add(domain, operation_format, "file_processing", filename); | ||
|
|
||
| __itt_task_begin(domain, __itt_null, __itt_null, __itt_string_handle_create("read_file")); | ||
|
|
||
| int bytes_read = 1024; | ||
| double read_time = 15.5; | ||
| __itt_formatted_metadata_add(domain, performance_format, bytes_read, read_time); | ||
|
|
||
| __itt_task_end(domain); | ||
|
|
||
| __itt_task_begin(domain, __itt_null, __itt_null, __itt_string_handle_create("transform_data")); | ||
|
|
||
| __itt_formatted_metadata_add(domain, operation_format, "data_transform", filename); | ||
|
|
||
| __itt_task_end(domain); | ||
| __itt_task_end(domain); | ||
| } | ||
|
|
||
| int main() { | ||
| process_file("document.txt"); | ||
| process_file("image.jpg"); | ||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| Usage Guidelines | ||
| ---------------- | ||
|
|
||
| - Format strings support standard printf-style format specifiers (``%s``, ``%d``, ``%f``, etc.) | ||
| - Metadata is associated with the currently running task at the time of the API call | ||
| - **Limit to one metadata call per task** - making multiple calls to ``__itt_formatted_metadata_add`` for the same task may result in incorrect processing | ||
| - For optimal performance, limit the frequency and size of metadata additions | ||
| - Format specifiers in square brackets (e.g., ``[%s]``) create additional grouping options in VTune analysis views | ||
| - Function arguments are processed during the API calls | ||
| - Maximum length of a string argument is 256 symbols | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.