当前位置:网站首页>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
- 23.1 qurt_get_core_pcycles()
- 23.2 qurt_atomic_compare_and_set()
- 23.3 qurt_profile_enable2()
- 23.4 qurt_profile_get()
- 23.5 qurt_profile_get_idle_pcycles()
- 23.6 qurt_profile_get_thread_pcycles()
- 23.7 qurt_get_hthread_pcycles()
- 23.8 qurt_get_hthread_commits()
- 23.9 qurt_profile_get_threadid_pcycles()
- 23.10 qurt_profile_reset_idle_pcycles()
- 23.11 qurt_profile_reset_threadid_pcycles()
- 23.12 Data Types
- 23 Macros
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
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 **
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
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
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
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
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
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
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 .
23.12.1.2 struct qurt_profile_result_t.thread_ready_time
And QURT_PROFILE_PARAM_THREAD_READY_TIME Relevant results .
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 .
边栏推荐
- Inftnews | the wide application of NFT technology and its existing problems
- USB (十八)2022-04-17
- Wechat forum exchange applet system graduation design (2) applet function
- Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem
- Dynamics 365 find field filtering
- 【编译原理】词法分析设计实现
- Install Fedora under RedHat
- [microservices SCG] gateway integration Sentinel
- Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
- Technology at home and abroad people "see" the future of audio and video technology
猜你喜欢
伸展树(一) - 图文解析与C语言实现
Explain
Inftnews | the wide application of NFT technology and its existing problems
13、 System optimization
Mysql索引优化实战一
Description of longitude and latitude PLT file format
Inftnews | web5 vs Web3: the future is a process, not a destination
Solve the problem of duplicate request resource paths /o2o/shopadmin/o2o/shopadmin/getproductbyid
移动端异构运算技术 - GPU OpenCL 编程(基础篇)
Spark 离线开发框架设计与实现
随机推荐
Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
Puce à tension stabilisée LDO - schéma de bloc interne et paramètres de sélection du modèle
The 19th Zhejiang Provincial College Programming Contest VP record + supplementary questions
js 获取对象的key和value
Caip2021 preliminary VP
Illegal behavior analysis 1
Oracle database backup and recovery
Install Fedora under RedHat
System design overview
v-for遍历对象
PCI-Express接口的PCB布线规则
Experience sharing of system architecture designers in preparing for the exam: the direction of paper writing
MATLAB signal processing [Q & A essays · 2]
Mysql索引优化实战二
Network security - information query of operating system
USB(十四)2022-04-12
sql 数据库执行问题
Freelink open source call center design idea
Ros2 topic (03): the difference between ros1 and ros2 [02]
云原生正在吞噬一切,开发者该如何应对?