A Dynamic Traversal Optimization Method, Device and Medium
Through the dynamic permeability optimization method, the genetic algorithm is used to optimize the execution order of the permeability, and the problem of manual intervention and inefficiency in the optimization of the compilation order is solved, and a more efficient compilation process and better code quality are achieved.
Patent Information
- Application Number
- CN202510105126.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2045-01-23
AI Technical Summary
Existing compilers require a lot of manual intervention when optimizing the compilation sequence, which makes it difficult to improve the compilation efficiency and code quality, and the fixed conversion order is difficult to adapt to various source programs, resulting in poor compilation results and operational performance.
A dynamic parabolic optimization method is proposed, and the order coding of transformation parabolics is optimized using genetic algorithms. Through steps such as initializing populations, compiling source programs, filtering individuals, crossing and mutations, the execution order of transformation parabolics is automatically adjusted to optimize the memory consumption and running time of the compilation process.
It realizes flexible adjustment and optimization of the compilation process, improves compilation efficiency and code quality, reduces manual intervention, and can find the optimal compilation order on different source programs, improving operating performance.
Smart Images

Figure CN119536745B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of program compilation technology, and particularly to a dynamic pass optimization method, device, and medium. Background Art
[0002] A "pass" in the compilation process refers to a head-to-tail scan and processing of the source program or its intermediate results, aiming to generate new intermediate results or target code. The entire compilation process is completed by the coordination of multiple such passes. According to whether it changes the intermediate representation structure of the program, passes are divided into two types: transform passes and analysis passes. Transform passes modify the program structure, while analysis passes do not. There are dependencies between passes. Some transform passes rely on the results of specific analysis passes as auxiliary information when executing. For example, the dead code elimination pass depends on the results of dominance tree analysis. Since only transform passes change the intermediate representation structure of the program, when the intermediate structure of the program does not change, the results of analysis passes can be cached and reused.
[0003] The design of passes follows the modular principle. Each pass is developed independently, and the compiler completes the compilation task by coordinating the execution of different passes, which enhances the reusability and flexibility of passes. The execution order of passes is not fixed. Different arrangements of passes will result in different memory spaces required for intermediate results and the running time of the finally compiled executable program.
[0004] The genetic algorithm (GA) is a heuristic algorithm that draws on the biological evolution principle of nature and provides a feasible solution for each instance of the combinatorial optimization problem within an acceptable computing time and space. The genetic algorithm does not directly process the specific parameters of the problem, but encodes the entire parameter space and starts searching from a set of initial points instead of a single initial point. For different problems, different individual selection strategies, crossover, and mutation schemes can be designed to ensure the convergence of the algorithm and the accuracy of the results. Therefore, the genetic algorithm has wide applicability, high nonlinearity, easy modifiability, and parallelism.
[0005] Mainstream compilers, such as LLVM, adopt a pass manager to automatically manage the execution order between passes with dependencies, but the order of the remaining transform passes still needs to be sorted manually. This results in a large amount of human cost in the compilation development process. In addition, the fixed order of transform passes is difficult to ensure the best compilation results and running performance on various source programs, becoming a bottleneck in the current compiler optimization process and restricting the further improvement of compilation efficiency and generated code quality. Summary of the Invention
[0006] To solve the above problems, the present application proposes a dynamic pass optimization method, including: initializing a population to determine an order encoding corresponding to a transformation pass for multiple individuals in the population; compiling a source program according to the order encoding to determine the memory consumption and running time of the compilation process, and determining an index of the population according to the memory consumption and the running time; screening the multiple individuals according to the index, determining a new order encoding corresponding to the transformation pass after screening, and determining a new index according to the new order encoding; determining a preset index threshold, and comparing the new index with the index threshold; if the new index is greater than or equal to the index threshold, end the optimization; if the new index is less than the index threshold, perform optimization again.
[0007] In one example, compiling the source program according to the order encoding specifically includes: determining whether the result of the analysis pass corresponding to the transformation pass is in the cache; if the result of the analysis pass is not in the cache, execute the analysis pass not in the cache to obtain an analysis result, and store the analysis result in the cache; if the result of the analysis pass is in the cache, determine the cache result and execute the transformation pass according to the cache result.
[0008] In one example, after executing the transformation pass according to the cache result, the method further includes: determining the analysis pass result with the structure changed, and invalidating the analysis pass result with the structure changed; checking all the transformation passes to determine whether all the transformation passes are traversed; if all the transformation passes are traversed, end the compilation; if all the transformation passes are not traversed, continue the compilation.
[0009] In one example, determining the new order encoding corresponding to the transformation pass after screening specifically includes: randomly selecting the multiple individuals to determine a first order encoding and a second order encoding, and determining a preset crossover order encoding; performing crossover filling on the crossover order encoding according to the first order encoding and the second order encoding.
[0010] In one example, performing crossover filling on the crossover order encoding according to the first order encoding and the second order encoding specifically includes: determining the reserved numbers of the first order encoding, and filling the content corresponding to the reserved numbers into the positions corresponding to the numbers of the crossover order encoding; determining the number of the remaining numbers of the crossover order encoding after filling, screening all the numbers of the second order encoding in sequence according to the number to determine the screened numbers; filling the content corresponding to the screened numbers into the positions of the remaining numbers in sequence.
[0011] In one example, determining the new sequential encoding corresponding to the transformed pass after screening specifically further includes: randomly selecting the multiple individuals to obtain a random sequential encoding and determining all the numbers of the random sequential encoding; determining a preset crossover sequential encoding, and mutating and filling the crossover sequential encoding according to all the numbers.
[0012] In one example, mutating and filling the crossover sequential encoding according to all the numbers specifically includes: determining a mutation number group of the random sequential encoding, exchanging the content corresponding to the mutation number group, and filling the exchanged content into the positions corresponding to the numbers of the crossover sequential encoding; determining the remaining numbers other than the mutation number group in the random sequential encoding, and filling the content corresponding to the remaining numbers into the positions corresponding to the numbers of the crossover sequential encoding.
[0013] In one example, the sequential encoding includes multiple positions, the multiple positions correspond to multiple numbers, and the multiple numbers correspond to multiple transformed passes.
[0014] On the other hand, the present application also proposes a dynamic pass optimization device, including: 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 dynamic pass optimization device can perform: initializing a population to determine a sequential encoding corresponding to the transformed pass for multiple individuals of the population; compiling a source program according to the sequential encoding to determine the memory consumption and running time of the compilation process, and determining an index of the population according to the memory consumption and the running time; screening the multiple individuals according to the index, determining the new sequential encoding corresponding to the transformed pass after screening, and determining a new index according to the new sequential encoding; determining a preset index threshold, and comparing the new index with the index threshold; if the new index is greater than or equal to the index threshold, end the optimization; if the new index is less than the index threshold, perform optimization again.
[0015] On the other hand, the present application also proposes a non-volatile computer storage medium storing computer-executable instructions, and the computer-executable instructions are configured to: initialize a population to determine the sequential encoding corresponding to the transformation passes for multiple individuals in the population; compile a source program according to the sequential encoding to determine the memory consumption and running time of the compilation process, and determine the metrics of the population according to the memory consumption and the running time; screen the multiple individuals according to the metrics to determine the new sequential encoding corresponding to the transformation passes after screening, and determine the new metrics according to the new sequential encoding; determine a preset metric threshold, and compare the new metrics with the metric threshold; if the new metrics are greater than or equal to the metric threshold, end the optimization; if the new metrics are less than the metric threshold, perform optimization again.
[0016] By initializing the population and determining the sequential encoding of the transformation passes, the present application realizes the flexible adjustment and optimization of the compilation process. The optimization strategy based on the population helps to explore various possible compilation orders, so as to find the optimal solution for memory consumption and running time. After determining whether the analysis pass results corresponding to the sequential encoding are in the cache, selectively execute the analysis pass or directly use the cache results, which greatly improves the compilation efficiency and reduces unnecessary repeated calculations. The present application continuously iteratively optimizes the sequential encoding of the transformation passes through a strict screening and updating mechanism. By comparing the new metrics with the preset metric threshold, it can intelligently judge when to end the optimization, thus controlling the computational cost while ensuring the optimization effect. In operations such as crossover filling and mutation filling, randomness and diversity are introduced, which helps to jump out of the local optimal solution and explore a broader solution space, so as to find a globally better compilation order. The present application considers multiple aspects such as the invalid processing of the analysis pass results with changed structures and the traversal check of the transformation passes, ensuring the stability and reliability of the compilation process. The present application proposes a method for sequential encoding of transformation passes, as well as crossover and mutation methods based on the sequential encoding of transformation passes, thus realizing the mathematical modeling and generation of feasible solutions for the pass order. On this basis, a dynamic pass optimization algorithm based on the genetic algorithm is designed. Compared with the traditional pass manager, it can automatically complete the compilation execution and search of different pass execution orders, solve the optimal pass execution order, so as to improve the running performance of the compiled program, not only improve the compilation efficiency, reduce the memory consumption, but also provide new ideas and directions for the optimization of compilers. Description of the Drawings
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0018] Figure 1It is a schematic flowchart of a dynamic pass optimization method in an embodiment of the present application;
[0019] Figure 2 It is a schematic diagram of cross - order coding generation in an embodiment of the present application;
[0020] Figure 3 It is a schematic diagram of mutation - order coding generation in an embodiment of the present application;
[0021] Figure 4 It is a schematic diagram of a dynamic pass optimization device in an embodiment of the present application. Detailed implementation manners
[0022] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0023] The following details the technical solutions provided by each embodiment of the present application in conjunction with the drawings.
[0024] As Figure 1 shown, to solve the above - mentioned problems, a dynamic pass optimization method provided by an embodiment of the present application includes:
[0025] S101. Initialize the population to determine the order coding corresponding to the transformation pass for multiple individuals in the population.
[0026] The population of the genetic algorithm is a set composed of multiple individuals, and these individuals represent potential solutions in the solution space. Each individual represents a solution to the problem through a specific coding method, such as binary coding, real - number coding, etc. During the operation of the genetic algorithm, the population evolves continuously through operations such as selection, crossover, and mutation in the simulation of the biological evolution process to seek the optimal solution or approximate optimal solution to the problem. At the beginning of the genetic algorithm, a population needs to be initialized. This is usually achieved by randomly generating a group of individuals, and each individual represents a potential solution. Randomly initialize an order coding for the transformation pass for each individual in the population.
[0027] In one embodiment, in terms of the encoding method, an array with a length of n is used as the initial encoding. Each position in this array represents the running order of the transformation passes, and the number filled in each position corresponds to a different transformation pass. For example, if the number filled in the second position of the array is 3, it means that in the running order of the transformation passes, the number of the second executed transformation pass is 3. Such an encoding method is clear and straightforward. It can not only ensure that each transformation pass is uniquely identified but also accurately reflect their running order.
[0028] S102. Compile the source program according to the sequential encoding to determine the memory consumption and running time of the compilation process, and determine the metrics of the population according to the memory consumption and the running time.
[0029] Compile and optimize the source program according to the transformation pass sequential encoding and execute it. Subsequently, count the memory consumption during the compilation process and the actual running time of the program. These two pieces of data are used as important metrics for evaluating the performance of each individual in the population. Specifically, the lower the memory consumption, the less the compilation process occupies system resources; the shorter the program running time, the higher the program execution efficiency. Therefore, both the memory consumption and the program running time are negatively correlated with the metrics, that is, the lower the value, the higher the corresponding metric. Such an evaluation mechanism helps to accurately measure and optimize the performance of individuals in the population.
[0030] In one embodiment, according to the transformation pass sequential encoding, determine the number of the transformation pass that needs to be executed currently. At the beginning, check whether the analysis pass results required for this transformation pass are already stored in the cache. If they exist in the cache, use the analysis results in the cache to execute the task of the current transformation pass. After executing the transformation pass, mark the analysis pass results that become invalid due to the change in the code structure as invalid to ensure data consistency in the cache. If the required analysis pass results do not exist in the cache, execute the corresponding analysis pass and save the calculated results to the cache for subsequent use.
[0031] Judge whether all the transformation passes in the transformation pass sequential encoding have been traversed. If so, end the entire process; if not, return to the starting step and continue to execute the next transformation pass.
[0032] S103. Screen the multiple individuals according to the metrics, determine the new sequential encoding corresponding to the transformation passes after screening, and determine the new metrics according to the new sequential encoding.
[0033] Implement a probabilistic elimination screening mechanism based on the metrics of each individual and a pre-set elimination threshold. Specifically, individuals with higher metrics have a higher probability of being retained to continue participating in the subsequent evolution process; conversely, individuals with lower metrics face a higher risk of being eliminated. This mechanism ensures the continuation of excellent individuals in the population and promotes the overall optimization and evolution of the population.
[0034] Generate a new sequential encoding for the transformed individuals. Due to the unique constraints of the encoding method for the transformation passes, the number of each transformation pass can only appear once in the encoding to ensure the correctness and efficiency of the compilation process and prevent duplicate numbers.
[0035] In one embodiment, the crossover method is an important step in the genetic algorithm, aiming to generate new offspring individuals by combining the genetic information of two parent individuals. During the crossover of the sequential encoding of the transformation passes, randomly select the sequential encodings of two individuals from the original population as parents. Then, for the first selected sequential encoding of the transformation passes (referred to as the first sequential encoding here), traverse the numbers at each position of the first sequential encoding. Determine whether the number at this position is retained in the new crossover sequential encoding with a pre-set random probability. This probability can be adjusted according to the requirements of the specific problem to balance the diversity of the new individuals and the inheritance of the excellent genes of the parents. For the second selected sequential encoding of the transformation passes (referred to as the second sequential encoding here), check whether the numbers in the second sequential encoding have appeared in the crossover encoding. For the numbers that have not appeared in the crossover encoding, fill them into the remaining positions of the crossover encoding in the order they appear in the second sequential encoding. In this way, a new crossover sequential encoding is generated, which combines the genetic information of the first sequential encoding and the second sequential encoding while ensuring that the number of each transformation pass only appears once in the encoding. As Figure 2 shown, for two parent sequential encodings of the transformation passes with a coding length of 8, for the first parent sequential encoding of the transformation passes, i.e., parent 1, starting from index 0, the numbers 5, 1, 7, 6 at positions 1, 3, 4, 7 are directly retained in the corresponding positions of the crossover sequential encoding of the transformation passes. For the second parent sequential encoding of the transformation passes, i.e., parent 2, the numbers 2, 4, 3, 8 that have not appeared in the crossover encoding are filled into the remaining positions of the crossover encoding in order. In this way, a crossover sequential encoding that contains both the excellent genes of the parents and has new characteristics is generated.
[0036] In one embodiment, the mutation method is another key step in the genetic algorithm, aiming to increase the diversity of the population by introducing new gene mutations. During the mutation process of the transformed pass sequence encoding, a transformed pass sequence encoding of an individual is randomly selected from the original population as the mutation object. Then, a loop process begins. In each loop, a pair of numbers that have not been selected yet are randomly chosen, that is, the transformed pass numbers at two positions (referred to as the mutation number group here). Next, it is determined whether to exchange this pair of numbers with a preset random probability. This probability is usually small to ensure the sparsity of the mutation operation and a moderate impact on the population diversity. In each loop, it is checked whether all the numbers have been queried. Once all the number pairs have been considered, whether or not an exchange has occurred, the mutation process ends, and a new mutated sequence encoding is obtained. As Figure 3 shown, starting from index 0, the numbers at positions 1 and 5 are randomly selected, and the numbers at these two positions are 5 and 4 respectively. After random probability query, it is decided to exchange these two numbers. For the numbers at other positions, after probability query, it is decided not to exchange. In this way, a mutated sequence encoding is obtained, which introduces new mutated elements while maintaining most of the characteristics of the original encoding, helping to explore new regions in the solution space.
[0037] S104. Determine a preset index threshold and compare the new index with the index threshold.
[0038] S105. If the new index is greater than or equal to the index threshold, end the optimization.
[0039] S106. If the new index is less than the index threshold, perform the optimization again.
[0040] During the process of genetic evolution, the results after each round of evolution are evaluated to determine whether the expected optimization goal has been achieved. Specifically, after each genetic evolution is completed, the index of the individuals in the current population is calculated and judged. If this index reaches the preset threshold, it means that we have obtained a solution that meets the requirements or is good enough, and at this time, the loop process of genetic evolution can be terminated. On the contrary, if the index has not reached the threshold, then evolution needs to continue to find a better solution. In this case, the algorithm will jump back to step S101, that is, perform genetic operations such as selection, crossover, and mutation again, and start a new round of evolution loop until a solution that meets the conditions is found or the preset maximum number of evolution generations is reached. Such a design can ensure that the algorithm finds the optimal or approximately optimal solution as much as possible within limited computing resources.
[0041] As Figure 2 shown, the embodiment of the present application also provides a dynamic pass optimization device, including:
[0042] At least one processor; and,
[0043] A memory communicatively connected to the at least one processor; wherein,
[0044] The memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the dynamic pass optimization device can perform:
[0045] Initialize a population to determine an order encoding corresponding to a transformation pass for multiple individuals of the population;
[0046] Compile a source program according to the order encoding to determine the memory consumption and running time of the compilation process, and determine an index of the population according to the memory consumption and the running time;
[0047] Screen the multiple individuals according to the index, determine a new order encoding corresponding to the transformation pass after screening, and determine a new index according to the new order encoding;
[0048] Determine a preset index threshold, and compare the new index with the index threshold;
[0049] If the new index is greater than or equal to the index threshold, end the optimization;
[0050] If the new index is less than the index threshold, re-perform the optimization.
[0051] An embodiment of the present application further provides a non-volatile computer storage medium storing computer-executable instructions, and the computer-executable instructions are set to:
[0052] Initialize a population to determine an order encoding corresponding to a transformation pass for multiple individuals of the population;
[0053] Compile a source program according to the order encoding to determine the memory consumption and running time of the compilation process, and determine an index of the population according to the memory consumption and the running time;
[0054] Screen the multiple individuals according to the index, determine a new order encoding corresponding to the transformation pass after screening, and determine a new index according to the new order encoding;
[0055] Determine a preset index threshold, and compare the new index with the index threshold;
[0056] If the new index is greater than or equal to the index threshold, end the optimization;
[0057] If the new index is less than the index threshold, optimization is performed again.
[0058] Each embodiment in this application is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. The key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, reference can be made to the partial description of the method embodiments.
[0059] The devices and media provided in the embodiments of this application correspond one by one to the methods. Therefore, the devices and media also have beneficial technical effects similar to those of their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be elaborated here.
[0060] Those skilled in the art should understand that the embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0061] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of this application. It should be understood that each process and / or block in the flowchart and / or block diagram can be realized by computer program instructions, and the combination of the processes and / or blocks in the flowchart and / or block diagram can also be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0062] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device realizes the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0063] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 steps of the functions specified in one block or multiple blocks.
[0064] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0065] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash RAM. The memory is an example of computer-readable media.
[0066] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0067] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0068] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A dynamic optimization method, characterized in that: include: Initializing a population to determine sequential codes corresponding to transformations for a plurality of individuals of the population; Compiling the source program according to the sequential encoding to determine the memory consumption and running time of the compilation process, and determining the index of the population according to the memory consumption and the running time; Screening the multiple individuals according to the indicator, determining a new sequence code corresponding to the transformation after screening, and determining a new indicator according to the new sequence code; Determine a preset indicator threshold, and compare the new indicator with the indicator threshold; If the new index is greater than or equal to the index threshold, the optimization is terminated; If the new index is less than the index threshold, re-optimization is performed; Compiling the source program according to the sequential coding specifically includes: Determining whether a result of an analysis pass corresponding to the conversion pass is in a cache; If the result of the analysis pass is not in the cache, performing the analysis pass that is not in the cache to obtain an analysis result, and storing the analysis result in the cache; If the result of the analysis pass is in the cache, determining the cache result, and performing the conversion pass according to the cache result; After performing the conversion according to the cached result, the method further includes: Determine the analysis results whose structure has been changed, and invalidate the analysis results whose structure has been changed; Check all the conversion passes to determine whether all the conversion passes have been completed; If all transformations are completed, the compilation ends; If all the conversion passes have not been completed, continue compiling; Determine the new sequence code corresponding to the transformation after screening, specifically including: Randomly selecting the plurality of individuals to determine a first sequence code and a second sequence code, and determining a preset cross-sequence code; Cross-filling the cross-sequence code according to the first sequence code and the second sequence code; The cross-sequence code is cross-filled according to the first sequence code and the second sequence code, specifically comprising: Determine the reserved number of the first sequence code, and fill the content corresponding to the reserved number into the position of the corresponding number of the cross sequence code; Determine the number of remaining serial numbers of the cross-sequence code after filling, and screen all serial numbers of the second sequence code in order according to the number to determine the screening number; Fill the contents corresponding to the screening numbers into the positions of the remaining numbers in sequence; Determining the new sequence code corresponding to the transformation after screening, specifically also includes: Randomly selecting the multiple individuals to obtain a random sequence code, and determining all numbers of the random sequence code; Determine a preset cross sequence code, and perform variation filling on the cross sequence code according to all the serial numbers; The cross sequence code is mutated and filled according to all the numbers, specifically including: Determine a variation number group of the random sequence code, exchange the content corresponding to the variation number group, and fill the exchanged content into the position of the number corresponding to the cross sequence code; Determine the remaining numbers outside the variation number group in the random sequence code, and fill the contents corresponding to the remaining numbers into the positions of the numbers corresponding to the cross sequence code; Traversing the numbers at each position of the first sequential code, and retaining the numbers in a new cross-sequential code according to a preset G probability; Checking the number of the second sequential code to determine whether the number of the second sequential code appears in the cross-coding; If no number appears in the cross code, the remaining positions of the cross code are filled in sequence according to the order in the second sequence code to generate a new cross sequence code; Select an individual's transformation sequence code from the original population as the mutation object, and start the cycle process. Each cycle selects a pair of mutation number groups at two positions that have not been selected. Exchanging the variant number group with a preset probability; In each cycle, all numbers are checked to determine whether all numbers have been queried; If all the numbers have been queried, the mutation process ends and a new mutated sequence code is obtained.
2. The method according to claim 1, characterized in that The sequential code includes a plurality of positions, the plurality of positions correspond to a plurality of numbers, and the plurality of numbers correspond to a plurality of conversion passes.
3. A dynamic optimization 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 executable by the at least one processor, and the instructions are executed by the at least one processor to enable the dynamic optimization device to perform: Initializing a population to determine sequential codes corresponding to transformations for a plurality of individuals of the population; Compiling the source program according to the sequential encoding to determine the memory consumption and running time of the compilation process, and determining the index of the population according to the memory consumption and the running time; Screening the multiple individuals according to the indicator, determining a new sequence code corresponding to the transformation after screening, and determining a new indicator according to the new sequence code; Determine a preset indicator threshold, and compare the new indicator with the indicator threshold; If the new index is greater than or equal to the index threshold, the optimization is terminated; If the new index is less than the index threshold, re-optimization is performed; Compiling the source program according to the sequential coding specifically includes: Determining whether a result of an analysis pass corresponding to the conversion pass is in a cache; If the result of the analysis pass is not in the cache, performing the analysis pass that is not in the cache to obtain an analysis result, and storing the analysis result in the cache; If the result of the analysis pass is in the cache, determining the cache result, and performing the conversion pass according to the cache result; After performing the conversion according to the cached result, Determine the analysis results whose structure has been changed, and invalidate the analysis results whose structure has been changed; Check all the conversion passes to determine whether all the conversion passes have been completed; If all transformations are completed, the compilation ends; If all the conversion passes have not been completed, continue compiling.
4. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured to: Initializing a population to determine sequential codes corresponding to transformations for a plurality of individuals of the population; Compiling the source program according to the sequential encoding to determine the memory consumption and running time of the compilation process, and determining the index of the population according to the memory consumption and the running time; Screening the multiple individuals according to the indicator, determining a new sequence code corresponding to the transformation after screening, and determining a new indicator according to the new sequence code; Determine a preset indicator threshold, and compare the new indicator with the indicator threshold; If the new index is greater than or equal to the index threshold, the optimization is terminated; If the new index is less than the index threshold, re-optimization is performed; Compiling the source program according to the sequential coding specifically includes: Determining whether a result of an analysis pass corresponding to the conversion pass is in a cache; If the result of the analysis pass is not in the cache, performing the analysis pass that is not in the cache to obtain an analysis result, and storing the analysis result in the cache; If the result of the analysis pass is in the cache, determining the cache result, and performing the conversion pass according to the cache result; After performing the conversion according to the cached result, Determine the analysis results whose structure has been changed, and invalidate the analysis results whose structure has been changed; Check all the conversion passes to determine whether all the conversion passes have been completed; If all transformations are completed, the compilation ends; If all the conversion passes have not been completed, continue compiling.
Citation Information
Patent Citations
Agent modeling method for multi-objective compilation optimization sequence selection
CN112035116A
Code file compiling method and device
CN113805888A