当前位置:网站首页>B_ QuRT_ User_ Guide(37)

B_ QuRT_ User_ Guide(37)

2022-07-07 23:26:00 weixin_ thirty-eight million four hundred and ninety-eight thou

B_QuRT_User_Guide(37)

23 Profiling

Threads use profiling to determine the number of cycles in selected parts of a user program . Use the collected data to determine a QuRT Threads ( Or the whole QuRT User program system ) Of CPU utilization .
Profiling supports running ( perform ) And leisure ( Don't execute ) The specific thread loop count of the cycle . Reset count can count the cycle of a specific part of the user program .
In addition to a profile cycle count , All cycle counts are based on processor cycles ( The actual number of processor cycles executed by all hardware threads ) Express , Not thread cycles ( for example , The number of cycles executed by a specific hardware thread ). Suppose there are six hardware threads , The following equation expresses the relationship between these two cycle types .
Thread cycle = Processor cycles /6
Enable profiling optionally enables or disables profiling ( Disabled by default ).
Be careful : Resetting the cycle count must be done explicitly by calling the reset operation before starting the cycle count .
Get profiling thread ID The processor cycle operation returns the specified QuRT The current count of running cycles per hardware thread of the thread ( The first 3 section ). This operation returns an array containing the current running cycle count of each hardware thread . Each count value represents the number of processor cycles that have passed on the corresponding hardware thread , And the thread has been scheduled to the specified QuRT Threads .
Get the configuration file thread processor cycle operation returns the specified QuRT The current running cycle count of the thread ( The first 3 section ). The count value represents the number of processor cycles that have passed on all hardware threads , At the same time, the thread has been scheduled to the specified QuRT Threads .
Be careful : The count value is equivalent to the thread that will get the configuration file ID The cycle count value of each hardware thread returned by the processor cycle operation is added .
get profile thread cycles Operation returns to the current QuRT The current running cycle count of the thread , Expressed in thread cycles .
get profile idle processor cycles The operation returns the current number of idle cycles ( namely , A hardware thread is in IDLE The number of cycles in which the state does not execute any instructions ). This operation returns an array containing the current number of idle cycles of each hardware thread . Each count value represents the number of processor cycles that have passed in the wait mode of the corresponding hardware thread .
Be careful : The cycle executed in the kernel is based on the state of the current thread when it transitions to the kernel ( for example , Idle or running ) To be divided into idle or running .
Get core processor cycle operation returned from Hexagon The number of processor cycles executed since the processor was last reset . This value is based on the hardware core clock , Its speed varies according to the processor clock frequency ( With the first 16 The system clock described in section is different .
In a given period of time , The number of cycles passed by this operation is related to the thread of getting the configuration file / Idle processor cycle operation ( Are described above ) The relationship between the returned values is expressed by the following formula :

 total_PCYCLES = run_pcycles + idle_pcycles

In this formula , Get core processor cycle operation return total_PCYCLES value .
run_pcycles and idle_pcycles Is based on getting the profile thread / The cycle value returned by the idle processor cycle operation is defined :

for (<all QuRT threads>) for (i = 0; i < MAX_HW_THREADS; i++) run_pcycles += profile_thread_pcycles[i] / 6;
for (i = 0; i < MAX_HW_THREADS; i++)
idle_pcycles += profile_idle_pcycles[i] / 6;

The loop count is summarized on a per thread basis , Therefore, the above code must convert each processor cycle count to thread cycle count ( By dividing by 6).
Be careful : When Hexagon When the processor is turned off , The hardware core clock stops running ( Because all its hardware threads are idle ), Treat the periodic value returned by this operation as a relative value rather than an absolute value .
Calculation CPU utilization - QuRT Threads ( Or the whole QuRT Application system ) Of CPU Utilization indicates , Within a certain period of time ,Hexagon How many cycles of processor execution are executed by specific threads ( Or application system ) Use :

CPU_utilization = run_pcycles / total_PCYCLES

In this equation ,run_pcycles Is the cycle count value returned by the get profile thread processor cycle operation .
total_PCYCLES It is operated by getting the cycle of the core processor ( Also described above ) The value returned .
Hexagon The processor may have spent some specified time in energy-saving mode , The hardware core clock is completely turned off ( Because all hardware threads are idle ). under these circumstances ,total_PCYCLES The value in does not represent absolute time .
In order to accurately calculate the CPU utilization , Turn off time adjustment with the core clock total_PCYCLES. Use the following formula to calculate QuRT Shutdown time of the system clock ( Also called ALL_WAIT period ):

ALL_WAIT_pcycles = ((total_sclk_samples / QTIMER_clock_freq)*
     core_clock_freq) - total_PCYCLES

In this equation ,total_sclk_samples yes QuRT The number of cycles passed by the system clock ( The first 16 section ). total_PCYCLES By get core processor cycles The value returned by the operation .QTIMER_clock_freq by
On all target systems 19.2 MHz.
core_clock_freq yes Hexagon The core clock frequency of the processor ( Specific to each target system ). in consideration of ALL_WAIT period , Adjusted CPU The utilization rate is :

CPU_utilization = run_pcycles / (total_PCYCLES + ALL_WAIT_pcycles)

Be careful :ALL_WAIT_pcycles The equation assumes Hexagon The processor core clock frequency does not change within the analyzed time interval . If the clock frequency does change during this time interval , The input value must be corrected , Because the weight of each sample is different .

23.1 qurt_get_core_pcycles()

23.1.1 Function document

23.1.1.1 unsigned long long int qurt_get_core_pcycles ( void )

Get the count of core processor cycles executed .
Return from Hexagon The current number of running processor cycles executed since the processor was last reset .
This value is based on the hardware core clock , Its speed varies according to the clock frequency of the processor .
Subtract the atomic variable by one .
Be careful : Because the hardware core clock stops running when the processor is turned off ( Because all hardware threads are idle ), Please treat the periodic value returned by this operation as a relative value rather than an absolute value .
The number of thread cycles is only V4 Hexagon Valid in processor version .
Return value
Integer – Current count of core processor cycles.

Dependencies
None.

23.2 qurt_atomic_compare_and_set()

23.2 Function document

23.2.1.1 void qurt_profile_enable ( int enable )

Enable profiling .
Enable or disable cycle counting for running and idle processor cycles . By default , Profiling is disabled .
Be careful : Enabling profiling does not automatically reset the cycle count - This must be done explicitly by invoking the reset operation before starting the cycle count .

Parameters
 Insert picture description here
Return value
None.
Dependencies
None.

23.3 qurt_profile_enable2()

23.3.1 Function document

23.3.1.1 int qurt_profile_enable2 ( qurt_profile_param_t param, qurt_thread_t thread_id, int enable )

Start analyzing specific parameters on specific threads ( If applicable ).
** Parameters **
 Insert picture description here
Return value
QURT_EOK – Success
QURT_EALREADY – Measurement already in progress or already stopped QURT_ENOTHREAD – Thread does not exist
QURT_EINVALID – Invalid profiling parameter

Dependencies
None.

23.4 qurt_profile_get()

23.4.1 Function document

23.4.1.1 int qurt_profile_get ( qurt_profile_param_t param, qurt_thread_t thread_id, qurt_profile_result_t ∗ result )

Get the value of the profiling parameter that was previously enabled .

Parameters
 Insert picture description here
Return value
QURT_EOK – Success
QURT_EFAILED – Operation failed; profiling was not enabled QURT_ENOTHREAD – Thread does not exist QURT_EINVALID – Invalid profiling parameter

Dependencies
None.

23.5 qurt_profile_get_idle_pcycles()

23.5.1 Function document

23.5.1.1 void qurt_profile_get_idle_pcycles ( unsigned long long ∗ pcycles )

Get the count of idle processor cycles .
Returns the current idle processor cycle count of all hardware threads .
This operation accepts a pointer to a user-defined array , And write the current idle cycle count of each hardware thread into the array .
Each count value represents the number of processor cycles that the corresponding hardware thread has passed in the wait mode .
Be careful : This operation does not return Hexagon Idle cycle that occurs when the processor is turned off ( Because all hardware threads are idle ).
Masked 64 Bitwise and operation of bitwise atomic variables .
Parameters
 Insert picture description here
Return value
None..

Dependencies
None.

23.6 qurt_profile_get_thread_pcycles()

23.6.1 Function document

23.6.1.1 unsigned long long int qurt_profile_get_thread_pcycles

Get the count of processor cycles that the current thread is running .
Returns the current QuRT The number of processor cycles the thread is running .

Return value
Integer – Running processor cycle count for current thread.

Dependencies
None.

23.7 qurt_get_hthread_pcycles()

23.7.1 Function document

23.7.1.1 unsigned int qurt_get_hthread_pcycles ( int n )

Read GCYCLE_nT register , In order to be in N Measure performance when threads are in run mode .
Be careful : When the architecture is older than v67 When to return to 0.
Parameters
 Insert picture description here
Return value
Value read from GCYCLE_nT register.

Dependencies
PMU must be enabled.

23.8 qurt_get_hthread_commits()

23.8.1 Function document

23.8.1.1 unsigned int qurt_get_hthread_commits ( int n )

Read GCOMMIT_nT register , In order to be in N Performance measurement when threads are in running mode .
Be careful : When the architecture is older than v67 When to return to 0.
Parameters
 Insert picture description here
Return value
Value read from the GCOMMIT_nT register.

Dependencies
PMU must be enabled.

23.9 qurt_profile_get_threadid_pcycles()

23.9.1 Function document

23.9.1.1 void qurt_profile_get_threadid_pcycles ( int thread_id, unsigned long long ∗ pcycles )

Get specified QuRT The running processor cycle count of the thread .
Returns the specified QuRT The current running cycle count of each hardware thread of the thread .
Each count value represents the number of processor cycles that have passed on the corresponding hardware thread , And the thread has been scheduled to the specified QuRT Threads .
Parameters
 Insert picture description here
Return value
None.

Dependencies
None.

23.10 qurt_profile_reset_idle_pcycles()

23.10.1 Function document

23.10.1.1 void qurt_profile_reset_idle_pcycles ( void

Set the idle cycle count of each hardware thread to zero .
Return value
None.

Dependencies
None.

23.11 qurt_profile_reset_threadid_pcycles()

23.11.1 Function document

23.11.1.1 void qurt_profile_reset_threadid_pcycles ( int thread_id )

Specifies the QuRT The run cycle count of each hardware thread of the thread is set to zero .

Parameters
 Insert picture description here
Return value
None.

Dependencies
None.

23.12 Data Types

This section describes the data types of profiling Services .

23.12.1 Data Structure Documentation

23.12.1.1 union qurt_profile_result_t

Analysis results .** Parameters **

23.12.1.2 struct qurt_profile_result_t.thread_ready_time

And QURT_PROFILE_PARAM_THREAD_READY_TIME Relevant results .
 Insert picture description here

23 Macros

This section describes the macros used to profile Services .

23.13 Define Documentation

23.13.1 Function document

23.13.1.1 static QURT_INLINE unsigned long long qurt_atomic64_sub_return (unsigned long long ∗ target, unsigned long long v )

Disable profiling .

23.13.1.2 #define QURT_PROFILE_ENABLE 1

Disable profiling .

23.13.2 Enumeration Type Documentation

23.13.2.1 enum qurt_profile_param_t

Enumerator :
QURT_PROFILE_PARAM_THREAD_READY_TIME Outline thread preparation time .

原网站

版权声明
本文为[weixin_ thirty-eight million four hundred and ninety-eight thou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207072054190981.html