Developer Guide

  • 2021.1
  • 11/03/2021
  • Public
Contents

About the Sample

To pinpoint the latency source in an application, you may need to measure not only the entire real-time cycle but also stages within it. You can add measurement library APIs to each of these parts of your code.
The multiple measurements sample (
tcc_multiple_measurements_sample
) illustrates what the instrumentation might look like. In this sample, three portions of code are being measured.
  • The first portion of code is the multiplication of two matrices. Matrices in this sample are square, and you can set their size.
  • The second calculates the Nth approximation of the number 2 / pi. You can set the parameter N, an increase in N leads to an increase in the accuracy of the approximation.
  • The last one includes both parts – matrix multiplication and approximation 2 / pi.
This sample represents an arbitrary computation workload that might be executed as part of a real-time control loop, such as computation of a robotic arm’s next position. The computation itself and the result are not relevant for this demonstration.
The sample also represents a use case in which an application is instrumented with measurement library APIs and the data generated from the application is intended to be analyzed by a separate profiling application. The sample does not print latency data but the data can be viewed when it is run with the Measurement Analysis Sample.

Implementation

This sample demonstrates the use of the following functions:
  1. ittnotify:
    • __itt_domain_create(domain_name)
      - Create ITT domain.
    • __itt_string_handle_create(measurement_name)
      - Create ITT task handle.
    • __itt_task_begin(domain, __itt_null, __itt_null, measurement)
      - Collect the measurement start time based on the CPU’s timestamp counter (TSC).
    • __itt_task_end(domain)
      - Collect the measurement end time based on the TSC and calculate the difference between the start and end times to get the latency measurement.
The sample has the following flow:
  1. The sample starts by defining the ITT domain and the task handle.
  2. When all the required variables are initialized, the sample runs the
    run_measurement_cycle
    function which starts two workloads:
    • The first workload executes matrices multiplication.
    • The second workload calculates the Nth approximation of the 2/pi number.
  3. The sample measures the overall latency for both workloads and the latencies for each workload.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.