Functions | |
itrace_return_t | itrace_open_profiler (itrace_logger_handle_t logger_handle, uint32_t domain, size_t log_size, itrace_profiler_handle_t *profiler_handle_ptr) |
Open profiler instance. More... | |
itrace_return_t | itrace_close_profiler (itrace_profiler_handle_t profiler_handle) |
Close profiler instance. More... | |
itrace_return_t | itrace_add_event (itrace_profiler_handle_t profiler_handle, itrace_event_t event) |
Add an event to be registered. More... | |
itrace_return_t | itrace_add_event_by_id (itrace_profiler_handle_t profiler_handle, uint32_t event_id) |
Add an event to be registered by specifying only its id. More... | |
itrace_return_t | itrace_add_events (itrace_profiler_handle_t profiler_handle, itrace_event_t *events, int num_events) |
Add multiple events to be registered. More... | |
itrace_return_t | itrace_add_events_from_file (itrace_profiler_handle_t profiler_handle, const char *events_filename) |
Add events to be registered from a file. More... | |
itrace_return_t | itrace_add_all_pmu_events (itrace_profiler_handle_t profiler_handle) |
Add all published PMU events supported on the current domain. More... | |
itrace_return_t | itrace_remove_all_events (itrace_profiler_handle_t profiler_handle) |
Remove all events to be registered. More... | |
itrace_return_t | itrace_add_event_set (itrace_profiler_handle_t profiler_handle, const char *set_name) |
Start a new named event set. More... | |
itrace_return_t | itrace_register_events (itrace_profiler_handle_t profiler_handle, itrace_event_t *attempted_to_register_events, int *num_attempted_to_register_events) |
Register new events. More... | |
itrace_return_t | itrace_get_num_events_left_to_register (itrace_profiler_handle_t profiler_handle, int *num_events_left_to_register) |
Return the number of events that are still to be registered. More... | |
itrace_return_t | itrace_set_processing_mode (itrace_profiler_handle_t profiler_handle, itrace_processing_mode_t processing_mode) |
Set processing mode to use for all events at registration time. More... | |
itrace_return_t | itrace_deregister_events (itrace_profiler_handle_t profiler_handle) |
Deregister all events currently registered with this profiler instance. More... | |
itrace_return_t | itrace_enable_event (itrace_profiler_handle_t profiler_handle, uint32_t event_id) |
Enable reading of event. More... | |
itrace_return_t | itrace_disable_event (itrace_profiler_handle_t profiler_handle, uint32_t event_id) |
Disable reading of event. More... | |
itrace_return_t | itrace_start_section (itrace_profiler_handle_t profiler_handle, const char *section_name, itrace_measured_events_t *measured_events) |
Define the start of a section for which all registered events will be monitored. More... | |
itrace_return_t | itrace_start_section_with_section_id (itrace_profiler_handle_t profiler_handle, section_id_t section_id, itrace_measured_events_t *measured_events) |
Define the start of a section for which all registered events will be monitored. This section is identified by an unsigned identifier. More... | |
itrace_return_t | itrace_end_section (itrace_profiler_handle_t profiler_handle, itrace_measured_events_t *measured_events) |
Define the end of a section for which all registered events will be monitored. More... | |
void | itrace_start_section_no_events (section_id_t section_id) |
Define the start of a section without monitoring registered events. More... | |
void | itrace_end_section_no_events (void) |
Define the end of a section without monitoring registered events. | |
itrace_return_t | itrace_read_events (itrace_profiler_handle_t profiler_handle, itrace_measured_events_t *measured_events) |
Read events. More... | |
itrace_return_t | itrace_add_marker (itrace_profiler_handle_t profiler_handle, const char *marker_name) |
Add a marker. More... | |
itrace_return_t | itrace_start_periodic_events_reader (itrace_profiler_handle_t profiler_handle, uint32_t events_reader_period_us, uint32_t thread_priority) |
Start a periodic sampler measuring registered events at regular intervals. More... | |
itrace_return_t | itrace_end_periodic_events_reader (itrace_profiler_handle_t profiler_handle) |
End the periodic sampler. More... | |
itrace_return_t | itrace_start_periodic_logs_flusher (itrace_logger_handle_t logger_handle, uint32_t flushing_period_us) |
Create a background thread to periodically flush and parse the log buffers for each active profiler. More... | |
itrace_return_t | itrace_end_periodic_logs_flusher (itrace_logger_handle_t logger_handle) |
Destroy the thread that is flushing and parsing the log buffers for each active profiler. More... | |
itrace_return_t | itrace_setup_from_file (itrace_logger_handle_t *logger_handle_ptr, const char *setup_filename) |
Setup itrace from a configuration file or using defaults. More... | |
itrace_return_t | itrace_teardown (itrace_logger_handle_t logger_handle) |
Close itrace when utilizing CPU and/or DSP automation. More... | |
itrace_return_t | itrace_flush_log (itrace_profiler_handle_t profiler_handle) |
Flush the log of the current profiler. More... | |
itrace_return_t | itrace_set_default_profiler (itrace_profiler_handle_t profiler_handle) |
Set the specified profiler instance as default. More... | |
itrace_return_t | itrace_get_dsp_version (itrace_profiler_handle_t profiler_handle, char *dsp_version) |
Get the DSP Version index of the profiler. More... | |
itrace_return_t | itrace_get_domain (itrace_profiler_handle_t profiler_handle, uint32_t *domain_id) |
Get the domain id of the profiler. More... | |
itrace_return_t | itrace_get_itrace_version (itrace_profiler_handle_t profiler_handle, uint32_t *version) |
Return the itrace library version running on the specified domain. More... | |
The profiler is responsible for:
itrace_return_t itrace_add_all_pmu_events | ( | itrace_profiler_handle_t | profiler_handle | ) |
Add all published PMU events supported on the current domain.
[in] | profiler_handle | Handle of the profiler instance. Profiler instance must be for a DSP domain. |
itrace_return_t itrace_add_event | ( | itrace_profiler_handle_t | profiler_handle, |
itrace_event_t | event | ||
) |
Add an event to be registered.
Events (itrace_event_t) specify what metrics to measure when monitoring a code section or sampling the code regularly. This API adds an event to the list of events that will be registered.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | event | Event. |
itrace_return_t itrace_add_event_by_id | ( | itrace_profiler_handle_t | profiler_handle, |
uint32_t | event_id | ||
) |
Add an event to be registered by specifying only its id.
Events (itrace_event_t) specify what metrics to measure when monitoring a code section or sampling the code regularly. This API adds an event to the list of events that will be registered.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | event_id | Event id. |
itrace_return_t itrace_add_event_set | ( | itrace_profiler_handle_t | profiler_handle, |
const char * | set_name | ||
) |
Start a new named event set.
[in] | profiler_handle | Handle of the profiler instance. Profiler instance must be for a DSP domain. |
[in] | set_name | Name of the set (currently ignored). |
itrace_return_t itrace_add_events | ( | itrace_profiler_handle_t | profiler_handle, |
itrace_event_t * | events, | ||
int | num_events | ||
) |
Add multiple events to be registered.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | events | Array of events to be added. |
[in] | num_events | Number of events to be added. |
itrace_return_t itrace_add_events_from_file | ( | itrace_profiler_handle_t | profiler_handle, |
const char * | events_filename | ||
) |
Add events to be registered from a file.
This API adds events to be registered based on information provided in a file.
The current file format must identify each event on a separate line by its opcode or itrace name as defined in DSP PMU event definitions, Non-PMU DSP event definitions, and CPU event definitions. E.g.
Limitation: This API is only supported with a profiler instance running on the CPU currently.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | events_filename | Filename containing the events to load. |
itrace_return_t itrace_add_marker | ( | itrace_profiler_handle_t | profiler_handle, |
const char * | marker_name | ||
) |
Add a marker.
A marker is a string that can be identified in the itrace output files.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | marker_name | Name of the marker. |
itrace_return_t itrace_close_profiler | ( | itrace_profiler_handle_t | profiler_handle | ) |
Close profiler instance.
[in] | profiler_handle | Handle of the profiler instance. |
itrace_return_t itrace_deregister_events | ( | itrace_profiler_handle_t | profiler_handle | ) |
Deregister all events currently registered with this profiler instance.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
itrace_return_t itrace_disable_event | ( | itrace_profiler_handle_t | profiler_handle, |
uint32_t | event_id | ||
) |
Disable reading of event.
When an event is disabled the itrace library has the option to not read that event. The event may still be read if doing so does not impact negatively performance and does not have any visible effect outside the library. The measured values of disabled events is undefined. Enabling or disabling an event does not affect their registration.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | event_id | Id of the event to disable. |
itrace_return_t itrace_enable_event | ( | itrace_profiler_handle_t | profiler_handle, |
uint32_t | event_id | ||
) |
Enable reading of event.
When an event is disabled the itrace library has the option to not read that event. The event may still be read if doing so does not impact negatively performance and does not have any visible effect outside the library. The measured values of disabled events is undefined. Enabling or disabling an event does not affect their registration.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | event_id | Id of the event to enable. |
itrace_return_t itrace_end_periodic_events_reader | ( | itrace_profiler_handle_t | profiler_handle | ) |
End the periodic sampler.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
itrace_return_t itrace_end_periodic_logs_flusher | ( | itrace_logger_handle_t | logger_handle | ) |
Destroy the thread that is flushing and parsing the log buffers for each active profiler.
The thread created in itrace_start_periodic_logs_flusher is destroyed and log buffers for each active profiler are flushed
Limitation: This API is only supported for killing the flushing profiler thread from the CPU.
[in] | logger_handle | Handle of the logger instance. |
itrace_return_t itrace_end_section | ( | itrace_profiler_handle_t | profiler_handle, |
itrace_measured_events_t * | measured_events | ||
) |
Define the end of a section for which all registered events will be monitored.
Section statistics are derived from post-processing the monitored values at the start and end of the section according to their respective itrace_processing_mode_t. Section statistics are shown in both the trace and CSV files.
The values measured at the end of the section are also displayed independently of section statistics in the timeline that tracks the values of each monitored events over time.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[out] | measured_events | Measured events at the end of the section. Set to NULL to ignore. |
itrace_return_t itrace_flush_log | ( | itrace_profiler_handle_t | profiler_handle | ) |
Flush the log of the current profiler.
Return the log buffer to the logger to which the profiler is registered.
Note: This function is called automatically by itrace_close_profiler. You may want to call this function manually instead in a couple of situations:
Limitation: This API is only supported with a profiler instance running on the CPU currently.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
itrace_return_t itrace_get_domain | ( | itrace_profiler_handle_t | profiler_handle, |
uint32_t * | domain_id | ||
) |
Get the domain id of the profiler.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | domain_id | Domain associated to the profiler. |
itrace_return_t itrace_get_dsp_version | ( | itrace_profiler_handle_t | profiler_handle, |
char * | dsp_version | ||
) |
Get the DSP Version index of the profiler.
Buffer dsp version length must have at least ITRACE_MAX_LENGTH_DSP_VERSION bytes allocated.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | dsp_version | In: Allocated buffer. Out: Actual DSP Version of the profiler (on success). |
itrace_return_t itrace_get_itrace_version | ( | itrace_profiler_handle_t | profiler_handle, |
uint32_t * | version | ||
) |
Return the itrace library version running on the specified domain.
Note: When the itrace library is delivered with header files, the version of all object files is <ITRACE_VERSION_MAJOR
>.<ITRACE_VERSION_MINOR
> with those constants defined in itrace.h.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[out] | version | <major (16-bit)>.<minor (16-bit)>. |
itrace_return_t itrace_get_num_events_left_to_register | ( | itrace_profiler_handle_t | profiler_handle, |
int * | num_events_left_to_register | ||
) |
Return the number of events that are still to be registered.
Note: Events currently registered are not counted towards this total.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[out] | num_events_left_to_register | Number of events still to be registered. |
itrace_return_t itrace_open_profiler | ( | itrace_logger_handle_t | logger_handle, |
uint32_t | domain, | ||
size_t | log_size, | ||
itrace_profiler_handle_t * | profiler_handle_ptr | ||
) |
Open profiler instance.
Each profiler is associated to a domain on which to run. A domain is a local or remote environment, such as the application processor or one of the DSPs (CDSP, ADSP, etc.). DSP valid domains values are specified in remote.h
and itrace defines additional domains in the Domain extensions.
[in] | logger_handle | Handle of the logger associated to this new profiler instance. |
[in] | domain | Domain on which the profiler instance will reside. |
[in] | log_size | Buffer size (bytes) needed for this profiler instance. Set to 0 to use default. |
[out] | profiler_handle_ptr | Handle of the profiler instance created. |
itrace_return_t itrace_read_events | ( | itrace_profiler_handle_t | profiler_handle, |
itrace_measured_events_t * | measured_events | ||
) |
Read events.
This API reads all registed events. The measured values are returned to the user and displayed in the timeline that tracks the values of each monitored events over time.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[out] | measured_events | Measured events. Set to NULL to ignore. |
itrace_return_t itrace_register_events | ( | itrace_profiler_handle_t | profiler_handle, |
itrace_event_t * | attempted_to_register_events, | ||
int * | num_attempted_to_register_events | ||
) |
Register new events.
Register the next set of events available.
Registered events will be measured from now on and until they are unregistered with itrace_deregister_events or a new set of events is registered. For some of these events, such as DSP PMU event definitions, the registration process can be time consuming and thus should not be done in any time-critical code.
When registering DSP events, all non-PMU events need to be registered prior to any PMU event. If this condition is not met, the registration will fail and return ITRACE_RET_BAD_PARAM.
An event will not be registered if it is not supported on the profiler domain.
Passing an attempted_to_register_events
argument allows the user to check which events were registered and which events were invalid.
The library will attempt to register events until one of these conditions is encountered:
Note: itrace_deregister_events will be automatically called before registering new events.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[out] | attempted_to_register_events | Set of registered events, including events that failed to register because they were invalid. A NULL value instructs the library to ignore this return value. |
[out] | num_attempted_to_register_events | Number of events that were considered for registration. |
itrace_return_t itrace_remove_all_events | ( | itrace_profiler_handle_t | profiler_handle | ) |
Remove all events to be registered.
[in] | profiler_handle | Handle of the profiler instance. Profiler instance must be for a DSP domain. |
itrace_return_t itrace_set_default_profiler | ( | itrace_profiler_handle_t | profiler_handle | ) |
Set the specified profiler instance as default.
When using Profiler APIs with a NULL profiler instance, the library will use the default profiler of the local domain. This API allows the client to set a profiler as the default profiler for its local domain.
Calling this API will replace the existing default profiler. The client is responsible for ensuring that any section opened with the previous default profiler using itrace_start_section has been properly closed with itrace_end_section.
[in] | profiler_handle | Handle of the profiler instance. |
itrace_return_t itrace_set_processing_mode | ( | itrace_profiler_handle_t | profiler_handle, |
itrace_processing_mode_t | processing_mode | ||
) |
Set processing mode to use for all events at registration time.
This API allows to set the itrace_processing_mode_t of any event whose itrace_processing_mode_t is set to ITRACE_PM_DEFAULT. .
Note: The processing mode specified in this API takes effect at registration time: the API has no effect on events that are already registered.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | processing_mode | Processing mode to use for all events that do not already have a processing mode at registration time. |
itrace_return_t itrace_setup_from_file | ( | itrace_logger_handle_t * | logger_handle_ptr, |
const char * | setup_filename | ||
) |
Setup itrace from a configuration file or using defaults.
The following actions are supported:
This API allows for itrace configuration, adding and registering events from a file.
The supported file format is as follows:
ITRACE_DEFAULT_ROOT_FILENAME
otherwise). The root filename supplied to itrace_set_root_filename.Notes:
[out] | logger_handle_ptr | Handle of the logger instance created, or the handle of a previously created logger instance. |
[in] | setup_filename | Filename containing itrace setup configuration and the events to load. If NULL, filename defaults to itrace_instrumentation_config.txt |
itrace_return_t itrace_start_periodic_events_reader | ( | itrace_profiler_handle_t | profiler_handle, |
uint32_t | events_reader_period_us, | ||
uint32_t | thread_priority | ||
) |
Start a periodic sampler measuring registered events at regular intervals.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | events_reader_period_us | Event reader period. Set to 0 to use default. |
[in] | thread_priority | Event reader thread priority. Set to 0 to use default. |
itrace_return_t itrace_start_periodic_logs_flusher | ( | itrace_logger_handle_t | logger_handle, |
uint32_t | flushing_period_us | ||
) |
Create a background thread to periodically flush and parse the log buffers for each active profiler.
Open a thread to flush and parse the logs at the specified period expressed in microseconds.
Limitation: This API is only supported for flushing a profiler from the CPU.
[in] | logger_handle | Handle of the logger instance. |
[in] | flushing_period_us | Period at which the log buffer will be flushed to be parsed |
itrace_return_t itrace_start_section | ( | itrace_profiler_handle_t | profiler_handle, |
const char * | section_name, | ||
itrace_measured_events_t * | measured_events | ||
) |
Define the start of a section for which all registered events will be monitored.
Section statistics are derived from post-processing the monitored values at the start and end of the section according to their respective itrace_processing_mode_t. Section statistics are shown in both the trace and CSV files.
The values measured at the start of the section are also displayed independently of section statistics in the timeline that tracks the values of each monitored events over time.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | section_name | Name of the monitored section. |
[out] | measured_events | Measured events at the beginning of the section. Set to NULL to ignore. |
void itrace_start_section_no_events | ( | section_id_t | section_id | ) |
Define the start of a section without monitoring registered events.
This API is recommended to monitor the most time-critical sections of code. Only critical statistics will be read to reduce the monitoring overhead: On the CPU, only time will be monitored. On the DSPs, time and the 30 LSBs of the pcycle counter will be monitored. The cycle counts are marked as :PCYCLES_30b: in the json trace output and are not shown in the CSV output. These numbers correspond to the 30 LSBs of the pcycle 64-bit counter. The json report displays the number of cycles consumed by a code section using this counter as :PCYCLES_30b:d. It is the result of the delta (:d) between the end and start pcycle count, and accounts for a possible wrap around of the 30 LSBs of the pcycle counter.
[in] | section_id | Section identifier. |
itrace_return_t itrace_start_section_with_section_id | ( | itrace_profiler_handle_t | profiler_handle, |
section_id_t | section_id, | ||
itrace_measured_events_t * | measured_events | ||
) |
Define the start of a section for which all registered events will be monitored. This section is identified by an unsigned identifier.
Same as itrace_start_section except for the name of the section is replaced by a section_id_t.
[in] | profiler_handle | Handle of the profiler instance. A NULL value instructs the library to use the default profiler for the local domain. |
[in] | section_id | Section identifier. |
[out] | measured_events | Measured events at the beginning of the section. Set to NULL to ignore. |
itrace_return_t itrace_teardown | ( | itrace_logger_handle_t | logger_handle | ) |
Close itrace when utilizing CPU and/or DSP automation.
[in] | logger_handle | Handle of the logger instance to be closed. A NULL value instructs the library to use the default instrumentation logger. |