Skip to content

Commit efeaa32

Browse files
authored
Merge pull request #93 from eparshut/counter_metadata
Add new counter and context metadata ITT APIs
2 parents 4ec60a1 + 615e8b3 commit efeaa32

File tree

8 files changed

+823
-4
lines changed

8 files changed

+823
-4
lines changed

include/ittnotify.h

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,6 +4021,173 @@ __itt_collection_state __itt_get_collection_state(void);
40214021
void __itt_release_resources(void);
40224022
/** @endcond */
40234023

4024+
/**
4025+
* @brief Create a typed counter with given domain pointer, string name and counter type
4026+
*/
4027+
#if ITT_PLATFORM==ITT_PLATFORM_WIN
4028+
__itt_counter ITTAPI __itt_counter_createA_v3(const __itt_domain* domain, const char* name, __itt_metadata_type type);
4029+
__itt_counter ITTAPI __itt_counter_createW_v3(const __itt_domain* domain, const wchar_t* name, __itt_metadata_type type);
4030+
#if defined(UNICODE) || defined(_UNICODE)
4031+
# define __itt_counter_create_v3 __itt_counter_createW_v3
4032+
# define __itt_counter_create_v3_ptr __itt_counter_createW_v3_ptr
4033+
#else /* UNICODE */
4034+
# define __itt_counter_create_v3 __itt_counter_createA_v3
4035+
# define __itt_counter_create_v3_ptr __itt_counter_createA_v3_ptr
4036+
#endif /* UNICODE */
4037+
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4038+
__itt_counter ITTAPI __itt_counter_create_v3(const __itt_domain* domain, const char* name, __itt_metadata_type type);
4039+
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4040+
4041+
#ifndef INTEL_NO_MACRO_BODY
4042+
#ifndef INTEL_NO_ITTNOTIFY_API
4043+
#if ITT_PLATFORM==ITT_PLATFORM_WIN
4044+
ITT_STUB(ITTAPI, __itt_counter, counter_createA_v3, (const __itt_domain* domain, const char* name, __itt_metadata_type type))
4045+
ITT_STUB(ITTAPI, __itt_counter, counter_createW_v3, (const __itt_domain* domain, const wchar_t* name, __itt_metadata_type type))
4046+
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4047+
ITT_STUB(ITTAPI, __itt_counter, counter_create_v3, (const __itt_domain* domain, const char* name, __itt_metadata_type type))
4048+
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4049+
#if ITT_PLATFORM==ITT_PLATFORM_WIN
4050+
#define __itt_counter_createA_v3 ITTNOTIFY_DATA(counter_createA_v3)
4051+
#define __itt_counter_createA_v3_ptr ITTNOTIFY_NAME(counter_createA_v3)
4052+
#define __itt_counter_createW_v3 ITTNOTIFY_DATA(counter_createW_v3)
4053+
#define __itt_counter_createW_v3_ptr ITTNOTIFY_NAME(counter_createW_v3)
4054+
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4055+
#define __itt_counter_create_v3 ITTNOTIFY_DATA(counter_create_v3)
4056+
#define __itt_counter_create_v3_ptr ITTNOTIFY_NAME(counter_create_v3)
4057+
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4058+
#else /* INTEL_NO_ITTNOTIFY_API */
4059+
#if ITT_PLATFORM==ITT_PLATFORM_WIN
4060+
#define __itt_counter_createA_v3(domain, name, type) (__itt_counter)0
4061+
#define __itt_counter_createA_v3_ptr 0
4062+
#define __itt_counter_createW_v3(domain, name, type) (__itt_counter)0
4063+
#define __itt_counter_create_typedW_ptr 0
4064+
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4065+
#define __itt_counter_create_v3(domain, name, type) (__itt_counter)0
4066+
#define __itt_counter_create_v3_ptr 0
4067+
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4068+
#endif /* INTEL_NO_ITTNOTIFY_API */
4069+
#else /* INTEL_NO_MACRO_BODY */
4070+
#if ITT_PLATFORM==ITT_PLATFORM_WIN
4071+
#define __itt_counter_createA_v3_ptr 0
4072+
#define __itt_counter_createW_v3_ptr 0
4073+
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4074+
#define __itt_counter_create_v3_ptr 0
4075+
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
4076+
#endif /* INTEL_NO_MACRO_BODY */
4077+
/** @endcond */
4078+
4079+
/**
4080+
* @brief Set the counter value api
4081+
*/
4082+
void ITTAPI __itt_counter_set_value_v3(__itt_counter counter, void *value_ptr);
4083+
4084+
#ifndef INTEL_NO_MACRO_BODY
4085+
#ifndef INTEL_NO_ITTNOTIFY_API
4086+
ITT_STUBV(ITTAPI, void, counter_set_value_v3, (__itt_counter counter, void *value_ptr))
4087+
#define __itt_counter_set_value_v3 ITTNOTIFY_VOID(counter_set_value_v3)
4088+
#define __itt_counter_set_value_v3_ptr ITTNOTIFY_NAME(counter_set_value_v3)
4089+
#else /* INTEL_NO_ITTNOTIFY_API */
4090+
#define __itt_counter_set_value_v3(counter, value_ptr)
4091+
#define __itt_counter_set_value_v3_ptr 0
4092+
#endif /* INTEL_NO_ITTNOTIFY_API */
4093+
#else /* INTEL_NO_MACRO_BODY */
4094+
#define __itt_counter_set_value_v3_ptr 0
4095+
#endif /* INTEL_NO_MACRO_BODY */
4096+
/** @endcond */
4097+
4098+
/**
4099+
* @brief describes the type of context metadata
4100+
*/
4101+
typedef enum {
4102+
__itt_context_unknown = 0, /*!< Undefined type */
4103+
__itt_context_nameA, /*!< ASCII string char* type */
4104+
__itt_context_nameW, /*!< Unicode string wchar_t* type */
4105+
__itt_context_deviceA, /*!< ASCII string char* type */
4106+
__itt_context_deviceW, /*!< Unicode string wchar_t* type */
4107+
__itt_context_unitsA, /*!< ASCII string char* type */
4108+
__itt_context_unitsW, /*!< Unicode string wchar_t* type */
4109+
__itt_context_pci_addrA, /*!< ASCII string char* type */
4110+
__itt_context_pci_addrW, /*!< Unicode string wchar_t* type */
4111+
__itt_context_tid, /*!< Unsigned 64-bit integer type */
4112+
__itt_context_max_val, /*!< Unsigned 64-bit integer type */
4113+
__itt_context_bandwidth_flag, /*!< Unsigned 64-bit integer type */
4114+
__itt_context_latency_flag, /*!< Unsigned 64-bit integer type */
4115+
__itt_context_occupancy_flag, /*!< Unsigned 64-bit integer type */
4116+
__itt_context_on_thread_flag, /*!< Unsigned 64-bit integer type */
4117+
__itt_context_is_abs_val_flag, /*!< Unsigned 64-bit integer type */
4118+
__itt_context_cpu_instructions_flag, /*!< Unsigned 64-bit integer type */
4119+
__itt_context_cpu_cycles_flag /*!< Unsigned 64-bit integer type */
4120+
} __itt_context_type;
4121+
4122+
#if defined(UNICODE) || defined(_UNICODE)
4123+
# define __itt_context_name __itt_context_nameW
4124+
# define __itt_context_device __itt_context_deviceW
4125+
# define __itt_context_units __itt_context_unitsW
4126+
# define __itt_context_pci_addr __itt_context_pci_addrW
4127+
#else /* UNICODE || _UNICODE */
4128+
# define __itt_context_name __itt_context_nameA
4129+
# define __itt_context_device __itt_context_deviceA
4130+
# define __itt_context_units __itt_context_unitsA
4131+
# define __itt_context_pci_addr __itt_context_pci_addrA
4132+
#endif /* UNICODE || _UNICODE */
4133+
4134+
/** @cond exclude_from_documentation */
4135+
#pragma pack(push, 8)
4136+
4137+
typedef struct ___itt_context_metadata
4138+
{
4139+
__itt_context_type type; /*!< Type of the context metadata value */
4140+
void* value; /*!< Pointer to context metadata value itself */
4141+
} __itt_context_metadata;
4142+
4143+
#pragma pack(pop)
4144+
/** @endcond */
4145+
4146+
/** @cond exclude_from_documentation */
4147+
#pragma pack(push, 8)
4148+
4149+
typedef struct ___itt_counter_metadata
4150+
{
4151+
__itt_counter counter; /*!< Associated context metadata counter */
4152+
__itt_context_type type; /*!< Type of the context metadata value */
4153+
const char* str_valueA; /*!< String context metadata value */
4154+
#if defined(UNICODE) || defined(_UNICODE)
4155+
const wchar_t* str_valueW;
4156+
#else /* UNICODE || _UNICODE */
4157+
void* str_valueW;
4158+
#endif /* UNICODE || _UNICODE */
4159+
unsigned long long value; /*!< Numeric context metadata value */
4160+
int extra1; /*!< Reserved to the runtime */
4161+
void* extra2; /*!< Reserved to the runtime */
4162+
struct ___itt_counter_metadata* next;
4163+
} __itt_counter_metadata;
4164+
4165+
#pragma pack(pop)
4166+
/** @endcond */
4167+
4168+
/**
4169+
* @brief Bind context metadata to counter instance
4170+
* @param[in] counter Pointer to the counter instance to which the context metadata is to be associated.
4171+
* @param[in] length The number of elements in context metadata array.
4172+
* @param[in] metadata The context metadata itself.
4173+
*/
4174+
void ITTAPI __itt_bind_context_metadata_to_counter(__itt_counter counter, size_t length, __itt_context_metadata* metadata);
4175+
4176+
/** @cond exclude_from_documentation */
4177+
#ifndef INTEL_NO_MACRO_BODY
4178+
#ifndef INTEL_NO_ITTNOTIFY_API
4179+
ITT_STUBV(ITTAPI, void, bind_context_metadata_to_counter, (__itt_counter counter, size_t length, __itt_context_metadata* metadata))
4180+
#define __itt_bind_context_metadata_to_counter ITTNOTIFY_VOID(bind_context_metadata_to_counter)
4181+
#define __itt_bind_context_metadata_to_counter_ptr ITTNOTIFY_NAME(bind_context_metadata_to_counter)
4182+
#else /* INTEL_NO_ITTNOTIFY_API */
4183+
#define __itt_bind_context_metadata_to_counter(counter, length, metadata)
4184+
#define __itt_bind_context_metadata_to_counter_ptr 0
4185+
#endif /* INTEL_NO_ITTNOTIFY_API */
4186+
#else /* INTEL_NO_MACRO_BODY */
4187+
#define __itt_bind_context_metadata_to_counter_ptr 0
4188+
#endif /* INTEL_NO_MACRO_BODY */
4189+
/** @endcond */
4190+
40244191
#ifdef __cplusplus
40254192
}
40264193
#endif /* __cplusplus */

rust/ittapi-sys/src/linux/ittnotify_bindings.rs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,3 +1887,110 @@ pub type __itt_histogram_submit_ptr__3_0_t = ::std::option::Option<
18871887
extern "C" {
18881888
pub static mut __itt_histogram_submit_ptr__3_0: __itt_histogram_submit_ptr__3_0_t;
18891889
}
1890+
pub type __itt_counter_create_v3_ptr__3_0_t = ::std::option::Option<
1891+
unsafe extern "C" fn(
1892+
domain: *const __itt_domain,
1893+
name: *const ::std::os::raw::c_char,
1894+
type_: __itt_metadata_type,
1895+
) -> __itt_counter,
1896+
>;
1897+
extern "C" {
1898+
pub static mut __itt_counter_create_v3_ptr__3_0: __itt_counter_create_v3_ptr__3_0_t;
1899+
}
1900+
pub type __itt_counter_set_value_v3_ptr__3_0_t = ::std::option::Option<
1901+
unsafe extern "C" fn(counter: __itt_counter, value_ptr: *mut ::std::os::raw::c_void),
1902+
>;
1903+
extern "C" {
1904+
pub static mut __itt_counter_set_value_v3_ptr__3_0: __itt_counter_set_value_v3_ptr__3_0_t;
1905+
}
1906+
#[doc = "< Undefined type"]
1907+
pub const __itt_context_type___itt_context_unknown: __itt_context_type = 0;
1908+
#[doc = "< ASCII string char* type"]
1909+
pub const __itt_context_type___itt_context_nameA: __itt_context_type = 1;
1910+
#[doc = "< Unicode string wchar_t* type"]
1911+
pub const __itt_context_type___itt_context_nameW: __itt_context_type = 2;
1912+
#[doc = "< ASCII string char* type"]
1913+
pub const __itt_context_type___itt_context_deviceA: __itt_context_type = 3;
1914+
#[doc = "< Unicode string wchar_t* type"]
1915+
pub const __itt_context_type___itt_context_deviceW: __itt_context_type = 4;
1916+
#[doc = "< ASCII string char* type"]
1917+
pub const __itt_context_type___itt_context_unitsA: __itt_context_type = 5;
1918+
#[doc = "< Unicode string wchar_t* type"]
1919+
pub const __itt_context_type___itt_context_unitsW: __itt_context_type = 6;
1920+
#[doc = "< ASCII string char* type"]
1921+
pub const __itt_context_type___itt_context_pci_addrA: __itt_context_type = 7;
1922+
#[doc = "< Unicode string wchar_t* type"]
1923+
pub const __itt_context_type___itt_context_pci_addrW: __itt_context_type = 8;
1924+
#[doc = "< Unsigned 64-bit integer type"]
1925+
pub const __itt_context_type___itt_context_tid: __itt_context_type = 9;
1926+
#[doc = "< Unsigned 64-bit integer type"]
1927+
pub const __itt_context_type___itt_context_max_val: __itt_context_type = 10;
1928+
#[doc = "< Unsigned 64-bit integer type"]
1929+
pub const __itt_context_type___itt_context_bandwidth_flag: __itt_context_type = 11;
1930+
#[doc = "< Unsigned 64-bit integer type"]
1931+
pub const __itt_context_type___itt_context_latency_flag: __itt_context_type = 12;
1932+
#[doc = "< Unsigned 64-bit integer type"]
1933+
pub const __itt_context_type___itt_context_occupancy_flag: __itt_context_type = 13;
1934+
#[doc = "< Unsigned 64-bit integer type"]
1935+
pub const __itt_context_type___itt_context_on_thread_flag: __itt_context_type = 14;
1936+
#[doc = "< Unsigned 64-bit integer type"]
1937+
pub const __itt_context_type___itt_context_is_abs_val_flag: __itt_context_type = 15;
1938+
#[doc = "< Unsigned 64-bit integer type"]
1939+
pub const __itt_context_type___itt_context_cpu_instructions_flag: __itt_context_type = 16;
1940+
#[doc = "< Unsigned 64-bit integer type"]
1941+
pub const __itt_context_type___itt_context_cpu_cycles_flag: __itt_context_type = 17;
1942+
#[doc = " @brief describes the type of context metadata"]
1943+
pub type __itt_context_type = ::std::os::raw::c_uint;
1944+
#[repr(C)]
1945+
#[derive(Debug, Copy, Clone)]
1946+
pub struct ___itt_context_metadata {
1947+
#[doc = "< Type of the context metadata value"]
1948+
pub type_: __itt_context_type,
1949+
#[doc = "< Pointer to context metadata value itself"]
1950+
pub value: *mut ::std::os::raw::c_void,
1951+
}
1952+
#[test]
1953+
fn bindgen_test_layout____itt_context_metadata() {
1954+
assert_eq!(
1955+
::std::mem::size_of::<___itt_context_metadata>(),
1956+
16usize,
1957+
concat!("Size of: ", stringify!(___itt_context_metadata))
1958+
);
1959+
assert_eq!(
1960+
::std::mem::align_of::<___itt_context_metadata>(),
1961+
8usize,
1962+
concat!("Alignment of ", stringify!(___itt_context_metadata))
1963+
);
1964+
assert_eq!(
1965+
unsafe { &(*(::std::ptr::null::<___itt_context_metadata>())).type_ as *const _ as usize },
1966+
0usize,
1967+
concat!(
1968+
"Offset of field: ",
1969+
stringify!(___itt_context_metadata),
1970+
"::",
1971+
stringify!(type_)
1972+
)
1973+
);
1974+
assert_eq!(
1975+
unsafe { &(*(::std::ptr::null::<___itt_context_metadata>())).value as *const _ as usize },
1976+
8usize,
1977+
concat!(
1978+
"Offset of field: ",
1979+
stringify!(___itt_context_metadata),
1980+
"::",
1981+
stringify!(value)
1982+
)
1983+
);
1984+
}
1985+
pub type __itt_context_metadata = ___itt_context_metadata;
1986+
pub type __itt_bind_context_metadata_to_counter_ptr__3_0_t = ::std::option::Option<
1987+
unsafe extern "C" fn(
1988+
counter: __itt_counter,
1989+
length: size_t,
1990+
metadata: *mut __itt_context_metadata,
1991+
),
1992+
>;
1993+
extern "C" {
1994+
pub static mut __itt_bind_context_metadata_to_counter_ptr__3_0:
1995+
__itt_bind_context_metadata_to_counter_ptr__3_0_t;
1996+
}

rust/ittapi-sys/src/macos/ittnotify_bindings.rs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,3 +1887,110 @@ pub type __itt_histogram_submit_ptr__3_0_t = ::std::option::Option<
18871887
extern "C" {
18881888
pub static mut __itt_histogram_submit_ptr__3_0: __itt_histogram_submit_ptr__3_0_t;
18891889
}
1890+
pub type __itt_counter_create_v3_ptr__3_0_t = ::std::option::Option<
1891+
unsafe extern "C" fn(
1892+
domain: *const __itt_domain,
1893+
name: *const ::std::os::raw::c_char,
1894+
type_: __itt_metadata_type,
1895+
) -> __itt_counter,
1896+
>;
1897+
extern "C" {
1898+
pub static mut __itt_counter_create_v3_ptr__3_0: __itt_counter_create_v3_ptr__3_0_t;
1899+
}
1900+
pub type __itt_counter_set_value_v3_ptr__3_0_t = ::std::option::Option<
1901+
unsafe extern "C" fn(counter: __itt_counter, value_ptr: *mut ::std::os::raw::c_void),
1902+
>;
1903+
extern "C" {
1904+
pub static mut __itt_counter_set_value_v3_ptr__3_0: __itt_counter_set_value_v3_ptr__3_0_t;
1905+
}
1906+
#[doc = "< Undefined type"]
1907+
pub const __itt_context_type___itt_context_unknown: __itt_context_type = 0;
1908+
#[doc = "< ASCII string char* type"]
1909+
pub const __itt_context_type___itt_context_nameA: __itt_context_type = 1;
1910+
#[doc = "< Unicode string wchar_t* type"]
1911+
pub const __itt_context_type___itt_context_nameW: __itt_context_type = 2;
1912+
#[doc = "< ASCII string char* type"]
1913+
pub const __itt_context_type___itt_context_deviceA: __itt_context_type = 3;
1914+
#[doc = "< Unicode string wchar_t* type"]
1915+
pub const __itt_context_type___itt_context_deviceW: __itt_context_type = 4;
1916+
#[doc = "< ASCII string char* type"]
1917+
pub const __itt_context_type___itt_context_unitsA: __itt_context_type = 5;
1918+
#[doc = "< Unicode string wchar_t* type"]
1919+
pub const __itt_context_type___itt_context_unitsW: __itt_context_type = 6;
1920+
#[doc = "< ASCII string char* type"]
1921+
pub const __itt_context_type___itt_context_pci_addrA: __itt_context_type = 7;
1922+
#[doc = "< Unicode string wchar_t* type"]
1923+
pub const __itt_context_type___itt_context_pci_addrW: __itt_context_type = 8;
1924+
#[doc = "< Unsigned 64-bit integer type"]
1925+
pub const __itt_context_type___itt_context_tid: __itt_context_type = 9;
1926+
#[doc = "< Unsigned 64-bit integer type"]
1927+
pub const __itt_context_type___itt_context_max_val: __itt_context_type = 10;
1928+
#[doc = "< Unsigned 64-bit integer type"]
1929+
pub const __itt_context_type___itt_context_bandwidth_flag: __itt_context_type = 11;
1930+
#[doc = "< Unsigned 64-bit integer type"]
1931+
pub const __itt_context_type___itt_context_latency_flag: __itt_context_type = 12;
1932+
#[doc = "< Unsigned 64-bit integer type"]
1933+
pub const __itt_context_type___itt_context_occupancy_flag: __itt_context_type = 13;
1934+
#[doc = "< Unsigned 64-bit integer type"]
1935+
pub const __itt_context_type___itt_context_on_thread_flag: __itt_context_type = 14;
1936+
#[doc = "< Unsigned 64-bit integer type"]
1937+
pub const __itt_context_type___itt_context_is_abs_val_flag: __itt_context_type = 15;
1938+
#[doc = "< Unsigned 64-bit integer type"]
1939+
pub const __itt_context_type___itt_context_cpu_instructions_flag: __itt_context_type = 16;
1940+
#[doc = "< Unsigned 64-bit integer type"]
1941+
pub const __itt_context_type___itt_context_cpu_cycles_flag: __itt_context_type = 17;
1942+
#[doc = " @brief describes the type of context metadata"]
1943+
pub type __itt_context_type = ::std::os::raw::c_uint;
1944+
#[repr(C)]
1945+
#[derive(Debug, Copy, Clone)]
1946+
pub struct ___itt_context_metadata {
1947+
#[doc = "< Type of the context metadata value"]
1948+
pub type_: __itt_context_type,
1949+
#[doc = "< Pointer to context metadata value itself"]
1950+
pub value: *mut ::std::os::raw::c_void,
1951+
}
1952+
#[test]
1953+
fn bindgen_test_layout____itt_context_metadata() {
1954+
assert_eq!(
1955+
::std::mem::size_of::<___itt_context_metadata>(),
1956+
16usize,
1957+
concat!("Size of: ", stringify!(___itt_context_metadata))
1958+
);
1959+
assert_eq!(
1960+
::std::mem::align_of::<___itt_context_metadata>(),
1961+
8usize,
1962+
concat!("Alignment of ", stringify!(___itt_context_metadata))
1963+
);
1964+
assert_eq!(
1965+
unsafe { &(*(::std::ptr::null::<___itt_context_metadata>())).type_ as *const _ as usize },
1966+
0usize,
1967+
concat!(
1968+
"Offset of field: ",
1969+
stringify!(___itt_context_metadata),
1970+
"::",
1971+
stringify!(type_)
1972+
)
1973+
);
1974+
assert_eq!(
1975+
unsafe { &(*(::std::ptr::null::<___itt_context_metadata>())).value as *const _ as usize },
1976+
8usize,
1977+
concat!(
1978+
"Offset of field: ",
1979+
stringify!(___itt_context_metadata),
1980+
"::",
1981+
stringify!(value)
1982+
)
1983+
);
1984+
}
1985+
pub type __itt_context_metadata = ___itt_context_metadata;
1986+
pub type __itt_bind_context_metadata_to_counter_ptr__3_0_t = ::std::option::Option<
1987+
unsafe extern "C" fn(
1988+
counter: __itt_counter,
1989+
length: size_t,
1990+
metadata: *mut __itt_context_metadata,
1991+
),
1992+
>;
1993+
extern "C" {
1994+
pub static mut __itt_bind_context_metadata_to_counter_ptr__3_0:
1995+
__itt_bind_context_metadata_to_counter_ptr__3_0_t;
1996+
}

0 commit comments

Comments
 (0)