Dynamic adaptive sampling simulation warm-up optimization method and high-performance CPU simulator
Through the dynamic adaptive sampling simulation preheating optimization method, the instruction flow characteristics are captured in real time and the preheating distance is optimized using deep learning and reinforcement learning, which solves the problem of simulation accuracy and inefficiency in the existing technology, and realizes multi-core collaboration and single-core optimization of high-performance CPU emulators.
Patent Information
- Application Number
- CN202510940755.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-07-09
AI Technical Summary
The existing sampling simulation preheating method is difficult to achieve accuracy and efficiency in dynamic instructions and multi-core processor environments, and cannot adapt to complex and changeable instruction flows and multi-core collaborative work, resulting in inaccurate and inefficient simulation results.
The dynamic adaptive sampling simulation preheating optimization method is adopted, and the dynamic features of the instruction flow are extracted in real time, and the preheating distance is dynamically adjusted using the deep learning model and reinforcement learning framework, combining cross-core state transmission and asynchronous preheating scheduling to optimize the preheating strategy of multi-core systems.
It significantly improves the accuracy and efficiency of simulation results, reduces the L1 D Cache missing rate and CPI error, improves the performance and scalability of multi-core systems, and adapts to different processor architectures and application scenarios.
Smart Images

Figure CN120430253B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of processor performance evaluation, and in particular to a dynamic adaptive sampling simulation preheating optimization method and a high-performance CPU simulator. Background Art
[0002] With the rapid development of information technology, processor performance evaluation plays a vital role in computer architecture design, system optimization, and software development. Sampling simulation, a commonly used method for processor performance evaluation, simulates the execution of a program on a processor to provide data support for performance analysis. Sampling simulation involves replacing the entire program with a set of representative program fragments to reduce simulation time. However, the sampled program fragments are not continuous. To establish accurate microarchitectural states (such as cache and branch instruction predictor states) for each program fragment, it is necessary to simulate the execution of a subset of other instructions before each selected program fragment. This process is called warm-up. However, with the increasing complexity of heterogeneous multi-core processor architectures and the widespread use of lightweight programs in emerging fields such as edge computing and artificial intelligence, traditional sampling simulation warm-up methods have gradually exposed numerous issues and are unable to meet the growing demand for performance evaluation.
[0003] Currently, mainstream sampling simulation warm-up methods include fixed-length warm-up and reuse distance vector (RDV)-based methods. Fixed-length warm-up methods preprocess programs using a fixed warm-up distance. While simple and straightforward, they completely ignore the dynamic nature of the instruction stream during execution. In real-world applications, program execution patterns are complex and dynamic, potentially leading to sudden bursts of computationally intensive segments or significant changes in the proportion of instruction types over short periods of time. Fixed-length warm-up methods are unable to effectively adjust to these dynamic changes, easily resulting in insufficient warm-up and making simulation results inaccurately reflect the processor's performance under real-world loads. Reuse distance vector-based methods, on the other hand, rely on static memory characteristics, analyzing historical memory access data to determine warm-up strategies. While these methods take memory access patterns into account to some extent, they lack the ability to perceive real-time dynamic changes in the instruction stream. Therefore, they struggle to adapt quickly to changes in programs with frequently changing instruction access patterns. This leads to a disconnect between warm-up strategies and actual requirements, compromising the accuracy of processor performance evaluation.
[0004] Furthermore, with multi-core processors becoming the mainstream computing platform, existing warmup synchronization mechanisms face significant challenges. In a multi-core environment, inter-thread collaboration complicates program execution. When program fragments involve thread synchronization, critical information, such as cache states, must be promptly communicated between cores to ensure microarchitectural state consistency. However, current warmup synchronization mechanisms generally lack an effective cross-thread warmup state transfer mechanism, resulting in poor coordination between cores during the warmup process. This ultimately leads to microarchitectural state deviations, severely impacting the overall performance of multi-core systems. Furthermore, existing synchronization mechanisms often lack effective error compensation and dynamic core adjustment strategies for handling uneven multi-core loads. Different cores may experience varying loads when executing tasks due to task characteristics, resource allocation, and other factors. Failure to promptly adjust warmup strategies can further exacerbate performance imbalances, hindering the full potential of multi-core processors' parallel computing capabilities and significantly limiting the system's scalability and stability in multi-core environments.
[0005] At the same time, most existing warm-up methods use a fixed warm-up distance or a simple rule-based allocation method, failing to take factors such as simulation progress, program characteristics, and the real-time status of the system into consideration. In actual processor performance evaluation, different programs have unique instruction characteristics and performance requirements. For example, artificial intelligence programs may have high requirements for the locality of memory access, while scientific computing programs focus more on the efficient use of computing resources. In addition, environmental factors such as system load are also in dynamic change. Fixed warm-up methods cannot be adaptively adjusted according to these dynamic changes, which can easily lead to excessively long warm-up times, reduced simulation efficiency, or poor warm-up effects, and cannot provide reliable data support for processor performance evaluation.
[0006] In summary, the existing sampling simulation preheating method has obvious shortcomings in terms of dynamic changes in instructions and multi-core processors, which seriously restricts the accuracy and efficiency of processor performance evaluation. There is an urgent need for a new preheating optimization method that can adapt to diverse application scenarios and complex system environments. Summary of the Invention
[0007] Purpose of the invention: In order to solve the problem that the existing sampling simulation preheating method has low simulation accuracy and efficiency when the instructions are complex and changeable, the present invention provides a dynamic adaptive sampling simulation preheating optimization method and a high-performance CPU simulator.
[0008] Technical solution: A dynamic adaptive sampling simulation preheating optimization method, comprising the following steps:
[0009] Step 1: prepare an instruction stream, which includes multiple program fragments, and extract dynamic features of each program fragment in real time. The dynamic features include instruction mixing ratio vector, branch history entropy, and cache access time-space matrix;
[0010] Step 2: Draw the warm-up distance error curve for each program segment and calculate the curvature parameter of the warm-up distance error curve; use a deep learning model to build a warm-up sensitivity prediction model. The model input is the dynamic features of step 1, and the output is the curvature parameter of the warm-up distance error curve. The warm-up sensitivity prediction model is trained;
[0011] Step 3: Use the warm-up sensitivity prediction model from step 2 to obtain the curvature parameter of the warm-up distance error curve of the sampled program fragment; formulate a warm-up distance allocation strategy based on the reinforcement learning framework to allocate warm-up distances to the sampled program fragments. The warm-up distances allocated to each program fragment are:
[0012]
[0013] in For the The distribution warm-up distance of each program fragment; For the The curvature parameter of the warm-up distance error curve of each program segment; For the The weight of each program fragment; is the total number of program fragments after sampling; is the total warm-up distance; is the reinforcement learning state value; is the dynamic adjustment coefficient;
[0014] And calculate the reward function, and continuously adjust the dynamic adjustment coefficient in the warm-up distance distribution strategy according to the result of the reward function , until the reward function converges and the simulation error and simulation time are within the preset thresholds.
[0015] Furthermore, in step 2, the method for drawing the preheating distance error curve of each program fragment is: for each program fragment, simulation is performed using different set preheating distances to obtain the simulation error. The simulation error is the error calculated by comparing the simulation results at each preheating distance with the actual operation data. The curve is drawn with the preheating distance as the horizontal axis and the corresponding error as the vertical axis, which is the preheating distance error curve.
[0016] Furthermore, the reward function in step 3 is: ,
[0017] in is the L1 D Cache miss rate error, is the preheating time, obtained from the preheating distance, and are the weighting coefficients of error and warm-up time, respectively, and .
[0018] Furthermore, if the CPU for sampling simulation is a multi-core CPU, step 4 is also included to update the preheating state through cross-core state transfer, which specifically includes: each core records and maintains a state information table, and the state information includes the preheating progress and resource allocation status; when a thread synchronization instruction is detected, the state information is serialized and transmitted through the inter-core communication interface; the target core deserializes the state information and updates the preheating strategy so that the preheating progress of the target core is synchronized with that of the source core.
[0019] Furthermore, if the CPU being sampled and simulated is a multi-core CPU, step five of asynchronous preheating scheduling adjustment is also included, specifically including: each core independent scheduler independently determines the preheating start time and resource allocation based on the preheating distance obtained in step three and the system resource situation; utilizes hardware synchronization primitives and software synchronization algorithms to ensure state consistency; detects the performance of each core, and when the performance gap between cores is greater than a preset threshold, dynamically adjusts the distribution of preheating distances, increases the preheating distance allocated to cores with poor performance, and reduces the preheating distance allocated to cores with good performance.
[0020] Furthermore, if the CPU being sampled and simulated is a multi-core CPU, the process further includes step 6, an error compensation step, which specifically includes: detecting the real-time load of each core and compensating the preheating distance obtained in step 3 according to the real-time load:
[0021]
[0022] For the The final warm-up distance of each core; For the Real-time load of each core; is the average load rate of all cores; 、 are the maximum and minimum values of the nuclear loading rate; is the load sensitivity factor.
[0023] Furthermore, the method further includes step seven, a long preheating distance cutting step, which specifically includes:
[0024] Set the upper limit of the preheating distance cutoff If the preheating distance obtained in step 3 or step 4 exceeds , then change it to ,
[0025]
[0026] in The upper limit of the preheating distance cutoff; is the total warm-up distance; is the cutoff coefficient.
[0027] Furthermore, in step one, the instruction mixture ratio vector is the proportion of arithmetic logic instructions, memory access instructions, and branch instructions under different instruction set architectures; the branch history entropy is based on the global branch prediction history, and the branch uncertainty of the instruction stream is calculated for different prediction algorithms, and the dynamic change characteristics of the branch behavior are characterized by the information entropy theory; the cache access time-space matrix is the time interval and spatial distribution of cache line access at different levels.
[0028] Furthermore, in step one, the dynamic features of each program fragment are extracted through hardware performance counters, and multiple instructions generate a set of dynamic feature vectors, which are stored in the feature database after standardization for use in model training in step two.
[0029] A high-performance CPU simulator is a computer software product installed on a computer, which can be executed by a computer processor to implement the above-mentioned dynamic adaptive sampling simulation preheating optimization method.
[0030] Compared with the prior art, the present invention provides a dynamic adaptive sampling simulation preheating optimization method and a high-performance CPU simulator, which has the following beneficial effects:
[0031] (1) Excellent dynamic adaptability: This method captures dynamic instruction features in real time and builds a warm-up sensitivity model based on a deep learning model, which can accurately allocate warm-up distances based on program characteristics. In complex instruction flow scenarios, compared with traditional fixed-length warm-up, the L1 D Cache miss rate error can be reduced by 38.7% to 50%, and the CPI error can be reduced by 41.2% to 55%. For example, when running big data analysis programs, traditional methods have difficulty coping with dynamic changes in instructions, while this method can quickly adapt to dynamic changes in instructions, significantly improving the cache hit rate and thus reducing the CPI;
[0032] (2) Powerful multi-core scalability: A synchronous warm-up mechanism is further proposed for multi-core scenarios, covering various cross-core state transfer methods and asynchronous warm-up scheduling strategies. Experiments have shown that when performing multi-threaded task testing on a 4-core processor, the cross-thread error fluctuation can be reduced by 52.3% to 65%. Taking parallel computing tasks as an example, each core can efficiently cooperate to ensure the consistency of the microarchitecture state, greatly improving the overall performance of the multi-core system;
[0033] (3) Efficient time utilization: By dynamically adjusting the warm-up distance and optimizing the warm-up time through reinforcement learning, the total warm-up time can be reduced by 27.5% to 40% compared to existing methods. Furthermore, this method does not require complex pre-trained neural networks and can be quickly deployed on resource-constrained edge computing devices, greatly improving simulation efficiency.
[0034] (4) Wide Applicability: The method adopted by this invention can be effectively run on mainstream x86 architecture processors, ARM, and the emerging RISC-V architecture processors. It can demonstrate good performance optimization effects in program simulation in different application fields, such as artificial intelligence computing, scientific computing, and industrial control scenarios.
[0035] (5) Flexible configurability: Various parameters in the method, such as feature extraction frequency, model structure parameters, state space and action space of reinforcement learning, and parameters related to the multi-core synchronization mechanism, can be flexibly configured according to different hardware environments, software requirements, and application scenarios. Users can customize the system according to actual conditions and ensure performance to meet diverse needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 This is a flow chart of a dynamic adaptive sampling simulation warm-up optimization method;
[0037] Figure 2 Extract flow chart for dynamic instruction features;
[0038] Figure 3 This is a structural diagram of the convolutional neural network model of Example 1;
[0039] Figure 4 A flowchart of a method for allocating adaptive preset distances;
[0040] Figure 5 Schematic diagram of the multi-core synchronous preheating mechanism. DETAILED DESCRIPTION
[0041] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments.
[0042] Example 1:
[0043] A dynamic adaptive sampling simulation warm-up optimization method, such as Figure 1 As shown, the following steps are included:
[0044] Step 1: Prepare the instruction stream, which includes multiple program fragments. Extract the dynamic features of each program fragment in real time. The dynamic features include the instruction mixture ratio vector (MV), branch history entropy (BHE), and cache access time and space matrix (CAST).
[0045] Among them, the instruction mixing ratio vector accurately records the proportion of arithmetic logic instructions, memory access instructions, and branch instructions in different instruction set architectures (such as x86, ARM, RISC-V, etc.), and is used to quantify the distribution characteristics of instruction types, which is different from traditional static statistical methods; the branch history entropy is based on the global branch prediction history, and calculates the branch uncertainty of the instruction stream for different prediction algorithms (such as static branch prediction, two-level adaptive prediction in dynamic branch prediction, etc.), and uses information entropy theory to characterize the dynamic change characteristics of branch behavior, providing key input for warm-up strategies; the cache access time-space matrix records in detail the time intervals and spatial distributions of cache line accesses at different levels (L1, L2, L3 cache, etc.), and the feature extraction process can flexibly adjust the sampling frequency according to different simulation accuracy requirements (such as cycle accuracy, instruction accuracy, etc.), and integrate cache access patterns through time and space dimensions. Figure 2 shown.
[0046] Custom instruction stream analysis modules can be added to the timing CPU modes (including but not limited to TimingSimpleCPU and O3CPU) of various mainstream simulators (including but not limited to Gem5, Simics, and QEMU). Hardware performance counters (including but not limited to Intel PMUs and ARM PMUs) can be used to extract and capture the three aforementioned dynamic features in real time. The feature extraction process flexibly adjusts the sampling frequency based on varying simulation accuracy requirements (e.g., cycle-accurate, instruction-accurate, etc.). Instruction execution data is collected using hardware performance counters (including but not limited to Intel PMUs and ARM PMUs). Based on different processor architectures and performance requirements, a set of feature vectors is generated for every certain number of instructions (e.g., every 500-5000 instructions). After normalization, these vectors are stored in a feature database for use in model training in step 2. This database can be selected from a variety of database types (e.g., relational databases like MySQL and non-relational databases like MongoDB) to accommodate diverse data storage and query requirements.
[0047] Step 2: Draw the warm-up distance error curve for each program fragment and calculate the curvature parameter of the warm-up distance error curve; use a deep learning model (including but not limited to a three-layer convolutional neural network, a recurrent neural network LSTM, a Transformer model based on an attention mechanism, etc.) to build a warm-up sensitivity prediction model. The model input is the dynamic features of step 1, and the output is the curvature parameter of the warm-up distance error curve. The warm-up sensitivity prediction model is trained.
[0048] Drawing the warmup distance error curve for each program fragment involves simulating each program fragment using different predefined warmup distances (e.g., 1000 instructions, 3000 instructions, 5000 instructions, etc.). Aside from the warmup distance, all other simulation conditions (e.g., instruction stream, system configuration, etc.) remain consistent to ensure that simulation errors are solely due to differences in warmup distance. Common simulation error metrics include cache miss rate error and CPI (cycles per instruction) error, which are determined based on the simulation objectives. Simulation error is calculated by comparing the simulation results at each warmup distance with the actual run data. Finally, a curve is drawn with the warmup distance as the horizontal axis and the corresponding error as the vertical axis; this is the warmup distance error curve.
[0049] The curvature parameter characterizes the preheating sensitivity, reflects the rate at which the error changes with the preheating distance, and is used to quantify the sensitivity of the program to the adjustment of the preheating distance. When the curvature parameter is large, it means that the error changes significantly with the preheating distance, and the preheating strategy needs to be fine-tuned; otherwise, a more extensive adjustment strategy can be used. The model structure can be flexibly adjusted according to different computing resource limitations (such as lightweight models on edge devices, or high-performance models in data centers). The convolution layer can use convolution kernels of different sizes (such as 3*3, 5*5, etc.) to extract spatial correlations between features; the pooling layer can use different strategies such as maximum pooling and average pooling to reduce feature dimensions; the fully connected layer outputs the curvature parameter to characterize the preheating sensitivity. Such as Figure 3 shown.
[0050] When using a convolutional neural network model, a variety of optimization algorithms (such as stochastic gradient descent SGD, adaptive moment estimation Adam, etc.) can be used in the model training process, with the mean square error (MSE) loss function as the optimization target. The learning rate is dynamically adjusted according to the changes in the loss function during the training process: for example, the initial learning rate can be set to 0.01. When the loss function decreases gradually, the learning rate is reduced by exponential decay (such as multiplying by 0.95); when the loss function decreases rapidly, the learning rate is increased by a certain coefficient (such as dividing by 1.1) to improve the convergence speed and prediction accuracy of the model.
[0051] Step 3: Utilizing the warmup sensitivity prediction model from Step 2, the curvature parameters of the warmup distance error curve for the sampled program snippet are obtained. A warmup distance allocation strategy is developed based on a reinforcement learning framework (such as Deep Q-Network (DQN), Dual Deep Q-Network (DDQN), Proximal Policy Optimization (PPO), or Deep Deterministic Policy Gradient (DDPG). The state space includes the characteristics of the current program snippet, the allocated warmup distance, and historical error data. Additionally, additional state information (such as current system load and instruction density) can be added for dynamic adjustment based on the actual application scenario. A distributed training approach is used to accelerate the training process and accommodate the processing needs of large-scale simulation data. Furthermore, the size of the experience replay buffer can be dynamically adjusted based on program complexity and training data diversity.
[0052] The warm-up distances are allocated to the sampled program segments. The warm-up distances allocated to each program segment are:
[0053]
[0054] in For the The distribution warm-up distance of each program fragment; For the The curvature parameter of the warm-up distance error curve of each program segment; For the The weight of each program fragment can be determined based on various factors (such as the frequency of program execution, the degree of impact on system performance, etc.); is the total number of program fragments after sampling; It is the total warm-up distance, which can be set according to different simulation task requirements; is the reinforcement learning state value; To dynamically adjust the coefficient, it can be adaptively adjusted according to the speed of different environmental changes (such as the frequency of changes in instruction characteristics during program operation). When the frequency of changes in instruction characteristics is higher than the threshold, the coefficient is increased. To speed up the adjustment; when the frequency of change is lower than the threshold, reduce To maintain the stability of the strategy. Figure 4 shown.
[0055] And set the reward function: ,
[0056] in is the L1 D Cache miss rate error, is the preheating time, which can be obtained from the preheating distance. Generally speaking, the greater the preheating distance, the longer the preheating time. and are the weighting coefficients of error and warm-up time, respectively, and ,These two weighted coefficients can be dynamically adjusted according to different ,optimization objectives (such as focusing more on reducing the miss rate error, or focusing more on reducing the ,warm-up time).
[0057] Continuously adjust the dynamic adjustment coefficient in the warm-up distance distribution strategy based on the results of the reward function Specifically, the current warm-up distance allocation strategy is judged based on the reward value. If the reward value increases towards the optimization goal (such as the cache miss rate error decreases, the warm-up time is shortened), it means that the current If the adjustment direction is correct, continue to adjust according to the current trend; if the reward value does not improve or even deteriorates, adjust in the opposite direction. Repeat this process until the adjustment end conditions are met, such as the reward function converges (for example, the fluctuation range of the reward value is less than the preset threshold in N consecutive iterations), the simulation error and simulation time do not exceed the warm-up threshold ( and )wait.
[0058] A high-performance CPU simulator is a computer software product installed on a computer, which can be executed by a computer processor to implement the above-mentioned dynamic adaptive sampling simulation preheating optimization method.
[0059] The following experiment is conducted in a single-core scenario to verify the effect of this embodiment.
[0060] Use Gem5's Deriv03cpu to simulate a single-core x86 architecture CPU and use the 401.bzip2 program in SPEC2006 for testing:
[0061] 1. The fragment size is set to 10,000 instructions according to the program characteristics and simulation requirements, and the total warm-up distance Set to 20,000, the total number of instructions for traditional fixed-length preheating is the same;
[0062] 2. The feature extraction module uses the CPU hardware counter to generate IMV, BHE, and CAST features every 1000 instructions and stores them in the MySQL database for management;
[0063] 3. A convolutional neural network model was used to build a warm-up sensitivity model. 200 rounds of training were performed using the Adam optimization algorithm. The learning rate was dynamically adjusted according to the change of the loss function. The initial setting was 0.001. The model adaptive adjustment took 0.8 seconds.
[0064] 4. The reinforcement learning agent uses the DDPG algorithm, and the experience replay buffer size is dynamically adjusted to 10,000 based on program complexity and data diversity.
[0065]
[0066] The experimental results are shown in the table above. Compared with the traditional equal-length warm-up strategy, the L1 D Cache miss rate error of this method is reduced from 18.7% to 11.5% (an improvement of 38.5%). This is because the dynamic feature extraction accurately captures the frequent memory access patterns during the bzip2 compression process. The curvature parameters output by the CNN model are Dynamically adjust the warmup distance distribution. CPI error is reduced from 17.3% to 10.2% (a 41% improvement). The reinforcement learning framework balances error and time through the reward function, reducing the warmup time from 32.5 seconds to 23.5 seconds (a 27.7% reduction).
[0067] Example 2:
[0068] The difference between the second embodiment and the first embodiment is that the first embodiment is suitable for application in a single-core CPU, while the second embodiment is applicable to a multi-core CPU.
[0069] If the CPU for sampling simulation is a multi-core CPU, in addition to steps 1 to 3 in Example 1, subsequent multi-core synchronous preheating steps may also be included, such as cross-core state transfer update preheating, asynchronous preheating scheduling adjustment and error compensation steps, etc., and only one or more of these methods may be included as needed to adapt to the simulation of multi-core CPUs, such as Figure 5 shown.
[0070] Among them, the cross-core state transfer update preheating includes: each core maintains a state information table to record the preheating progress and resource allocation status; when a thread synchronization instruction (such as a lock operation, a barrier instruction, etc.) is detected, the state information is serialized and transmitted through the inter-core communication interface (such as shared memory, message passing interface MPI, etc.); the target core deserializes the state information and updates the preheating strategy, specifically: it is restored to structured data through the deserialization operation, mainly parsing the source core preheating progress, including the number of completed preheating instructions, the ID and location of the currently processed program fragment. The source core resource allocation status, including the usage of micro-architecture resources such as cache occupancy at all levels, branch predictor status, and memory access queues; dynamic feature parameters, including the latest value of the instruction mixing ratio vector extracted by the source core, branch history entropy, and cache access time-space matrix; strategy parameters, including the curvature parameter in the preheating distance allocation formula currently used by the source core , weight and dynamic adjustment coefficient .
[0071] The update strategy mainly includes three points:
[0072] The first is the dynamic reallocation of the warm-up distance. 1) Adjustments are made based on the warm-up progress of the source core. If the warm-up progress of the target core lags behind that of the source core, the warm-up distance of the target core is increased according to the following formula:
[0073]
[0074] in is the progress compensation coefficient (usually 0.2~0.5) to ensure that the preheating progress of the two cores is quickly synchronized.
[0075] 2) Adjust based on the resource allocation status of the source core. If the source core reports that a cache line is frequently accessed, the target core marks the cache line as a "hotspot" and loads it first during warm-up. The warm-up distance formula of the program fragment allocation is adjusted. (Increase the curvature parameter to increase the warm-up distance).
[0076] The second is dynamic feature fusion update. Based on the weighted fusion of dynamic feature parameters, the dynamic features transmitted by the source core and the local features are merged according to the weights, such as:
[0077]
[0078] in, is the new instruction mixing ratio vector, is a local dynamic feature, is the source core dynamic feature, is the local feature weight (usually 0.6~0.8). Input the fused dynamic features into the preheating sensitivity prediction model and recalculate the curvature parameters ,like Yohara If the difference exceeds a threshold (e.g., 20%), the warm-up distance redistribution is triggered.
[0079] The third is to synchronize the reinforcement learning state. Merge with the local state in time series to form a new state vector ,like ,in The time difference between the two core state transmissions is used for timing consistency calibration. Calculate new dynamic adjustment coefficient ,like , then the smooth adjustment is made according to the following formula: ,in is a smoothing factor (ranging from 0.3 to 0.5) to avoid simulation fluctuations caused by sudden changes in the strategy.
[0080] The cross-core state transfer interval can be flexibly set between 5,000 and 20,000 instructions according to different multi-core system performance and synchronization overhead requirements to ensure a balance between multi-core synchronization efficiency and accuracy.
[0081] Asynchronous preheating scheduling adjustment: refers to the independent allocation of preheating distance for each core, which can be differentiated according to the performance differences of different cores (frequency, cache size, etc.). Specifically, each core independent scheduler independently determines the preheating start time and resource allocation (including cache line priority allocation, memory bandwidth ratio division, processor time slice scheduling, etc.) based on the preheating distance obtained in step 3 and the system resource status (specifically including the cache occupancy rate at all levels, the remaining amount of memory bandwidth, the processor core utilization rate, the shared cache partition status and other hardware resource status); uses hardware synchronization primitives (such as LOCK instructions, MFENCE cache consistency instructions, etc.), software synchronization algorithms (such as spin locks, memory barrier mechanisms) and other synchronization mechanisms to ensure the consistency of micro-architectural states such as cache status and global state during branch prediction, to avoid the failure of preheating strategy due to state deviation; detects the performance of each core, and when the performance gap between cores is greater than the preset threshold, dynamically adjusts the allocation of preheating distance, optimizes the overall preheating efficiency, increases the preheating distance allocated to the core with poor performance, and reduces the preheating distance allocated to the core with good performance;
[0082] The error compensation step includes: detecting the real-time load of each core, which can be obtained through various load detection methods (such as hardware performance counters, operating system load statistics, etc.), and compensating the warm-up distance obtained in step 3 based on the real-time load:
[0083]
[0084] For the The final warm-up distance of each core; For the Real-time load of each core; is the average load rate of all cores; 、 are the maximum and minimum values of the nuclear loading rate; It is a load-sensitive coefficient and can be adjusted according to different multi-core application scenarios (such as compute-intensive, I / O-intensive, etc.).
[0085] In order to further avoid allocating too long preheating distances for program fragments, a long preheating truncation step can be added at the end, including a long preheating distance truncation step, specifically including:
[0086] Set the upper limit of the preheating distance cutoff If the preheating distance obtained in step 3 or step 4 exceeds , then change it to ,
[0087]
[0088] in The upper limit of the preheating distance cutoff; is the total warm-up distance; It is the truncation coefficient, which can be set according to different program characteristics (such as program stability, instruction flow volatility, etc.).
[0089] The following experiments are conducted in a multi-core scenario to verify the effect of this embodiment.
[0090] Using Gem5's Deriv03cpu to simulate a quad-core ARM Cortex-A76 processor, we tested the multi-threaded version of the 436.cactusADM program:
[0091] 1. Each core runs a thread independently, and the fragment size is set to 50,000 instructions based on the multi-core performance and task characteristics;
[0092] 2. Synchronous preheating mechanism The parameter is set to 0.5 according to the multi-core application scenario (this is a computationally intensive scenario), and the truncation coefficient Set to 3 according to program stability;
[0093] 3. The cross-core state transfer interval is set to 10,000 instructions based on the core synchronization overhead requirements of the multi-core system performance, and the cache state is transferred using shared memory;
[0094] 4. The reinforcement learning model adds core load rate as a state feature and uses hardware performance counters to obtain real-time load rate.
[0095]
[0096] The experimental results are shown in the table above. The inter-core error fluctuation is reduced from 24.5% in the traditional method to 11.6% (an improvement of 52.7%). The asynchronous warm-up scheduling combined with the load compensation algorithm improves the load balancing efficiency from 68% to 92%. The overall simulation time is shortened from 82.3 seconds to 55.8 seconds (a reduction of 32.2%), and the synchronization overhead ratio is reduced from 12.7% to 4.9% (a reduction of 61.4%), thanks to the cross-core state transfer and truncation mechanism that reduces ineffective warm-up.
Claims
1. A dynamic adaptive sampling simulation preheating optimization method, characterized in that: The following steps are involved: Step 1: prepare an instruction stream, which includes multiple program fragments, and extract dynamic features of each program fragment in real time. The dynamic features include instruction mixing ratio vector, branch history entropy, and cache access time-space matrix; Step 2: Draw the warm-up distance error curve for each program segment and calculate the curvature parameter of the warm-up distance error curve; use a deep learning model to build a warm-up sensitivity prediction model. The model input is the dynamic features of step 1, and the output is the curvature parameter of the warm-up distance error curve. The warm-up sensitivity prediction model is trained; Step 3: Use the warm-up sensitivity prediction model from step 2 to obtain the curvature parameter of the warm-up distance error curve of the sampled program fragment; formulate a warm-up distance allocation strategy based on the reinforcement learning framework to allocate warm-up distances to the sampled program fragments. The warm-up distances allocated to each program fragment are: in For the The distribution warm-up distance of each program fragment; For the The curvature parameter of the warm-up distance error curve of each program segment; For the The weight of each program fragment; is the total number of program fragments after sampling; is the total warm-up distance; is the reinforcement learning state value; is the dynamic adjustment coefficient; And calculate the reward function, and continuously adjust the dynamic adjustment coefficient in the warm-up distance distribution strategy according to the result of the reward function , until the reward function converges and the simulation error and simulation time are within the preset thresholds.
2. The dynamic adaptive sampling simulation preheating optimization method according to claim 1, characterized in that: In step 2, the method for drawing the preheating distance error curve of each program fragment is: for each program fragment, use the set different preheating distances to simulate and obtain the simulation error. The simulation error is the error calculated by comparing the simulation results at each preheating distance with the actual operation data. The curve is drawn with the preheating distance as the horizontal axis and the corresponding error as the vertical axis, which is the preheating distance error curve.
3. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: The reward function in step 3 is: , in is the L1 D Cache miss rate error, is the preheating time, obtained from the preheating distance, and are the weighting coefficients of error and warm-up time, respectively, and .
4. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: If the CPU being sampled and simulated is a multi-core CPU, the step 4 of cross-core state transfer and preheating update is also included, specifically including: each core records and maintains a state information table, where the state information includes preheating progress and resource allocation status; when a thread synchronization instruction is detected, the state information is serialized and transmitted through the inter-core communication interface; the target core deserializes the state information and updates the preheating strategy to synchronize the preheating progress of the target core with that of the source core.
5. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: If the CPU being sampled and simulated is a multi-core CPU, the process also includes step five, asynchronous preheating scheduling adjustment, which specifically includes: each core's independent scheduler independently determines the preheating start time and resource allocation based on the preheating distance obtained in step three and the system resource situation; utilizes hardware synchronization primitives and software synchronization algorithms to ensure state consistency; detects the performance of each core, and when the performance gap between cores is greater than a preset threshold, dynamically adjusts the preheating distance allocation, increasing the preheating distance allocated to the core with poor performance and reducing the preheating distance allocated to the core with good performance.
6. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: If the CPU being sampled and simulated is a multi-core CPU, the error compensation step is also included in step 6, specifically including: detecting the real-time load of each core and compensating the preheating distance obtained in step 3 according to the real-time load: For the The final warm-up distance of each core; For the Real-time load of each core; is the average load rate of all cores; 、 are the maximum and minimum values of the nuclear loading rate; is the load sensitivity factor.
7. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: The method also includes a step 7 of long preheating distance cutting step, specifically including: Set the upper limit of the preheating distance cutoff If the preheating distance obtained in step 3 or step 4 exceeds , then change it to , in The upper limit of the preheating distance cutoff; is the total warm-up distance; is the cutoff coefficient.
8. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: In step one, the instruction mix ratio vector is the proportion of arithmetic logic instructions, memory access instructions, and branch instructions under different instruction set architectures; the branch history entropy is based on the global branch prediction history, calculates the branch uncertainty of the instruction stream for different prediction algorithms, and characterizes the dynamic change characteristics of branch behavior through information entropy theory; the cache access time-space matrix is the time interval and spatial distribution of cache line access at different levels.
9. The dynamic adaptive sampling simulation preheating optimization method according to claim 1 or 2, characterized in that: In step one, the dynamic features of each program fragment are extracted through hardware performance counters, and multiple instructions generate a set of dynamic feature vectors, which are stored in the feature database after standardization for use in model training in step two.
10. A high-performance CPU emulator, characterized in that: It is a computer software product installed on a computer, which can be executed by a computer processor to implement the dynamic adaptive sampling simulation preheating optimization method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Sampling method for accelerating software trace information extraction
CN110781062A
Performance evaluation method of processor, electronic equipment and medium
CN117806925A