Dynamic Binary Translation Method and Device Based on Neural Network-Assisted Simulated Annealing
Through neural network-assisted simulation annealing algorithm, the problem of difficulty in dynamic adjustment of optimization options in dynamic binary translation systems is solved, and efficient and accurate optimization option configuration is achieved, which improves translation efficiency and performance.
Patent Information
- Application Number
- CN202510467133.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-04-15
AI Technical Summary
In the prior art, simulation annealing algorithms are inefficient in exploration in dynamic binary translation systems, and it is difficult to dynamically adjust optimization options during program operation, resulting in distortion of performance evaluation and waste of computing resources.
A neural network-assisted simulated annealing algorithm is introduced, through sensitivity analysis and dynamic parameter adjustment, combined with the simulation annealing algorithm to perform intelligent configuration of optimization options, and the neural network is used to predict the optimal optimization option values to build a coarse-grained exploration model and iteratively optimize it.
It improves the optimization efficiency of the binary translation system, reduces waste of computing resources, ensures the accuracy and efficiency of dynamic adjustment of optimization options during program operation, and avoids blind trial and error.
Smart Images

Figure CN119987787B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and particularly relates to a dynamic binary translation method and device based on neural network-assisted simulated annealing. Background Art
[0002] Currently, there are multiple instruction set architectures. Many emerging instruction set architectures (such as RISC-V) have attracted the attention of the academic and industrial communities due to their open source characteristics, flexibility, and scalability. However, compared with mature instruction set architectures (such as x86 and ARM), the maturity of the ecosystem of emerging instruction set architectures needs to be improved. To accelerate ecosystem construction and application promotion, binary translation systems have become an important way for software to migrate across instruction set architectures.
[0003] A binary translation system contains a large number of optimization parameters and optional values, constituting a huge optimization combination space. Taking the translation of x86 architecture instructions to RISC-V architecture instructions using the Box64 simulator as an example, Box64 has provided 11 relatively mature optimization options so far, forming an exploration space of size 30720. These optimization options directly affect the quality and performance of the generated target architecture instruction code. However, modifying the values of optimization options during program execution can only act on the untranslated code and is powerless for the translated code. This coexistence of optimized and non-optimized code blocks not only leads to distorted performance evaluation but may even cause the program to crash. Therefore, the setting of current optimization options needs to be completed before the program runs and cannot be dynamically adjusted during program execution.
[0004] In addition, the effects of optimization options on different applications vary. For example, when the value of the BOX64_DYNAREC_BIGBLOCK option is set to 2, 401.bzip2 achieves a 1.61% improvement in binary translation efficiency, while a 3.98% decrease in translation efficiency occurs for 403.gcc. The complex interactions between optimization options and their high dependence on application scenarios make it difficult to predict the actual benefits of each option in advance during the optimization process. If the optimization option combination is re-specified and the program is fully run for each test, for a single-threaded test of the SPEC CPU 2006 INT test set with an input scale of ref, it takes more than 10 hours for one round. If one attempts to exhaust all possible optimization combinations for each application to find the optimal solution, it will consume more than 300,000 hours of CPU single-core time. To avoid a reduction in test accuracy caused by L3 cache pollution, experiments usually avoid running multiple groups of tests simultaneously on different cores of the same server, which further increases the difficulty of space exploration.
[0005] In the optimization of dynamic binary translation systems, several technologies have proposed different solutions. The following patents optimize the system from different perspectives.
[0006] The Chinese national patent "Dynamic Binary Translation Method and System Based on Speculative x86 Flag Calculation" (Publication No.: CN117234526A) proposes a dynamic binary translation method based on speculative x86 flag calculation, which obtains the basic blocks of the guest program and translates the guest instruction sequence in the basic block into a semantically equivalent host instruction sequence.
[0007] The Chinese national patent "A Binary Translation Method Based on Rule Learning for Virtualization" (Publication No.: CN113885883A) completes pre-translation training of the translation learning model based on the code to be translated and the target code, which is used to automatically obtain translation rules and accelerate the speed of the dynamic binary translation system. The idea of using neural networks to assist in optimizing the dynamic binary translation system is also used.
[0008] The Chinese national patent "Casing Length Matching Optimization Method, System and Terminal for Mandrel Hangers" (Publication No.: CN119249849A) is based on the simulated annealing algorithm, which transforms the problem of casing length matching for mandrel hangers into a combinatorial optimization problem, randomly searches in the solution space and gradually optimizes to find the optimal length closest to the target. Its problem-solving idea is to transform the actual problem into a combinatorial optimization problem and explore the optimal solution through the simulated annealing algorithm.
[0009] The Chinese national patent "An Edge Computing Task Scheduling Method, System and Storage Medium Based on Genetic Simulated Annealing Algorithm" (Publication No.: CN119415227A) introduces another improvement of the simulated annealing algorithm, which combines the global search characteristics of the genetic algorithm to obtain better decision results.
[0010] The Chinese national patent "A Method for Solving the Unit Commitment Model of Power Systems Based on Improved Simulated Annealing Algorithm" (Publication No.: CN119442868A) improves the global search ability and convergence speed through the multi-start strategy.
[0011] The Chinese national patent "An Optimization Method for Multi-Sampling Rate Observation Systems Based on Improved Simulated Annealing" (Publication No.: CN119414456A) improves the efficiency and accuracy of optimization calculations by improving the annealing function and probability function.
[0012] The Chinese national patent "A Scheduling Method for Weaving Flexible Workshop Based on Improved NSGA-II" (Publication No.: CN118657448A) combines the fast search ability of the artificial bee colony algorithm to initially search the initial population and combines simulated annealing to perform local search on the Pateto solution.
[0013] The Chinese national patents "Data detection method based on simulated annealing neural network and interference elimination" (Publication No.: CN108282437A) and "Method for predicting water turbidity based on BP neural network optimized by simulated annealing algorithm" (Publication No.: CN119047295A) also introduce the strategy of combining the simulated annealing algorithm with the neural network. They both use the simulated annealing algorithm to assist the training process of the neural network and optimize the weight and threshold parameter values of the network.
[0014] The Chinese national patent "Metering task synchronous scheduling method and system based on improved simulated annealing algorithm" (Publication No.: CN119383187A) introduces an improved simulated annealing algorithm, and its improvement mainly includes introducing the Metropolis criterion and improving the termination criterion. Summary of the Invention
[0015] Aiming at the problem of low exploration efficiency of the simulated annealing algorithm in the prior art, the present invention proposes a dynamic binary translation method, including: generating multiple optimization options for binary translation according to the running command of the target application, quantifying the sensitivity corresponding to the translation efficiency of the optimization option, sorting according to the sensitivity, and dividing the optimization option into multiple optimization option sets with exploration weights according to the sorting result; constructing a coarse-grained exploration model, and predicting the optimal optimization option value vector corresponding to the running command based on the running command; setting the initial parameters of the simulated annealing exploration job, using the optimal optimization option value vector as the starting input of the simulated annealing exploration job, and exploring the best optimization option for binary translation of the running command in the optimization option set; performing binary translation on the running command based on the best optimization option.
[0016] Further, the steps of the simulated annealing exploration job specifically include: setting the initial parameters, where the initial parameters include the initial temperature, the cooling coefficient, the iteration stability threshold, and the termination temperature; obtaining the dynamic threshold of the acceptable new solution for each iteration round of the simulated annealing exploration job, and the perturbation range for generating a new parameter combination; performing iterative calculation based on the initial parameters, the dynamic threshold, the perturbation range, and the starting input to obtain the best optimization option.
[0017] Further, the dynamic threshold dynamic_threshold = threshold×(temperature / T), where threshold is the preset update threshold, temperature is the temperature of the current iteration round, and T is the initial temperature; the perturbation is randomly generated within the range of the maximum offset max_offset, and max_offset = max(min_step_size, int(round(len(options)×step_size×(temperature / T)))), where step_size is the offset step size, min_step_size is the minimum offset step size, and len(options) is the number of available values of the optimization option.
[0018] Further, a neural network predictor is constructed to evaluate the solution S' obtained in the current iteration round through the neural network predictor. If the solution S' has better performance than the optimal solution S obtained in the previous iteration round, the optimal solution S is updated with the solution S'; if the solution S' has worse performance than the optimal solution S, but the performance difference satisfies the dynamic threshold of the current iteration round, the solution S' is accepted with probability P to update the optimal solution S; if the solution S' has worse performance than the optimal solution S, and the performance difference does not satisfy the dynamic threshold of the current iteration round, the solution S' is discarded; if, after updating the optimal solution S from a certain iteration round, for each solution S' obtained in N consecutive iteration rounds, its performance does not satisfy the update of the optimal solution S, after N iterations, the optimal solution S is taken as the final optimal solution, the N iteration rounds are defined as the inspection window of the optimal solution S, and the optimal solution S is the solution after inspection, then N is called the iteration stability threshold; the optimal solution S when the inspection window reaches the iteration stability threshold or the simulated annealing reaches the termination temperature is taken as the best optimization option.
[0019] The present invention also proposes a dynamic binary translation device based on neural network-assisted simulated annealing, including: a preparation module for performing preparatory operations before the simulated annealing exploration operation; including: generating multiple optimization options for binary translation according to the running command of the target application, quantifying the sensitivity corresponding to the translation efficiency of the optimization option, sorting according to the sensitivity, and dividing the optimization option into optimization option sets with multiple exploration weights according to the sorting result; constructing a coarse-grained exploration model, and predicting the optimal optimization option value vector corresponding to the running command based on the running command; an exploration module for setting the initial parameters of the simulated annealing exploration operation, taking the optimal optimization option value vector as the starting input of the simulated annealing exploration operation, and exploring the best optimization option for binary translation of the running command in the optimization option set; a translation module for performing binary translation of the running command based on the best optimization option.
[0020] Further, the exploration operation module includes: an initialization module for setting the initial parameters, which include the initial temperature, the cooling coefficient, the iteration stability threshold, and the termination temperature; a dynamic threshold acquisition module for acquiring the dynamic threshold of acceptable new solutions for each iteration round of the simulated annealing exploration operation; a perturbation acquisition module for acquiring the perturbation range for generating new parameter combinations for each iteration round of the simulated annealing exploration operation; and an iteration module for performing iterative calculations based on the initial parameters, the dynamic threshold, the perturbation range, and the starting input to obtain the best optimization option.
[0021] Further, the dynamic threshold dynamic_threshold = threshold × (temperature / T), where threshold is the preset update threshold, temperature is the temperature of the current iteration round, and T is the initial temperature; the perturbation is randomly generated within the range of the maximum offset max_offset, and max_offset = max(min_step_size, int(round(len(options) × step_size × (temperature / T)))), where step_size is the offset step size, min_step_size is the minimum offset step size, and len(options) is the number of available values of the optimization option.
[0022] Further, the iteration module includes: an evaluation module for constructing a neural network predictor to evaluate the solution S' obtained in the current iteration round through the neural network predictor; a selection module for obtaining the evaluation result through the neural network predictor and selecting the optimal solution S in the current iteration round; if the solution S' obtained in the current iteration round is better than the optimal solution S in the current iteration round in terms of performance, updating the optimal solution S with the solution S'; if the solution S' is worse than the optimal solution S in terms of performance, but the performance difference satisfies the dynamic threshold of the current iteration round, accepting the solution S' to update the optimal solution S with a probability P; if the solution S' is worse than the optimal solution S in terms of performance and the performance difference does not satisfy the dynamic threshold of the current iteration round, discarding the solution S'; a result acquisition module for obtaining the best optimization option; including: if, after a certain iteration round of updating the optimal solution S, the performance of each solution S' obtained in N consecutive iteration rounds does not satisfy the update of the optimal solution S, after N iterations, taking the optimal solution S as the final optimal solution, defining the N iteration rounds as the inspection window of the optimal solution S, and the optimal solution S as the inspected solution, then N is called the iteration stability threshold; taking the optimal solution S when the inspection window reaches the iteration stability threshold or the simulated annealing reaches the termination temperature as the best optimization option.
[0023] The present invention also proposes an electronic device including the dynamic binary translation device based on neural network-assisted simulated annealing as described above.
[0024] The present invention also provides a computer-readable storage medium storing computer-executable instructions, characterized in that when the computer-executable instructions are executed, the dynamic binary translation method based on neural network-assisted simulated annealing as described above is implemented.
[0025] The present invention adopts neural network-assisted technology to accelerate the convergence process and improve the optimization efficiency by means of sensitivity analysis, search path guidance, and dynamic parameter adjustment. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 is a flowchart of the dynamic binary translation method of the present invention.
[0027] Figure 2 is a flowchart of the simulated annealing refined exploration of the dynamic binary translation method of the present invention.
[0028] Figure 3 is a schematic diagram of the pseudo code of the simulated annealing refined exploration of the dynamic binary translation method of the present invention.
[0029] Figure 4 is a schematic diagram of the two-layer optimization execution of the dynamic binary translation method of the present invention.
[0030] Figure 5 is a schematic diagram of the dynamic binary translation device of the present invention.
[0031] Figure 6 is a schematic diagram of an electronic device of the present invention.
[0032] Figure 7 is a schematic diagram of the hardware structure of an electronic device of the present invention.
[0033] Among them, the reference numerals are:
[0034] 100: Electronic device 10: Dynamic binary translation device
[0035] 11: Preparation module 111: Sensitivity detection module
[0036] 112: Neural network prediction module 12: Exploration module
[0037] 121: Initialization module 122: Dynamic threshold acquisition module
[0038] 123: Perturbation acquisition module 124: Iteration module
[0039] 13: Translation module
[0040] S1, S2, S3, S4, S401, S402, S403, S404, S405, S406, S407, S408, S409, S410, S411, S412, S413, S5, S6, S7: Steps Detailed implementation manners
[0041] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific implementation methods described herein are only used to explain the present invention and are not used to limit the present invention.
[0042] It should be noted that in this application, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device.
[0043] Without more limitations, an element defined by the statement "comprising one..." does not exclude the existence of another identical element in the process, method, article or device comprising the element.
[0044] In order to address the problem of low exploration efficiency of the simulated annealing algorithm in the prior art, the present invention designs and implements an intelligent configuration method for optimization options based on a neural network-assisted simulated annealing algorithm. More specifically, the present invention proposes a dynamic binary translation method based on neural network-assisted simulated annealing, which introduces neural network-assisted technology on the basis of the traditional simulated annealing algorithm. Through sensitivity analysis, search path guidance, and dynamic parameter adjustment, etc., an approximate optimal optimization option combination for each application is efficiently explored. Through this method, the system can intelligently select and adjust optimization options, avoid blind trial and error, reduce the waste of computing resources in the optimization process, and improve the efficiency and performance of binary translation.
[0045] Based on the binary translation optimization combination space of the prior art, in order to address the challenges of high-dimensional solution space, complex interactions between optimization options, high dependence on application scenarios, and large test overhead, the present invention introduces neural network-assisted technology. Through sensitivity analysis, search path guidance, and dynamic parameter adjustment, etc., the convergence process is accelerated, and finally the approximate optimal values of each optimization option are found, and an approximate optimal option configuration is generated by combination.
[0046] In the academic and industrial communities, the "translation efficiency E" as shown in formula (1) is generally used to quantify the performance of binary translation systems. Among them, T local is the time of applying native execution, that is, the time spent directly running the natively compiled binary program on the target platform. T BinaryTranslation is the time of applying binary translation-based execution, that is, the time spent simulating the execution of the source program using binary translation technology on the target platform. Taking the binary translation of an x86 program to a RISC-V platform as an example, native execution means directly compiling and executing the source code on the RISC-V platform; binary translation-based execution means compiling the source code on the x86 platform, and the compiled application is executed on the RISC-V platform through binary translation technology. Combining the performance monitoring unit (PMU) to obtain the time consumption of both, and the ratio of the time consumption is the translation efficiency.
[0047] (1)
[0048] Figure 1 is the flowchart of the dynamic binary translation method of the present invention. As Figure 1 shown, in the first embodiment of the present invention, a dynamic binary translation method based on neural network-assisted simulated annealing is proposed, which specifically includes:
[0049] Step S1, input initialization
[0050] At the starting stage of the entire algorithm, first, an input initialization operation needs to be performed, that is, providing the running command of the target application to the binary translation system to clarify the set of optimization options to be explored.
[0051] Step S2, sensitivity detection
[0052] Given that the impacts of different optimization options on different applications are inconsistent, and the direction and magnitude of the impacts are uncertain; moreover, the exploration space is huge, and the time overhead of directly exploring comprehensively is unacceptable. To improve the algorithm efficiency, it is necessary to detect and analyze the sensitivity of the performance impacts of each optimization option. The sensitivity Sensitivity of each optimization option is defined as the magnitude of the impact of a specific optimization option on the translation efficiency of the binary translation system. Specifically, select the value with the largest gap between the translation efficiency corresponding to each value of a certain option and the translation efficiency corresponding to the default value of this option, and use the proportional change amount of the translation efficiency E test corresponding to this value and the translation efficiency E default corresponding to the default value of the optimization option to quantify the sensitivity Sensitivity of each optimization option, as shown in formula (2).
[0053] (2)
[0054] Calculate the sensitivity of each optimization option based on the test data to generate a sensitivity ranking sequence. After locking the highly sensitive options based on the generated sensitivity ranking sequence, the "sensitive subspace" can be focused on during the subsequent automated exploration process: highly sensitive options will be given priority or emphasized in the subsequent exploration of the optimization space, while options with low sensitivity can be considered later or relatively fixed, reducing unnecessary combinatorial exploration. Sensitivity detection provides intelligent guidance for traditional parameter space exploration algorithms and is expected to improve the global exploration efficiency.
[0055] The core of sensitivity detection lies in the experiment of changing the value of a single option. The binary translation system defines the default configuration of the optimization option space. First, use the combination of the default values of each option as the baseline configuration, and record the application running time of the command line using this optimization combination as the baseline for comparing translation efficiency. Subsequently, change the value of each option one by one, and test its impact on translation efficiency while keeping the other options at their default values. By calculating the proportional change in translation efficiency of each option's value relative to the default value, the sensitivity ranking of each option is obtained, and then options with high sensitivity to performance are identified. These options form the "sensitive subspace". Conducting automated exploration based on this "sensitive subspace" helps to significantly shorten the overall exploration time and provides a new idea for optimizing the dynamic binary translation system.
[0056] Step S3, coarse-grained exploration of the neural network
[0057] Use the pre-trained neural network model for coarse-grained exploration. The input of this neural network is the specific application program to be executed and its configuration parameters, and the output is the vector of the optimal optimization option values predicted for this application program. Through this model, initial value suggestions for the simulated annealing algorithm are generated for each current optimization option. Through training with a large amount of running result data, the predicted values generated by the neural network model are expected to be close to the optimal solution. Using this as the starting point for the simulated annealing algorithm's search can effectively narrow the search range during the global optimization of the simulated annealing algorithm. This solves the cold start problem, helps to find the global optimal solution faster and more accurately, and avoids the disadvantages of long exploration time and wasted computing resources caused by blind exploration.
[0058] Step S4, refined exploration of simulated annealing
[0059] For each optimization option, start the refined search process of simulated annealing with the best value predicted by the neural network. During this process, new parameter combinations are generated through perturbation, and multi-round iterative optimization is carried out in combination with the dynamic threshold strategy. It includes a global prediction part and a local correction part.
[0060] The global prediction part uses the neural network prediction value as the initial solution for simulated annealing exploration, provides a possible approximate optimal solution at the global level, and conducts simulated annealing exploration within its neighborhood. Such a global prediction unit can avoid problems such as long exploration time and wasted computing resources caused by blind exploration.
[0061] The local correction part performs simulated annealing search dependent on temperature gradient, including a neural network efficiency predictor, a dynamic threshold calculator, and a temperature-controlled perturbation generator. The neural network efficiency predictor is used to predict the translation efficiency corresponding to the new parameter combination generated by perturbation in each iteration, avoiding blindly running commands corresponding to parameter combinations with low efficiency, which may lead to overly long exploration time. The dynamic threshold calculator calculates the discard condition for a parameter combination with relatively poor performance according to the temperature. Only when the performance gap exceeds the threshold will it be discarded. By setting the threshold dynamically according to the temperature, the convergence speed can be adjusted at different exploration stages. The temperature-controlled perturbation generator is used to adjust the step size according to the temperature, perturb the current parameter combination to generate a new parameter combination, and adjust the exploration accuracy at different exploration stages through dynamic temperature control.
[0062] Figure 2 It is the flowchart of the simulated annealing refined exploration of the dynamic binary translation method of the present invention. Figure 3 It is the schematic diagram of the pseudo-code of the simulated annealing refined exploration of the dynamic binary translation method of the present invention. As Figure 2 、 3 shown, the process of simulated annealing refined exploration includes:
[0063] Step S401, initialize the parameters, set the initial temperature, cooling coefficient, iteration stability threshold, and termination temperature; among them, if after a certain iteration round, after updating the optimal solution S, for each solution S' obtained in N consecutive iteration rounds, its performance does not satisfy updating the optimal solution S, after N iterations, take this optimal solution S as the final optimal solution. Define these N iteration rounds as the inspection window of this optimal solution S, and this optimal solution S as the inspected solution, then N is called the iteration stability threshold.
[0064] The values of these parameters will directly affect the search efficiency and final result of the algorithm. The initial temperature should be high enough to ensure that the algorithm can conduct sufficient random search in the solution space and avoid falling into a local optimal solution prematurely. The cooling rate determines the speed at which the temperature decreases with the number of iterations. A suitable cooling rate can ensure the search breadth while gradually focusing near the global optimal solution. The termination temperature is one of the conditions for the algorithm to stop searching. When the temperature drops to this value, it is considered that the algorithm has converged to a relatively good solution.
[0065] Step S402: Determine whether the iteration end condition is reached. The iteration end condition is that the exploration window of the current optimal solution reaches the iteration stability threshold or the simulated annealing reaches the termination temperature. If it has reached, that is, when the stability counter exceeds the iteration stability threshold or reaches the termination temperature, end the iteration process of simulated annealing and transfer to step S413 to output the best optimization option for binary translation. If it has not reached, then enter step S403;
[0066] Step S403: Calculate the dynamic threshold dynamic_threshold using formula (3) according to the current temperature. This dynamic threshold is used to determine whether to update the optimal solution.
[0067] dynamic_threshold = threshold × (temperature / T) (3)
[0068] Where threshold is the preset solution update threshold, T is the initial temperature, and temperature is the current temperature. When the temperature is high (close to the initial temperature), it is easier to update the solution and avoid falling into a local optimum; when the temperature is low, the acceptance of new solutions decreases, improving the search accuracy of the optimal solution.
[0069] Step S404: Generate perturbations. Perform random perturbations within the neighborhood of the current solution to generate a new parameter combination. The perturbation range is also affected by the temperature. Calculate the maximum offset max_offset using formula (4) and randomly generate perturbations within the maximum offset range:
[0070] max_offset = max(min_step_size, int(round(len(options) × step_size × (temperature / T)))) (4)
[0071] Where step_size is the offset step size, min_step_size is the minimum offset step size, and len(options) is the number of values that this optimization option can take.
[0072] When the temperature is high (close to the initial temperature), the maximum offset is large, ensuring the global exploration ability; when the temperature is low, the maximum offset is small, so the perturbation range decreases and gradually converges to the optimal solution.
[0073] Step S405: The neural network predicts the performance of the new optimization combination;
[0074] Evaluate the performance of the newly generated solution S'. Different from the traditional simulated annealing algorithm, a neural network predictor module is added inside the simulated annealing algorithm in the present invention, which can quickly complete the objective function evaluation of the perturbed generated solution S' through neural network prediction, without actually evaluating the solution S' after each perturbation. Making the above improvements to the simulated annealing algorithm can effectively reduce the overhead caused by the binary translation system when calculating the translation efficiency, avoid wasting the computing resources required for running a complete translation process, and save exploration time at the same time;
[0075] Step S406, if the performance of the new solution S' is much worse than the current optimal solution S, directly discard the solution S' and return to step S404 to regenerate a new parameter combination; otherwise, go to step S407;
[0076] Step S407, add the new optimization combination to generate a complete command line, and actually run a binary translation once to evaluate the performance of the solution S';
[0077] Step S408, after the evaluation in step S407, if the solution S' is better than the current optimal solution S, go to step S409; if the solution S' is slightly worse than the current optimal solution S but meets the dynamic threshold, go to step S410; if the solution S' is much worse than the current optimal solution S, that is, the solution S' does not meet the dynamic threshold, go to step S411;
[0078] Step S409, update the optimal solution S with the solution S' and reset the stability counter, and go to step S412;
[0079] Step S410, accept the new solution S' with probability P to update the optimal solution S, and go to step S412;
[0080] Step S411, directly discard the new solution S', increase the stability counter, and go to step S412;
[0081] Step S412, perform cooling treatment, adjust the temperature according to the dynamic cooling strategy, and the temperature decrease rate increases with the increase of the current iteration number. That is to say, in the initial stage of iteration, the temperature decreases slowly and the temperature is high to increase the search range; while in the later stage of iteration, the temperature decrease rate speeds up and the temperature is low, and the exploration is carried out in a small range, gradually converging to the optimal solution; return to step S402;
[0082] Step S413, output the best optimization combination of the binary translation.
[0083] In the whole algorithm, the neural network and the simulated annealing algorithm cooperate with each other. The neural network provides coarse-grained guidance, and the simulated annealing algorithm is responsible for fine-grained tuning. The two are organically combined to achieve a two-layer optimization execution mode of "global prediction + local correction". As Figure 4As shown in the figure, ① represents the simulated annealing exploration including the double-layer optimization execution module, and ② represents the traditional simulated annealing exploration. Compared with the single optimization method, the double-layer optimization execution mode predicts possible optimal solutions in the global solution space, provides a hot start starting point for the subsequent local correction stage, and is expected to focus on exploring near the actual optimal solution more quickly, achieving more efficient solution seeking. Such an optimization operation on the simulated annealing algorithm breaks through the limitations of traditional heuristic algorithms. At the same time, in the local correction stage, the probability jump characteristic of the simulated annealing algorithm in the local solution space is utilized to effectively avoid the local optimal trap caused by the prediction deviation of the neural network. In addition, the optimization options are explored in descending order of sensitivity in turn to ensure that the high-impact parameters with great influence on performance can converge preferentially, avoiding inefficient global search situations. Through this way of combining intelligent guidance and random search, the algorithm significantly reduces the exploration complexity of the optimization combination space of the user-level dynamic binary translation system and ensures that the algorithm has the ability to approach the optimal solution.
[0084] Step S5, when traversing all optimization options, process them in the order of sensitivity to ensure full coverage of the global combination space;
[0085] Step S6, when all options have been explored, summarize the best values of each option and output the final best optimization option configuration;
[0086] Step S7, based on this best optimization option, perform binary translation on the running command of the target application.
[0087] The automation characteristics of the present invention are reflected in many aspects, ensuring the efficiency and accuracy of the entire optimization process. First, in terms of "automated priority allocation", through the sensitivity detection module, the system can automatically identify and determine the exploration order of optimization options without relying on manual configuration, thus saving the time and effort of manual intervention. Secondly, the "automated path guidance" of the system is dominated by the neural network prediction module, which can intelligently generate the initial solution and correct the exploration direction in real time, avoiding the generation of ineffective searches and ensuring the efficient progress of the optimization process. In addition, the "automated strategy adjustment" function adopted by the system dynamically adjusts the perturbation range and performance threshold based on the temperature gradient, achieving an automatic balance between accuracy and efficiency and avoiding the inconsistency and instability that may be brought by artificially setting strategies. Finally, with the help of the "automated configuration deployment" function, the command line generation module can automatically complete parameter verification, error detection and command generation, directly apply the optimization results to the actual binary translation environment, reduce the manual operation link, and ensure the operability and accuracy of the results.
[0088] Overall, through a highly automated process, the system ensures seamless connection from data flow to control flow. Data is automatically transferred between modules and they work together in coordination, avoiding possible errors and delays caused by manual intervention, and improving the efficiency and stability of the optimization process. Meanwhile, through a closed-loop control mechanism, the system can automatically monitor and adjust parameters to ensure that the whole process has both wide-area exploration capabilities and can accurately converge in the later stage to achieve the optimization goal.
[0089] Figure 5 It is a schematic diagram of the dynamic binary translation device of the present invention. As Figure 5 shown, in the second embodiment of the present invention, a dynamic binary translation device 10 is proposed, including:
[0090] A preparation module 11, used for performing preparatory operations before the simulated annealing exploration operation; including: generating multiple translation options for binary translation according to the running command of the target application, quantifying the sensitivity corresponding to the translation efficiency of the translation option, selecting the translation option with a sensitivity higher than the selection threshold as the optimization option, and constructing it into an optimization option set; constructing a coarse-grained exploration model, and predicting the optimal optimization option value vector corresponding to the running command based on the running command; including:
[0091] A sensitivity detection module 111: This module provides intelligent guidance for traditional parameter space exploration algorithms. The sensitivity of each optimization option is defined as the magnitude of the impact of a specific optimization option on the translation efficiency of the binary translation system. Specifically, select the value with the largest difference in translation efficiency between the translation efficiency of each value of a certain option and the translation efficiency corresponding to the default value of the option, and use the proportional change amount of the translation efficiency corresponding to this value compared to the translation efficiency corresponding to the default value of the optimization option to quantify the sensitivity of each optimization option. Calculate the sensitivity of each optimization option based on the test data, generate a sensitivity ranking sequence, and high-sensitivity options will be given priority in the subsequent exploration of the optimization space, while low-sensitivity options can be considered later or relatively fixed;
[0092] A neural network prediction module 112: Assists the exploration of the simulated annealing algorithm in generating the initial solution and real-time correcting the exploration direction. On the one hand, the input of the neural network is the specific application program to be executed and its configuration parameters, and the output is the predicted optimal optimization option value vector, and this predicted optimization combination is used as the starting point of the simulated annealing exploration. This module obtains the initial value of option exploration for a specific application through pre-training, and is expected to converge to the optimal solution more quickly and accurately. On the other hand, the neural network also predicts the efficiency of the new combination during the simulated annealing exploration process, guides the exploration path, and avoids wasting computing resources due to unnecessary performance evaluations.
[0093] The exploration module 12 is used to set the initial parameters of the simulated annealing exploration job, take the optimal optimization option value vector as the starting input of the simulated annealing exploration job, and explore the best optimization option for binary translation of the running command; it includes:
[0094] The initialization module 121 is used to set the initial parameters, and the initial parameters include the initial temperature, the cooling coefficient, the iteration stability threshold, and the termination temperature;
[0095] The dynamic threshold acquisition module 122 is used to acquire the dynamic threshold of the acceptable new solution for each iteration round of the simulated annealing exploration job;
[0096] The perturbation acquisition module 123 is used to acquire the perturbation range for generating new parameter combinations for each iteration round of the simulated annealing exploration job;
[0097] The iteration module 124 is used to perform iterative calculations based on the initial parameters, the dynamic threshold, the perturbation range, and the starting input to obtain the best optimization option.
[0098] The translation module 13 is used to perform binary translation on the running command based on the best optimization option.
[0099] It should be noted that in various embodiments of the present invention, the magnitudes of the sequence numbers of the above steps do not mean the order of execution. The order of execution of each step should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0100] The following is a system embodiment corresponding to the above method embodiment. This embodiment can be implemented in cooperation with the above embodiment. The relevant technical details mentioned in the above embodiment are still valid in this embodiment. To avoid repetition, they will not be elaborated here. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied in the above embodiment.
[0101] In the third embodiment of the present invention, a computer-readable storage medium is proposed. When the function of the streaming generation model training device of the present invention is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a computer-readable storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. Therefore, in the third embodiment of the present invention, a computer-readable storage medium is provided for storing a computer program for a dynamic binary translation method based on neural network-assisted simulated annealing. It should be understood that the computer-readable storage medium in the embodiments of the present invention may be a volatile memory and / or a non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM), and direct rambus random access memory (DR RAM).
[0102] Figure 5 is a schematic diagram of an electronic device of the present invention. As Figure 5As shown in the figure, in the fourth embodiment of the present invention, an electronic device 100 is proposed, which includes the dynamic binary translation device based on neural network-assisted simulated annealing as described above. Those of ordinary skill in the art can understand that all or part of the steps in the above method can be completed by a program instructing related hardware (such as a processor, FPGA, ASIC, etc.). All or part of the steps of the above embodiments can also be implemented using one or more integrated circuits. Correspondingly, each module in the above embodiments can be implemented in the form of hardware, for example, by an integrated circuit to implement its corresponding function, or can be implemented in the form of a software function module, for example, by a processor executing a program / instruction stored in a memory to implement its corresponding function. The embodiments of the present invention are not limited to any specific form of combination of hardware and software.
[0103] It should be noted that the structure of the electronic device shown in the drawings of the present invention does not constitute a limitation thereto. The actual knowledge structure recognition device may include more or fewer components than shown in the drawings, or combine certain components, or have different component arrangements.
[0104] The electronic device of the present invention can be any device with data processing capabilities, and such a device with data processing capabilities can be a device or apparatus such as a computer. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by a processor of any device with data processing capabilities reading the corresponding computer program instructions in the non-volatile memory into the memory and running them. Figure 6 It is a schematic diagram of the hardware structure of an electronic device of the present invention. As Figure 6 shown, from the hardware level, it is a hardware structure diagram of any device with data processing capabilities where the dynamic binary translation device based on neural network-assisted simulated annealing of the present invention is located. In addition to Figure 6 the processor, memory, network interface, and non-volatile memory shown, the device of the embodiment in any device with data processing capabilities usually includes other hardware according to the actual functions of the device with data processing capabilities, which will not be elaborated herein.
[0105] When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains a collection of one or more available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, or magnetic tape), an optical medium (such as a DVD), or a semiconductor medium. The semiconductor medium may be a solid-state drive.
[0106] The dynamic binary translation method based on neural network-assisted simulated annealing of the present invention is used to solve the problem of exploring the large-scale optimization combination space of a dynamic binary translation system. The present invention is an implementation of a global space automatic exploration algorithm that heuristically explores neighboring solutions using the simulated annealing algorithm and gradually converges to the optimal solution. To address the challenges of high-dimensional solution spaces, complex interactions between optimization options, high dependence on application scenarios, and high test overhead, the present invention introduces neural network-assisted technologies to accelerate the convergence process and improve the optimization efficiency through sensitivity analysis, search path guidance, and dynamic parameter adjustment.
[0107] The above embodiments are only used to illustrate the present invention and are not intended to limit the present invention. Those of ordinary skill in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the present invention. The patent protection scope of the present invention shall be defined by the claims.
Claims
1. A dynamic binary translation method based on neural network-assisted simulated annealing, characterized in that Including: Generate multiple optimization options for binary translation according to the running commands of the target application, quantify the sensitivity corresponding to the translation efficiency of the optimization options, sort them according to the sensitivity, and divide the optimization options into optimization option sets with multiple exploration weights according to the sorting results; Construct a coarse-grained exploration model, and based on the running command, predict the optimal optimization option value vector corresponding to the running command. Among them, use the configuration parameters of the target application and the corresponding optimization options as training data to train the neural network model to obtain the coarse-grained exploration model; Set the initial parameters of the simulated annealing exploration job, use the optimal optimization option value vector as the starting input of the simulated annealing exploration job, and explore the best optimization option for binary translation of the running command in the optimization option set; Based on the best optimization option, perform binary translation on the running command.
2. The dynamic binary translation method according to claim 1, characterized in that The steps of the simulated annealing exploration job specifically include: Set the initial parameters, and the initial parameters include the initial temperature, cooling coefficient, iteration stability threshold, and termination temperature; Obtain the dynamic threshold of the acceptable new solution for each iteration round of the simulated annealing exploration job, and generate the perturbation of the new parameter combination; Based on the initial parameters, the dynamic threshold, the perturbation, and the starting input, perform iterative calculation to obtain the best optimization option.
3. The dynamic binary translation method according to claim 2, wherein The dynamic threshold dynamic_threshold = threshold × (temperature / T), where threshold is the preset solution update threshold, temperature is the temperature of the current iteration round, and T is the initial temperature; Randomly generate the perturbation within the range of the maximum offset max_offset, max_offset = max(min_step_size, int(round(len(options) × step_size × (temperature / T)))), step_size is the offset step size, min_step_size is the minimum offset step size, and len(options) is the number of values that the optimization option can take.
4. The dynamic binary translation method according to claim 3, wherein, Construct a neural network predictor, and evaluate the solution S' obtained in the current iteration round through the neural network predictor. If the solution S' has better performance than the optimal solution S obtained in the previous iteration round, update the optimal solution S with the solution S'; If the solution S' has worse performance than the optimal solution S, but its performance difference meets the dynamic threshold of the current iteration round, accept the solution S' to update the optimal solution S with probability P; If the solution S' has worse performance than the optimal solution S, and its performance difference does not meet the dynamic threshold of the current iteration round, discard the solution S'; If after a certain iteration round of updating the optimal solution S, for each solution S' obtained in N consecutive iteration rounds, its performance does not meet the requirement of updating the optimal solution S, after N iterations, take the optimal solution S as the final optimal solution. Define these N iteration rounds as the inspection window of the optimal solution S, and the optimal solution S as the inspected solution, then N is called the iteration stability threshold; take the optimal solution S when the inspection window reaches the iteration stability threshold or the simulated annealing reaches the termination temperature as the best optimization option.
5. A dynamic binary translation device based on neural network-assisted simulated annealing, characterized in that, Including: A preparation module for performing preparation operations before the simulated annealing exploration operation; including: generating multiple optimization options for binary translation according to the running command of the target application, quantifying the sensitivity corresponding to the translation efficiency of the optimization option, sorting according to the sensitivity, and dividing the optimization option into multiple exploration weight optimization option sets according to the sorting result; constructing a coarse-grained exploration model, and predicting the optimal optimization option value vector corresponding to the running command based on the running command, wherein, using the configuration parameters of the target application and the corresponding optimization options as training data, training a neural network model to obtain the coarse-grained exploration model; An exploration module for setting the initial parameters of the simulated annealing exploration operation, using the optimal optimization option value vector as the starting input of the simulated annealing exploration operation, and exploring the best optimization option for binary translation of the running command in the optimization option set; A translation module for performing binary translation on the running command based on the best optimization option.
6. The dynamic binary translation device according to claim 5, wherein The exploration operation module includes: An initialization module for setting the initial parameters, where the initial parameters include an initial temperature, a cooling coefficient, an iteration stability threshold, and a termination temperature; A dynamic threshold acquisition module for acquiring the dynamic threshold of acceptable new solutions for each iteration round of the simulated annealing exploration operation; A perturbation acquisition module for acquiring the perturbation range for generating new parameter combinations for each iteration round of the simulated annealing exploration operation; An iteration module for performing iterative calculations based on the initial parameters, the dynamic threshold, the perturbation range, and the starting input to obtain the best optimization option.
7. The dynamic binary translation device according to claim 6, wherein The dynamic threshold dynamic_threshold = threshold×(temperature / T), where threshold is a preset solution update threshold, temperature is the temperature of the current iteration round, and T is the initial temperature; Randomly generate the perturbation within the range of the maximum offset max_offset, where max_offset = max(min_step_size, int(round(len(options)×step_size×(temperature / T)))), step_size is the offset step size, min_step_size is the minimum offset step size, and len(options) is the number of values that the optimization option can take.
8. The dynamic binary translation device according to claim 7, wherein The iteration module includes: An evaluation module for constructing a neural network predictor and evaluating the solution S' obtained in the current iteration round through the neural network predictor; A selection module for the neural network predictor to obtain the evaluation result and select the optimal solution S in the current iteration round; if the solution S' obtained in the current iteration round is superior in performance to the optimal solution S in the current iteration round, update the optimal solution S with the solution S'; if the solution S' is inferior in performance to the optimal solution S, but its performance difference meets the dynamic threshold of the current iteration round, accept the solution S' to update the optimal solution S with a probability P; if the solution S' is inferior in performance to the optimal solution S, and its performance difference does not meet the dynamic threshold of the current iteration round, discard the solution S'. A result acquisition module for acquiring the optimal optimization option, including: if after updating the optimal solution S from a certain iteration round, for each solution S' obtained in N consecutive iteration rounds, its performance does not satisfy the update of the optimal solution S, after N iterations, taking the optimal solution S as the final optimal solution, defining these N iteration rounds as the inspection window of the optimal solution S, and the optimal solution S as the solution after inspection, then N is called the iteration stability threshold; taking the optimal solution S when the inspection window reaches the iteration stability threshold or the simulated annealing reaches the termination temperature as the optimal optimization option.
9. An electronic device, comprising the dynamic binary translation device based on neural network-assisted simulated annealing according to any one of claims 5 to 8.
10. A computer-readable storage medium storing computer-executable instructions, characterized in that, When the computer-executable instructions are executed, the neural network-assisted simulated annealing-based dynamic binary translation method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Data detection method based on simulated annealing neural network and interference elimination
CN108282437A
Virtualization-oriented binary translation method based on rule learning
CN113885883A
Dynamic binary translation method and system for calculating x86 flag bit based on speculation
CN117234526A
Improved weaving flexible workshop production scheduling method based on NSGA-II
CN118657448A
Method for predicting water turbidity based on BP neural network optimized by simulated annealing algorithm
CN119047295A