Skip to content

add support of formatted metadata #174

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion include/ittnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -2454,9 +2454,58 @@ typedef enum {
__itt_metadata_u16, /**< Unsigned 16-bit integer */
__itt_metadata_s16, /**< Signed 16-bit integer */
__itt_metadata_float, /**< Signed 32-bit floating-point */
__itt_metadata_double /**< SIgned 64-bit floating-point */
__itt_metadata_double /**< Signed 64-bit floating-point */
} __itt_metadata_type;

/**
* @ingroup parameters
* @brief Add metadata to an instance of a named entity.
* @param[in] domain The domain controlling the call
* @param[in] format The printf-style format of the metadata
* @param[in] ... The metadata itself as multiple arguments
*/
void ITTAPI __itt_formatted_metadata_add(const __itt_domain *domain, __itt_string_handle *format, ...);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you plan to separate char* and wchar_t* strings parameter somehow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, thank you for pointing into it. it's supported and will be covered in another component

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you going to provide users the ability to explicitly specify what type of strings style they are using?
it would be better to document this somehow

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it could be specified using the standard %s / %ls print format specifiers. As an example, there's a printf format string for metadata, say "Arguments go here %s %ls %ld", and we call the new API like "__itt_formatted_metadata_add(domain, format, argumen1, argument2, argument3)", where argument1 is a char*, argument2 is wchar_t* and argument3 is long int.


/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, formatted_metadata_add, (const __itt_domain *domain, __itt_string_handle *format, ...))
#define __itt_formatted_metadata_add ITTNOTIFY_VOID(formatted_metadata_add)
#define __itt_formatted_metadata_add_ptr ITTNOTIFY_NAME(formatted_metadata_add)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_formatted_metadata_add(domain, format, metadata)
#define __itt_formatted_metadata_add_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_formatted_metadata_add_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */

/**
* @ingroup parameters
* @brief Add metadata to an instance of a named entity.
* @param[in] domain The domain controlling the call
* @param[in] taskid The identifier for this task instance, *cannot* be __itt_null.
* @param[in] format The printf-style format of the metadata
* @param[in] ... The metadata itself as multiple arguments
*/
void ITTAPI __itt_formatted_metadata_add_overlapped(const __itt_domain *domain, __itt_id taskid, __itt_string_handle *format, ...);

/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, formatted_metadata_add_overlapped, (const __itt_domain *domain, __itt_id taskid, __itt_string_handle *format, ...))
#define __itt_formatted_metadata_add_overlapped ITTNOTIFY_VOID(formatted_metadata_add_overlapped)
#define __itt_formatted_metadata_add_ptr_overlapped ITTNOTIFY_NAME(formatted_metadata_add_overlapped)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_formatted_metadata_add_overlapped(domain, taskid, format, metadata)
#define __itt_formatted_metadata_add_ptr_overlapped 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_formatted_metadata_add_ptr_overlapped 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */

/**
* @ingroup parameters
* @brief Add metadata to an instance of a named entity.
Expand Down
22 changes: 20 additions & 2 deletions rust/ittapi-sys/src/linux/ittnotify_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.4 */
/* automatically generated by rust-bindgen 0.69.5 */

pub const ITT_OS_WIN: u32 = 1;
pub const ITT_OS_LINUX: u32 = 2;
Expand Down Expand Up @@ -796,10 +796,28 @@ pub const __itt_metadata_type___itt_metadata_u16: __itt_metadata_type = 5;
pub const __itt_metadata_type___itt_metadata_s16: __itt_metadata_type = 6;
#[doc = "< Signed 32-bit floating-point"]
pub const __itt_metadata_type___itt_metadata_float: __itt_metadata_type = 7;
#[doc = "< SIgned 64-bit floating-point"]
#[doc = "< Signed 64-bit floating-point"]
pub const __itt_metadata_type___itt_metadata_double: __itt_metadata_type = 8;
#[doc = " @ingroup parameters\n @brief describes the type of metadata"]
pub type __itt_metadata_type = ::std::os::raw::c_uint;
pub type __itt_formatted_metadata_add_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(domain: *const __itt_domain, format: *mut __itt_string_handle, ...),
>;
extern "C" {
pub static mut __itt_formatted_metadata_add_ptr__3_0: __itt_formatted_metadata_add_ptr__3_0_t;
}
pub type __itt_formatted_metadata_add_overlapped_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(
domain: *const __itt_domain,
taskid: __itt_id,
format: *mut __itt_string_handle,
...
),
>;
extern "C" {
pub static mut __itt_formatted_metadata_add_overlapped_ptr__3_0:
__itt_formatted_metadata_add_overlapped_ptr__3_0_t;
}
pub type __itt_metadata_add_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(
domain: *const __itt_domain,
Expand Down
2 changes: 1 addition & 1 deletion rust/ittapi-sys/src/linux/jitprofiling_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.4 */
/* automatically generated by rust-bindgen 0.69.5 */

#[doc = "<\\brief Send this to shutdown the agent.\n Use NULL for event data."]
pub const iJIT_jvm_event_iJVM_EVENT_TYPE_SHUTDOWN: iJIT_jvm_event = 2;
Expand Down
22 changes: 20 additions & 2 deletions rust/ittapi-sys/src/macos/ittnotify_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.4 */
/* automatically generated by rust-bindgen 0.69.5 */

pub const ITT_OS_WIN: u32 = 1;
pub const ITT_OS_LINUX: u32 = 2;
Expand Down Expand Up @@ -796,10 +796,28 @@ pub const __itt_metadata_type___itt_metadata_u16: __itt_metadata_type = 5;
pub const __itt_metadata_type___itt_metadata_s16: __itt_metadata_type = 6;
#[doc = "< Signed 32-bit floating-point"]
pub const __itt_metadata_type___itt_metadata_float: __itt_metadata_type = 7;
#[doc = "< SIgned 64-bit floating-point"]
#[doc = "< Signed 64-bit floating-point"]
pub const __itt_metadata_type___itt_metadata_double: __itt_metadata_type = 8;
#[doc = " @ingroup parameters\n @brief describes the type of metadata"]
pub type __itt_metadata_type = ::std::os::raw::c_uint;
pub type __itt_formatted_metadata_add_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(domain: *const __itt_domain, format: *mut __itt_string_handle, ...),
>;
extern "C" {
pub static mut __itt_formatted_metadata_add_ptr__3_0: __itt_formatted_metadata_add_ptr__3_0_t;
}
pub type __itt_formatted_metadata_add_overlapped_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(
domain: *const __itt_domain,
taskid: __itt_id,
format: *mut __itt_string_handle,
...
),
>;
extern "C" {
pub static mut __itt_formatted_metadata_add_overlapped_ptr__3_0:
__itt_formatted_metadata_add_overlapped_ptr__3_0_t;
}
pub type __itt_metadata_add_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(
domain: *const __itt_domain,
Expand Down
2 changes: 1 addition & 1 deletion rust/ittapi-sys/src/macos/jitprofiling_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.4 */
/* automatically generated by rust-bindgen 0.69.5 */

#[doc = "<\\brief Send this to shutdown the agent.\n Use NULL for event data."]
pub const iJIT_jvm_event_iJVM_EVENT_TYPE_SHUTDOWN: iJIT_jvm_event = 2;
Expand Down
22 changes: 20 additions & 2 deletions rust/ittapi-sys/src/windows/ittnotify_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.4 */
/* automatically generated by rust-bindgen 0.69.5 */

pub const ITT_OS_WIN: u32 = 1;
pub const ITT_OS_LINUX: u32 = 2;
Expand Down Expand Up @@ -855,10 +855,28 @@ pub const __itt_metadata_type___itt_metadata_u16: __itt_metadata_type = 5;
pub const __itt_metadata_type___itt_metadata_s16: __itt_metadata_type = 6;
#[doc = "< Signed 32-bit floating-point"]
pub const __itt_metadata_type___itt_metadata_float: __itt_metadata_type = 7;
#[doc = "< SIgned 64-bit floating-point"]
#[doc = "< Signed 64-bit floating-point"]
pub const __itt_metadata_type___itt_metadata_double: __itt_metadata_type = 8;
#[doc = " @ingroup parameters\n @brief describes the type of metadata"]
pub type __itt_metadata_type = ::std::os::raw::c_int;
pub type __itt_formatted_metadata_add_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(domain: *const __itt_domain, format: *mut __itt_string_handle, ...),
>;
extern "C" {
pub static mut __itt_formatted_metadata_add_ptr__3_0: __itt_formatted_metadata_add_ptr__3_0_t;
}
pub type __itt_formatted_metadata_add_overlapped_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(
domain: *const __itt_domain,
taskid: __itt_id,
format: *mut __itt_string_handle,
...
),
>;
extern "C" {
pub static mut __itt_formatted_metadata_add_overlapped_ptr__3_0:
__itt_formatted_metadata_add_overlapped_ptr__3_0_t;
}
pub type __itt_metadata_add_ptr__3_0_t = ::std::option::Option<
unsafe extern "C" fn(
domain: *const __itt_domain,
Expand Down
2 changes: 1 addition & 1 deletion rust/ittapi-sys/src/windows/jitprofiling_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.4 */
/* automatically generated by rust-bindgen 0.69.5 */

#[doc = "<\\brief Send this to shutdown the agent.\n Use NULL for event data."]
pub const iJIT_jvm_event_iJVM_EVENT_TYPE_SHUTDOWN: iJIT_jvm_event = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/ittnotify/ittnotify_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@
#define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 }

/* Replace with snapshot date YYYYMMDD for promotion build. */
#define API_VERSION_BUILD 20230630
#define API_VERSION_BUILD 20250429

#ifndef API_VERSION_NUM
#define API_VERSION_NUM 3.24.6
#define API_VERSION_NUM 3.26.0
#endif /* API_VERSION_NUM */

#define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \
Expand Down
6 changes: 6 additions & 0 deletions src/ittnotify/ittnotify_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ ITT_STUBV(ITTAPI, void, counter_dec_delta_v3, (const __itt_domain *domain, __itt

ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, id, name, scope), marker, __itt_group_structure, "%p, %lu, %p, %d")

ITT_STUBV(ITTAPI, void, formatted_metadata_add, (const __itt_domain *domain, __itt_string_handle *format, ...), \
(ITT_FORMAT domain, format), formatted_metadata_add, __itt_group_structure, "%p, %p")

ITT_STUBV(ITTAPI, void, formatted_metadata_add_overlapped, (const __itt_domain *domain, __itt_id id, __itt_string_handle *format, ...), \
(ITT_FORMAT domain, id, format), formatted_metadata_add_overlapped, __itt_group_structure, "%p, %lu, %p")

ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, id, key, type, count, data), metadata_add, __itt_group_structure, "%p, %lu, %p, %d, %lu, %p")
#if ITT_PLATFORM==ITT_PLATFORM_WIN
ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addA, __itt_group_structure, "%p, %lu, %p, %p, %lu")
Expand Down
20 changes: 20 additions & 0 deletions src/ittnotify_refcol/itt_refcol_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,26 @@ ITT_EXTERN_C void __itt_metadata_add(const __itt_domain *domain, __itt_id id,
}
}

ITT_EXTERN_C void __itt_formatted_metadata_add(const __itt_domain *domain, __itt_string_handle *format, ...)
{
if (domain == NULL || format == NULL)
{
LOG_FUNC_CALL_WARN("Incorrect function call");
return;
}

va_list args;
va_start(args, format);

char formatted_metadata[LOG_BUFFER_MAX_SIZE];
vsnprintf(formatted_metadata, LOG_BUFFER_MAX_SIZE, format->strA, args);

LOG_FUNC_CALL_INFO("functions args: domain=%s formatted_metadata=%s",
domain->nameA, formatted_metadata);

va_end(args);
}

ITT_EXTERN_C void __itt_histogram_submit(__itt_histogram* hist, size_t length, void* x_data, void* y_data)
{
if (hist == NULL)
Expand Down