Method for filtering timing fluctuations by analog sampling
By simulating the sampling filtering timing fluctuations, the timing error is calculated using the internal and external two-layer loop structure, the problem of difficult time fluctuation errors in the performance test of the multi-core central processor is solved, and a more accurate and stable program execution time distribution is achieved.
Patent Information
- Application Number
- CN202411920600.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-22
AI Technical Summary
In the multi-core performance test of modern central processors, the errors caused by timing fluctuations are difficult to filter, affecting accurate program timing.
By simulating the sampling filtering timing fluctuations, the internal and external loop structure is used to calculate the impact of timing errors on the original timing results, thereby filtering the errors caused by timing fluctuations and obtaining a more realistic running time distribution.
It effectively reduces the error caused by timing fluctuations, obtains a more accurate program execution time distribution, and improves the stability and reliability of timing results.
Smart Images

Figure CN119861790A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a technology in the field of supercomputers, in particular to a method for filtering timing fluctuations through analog sampling. Background Art
[0002] Modern advanced CPUs generally contain multiple physical cores. In order to test the performance of multi-cores, it is usually necessary to time the programs executed in parallel by multiple cores. The differences in the timing results between multiple tests and different cores reflect the performance fluctuations of the processor. In addition to the fluctuations caused by the execution of the program, performance fluctuations also include fluctuations caused by timing behavior. Timing fluctuations commonly occur in various software and hardware timing methods. When the impact of the timed code segment on the cache changes, the results of different timing tools will also change to varying degrees. When different timing tools cannot give relatively uniform results, the actual execution time is difficult to determine. Therefore, filtering the timing fluctuations in the measured values is very necessary for accurate program timing. Summary of the invention
[0003] In view of the above-mentioned deficiencies in the prior art, the present invention proposes a method for filtering timing fluctuations through simulated sampling. The method comprises an inner and outer two-layer loop structure, and utilizes the distribution of original timing measurement results of the timed program and the distribution of timing fluctuation sampling results. The influence of timing errors on the original timing results is calculated through simulated sampling. Thus, the errors caused by timing fluctuations are filtered out from the time distribution obtained from the original timing measurement, so as to obtain a more realistic running time distribution.
[0004] The present invention is achieved through the following technical solutions:
[0005] The present invention relates to a method for filtering timing fluctuations through analog sampling, wherein a simulated measurement value of a simulated interval is calculated, and the calculation of the simulated interval is cyclically adjusted with the goal of minimizing the error between the simulated measurement value and the real measurement value until the calculation of all intervals is completed, thereby obtaining the distribution of actual time consumption;
[0006] The circulation adjustment includes outer circulation processing and inner circulation processing.
[0007] The simulated measurement value is defined by the simulated probability to obtain the actual time-consuming distribution probability, and the simulated probability and the timing fluctuation are sampled and superimposed to simulate the measurement value, that is, the inner loop processing.
[0008] The present invention relates to a system for implementing the above method, comprising: a measurement value acquisition module, a distribution conversion module and a filtering module, wherein: the measurement value acquisition module performs a timing operation on the program to be measured to obtain the specific time consumption of the measurement value and the timing fluctuation; the distribution conversion module converts the specific time consumption of the measurement value and the timing fluctuation into a probability distribution; the filtering module obtains the probability distribution of the actual time consumption according to the measurement value and the timing fluctuation probability distribution through a filtering algorithm including inner and outer loop processing to filter the timing fluctuation. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is the schematic diagram of the invention;
[0010] In the figure: the blue rectangle represents the data collected by the timing operation, which is also the input value of the filtering method of the present invention; the green matrix represents two meanings: one is used to simulate the distribution of actual time consumption, initialized with the measured value distribution as input; the other is the output obtained by continuous adjustment during the simulation process; the yellow rectangle represents the intermediate result of adding the sampling results of the two distributions in the simulation; the arrow represents the operation on the distribution;
[0011] Figure 2 It is a flow chart of the present invention;
[0012] In the figure: the outer loop is i increasing by itself, and the time intervals of simulation / actual time consumption distribution are processed from small to large; the inner loop is simulation and error convergence judgment, until the final probability of a certain time interval is calculated;
[0013] Figure 3 , Figure 4 They are respectively the measured values and the cumulative distribution graphs of the program execution time after the measured values are subjected to the filtering operation of the present invention;
[0014] In the figure: the vertical axis is time, the horizontal axis is proportion, cgt, pmccntr, papi, and papix6 represent different timing functions. DETAILED DESCRIPTION
[0015] like Figure 2 As shown, this embodiment involves a method for filtering timing fluctuations by simulated sampling, which is implemented on a rack-mounted Kunpeng Arm server, which is equipped with an openEuler 22.03 64-bit operating system, two Kunpeng 920 processors (a total of 128 cores) and 512GB of main memory, and specifically includes:
[0016] Step 1: Calculate the distribution S of the measured values m , including:
[0017] 1.1 Select the jacobi2d5point calculation process with a measurement matrix size of 400x400, and call the clock_gettime function of the POSIX standard library twice at the beginning and end to obtain the timestamp information. The difference between the two times read is t m The time for this timing is repeated 1000 times, and 128 cores get a total of 128000 t m , that is, the measurement value set T m ;
[0018] 1.2 Arrange it into a distribution form S at intervals of 10 nanoseconds m ={(t m,i ,P(t m,i ))}, where: t m,i is the starting point of an interval of measured values, P(t m,i ) is the measured value in the distribution [t m,i ,t m,i+1 ), using n bin =51 is the distribution S m Medium m,i The number of .
[0019] Step 2: Calculate the timing fluctuation T under the measurement experiment e : Taking the measurement value set T m The median of the theoretical number of instructions executed in the measurement process is approximated by n. Add n mutually related ADD instructions to the jacobi2d5point process in step 1. Insert clock_gettime at the beginning and end of the n ADD instructions and calculate the difference between the two read times. n , multiple executions with t m The same number (128000) of t n , for each t n , based on the operating frequency f = 2.4GHz, calculate the difference τ between the theoretical and measured results e =t n -n / f, that is, the timing fluctuation time, the set of which is T e .
[0020] Step 3. Initialize global variables: set cumulative probability p tot = 0, the last round of all intervals before the simulation sampling starts S m Simulation results h,i =0, simulation error threshold Δp min = 0.00001, initialize the simulated probability distribution S r ={(t r,i =t m,i -τ e,min ,0)}, where: tr,i is the start of the ith time interval of the simulation, t r,i The set of r , t m,i is the start of the ith time interval of the measurement value, τ e,min is the timing fluctuation set T e The minimum value in .
[0021] Step 4: outer loop processing, specifically including:
[0022] 4.1 Determine whether to perform sampling simulation, specifically: when p = P (t m,i )-sim h,i <Δp min , that is, when the probability of the current interval is too small and no simulation sampling is required, end this outer loop, otherwise execute step 4.2.
[0023] 4.2 Initialize simulation probability: Set the simulation time interval [y r,i ,t r,i+1 )’s initial probability P(t r,i ) = p, the actual time distribution of the simulation S r ={(t r,i ,P(t r,i )}.
[0024] 4.3 Complete a measurement distribution S m Simulation: Distribution of actual simulation time S r and the timing fluctuation time set T e Perform nsamp=1000000 sampling times, and add the two sampling results to get the simulated measurement time t sim,j , statistics t sim,j falls within the distribution of the measured distribution S m All forms like [t m,i′ ,t m.i′+1 ) The frequency f in the interval i′ , get the current round of sampling distribution S m The simulation results
[0025] 4.4 Perform inner loop processing including simulation and adjusting simulation probability based on simulation results, specifically including:
[0026] a. Initialization before the inner loop: set Δp0 = ∞, Δp1 = sim′ h,i -t m,i , Δm Δr =(sim′ h,i -sim h,i ) / P(t r,i ).
[0027] b. Simulate sampling again to approach the target probability: set p tr =P(t r,i ), that is, define p tr is the time interval [t r,i ,t r,i+1 ) r,i ), update the error Δp0 of the previous simulation and the result cache sim of the previous simulation h , Δp0=Δp1,sim h,i′ =sim′ h,i′ , where: i′=0,1,…,n bin -1.
[0028] c. Determine when the probability P(t r,i )<0, that is, when the current interval probability is invalid, jump to step 4.5, otherwise execute step d.
[0029] d. Perform a new round of simulation sampling according to the process of step 4.3 to obtain the updated simulation result sim′ h,i And update the current round simulation error Δp1, specifically: Δp1 = sim′ h,i -P(t m,i ).
[0030] e. When the simulation error of the current round converges, that is, Δp1<Δp min When , the probability of the current round of simulation is updated to the cache p tr =P(t r,i ) and execute step 4.5, otherwise determine whether the simulation error Δp1 of the current round is less than the simulation error Δp0 of the previous round, that is, when |Δp0|>|Δp1|, return to step b, otherwise execute step 4.5.
[0031] 4.5 Calculation of cumulative probability p tot =p tot +p tr After that, when the cumulative probability has not reached 1, the probability P(t r,i )=p tr The outer loop processing ends and returns to step 4.1, otherwise proceed to step 5.
[0032] Step 5: Tail interval selection: Determine the cumulative probability range |p tot -1|>|p tot -1-p tr |, that is, p tot -p tr When the probability is closer to 1, the last interval is discarded, that is, cache p trThe probability in is not included in the cumulative probability p tot and update the cumulative probability p tot =p tot -p tr , P(t r,i )=0; otherwise P(t r,i )=p tr .
[0033] Step 6: Perform standardization operation P(t r,i )=P(t r,i ) / p tot , the actual time consumption distribution S r ={(t r,i ,P(t r,i )} is converted into a legal distribution, so that the result conforms to the normalization theorem. At this time, the filtering process of timing fluctuations is completed. At this time, the distribution S r is the measurement distribution S m Probability distribution of actual elapsed time after filtering timing fluctuations.
[0034] After specific practical experiments, in the experimental environment described in step 1, for the jacobi2d5point program without a fixed theoretical actual time consumption, the measured values obtained by timing using different measurement methods are as follows Figure 3 As shown, the actual time consumed by the filtration method of the present invention is as follows Figure 4 As shown, by comparing the two, it can be observed that after the four methods are used to filter the timing fluctuations, the long tail ratio in the measured values is reduced, and the actual time consumption obtained from the measured values of the four methods is also closer.
[0035] Compared with the prior art which usually uses the deconvolution method to decouple the distribution of measured values caused by the superposition of timing fluctuations and actual time consumption, resulting in poor robustness, the present invention uses the analog sampling method to increase the sampling volume to reduce the deviation caused by noise, does not rely on mathematical inversion, and can obtain more stable results.
[0036] The above-mentioned specific implementation can be partially adjusted in different ways by those skilled in the art without departing from the principle and purpose of the present invention. The protection scope of the present invention shall be based on the claims and shall not be limited by the above-mentioned specific implementation. Each implementation scheme within its scope shall be subject to the constraints of the present invention.
Claims
1. A method for filtering timing fluctuations by analog sampling, characterized in that: By calculating the simulated measurement value of a simulation interval, the calculation of the simulation interval is cyclically adjusted with the goal of minimizing the error between the simulated measurement value and the real measurement value until the calculation of all intervals is completed, and the distribution of actual time consumption is obtained; The circulation adjustment includes outer circulation processing and inner circulation processing; The simulated measurement value is defined by the simulated probability to obtain the actual time-consuming distribution probability, and the simulated probability and the timing fluctuation are sampled and superimposed to simulate the measurement value, that is, the inner loop processing.
2. The method for filtering timing fluctuations by analog sampling according to claim 1, characterized in that: The simulated measurement value of the simulation interval is obtained by: 1.1 Call the time acquisition function at the beginning and end of the program to be tested to obtain timestamp information. The difference between the two times read is t m is the time of this timing, repeat this process several times to get the measurement value set T m ; 1.2 Set the measurement value set T m Arranged into distribution form S m ={(t m,i ,P(t m,i ))}, where: t m,i is the starting point of an interval of measured values, P(t m,i ) is the measured value in the distribution [t m,i ,t m,i+1 ) probability.
3. The method for filtering timing fluctuations by analog sampling according to claim 2, characterized in that: The outer layer circulation treatment comprises: 4.1 Determine whether to perform sampling simulation, specifically: when p = P (t m,i )-sim h,i <Δp min , that is, when the probability ratio of the current interval is too small and no simulation sampling is required, end this outer loop, otherwise execute step 4.2; 4.2 Initialize simulation probability: Set the simulation time interval [t r,i ,t r,i+1 )’s initial probability P(t r,i ) = p, the actual time distribution of the simulation S r ={(t r,i ,P(t r,i )}; 4.3 Complete a measurement distribution S m Simulation: Distribution of actual simulation time S r and the timing fluctuation time set T e Perform nsamp=1000000 sampling times, and add the two sampling results to get the simulated measurement time t sim,j , statistics t sim,j falls within the distribution of the measured distribution S m All forms like [t m,i′ ,t m.i′+1 ) The frequency f in the interval i′ , get the current round of sampling distribution S m The simulation results 4.4 Performing inner loop processing including simulation and adjusting simulation probability based on simulation results; 4.5 Calculation of cumulative probability p tot =p tot +p tr After that, when the cumulative probability has not reached 1, the probability P(t r,i )=p tr The outer loop processing ends and returns to step 4.1, otherwise the tail interval selection processing is performed.
4. The method for filtering timing fluctuations by analog sampling according to claim 2 or 3, characterized in that: The inner layer circulation process comprises: a. Initialization before the inner loop: set Δp0 = ∞, Δp1 = sim′ h,i -t m,i , Δm Δr =(sim′ h,i -sim h,i ) / P(t r,i ); b. Simulate sampling again to approach the target probability: set p tr =P(t r,i ), that is, define p tr is the time interval [t r,i ,t r,i+1 ) r,i ), update the error Δp0 of the previous simulation and the result cache sim of the previous simulation h , Δp0=Δp1,sim h,i′ =sim′ h,i′ , where: i′=0,1,…,n bin -1; c. Determine when the probability P(t r,i )<0, that is, when the current interval probability fails, jump to step 4.5, otherwise execute step d; d. Perform a new round of simulation sampling according to the process of step 4.3 to obtain the updated simulation result sim′ h,i And update the current round simulation error Δp1, specifically: Δp1 = sim′ h,i -P(t m,i ); e. When the simulation error of the current round converges, that is, Δp1<Δp min When , the probability of the current round of simulation is updated to the cache p tr =P(t r,i ) and execute step 4.5, otherwise determine whether the simulation error Δp1 of the current round is less than the simulation error Δp0 of the previous round, that is, when |Δp0|>|Δp1|, return to step b, otherwise execute step 4.
5.
5. The method for filtering timing fluctuations by analog sampling according to claim 3, characterized in that: The tail interval selection process is to determine the cumulative probability range |p tot -1|>|p tot -1-p tr |, that is, p tot -p tr When the probability is closer to 1, the last interval is discarded, that is, cache p tr The probability in is not included in the cumulative probability p tot and update the cumulative probability p tot =p tot -p tr , P(t r,i )=0; otherwise P(t r,i )=p tr .
6. The method for filtering timing fluctuations by analog sampling according to claim 5, characterized in that: After the tail interval is selected, the standardization operation P(t r,i )=P(t r,i ) / p tot , the actual time consumption distribution S r ={(t r,i ,P(t r,i )} is converted into a legal distribution, so that the result conforms to the normalization theorem. At this time, the filtering process of timing fluctuations is completed. At this time, the distribution S r is the measurement distribution S m Probability distribution of actual elapsed time after filtering timing fluctuations.
7. A system for filtering timing fluctuations according to any one of the methods of claims 1 to 6, characterized in that: include: A measurement value acquisition module, a distribution conversion module and a filtering module, wherein: the measurement value acquisition module performs a timing operation on the program to be measured to obtain the specific time consumption of the measurement value and the timing fluctuation; The distribution conversion module converts the specific time consumption of the measurement value and timing fluctuation into a probability distribution; the filtering module obtains the probability distribution of the actual time consumption based on the measurement value and the timing fluctuation probability distribution through a filtering algorithm including inner and outer loop processing to filter the timing fluctuation.