K value selection method and related equipment for K-means clustering algorithm in chip simulation
Through feature analysis and Bayesian information criterion algorithm, the K value selection of the K mean clustering algorithm is optimized, which solves the problem of insufficient K value selection in chip simulation, and achieves dual optimization of time and accuracy.
Patent Information
- Application Number
- CN202411335742.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-09-24
AI Technical Summary
In chip simulation, when the traditional K-mean clustering algorithm is used to select the target test program, the determination of the K value leads to insufficient time-consuming and insufficient accuracy of the simulation results.
By obtaining the performance index data of the benchmark program of the target chip, performing feature analysis to determine the maximum preset K value, generating a K value range, and selecting the model to output the target K value using the Bayesian information criterion algorithm, optimizing the K mean clustering algorithm K value is selected to reduce simulation time and improve the accuracy of simulation results.
It effectively reduces the chip simulation time, and ensures the accuracy of simulation results, solving the problem of insufficient simulation time and accuracy in traditional methods.
Smart Images

Figure CN118861740B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip technology, and in particular to a K value selection method and related equipment for a K-means clustering algorithm in chip simulation. Background Art
[0002] In the modern chip R&D process, chip architecture R&D relies heavily on detailed pipeline simulation. However, in the actual chip simulation execution process, it usually takes weeks and months to set up a benchmark test program to fully and comprehensively simulate a specific chip architecture design. The simulation process consumes a lot of chip R&D time and increases the overall time consumption of chip architecture R&D design. The traditional technology solves the problem of time-consuming chip simulation mentioned above by selecting a part of the test programs from the above benchmark test programs to perform simulation evaluation. However, how to select the target test program from the above benchmark test programs and how to make the simulation results of the selected target test program and the simulation results of the benchmark test program within the preset error range have become new technical problems that need to be solved. At present, the technical solution for selecting a part of the test programs from the benchmark test programs as the target test programs for chip simulation is to use the K-means clustering algorithm, because the K-means clustering algorithm is simple to implement and has high efficiency, and is particularly suitable for large data sets. However, in the process of selecting a target test program from a benchmark test program using the K-means clustering algorithm, it is necessary to determine the number of clusters K. Traditional K value determination technical solutions, such as the Elbow Method, Silhouette Coefficient, Gap Statistics, Cross-validation, and density-based criteria, etc., but when the target K value is obtained by the aforementioned K value determination technical solution and the target test program obtained by clustering according to the target K value is used for chip simulation, on the one hand, the accuracy of the simulation results (compared with the simulation results using the benchmark test program) has certain shortcomings, and on the other hand, the simulation process time is not much reduced (compared with the simulation time using the benchmark test program). Summary of the invention
[0003] The main technical problem solved by the implementation method of the present application is that the target K value obtained by the traditional selection method of the K value of the K-means clustering algorithm in chip simulation leads to insufficient simulation time optimization and insufficient accuracy of the simulation results.
[0004] To solve the above technical problems, the first technical solution adopted in the implementation mode of the present application is: to provide a K value selection method for the K-means clustering algorithm in a chip simulation, including: obtaining a first number of first program slices of a benchmark test program corresponding to a target chip, and calculating a first type of performance indicator data of the first program slices; performing feature analysis on the first type of performance indicator data to obtain a corresponding feature classification result; performing calculations based on the feature classification results to obtain a corresponding maximum preset K value, and generating a K value range based on the maximum preset K value; sending the K value range to a preset K value selection model, and receiving a target K value output by the K value selection model.
[0005] Optionally, the step of calculating the first type of performance indicator data of the first program slice includes: calculating the average number of instruction cycles of the first program slice as the first indicator data; calculating the first-level data cache miss rate of the first program slice as the second indicator data; calculating the branch prediction error data of the first program slice as the third indicator data; and merging the first indicator data, the second indicator data and the third indicator data into the first type of performance indicator data.
[0006] Optionally, the step of performing feature analysis on the first category of performance indicator data to obtain corresponding feature classification results includes: generating a time series graph of the first category of performance indicator data showing changes of the first category of performance indicator data over time; analyzing the time series graph of the first category of performance indicator data through a preset time series graph analysis model to obtain corresponding feature classification results, wherein the feature classification results are uniformly distributed, periodically distributed or non-periodically distributed.
[0007] Optionally, the step of calculating according to the feature classification result to obtain the corresponding maximum preset K value includes: if the feature classification result corresponding to the first category of performance indicator data is a uniform distribution, setting the corresponding maximum preset K value to 1; if the feature classification result corresponding to the first category of performance indicator data is a periodic distribution, setting the corresponding maximum preset K value to the number of periods in the timing diagram of the first category of performance indicator data; if the feature classification result corresponding to the first category of performance indicator data is a non-periodic distribution, setting the corresponding maximum preset K value to the preset maximum K threshold.
[0008] Optionally, the K value selection model is a selection model based on the Bayesian information criterion algorithm. After the step of sending the K value range to the preset K value selection model, it also includes: obtaining each integer in the K value range in turn as a temporary K value; clustering the first program slices using the temporary K value to obtain a program slice cluster with the number of temporary K values; calculating the cluster center and covariance matrix of each program slice cluster, and then calculating the Bayesian information criterion score corresponding to the temporary K value based on the cluster center and the covariance matrix; and outputting the temporary K value corresponding to the maximum Bayesian information criterion score as the target K value.
[0009] Optionally, after the step of receiving the target K value output by the K value selection model, it also includes: obtaining a second number of second program slices from the first program slices using the target K value through a K-means clustering algorithm; sending the second program slices to a preset chip simulator for simulation to obtain corresponding chip simulation result data; if the accuracy of the chip simulation result data is less than or equal to a preset accuracy threshold, optimizing the K value selection model according to the simulation result data to obtain a new target K value; first repeating the steps between obtaining a second number of second program slices from the first program slice using the target K value through a K-means clustering algorithm and obtaining the new target K value, until the accuracy of the chip simulation result data is greater than the preset accuracy threshold, or the first repeated execution number is greater than the preset first repetition number threshold.
[0010] Optionally, after the step of sending the second program slice to the preset chip simulator for simulation and obtaining the corresponding chip simulation result data, it also includes: if the accuracy of the chip simulation result data is less than or equal to the preset accuracy threshold, calculating the second type of performance indicator data of the first program slice, wherein the second type of performance indicator data is completely different from or partially the same as the first type of performance indicator data; using the second type of performance indicator data to replace the first type of performance indicator data, re-executing the steps between performing feature analysis on the first type of performance indicator data and sending the second program slice to the preset chip simulator for simulation to obtain new chip simulation result data; if the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, then repeating the steps between calculating the second type of performance indicator data of the first program slice and obtaining the new chip simulation result data for a second time, until the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, or the second repeated execution number is greater than the preset first repetition number threshold.
[0011] To solve the above technical problems, the second technical solution adopted in the implementation mode of the present application is: to provide a K value selection system for the K-means clustering algorithm in a chip simulation, including: a first program slicing module, used to obtain a first program slice of a benchmark test program corresponding to a target chip, and calculate a first type of performance indicator data of the first program slice; a feature classification module, used to perform feature analysis on the first type of performance indicator data to obtain a corresponding feature classification result; a K value range module, used to perform calculations based on the feature classification results to obtain a corresponding maximum preset K value, and generate a K value range based on the maximum preset K value; a target K value module, used to send the K value range to a preset K value selection model, and receive a target K value output by the K value selection model.
[0012] To solve the above technical problems, the third technical solution adopted in the implementation mode of the present application is: to provide an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the K value selection method of the K-means clustering algorithm in the chip simulation as described above.
[0013] In order to solve the above technical problems, the third technical solution adopted in the implementation mode of the present application is: providing a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device executes the K value selection method of the K-means clustering algorithm in the chip simulation as described above.
[0014] Different from the related art, the present application obtains a first number of first program slices of the benchmark test program corresponding to the target chip, calculates the first type of performance indicator data of the first program slices; performs feature analysis on the first type of performance indicator data to obtain corresponding feature classification results; performs calculations based on the feature classification results to obtain the corresponding maximum preset K value, and generates a K value range based on the maximum preset K value; sends the K value range to a preset K value selection model, receives the target K value output by the K value selection model, and finally uses the target K value in the K-means clustering algorithm in the chip simulation to obtain the corresponding simulation results, which not only reduces the simulation time but also ensures the accuracy of the simulation results. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] One or more embodiments are exemplarily described by corresponding drawings, which do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and the figures in the drawings do not constitute proportional limitations unless otherwise stated.
[0016] Figure 1 It is a schematic diagram of the application environment of the K value selection method of the K-means clustering algorithm in chip simulation provided in an embodiment of the present application.
[0017] Figure 2 It is a schematic diagram of the execution flow of the K value selection method of the K-means clustering algorithm in chip simulation provided in an embodiment of the present application.
[0018] Figure 3 It is an execution flow chart of the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application to obtain the first type of performance indicator data.
[0019] Figure 4 It is a schematic diagram of the execution flow of obtaining feature classification results by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application.
[0020] Figure 5 This is an example diagram showing that the performance indicator data obtained by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application is uniformly distributed.
[0021] Figure 6 This is an example diagram of performance indicator data with periodic distribution obtained by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application.
[0022] Figure 7 This is an example diagram of the non-periodic distribution of performance indicator data obtained by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application.
[0023] Figure 8 It is a schematic diagram of the execution flow of obtaining the maximum preset K value by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application.
[0024] Fig. 9 It is a structural schematic diagram of the K value selection system of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application.
[0025] Fig.10 It is a hardware structure diagram of an electronic device for executing the K value selection method of the K-means clustering algorithm in chip simulation provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, all within the scope of protection of the present application. In addition, although the functional modules are divided in the system schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order than the module division in the system schematic diagram or the order in the flow chart.
[0028] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.
[0029] To facilitate understanding of this embodiment, we first introduce in detail a method for selecting a K value for a K-means clustering algorithm in a chip simulation disclosed in an embodiment of the present application. The executor of the method for selecting a K value for a K-means clustering algorithm in a chip simulation provided in the embodiment of the present application is generally an electronic device with certain computing capabilities, such as a computer device. In some possible implementation methods, the method for selecting a K value for the K-means clustering algorithm in a chip simulation can be implemented by a processor calling computer-readable instructions stored in a memory.
[0030] The following uses a computer device as an example to illustrate the K value selection method of the K-means clustering algorithm in chip simulation provided by the embodiment of the present application. Figure 1 , Figure 1 It is a schematic diagram of the application environment of the K value selection method of the K-means clustering algorithm in the chip simulation provided by the embodiment of the present application. First, the corresponding program slice (Program Slicing) is obtained from the benchmark program, workload or application corresponding to the target chip architecture design. The program slice is used to extract a subset of the program, which contains statements and variables related to the preset criteria or standards. The goal of the program slice is to reduce the complexity of the program and focus the attention of the program on specific functions or problems. Then the corresponding feature analysis is performed on the program slice, and the corresponding feature classification results are obtained, and then the corresponding K value is obtained according to the characteristics of the feature classification results. In addition, after obtaining the corresponding K value, the above-mentioned program slice can also be processed by the K-means clustering algorithm to obtain the corresponding K program slices. Finally, the above-mentioned K program slices obtained can also be simulated by a chip simulator, and the process of obtaining the K value can be optimized according to the obtained simulation results.
[0031] Please continue reading Figure 2 , Figure 2: is a schematic diagram of the execution flow of the K value selection method of the K-means clustering algorithm in the chip simulation provided by the embodiment of the present application, which specifically includes the following steps:
[0032] S10. Obtain a first number of first program slices of a benchmark test program corresponding to a target chip, and calculate first type of performance indicator data of the first program slices.
[0033] Among them, the benchmark program corresponding to the chip is used to evaluate and measure the chip performance. It usually contains a series of test cases covering different types of calculations and workloads. The test cases can be specific algorithms, computationally intensive tasks, graphics processing, multi-threaded operations, etc. The benchmark program will run the aforementioned test cases and measure the performance indicators of the chip under different conditions, such as processing speed, power consumption, memory access speed, etc., providing an objective way to measure the performance of the chip and provide decision-making basis for users and developers.
[0034] As a preferred implementation, please continue to refer to Figure 3 , Figure 3 This is an execution flow chart of obtaining the first type of performance indicator data by the K value selection method of the K-means clustering algorithm in the chip simulation provided by the embodiment of the present application, that is, the above step S10 may also include the following specific steps:
[0035] S101. Calculate the average number of instruction cycles of a first program slice as first indicator data.
[0036] Among them, the average number of cycles per instruction (CPI) indicates the number of clock cycles required to execute an instruction. The lower the CPI, the fewer clock cycles are required to execute each instruction on average, that is, the higher the execution efficiency of the processor. CPI can be calculated by the following formula:
[0037] CPI = total number of clock cycles / number of instructions executed
[0038] The total number of clock cycles is the total number of clock cycles used by the processor during the execution of a program or task, and the number of instructions executed is the total number of instructions executed by the processor during the same program or task. The value of CPI depends on many factors, including processor architecture, pipeline design, cache hit rate, instruction-level parallelism, etc.
[0039] S102. Calculate the first-level data cache miss rate of the first program slice as the second indicator data.
[0040] Among them, the Level 1 Data Cache Miss Rate (Level 1 Data Cache Miss Rate or L1-D Cache Miss Rate). The Level 1 Data Cache is the first-level data cache in the processor, which is used to store the most commonly used data. When the processor needs to access certain data, it will first look for the data in the Level 1 Data Cache. If the data is found in the Level 1 Data Cache, it is a cache hit (Cache Hit), and the data can be quickly obtained. However, if the required data is not found in the Level 1 Data Cache, a cache miss (Cache Miss) will occur, and the data needs to be obtained from the slower main memory or other higher-level caches. The Level 1 Data Cache Miss Rate refers to the proportion of the required data that the Level 1 Data Cache cannot provide when executing a program, that is, the frequency of cache misses. It is calculated by counting the number of cache misses and is usually expressed as a percentage.
[0041] S103 , calculating branch prediction error data of the first program slice as third indicator data.
[0042] Among them, branch prediction misprediction refers to the error when the processor predicts the execution path of branch instructions (such as conditional branches and loops) when executing a program. During the execution process, the processor will make predictions based on the previous execution history and the characteristics of the branch instruction to determine the execution path of the branch. If the processor's prediction is inconsistent with the actual execution path, a branch prediction misprediction will occur. Branch prediction misprediction has an important impact on the performance and efficiency of the processor, such as pipeline interruption, resource waste, and limited instruction-level parallelism. Once a branch prediction misprediction is detected, the processor needs to interrupt the current execution pipeline and restart the execution of the correct branch path, resulting in additional clock cycles and delays, reducing the efficiency of the processor. When a branch prediction misprediction occurs, the processor may have pre-fetched instructions and data for the wrong path, and the pre-fetched resources will eventually be discarded, wasting the processor's computing power and memory bandwidth. When the processor executes the wrong branch path, it cannot fully utilize the instructions on the correct branch path, thereby reducing the effect of instruction-level parallelism.
[0043] S104. Combine the first indicator data, the second indicator data, and the third indicator data into first-category performance indicator data.
[0044] Among them, in addition to the above-mentioned average instruction cycles, first-level data cache miss rate and branch prediction errors can be used as the performance indicator data of the chip, other data can also be used as the above-mentioned performance indicator data, such as instructions per cycle (Instructions per Cycle, IPC), cache hit rate (Cache Hit Rate), data TLB miss rate (DataTLB Miss Rate), instruction TLB miss rate (Instruction TLB Miss Rate), memory latency (MemoryLatency) and floating point operations per second (Floating Point Operations per Second, FLOPS), etc.
[0045] S20: Perform feature analysis on the first type of performance indicator data to obtain corresponding feature classification results.
[0046] As a preferred implementation, combined with the technical problem of selecting K of the K-means clustering algorithm, the feature analysis of the chip's performance time-scale data can be a periodic analysis, that is, to determine whether the above-mentioned first type of performance indicator data is periodically changing data.
[0047] Specifically, as another preferred implementation, please continue to refer to Figure 4 , Figure 4 This is a schematic diagram of the execution flow of obtaining feature classification results by the K value selection method of the K-means clustering algorithm in chip simulation provided by the embodiment of the present application, that is, the above step S20 may also include the following sub-steps:
[0048] S201. Generate a time series diagram of first-category performance indicator data showing changes of first-category performance indicator data over time.
[0049] S202: Analyze the first type of performance indicator data time series diagram using a preset time series diagram analysis model to obtain corresponding feature classification results.
[0050] The above feature classification results are uniform distribution, periodic distribution or non-periodic distribution. Figure 5 , Figure 6 and Figure 7 . Figure 5 This is an example diagram showing that the performance indicator data obtained by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application is uniformly distributed. Figure 6 This is an example diagram of performance indicator data with periodic distribution obtained by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application. Figure 7 This is an example diagram of the non-periodic distribution of performance indicator data obtained by the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application. Figure 5 , Figure 6 and Figure 7 Taking the three possible timing situations of the average instruction cycle number CPI as examples, it can be seen from the figure that: Figure 5 The average instruction cycle number CPI in is uniformly distributed (almost a straight line), Figure 6 The average instruction cycle number CPI in is a periodic distribution. Figure 7 The average instruction cycle number CPI in is a non-periodic distribution.
[0051] S30. Calculate according to the feature classification result to obtain the corresponding maximum preset K value, and generate a K value range according to the maximum preset K value.
[0052] As a preferred implementation, different maximum preset K values can be set according to the results of the periodic analysis of the performance indicator data. Figure 8 , Figure 8 The embodiment of the present application provides a schematic diagram of the execution flow of obtaining the maximum preset K value by the K value selection method of the K-means clustering algorithm in the chip simulation, that is, the above step of calculating according to the feature classification result to obtain the corresponding maximum preset K value may include the following sub-steps:
[0053] S301. If the feature classification result corresponding to the first type of performance indicator data is uniformly distributed, the corresponding maximum preset K value is set to 1. If the periodicity of the performance indicator data is uniformly distributed, it can be approximately considered that the period of the performance indicator data is 1, so the corresponding maximum preset K value is set to 1 in step S301.
[0054] S302: If the characteristic classification result corresponding to the first type of performance indicator data is periodic distribution, the corresponding maximum preset K value is set to the number of periods of the first type of performance indicator data time series diagram.
[0055] S303. If the feature classification result corresponding to the first type of performance indicator data is a non-periodic distribution, the corresponding maximum preset K value is set to a preset maximum K threshold. If the periodicity of the performance indicator data is a non-periodic distribution, the maximum preset K value is not set to a larger value according to the above periodicity rule, but is set to a preset maximum K threshold, which is obtained based on the historical use experience of the K-means clustering algorithm in chip simulation.
[0056] S40: Send the K value range to a preset K value selection model, and receive the target K value output by the K value selection model.
[0057] As a preferred embodiment, the above-mentioned K value selection model can be a K value selection model based on the Bayesian information criterion algorithm. After the above-mentioned K value selection model receives the above-mentioned K value range, each integer in the K value range is sequentially obtained as a temporary K value, and the above-mentioned first program slice is clustered using the temporary K value to obtain a program slice cluster with a temporary K value. Then, the cluster center and covariance matrix of each program slice cluster are calculated, and then the Bayesian information criterion score corresponding to the temporary K value is calculated based on the cluster center and the covariance matrix. Finally, the temporary K value corresponding to the maximum Bayesian information criterion score is output as the target K value.
[0058] As an example, the above K value range can also be sent to the SIMPOINT tool software based on the Bayesian Information Criterion algorithm to obtain the target K value returned by the tool software. SIMPOINT is a tool for program behavior analysis and program integration testing. Its main goal is to simplify complex computer programs into a set of key areas, which are called "simpoints". The simpoints represent representative execution fragments in the program and can be used as a benchmark for program integration testing, simulation, and performance evaluation.
[0059] As a preferred embodiment, after the step of receiving the target K value output by the K value selection model, the target K value can also be used to obtain a second number of second program slices from the above-mentioned first program slices through the K-means clustering algorithm. Then, the second program slices are sent to the preset chip simulator for simulation to obtain corresponding chip simulation result data. If the accuracy of the chip simulation result data is less than or equal to the preset accuracy threshold, the above-mentioned K value selection model is optimized according to the simulation result data to obtain a new target K value, that is, the corresponding K value selection model is optimized according to the chip simulation result. Repeat the above steps from obtaining a second number of second program slices from the first program slice using the target K value through the K-means clustering algorithm to obtaining a new target K value, until the accuracy of the chip simulation result data is greater than the preset accuracy threshold, or the number of repeated executions is greater than the preset first repetition threshold.
[0060] As another preferred embodiment, after the step of receiving the target K value output by the K value selection model, if the accuracy of the above chip simulation result data is less than or equal to the preset accuracy threshold, the second type of performance indicator data of the first program slice is calculated, wherein the second type of performance indicator data is completely different from or partially the same as the first type of performance indicator data. Then, the first type of performance indicator data is replaced with the calculated second type of performance indicator data, and the steps between feature analysis of the first type of performance indicator data and sending the second program slice to the preset chip simulator for simulation are re-executed to obtain new chip simulation result data, that is, the new performance indicator data is used as reference data for selecting the K value. Finally, if the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, the steps between calculating the second type of performance indicator data of the first program slice and obtaining the new chip simulation result data are repeated until the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, or the second number of repeated executions is greater than the preset first number of repeated executions threshold.
[0061] The K value selection method of the K-means clustering algorithm in chip simulation provided in an embodiment of the present application obtains a first number of first program slices of a benchmark test program corresponding to a target chip, calculates a first type of performance indicator data of the first program slice; performs feature analysis on the first type of performance indicator data to obtain a corresponding feature classification result; performs calculation based on the feature classification result to obtain a corresponding maximum preset K value, and generates a K value range based on the maximum preset K value; sends the K value range to a preset K value selection model, receives a target K value output by the K value selection model, and finally uses the target K value in the K-means clustering algorithm in chip simulation to obtain a corresponding simulation result, which not only reduces the simulation time but also ensures the accuracy of the simulation result.
[0062] Please continue reading Fig. 9 , Fig. 9 It is a structural diagram of the K value selection system of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application, which specifically includes: a first program slicing module 91, a feature classification module 92, a K value range module 93 and a target K value module 94.
[0063] The first program slicing module 91 is used to obtain a first program slice of a benchmark test program corresponding to a target chip, and calculate first-type performance indicator data of the first program slice.
[0064] The feature classification module 92 is used to perform feature analysis on the first type of performance indicator data to obtain corresponding feature classification results.
[0065] The K value range module 93 is used to perform calculations according to the feature classification results to obtain a corresponding maximum preset K value, and generate a K value range according to the maximum preset K value.
[0066] The target K value module 94 is used to send the K value range to a preset K value selection model, and receive the target K value output by the K value selection model.
[0067] As an optional implementation, the first program slicing module 91 is also used to calculate the average number of instruction cycles of the first program slice as the first indicator data; calculate the first-level data cache miss rate of the first program slice as the second indicator data; calculate the branch prediction error data of the first program slice as the third indicator data; and merge the first indicator data, the second indicator data and the third indicator data into the first type of performance indicator data.
[0068] As an optional implementation, the feature classification module 92 is also used to generate a time series diagram of the first category of performance indicator data showing changes of the first category of performance indicator data over time; the time series diagram of the first category of performance indicator data is analyzed by a preset time series diagram analysis model to obtain a corresponding feature classification result, wherein the feature classification result is a uniform distribution, a periodic distribution or a non-periodic distribution.
[0069] As an optional implementation, the K value range module 93 is also used to set the corresponding maximum preset K value to 1 if the feature classification result corresponding to the first category of performance indicator data is a uniform distribution; if the feature classification result corresponding to the first category of performance indicator data is a periodic distribution, the corresponding maximum preset K value is set to the number of periods in the first category of performance indicator data timing diagram; if the feature classification result corresponding to the first category of performance indicator data is a non-periodic distribution, the corresponding maximum preset K value is set to the preset maximum K threshold.
[0070] As a preferred embodiment, the target K value module 94 is also used to sequentially obtain each integer within the K value range as a temporary K value; use the temporary K value to cluster the first program slices to obtain program slice clusters with the temporary K value; calculate the cluster center and covariance matrix of each program slice cluster, and then calculate the Bayesian information criterion score corresponding to the temporary K value based on the cluster center and the covariance matrix; output the temporary K value corresponding to the maximum Bayesian information criterion score as the target K value.
[0071] As another preferred embodiment, the target K value module 94 is also used to obtain a second number of second program slices from the first program slice using the target K value through a K-means clustering algorithm; send the second program slices to a preset chip simulator for simulation to obtain corresponding chip simulation result data; if the accuracy of the chip simulation result data is less than or equal to a preset accuracy threshold, optimize the K value selection model according to the simulation result data to obtain a new target K value; first repeat the steps from obtaining a second number of second program slices from the first program slice using the target K value through a K-means clustering algorithm to obtaining a new target K value, until the accuracy of the chip simulation result data is greater than the preset accuracy threshold, or the first repeated execution number is greater than the preset first repetition number threshold.
[0072] As another preferred embodiment, the target K value module 94 is also used to calculate the second type of performance indicator data of the first program slice if the accuracy of the chip simulation result data is less than or equal to a preset accuracy threshold, wherein the second type of performance indicator data is completely different from or partially the same as the first type of performance indicator data; use the second type of performance indicator data to replace the first type of performance indicator data, and re-execute the steps from performing feature analysis on the first type of performance indicator data to sending the second program slice to a preset chip simulator for simulation to obtain new chip simulation result data; if the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, then repeat the steps from calculating the second type of performance indicator data of the first program slice to obtaining the new chip simulation result data for a second time, until the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, or the second repeated execution number is greater than the preset first repetition number threshold.
[0073] It should be noted that the K value selection system of the K-means clustering algorithm in the chip simulation can execute the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in the embodiment of the K value selection system of the K-means clustering algorithm in the chip simulation, please refer to the K value selection method of the K-means clustering algorithm in the chip simulation provided in the embodiment of the present application.
[0074] Fig.10 1 is a schematic diagram of the hardware structure of an electronic device 1000 for executing a K value selection method of a K-means clustering algorithm in a chip simulation according to an embodiment of the present application, such as Figure 6 As shown, the electronic device 1000 includes:
[0075] One or more processors 1010 and memory 1020, Figure 6A processor 1010 is taken as an example.
[0076] The processor 1010 and the memory 1020 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0077] The memory 1020, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as the program instructions / modules corresponding to the K value selection method of the K-means clustering algorithm in the chip simulation in the embodiment of the present application. The processor 1010 executes various functional applications and data processing of the electronic device by running the non-volatile software programs, instructions and modules stored in the memory 1020, that is, the K value selection method of the K-means clustering algorithm in the chip simulation in the above method embodiment is realized.
[0078] The memory 1020 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the K value selection system of the K-means clustering algorithm in chip simulation, etc. In addition, the memory 1020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 1020 may optionally include a memory remotely arranged relative to the processor 1010, and these remote memories may be connected to the K value selection system of the K-means clustering algorithm in chip simulation via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0079] The one or more modules are stored in the memory 1020, and when executed by the one or more processors 1010, the K value selection method of the K-means clustering algorithm in the chip simulation in any of the above method embodiments is executed, for example, the above described Figure 2 Steps S10 to S40 of the method, Figure 3 Steps S101 to S104 of the method, Figure 4 Steps S201 to S202 of the method, Figure 8 Steps S301 to S303 of the method are implemented Fig. 9 The functions of modules 91-94 in.
[0080] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.
[0081] The embodiment of the present application provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, such as Fig.10 A processor 1010 in the embodiment may enable the one or more processors to execute the K value selection method of the K-means clustering algorithm in the chip simulation in any of the above method embodiments, for example, to execute the above described Figure 2 Steps S10 to S40 of the method, Figure 3 Steps S101 to S104 of the method, Figure 4 Steps S201 to S202 of the method, Figure 8 Steps S301 to S303 of the method are implemented Fig. 9 The functions of modules 91-94 in.
[0082] The present application provides a computer program product, wherein the computer program product includes a computer program stored on a non-volatile computer-readable storage medium, wherein the computer program includes program instructions, and when the program instructions are executed by the electronic device, the electronic device is enabled to execute the K value selection method of the K-means clustering algorithm in the chip simulation in any of the above method embodiments, for example, to execute the above described Figure 2 Steps S10 to S40 of the method, Figure 3 Steps S101 to S104 of the method, Figure 4 Steps S201 to S202 of the method, Figure 8 Steps S301 to S303 of the method are implemented Fig. 9 The functions of modules 91-94 in.
[0083] The system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0084] Through the description of the above embodiments, it can be clearly understood by those skilled in the art that each embodiment can be implemented by means of software plus a general hardware platform, or by hardware. It can be understood by those skilled in the art that all or part of the processes in the above embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0085] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as described above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for selecting a K value for a K-means clustering algorithm in chip simulation, characterized in that: include: Obtaining a first number of first program slices of a benchmark test program corresponding to a target chip, and calculating first type of performance indicator data of the first program slices; Performing feature analysis on the first type of performance indicator data to obtain corresponding feature classification results; Calculate according to the feature classification result to obtain the corresponding maximum preset K value, and generate a K value range according to the maximum preset K value; Sending the K value range to a preset K value selection model, and receiving a target K value output by the K value selection model; The step of performing feature analysis on the first type of performance indicator data to obtain a corresponding feature classification result includes: generating a time series diagram of the first type of performance indicator data changing over time; analyzing the time series diagram of the first type of performance indicator data by a preset time series diagram analysis model to obtain a corresponding feature classification result, wherein the feature classification result is uniform distribution, periodic distribution or non-periodic distribution; Among them, the step of calculating according to the feature classification result to obtain the corresponding maximum preset K value includes: if the feature classification result corresponding to the first category of performance indicator data is a uniform distribution, setting the corresponding maximum preset K value to 1; if the feature classification result corresponding to the first category of performance indicator data is a periodic distribution, setting the corresponding maximum preset K value to the number of periods in the timing diagram of the first category of performance indicator data; if the feature classification result corresponding to the first category of performance indicator data is a non-periodic distribution, setting the corresponding maximum preset K value to the preset maximum K threshold.
2. The K value selection method of the K-means clustering algorithm in chip simulation according to claim 1, characterized in that: The step of calculating the first type of performance indicator data of the first program slice includes: Calculating an average number of instruction cycles of the first program slice as first indicator data; Calculating a first-level data cache miss rate of the first program slice as second indicator data; Calculating branch prediction error data of the first program slice as third indicator data; The first indicator data, the second indicator data and the third indicator data are combined into the first type of performance indicator data.
3. The K value selection method of the K-means clustering algorithm in chip simulation according to claim 1, characterized in that: The K value selection model is a selection model based on the Bayesian Information Criterion algorithm. After the step of sending the K value range to the preset K value selection model, the step further includes: Sequentially obtain each integer within the K value range as a temporary K value; Clustering the first program slices using the temporary K value to obtain program slice clusters of the number of the temporary K value; Calculating the cluster center and covariance matrix of each of the program slice clusters, and then calculating the Bayesian information criterion score corresponding to the temporary K value based on the cluster center and the covariance matrix; The temporary K value corresponding to the maximum Bayesian information criterion score output is the target K value.
4. The K value selection method of the K-means clustering algorithm in chip simulation according to claim 1, characterized in that: After the step of receiving the target K value output by the K value selection model, the method further includes: Obtaining a second number of second program slices from the first program slices using the target K value through a K-means clustering algorithm; Sending the second program slice to a preset chip simulator for simulation to obtain corresponding chip simulation result data; If the accuracy of the chip simulation result data is less than or equal to a preset accuracy threshold, optimizing the K value selection model according to the simulation result data to obtain a new target K value; The first repetition executes the steps from obtaining a second number of second program slices from the first program slice using the target K value through the K-means clustering algorithm to obtaining the new target K value until the accuracy of the chip simulation result data is greater than a preset accuracy threshold, or the number of times the first repetition is executed is greater than a preset first repetition number threshold.
5. The K value selection method of the K-means clustering algorithm in chip simulation according to claim 4, characterized in that: After the step of sending the second program slice to a preset chip simulator for simulation and obtaining corresponding chip simulation result data, the method further includes: If the accuracy of the chip simulation result data is less than or equal to a preset accuracy threshold, calculating the second type of performance indicator data of the first program slice, wherein the second type of performance indicator data is completely different from or partially the same as the first type of performance indicator data; Use the second type of performance indicator data to replace the first type of performance indicator data, re-execute the steps from performing feature analysis on the first type of performance indicator data to sending the second program slice to a preset chip simulator for simulation, and obtain new chip simulation result data; If the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, the steps between calculating the second type of performance indicator data of the first program slice and obtaining the new chip simulation result data are repeated for the second time until the accuracy of the new chip simulation result data is less than or equal to the preset accuracy threshold, or the number of second repetitions is greater than the preset first repetition number threshold.
6. A K value selection system for K-means clustering algorithm in chip simulation, characterized in that: include: A first program slicing module, used to obtain a first program slice of a benchmark test program corresponding to a target chip, and calculate first type of performance indicator data of the first program slice; A feature classification module, used to perform feature analysis on the first type of performance indicator data to obtain corresponding feature classification results; Generate a first-category performance indicator data time series diagram of the first-category performance indicator data changing over time; Analyze the first-category performance indicator data time series diagram through a preset time series diagram analysis model to obtain a corresponding feature classification result, wherein the feature classification result is uniform distribution, periodic distribution or non-periodic distribution; A K value range module is used to calculate according to the feature classification result to obtain the corresponding maximum preset K value, and generate a K value range according to the maximum preset K value; if the feature classification result corresponding to the first type of performance indicator data is uniform distribution, the corresponding maximum preset K value is set to 1; if the feature classification result corresponding to the first type of performance indicator data is periodic distribution, the corresponding maximum preset K value is set to the number of periods of the first type of performance indicator data time series diagram; if the feature classification result corresponding to the first type of performance indicator data is non-periodic distribution, the corresponding maximum preset K value is set to the preset maximum K threshold; The target K value module is used to send the K value range to a preset K value selection model and receive the target K value output by the K value selection model.
7. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the K value selection method of the K-means clustering algorithm in chip simulation described in any one of claims 1-5.
8. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device executes the K value selection method of the K-means clustering algorithm in chip simulation according to any one of claims 1 to 5.
Citation Information
Patent Citations
Chip large-scale parallel electrical detection method based on data dimension reduction and K-means + + algorithm
CN117668709A
Method and apparatus for identifying similar regions of a program's execution
US20040111708A1