LLVM compile-time energy consumption optimization method and system with the help of frequent sequence mining
Through the help of frequent sequence mining, interactive information of LLVM options is dynamically captured and used to generate frequent option sequences with energy consumption improvement annotations, solving the problem of LLVM option sequence optimization in the existing technology, and significantly improving the solution to energy consumption optimization at compile time Mass and convergence speed.
Patent Information
- Application Number
- CN202210183569.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2042-02-25
AI Technical Summary
Existing LLVM compilation optimization methods are difficult to search for the best option sequence in a given hardware platform and application to obtain better executable code with better non-functional attributes, and lack effective capture and use option interaction information, affecting solution quality and Convergence speed.
Using the help of frequent sequence mining, we generate initial candidate solution sets and build an option sequence transaction database with energy consumption improvement annotation. Based on this, we generate frequent option sequence prefix trees and suffix trees, dynamically capture and use option interaction information, and continuously generate new The solution is output until the preset down time or solution quality is reached.
Significantly improve the understanding of quality and convergence speed. The solution quality improvements of Georgiou and GA algorithms can be as high as 15.52% and 101.81% under reference downtime, and the convergence speed improvements can be as high as 18.00% and 25.25%.
Smart Images

Figure CN114564184B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of compilation optimization, and in particular to an LLVM compilation-time energy consumption optimization method and system assisted by frequent sequence mining. Background Art
[0002] The open source compiler LLVM has the characteristics of high modularity and cross-language and cross-hardware platform compilation optimization capabilities, and is now widely used in the development of various software. LLVM provides a large number of compilation options for optimizing non-functional properties, and these options can be applied at different stages of the compilation optimization process, thereby generating executable code with different optimization effects. Although LLVM developers have provided standard optimization levels such as -O0, -O1, -O2, and -O3 based on domain knowledge and experimental results in typical applications and common hardware platforms, the option sequences corresponding to these standard levels often only produce averagely good optimization results.
[0003] How to search for the best LLVM option sequence for a given hardware platform and application to obtain executable code with better non-functional properties has always been an open and hot issue in the field of compiler optimization. Solving this problem will face two major challenges: First, the huge and discrete option sequence optimization space. If a specific version of LLVM provides n options, the sequence length is specified to be n (each option has a chance to be used) and the options can be reused, then the discrete optimization space composed of different option sequences will be as large as n. n For the 84 options that appear in the sequence corresponding to the -O2 level in LLVM10.01, the optimization space will exceed 10 160 . Second, there are complex interactions between options. The application of one option in a sequence can make subsequent options effective or invalid, so that applying a set of exactly the same options in different orders can obtain different versions of executable code with different non-functional property optimization effects. In response to the above challenges, academia and industry have carried out a lot of LLVM compilation optimization research. In the early days, the non-functional property optimization targets were mostly executable code size or execution time. With the widespread application of the Internet of Things and cloud computing technologies, long-running embedded systems and data center applications have been vigorously promoted. Energy consumption optimization of these systems or applications has also received increasing attention.
[0004] At present, two types of methods have emerged at home and abroad: machine learning and design space search (also known as iterative compilation). However, these methods mostly focus on execution time optimization, and work on energy consumption optimization is relatively scarce. Unlike machine learning methods, although design space search methods do not rely on offline prediction models or knowledge bases and have good portability, they still lack the means to effectively capture and use option interaction information during the search process, which in turn affects the solution quality and convergence speed. Although the Nobre method and the Georgiou method rely on the option dependencies implied by the standard level, they have not yet considered the impact of the hardware platform and the application to be optimized on the option interaction, and have not dynamically captured option interaction information from the optimization process. The Asher method only captures the interaction information between any two options. In addition, Ni Youcong and others from Fujian Normal University used frequent patterns to capture the interaction information between any multiple options online for the GCC compiler, and proposed two GCC compile-time energy consumption optimization genetic algorithms GA-FP and FACET. However, these works solve the optimization problem of option selection under a set of options predefined by GCC and their prescribed order of use, which is completely different from the option sequence optimization problem in this paper (the former has an optimization space of 2 n The latter is as high as n n , assuming that GCC and LLVM both provide n options). In other words, GA-FP and FACET are not suitable for capturing option interaction information in LLVM arbitrary order scenarios, so it is still necessary to rebuild the mining model, representation method and mining algorithm of option interaction information, and design new optimization algorithms on this basis. At the same time, it is worth noting that: we have not yet found any research work on dynamically capturing and using LLVM option interaction information associated with optimization goals during iterative optimization. According to the theory of solving optimization problems with large-scale variables and variable interactions, this will significantly affect the optimization quality and optimization speed of LLVM option sequences. Summary of the invention
[0005] The object of the present invention is to provide a method and system for optimizing energy consumption during LLVM compilation with the help of frequent sequence mining, which is conducive to improving the solution quality and convergence speed under the same downtime.
[0006] To achieve the above purpose, the technical solution adopted by the present invention is: a frequent sequence mining-assisted LLVM compile-time energy consumption optimization method, firstly generating an initial candidate solution set S, and constructing an initial option sequence transaction database DB with energy consumption improvement annotations based on the candidate solution set S E , then based on DB E Mining and generating frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E , then based on the prefix tree prefixTreeE and postfixTree E Generate new solutions with energy consumption improvement annotations and help with frequent option sequences, evaluate and generate new solutions and update DB E ; Continuously generate new solutions until the preset downtime or solution quality is reached, and output the optimal solution in S.
[0007] Further, the method comprises the following steps:
[0008] Step S1, input the initial solution set size N and the optimization environment Env;
[0009] Step S2, assign an initial value of 1 to the number of iterations t; generate a candidate solution set S of size N = {X1, X2, ..., X i ,…,X N}, where 1≤i≤N, X i ∈Ω, N-1 candidate solutions are generated by Latin hypercube sampling, and the other solution is the solution corresponding to level -O2; the transaction identifier tID is initialized to 0, and DB E Initialize to an empty set
[0010] Step S3: For each candidate solution X in the candidate solution set S i : Calculate X i The energy consumption optimization target value f Env (X i ); said f Env (X i ) is the solution of X under the optimized environment Env i Compared with the sequence energy consumption improvement percentage corresponding to LLVM's -O2 level, that is, the percentage of energy consumption reduction; if f Env (X i )>0, that is, there is an energy consumption improvement effect, then update DB E , that is, let the transaction identifier tID increase by 1, and the option sequence transaction T with energy consumption improvement mark E (tID,X i ,f Env (X i ))Join DB E ;
[0011] Step S4: If the preset downtime or solution quality is not reached, go to the next step, otherwise go to step S8;
[0012] Step S5: Based on DB E Mining and generating frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E ;
[0013] Step S6: For each candidate solution X in the candidate solution set S i : Based on X i , prefix tree prefixTree E and postfixTree E Generate a new solution Y i , and calculate Y i The energy consumption optimization target value f Env (Y i ); if f Env (Y i )>f Env (X i ), then on the one hand, in DB E Find X in i Corresponding transaction T E , if it exists, use Y i and f Env (Y i ) replace T E X in i and f Env (X i ), on the other hand, the X in S i Use Y i replace;
[0014] Step S7, increment the number of iterations t by 1, and return to step S4 to continue judging and looping;
[0015] Step S8: output the optimal solution X.
[0016] Furthermore, the prefix tree prefixTree of frequent option sequences with energy consumption improvement annotations is generated by mining the frequent option sequence prefix tree with energy consumption improvement annotations. E and postfixTree E , specifically including the following steps:
[0017] Step A1, input points to the prefix tree prefixTree E The node pointer ptr where the child node is to be inserted pre , pointing to the suffix tree postfixTree E Pointer to the root node ptr post , frequent option sequence β, minimum support count Sup min , and the projection database DB prefixed with β E | β ;
[0018] Step A2: Determine DB E | β Is the number of transactions in less than Sup? minIf yes, then end, otherwise scan the database DB E | β , and calculate the sequence α corresponding to each option op during the scanning process <op>Support count and energy consumption improvement mark E α , and generate a set of frequent option sequences
[0019] Step A3: For each Generate a sequence γ = β°α, which is used to represent a frequent option sequence generated by concatenation with β as the prefix and α as the suffix; set the support count of γ and energy consumption improvement mark E γ Set to and E α , construct a frequent option sequence With α, ptr pre and For input Insert into the prefix tree and assign the return value to ptr pre , with ptr post and For input Insert into the suffix tree to get the frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E ;
[0020] Step A4: Constructing the prefix projection database DB of γ E | γ , which is equal to (DB E | β )| α ;
[0021] Step A5: ptr pre 、ptr post ,γ,Sup min and DB E | γ Recursively call prefixspan with the value as parameter + algorithm.
[0022] Furthermore, each Use a triple , where β captures which options interact in sequence. and E β They are used to represent the number of occurrences and efficacy of interactions, respectively; and E β Calculated by formula (1) and formula (2) respectively:
[0023]
[0024]
[0025] In the formula, X represents β as transaction T E is a subsequence of the option sequence X, and E β is the number of transactions that β participates in E The cumulative energy consumption improvement is calculated by Quantitatively characterize the average effectiveness of frequent option sequences β; by capturing option interactions in dominant solutions with the help of frequent option sequences with energy consumption improvement annotations, useful heuristic information is provided for the option sequence optimization process.
[0026] Furthermore, with α, ptr pre and For input The specific method of inserting into the prefix tree is:
[0027] Step B1: Input the sequence α of radio buttons and point to the prefix tree prefixTree E The node pointer ptr where the child node is to be inserted pre , and frequent option sequences with energy consumption improvement annotations
[0028] Step B2: Based on Generate a new node newNode with an empty hash table and set ptr newNode Point to the node newNode;
[0029] Step B3: In ptr pre Add an entry to the hash table pointing to the node. The key value of the entry is the corresponding option α, and the value is the pointer ptr newNode ;
[0030] Step B4: Set the pointer ptr pre Points to ptr newNode ;
[0031] Step B5: Output and return the new pointer ptr of the node to be inserted pre .
[0032] Furthermore, with ptr post and For input The specific method of inserting into the suffix tree is:
[0033] Step C1, input points to the suffix tree postfixTree E Pointer to the root node ptr post and frequent option sequences with energy efficiency improvements
[0034] Step C2: Assign i to the length len of the sequence γ and set the pointer ptr par Points to ptr post ;
[0035] Step C3: when i>0, go to the next step, otherwise end;
[0036] Step C4: Use γ[i] as the key in ptr par Look up the hash table pointing to the node and get the pointer ptr pointing to the matching child node chd ;
[0037] Step C5: If ptr chd is not empty, the match is successful, further judgment: if ptr chd The support count of the frequent sequence pointing to the node is less than Then update the label of the frequent sequence in the node, that is, ptr chd The support count and energy consumption improvement label of the frequent sequence corresponding to the pointing node are set as and E γ ; if ptr chd If it is empty, do the following: Let δ = <γ[i],…,γ[len]>, and set its support count and energy consumption improvement label to and E γ , construct a frequent suffix option sequence with energy consumption improvement annotation based on Generate a new node newNode with an empty hash table and set ptr newNode Points to the node newNode; in ptr par Add an entry to the hash table pointing to the node, the key value of the entry is the γ[i] option, and the value is the pointer ptr newNode ; Then the pointer ptr par Points to ptr newNode ;
[0038] Step C6, subtract 1 from i, and return to step C3 to continue judging and looping, otherwise end.
[0039] Further, based on the solution X, prefix tree prefixTree E and postfixTree E The specific method to generate a new solution Y is:
[0040] Step D1, randomly generate 0 or 1 and assign it to i, and assign solution X to solution Y;
[0041] Step D2: If i==0, go to step D3 to generate a new solution by prefix matching; otherwise, go to step D4 to generate a new solution by suffix matching;
[0042] Step D3: Randomly generate a starting position strt and an ending position end, where 1 ≤ strt ≤ end < n, and generate a continuous subsequence α = <x strt , x strt+1 , …, x end >; Apply the prefix matching rule and obtain the matching result S op , that is, the option-average efficacy set; Based on Sop and apply the probability selection rule to obtain the selected option j; Update the (end + 1)-th element in Y to j; Then go to step D5;
[0043] Step D4: Randomly generate a starting position strt and an ending position end, and generate a continuous subsequence α = <x strt , x strt+1 , …, x end >; Apply the suffix matching rule and obtain the matching result S op ; Based on S op and apply the probability selection rule to obtain the selected option j; Update the (strt - 1)-th element in Y to j; Then go to step D5;
[0044] Step D5: Output the new solution Y and end.
[0045] Furthermore, the specific method for applying the prefix matching rule and obtaining the matching result S op is as follows:
[0046] Match the determined continuous subsequence α = <x n > in the solution X = <x1, x2, …, x strt , x strt+1 , …, x end > with the option rule sequence formed by the path starting from the root node of the prefix tree prefixTree E in ascending order. If the match is successful, generate the option-average efficacy set S defined in formula (3) according to the child node set op corresponding to the matching node as the matching result;
[0047]
[0048] If the match is unsuccessful, use the empty set as the matching result; In formula (3), chd.β[end - strt + 2] represents the option op corresponding to the last element of the option sequence in the child node chd.
[0049] Furthermore, the specific method for applying the suffix matching rule and obtaining the matching result S op is as follows:
[0050] Match the solution X = <x1, x2, …, x n >The continuous subsequence α determined in <x strt ,x strt+1 ,…,x end > In reverse order from the suffix tree postfixTree E The option rule sequence formed by the path starting from the root node is matched. If the match is successful, the child node set corresponding to the matching node is The option-average power set S defined by formula (4) op As a result of the match;
[0051]
[0052] If the match fails, an empty set As the matching result; in formula (4), chd.γ[1] represents the option corresponding to the first element of the option sequence in the child node chd.
[0053] The present invention also provides an LLVM compile-time energy consumption optimization system assisted by frequent sequence mining, comprising a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the above-mentioned method steps can be implemented.
[0054] Compared with the prior art, the present invention has the following beneficial effects: a method and system for optimizing energy consumption during LLVM compilation with the assistance of frequent sequence mining are provided. Experimental comparison of the method with the Georgiou algorithm, which is the fastest algorithm for obtaining good quality solutions, and the GA algorithm, which is generally recognized to be able to obtain high-quality solutions after a sufficiently long evolution time, in 7 typical cases in 4 different fields shows that under the benchmark downtime, the average relative improvement of the solution quality of the method compared with Georgiou and GA can reach 15.52% and 101.81% at best; in terms of the convergence speed to achieve the benchmark solution quality, the average relative improvement of the method compared with Georgiou and GA can reach 18.00% and 25.25% at best. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a mining model and a representation method of option interaction information in an embodiment of the present invention.
[0056] Figure 2 In the embodiment of the present invention, the minimum support count is 2 pairs. Figure 1 Schematic diagram of the recursive mining process of the updated database.
[0057] Figure 3 In the embodiment of the present invention, frequent sequences are inserted Schematic diagram of (<1,2>,2,17%) before and after prefix tree.
[0058] Figure 4 In the embodiment of the present invention, frequent sequences are inserted Schematic diagram of (<1,2>,2,17%) before and after to the suffix tree.
[0059] Figure 5 In the embodiment of the present invention, frequent sequences are inserted ( <2> ,4,34%) to the suffix tree.
[0060] Figure 6 is the target value f obtained by the three algorithms FHIA-FSM, GA and Georgiou for each case under the benchmark downtime in the embodiment of the present invention Env (X * Statistical box plot of )(percent improvement in energy consumption relative to -O2 level).
[0061] Figure 7 The calculation time improvement percentage I of the three algorithms FHIA-FSM, GA and Georgiou in the embodiment of the present invention for each case under the benchmark solution quality Δt% Statistical box plot of .
[0062] Figure 8 It is a flow chart of the method implementation of the embodiment of the present invention.
[0063] Fig. 9 It is a flow chart for implementing the frequent option sequence mining algorithm prefixspan+ with energy consumption improvement annotation in an embodiment of the present invention.
[0064] Fig.10 It is a flow chart of the implementation of the prefix tree insertion algorithm in the embodiment of the present invention.
[0065] Fig.11 It is a flow chart of the implementation of the suffix tree insertion algorithm in the embodiment of the present invention.
[0066] Fig.12 It is a flow chart of the implementation of the new solution generation algorithm in the embodiment of the present invention. DETAILED DESCRIPTION
[0067] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0068] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0069] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0070] This embodiment provides a LLVM compile-time energy consumption optimization method FHIA-FSM (Fast Heuristic Iteration Algorithm for energy consumption optimization under LLVM based on Frequent options Sequence Mining) assisted by frequent sequence mining. First, an initial candidate solution set S is generated, and an initial option sequence transaction database DB with energy consumption improvement annotations is constructed based on the candidate solution set S. E , then based on DB E Mining and generating frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E , then based on the prefix tree prefixTree E and postfixTree E Generate new solutions with energy consumption improvement annotations and help with frequent option sequences, evaluate and generate new solutions and update DB E ; Continuously generate new solutions until the preset downtime or solution quality is reached, and output the optimal solution in S.
[0071] This method uses sequence encoding <x1,x2,…,x n >(xi∈{1,2,…n}) represents the candidate solution X. Among them, LLVM options are numbered from 1 to n. The energy consumption optimization objective function f in this method Env (X) is defined as: the percentage of energy consumption improvement (percentage of energy consumption reduction) obtained by solving X relative to the corresponding sequence at -O2 level under the optimization environment Env consisting of a given hardware platform, LLVM, application source code to be optimized, and typical input.
[0072] like Figure 8 As shown, the method specifically comprises the following steps:
[0073] Step S1, input the initial solution set size N and the optimization environment Env;
[0074] Step S2, assign an initial value of 1 to the number of iterations t; generate a candidate solution set S of size N = {X1, X2, ..., X i ,…,X N }, where 1≤i≤N, X i ∈Ω, N-1 candidate solutions are generated by Latin hypercube sampling, and the other solution is the solution corresponding to level -O2; the transaction identifier tID is initialized to 0, and DB E Initialize to an empty set
[0075] Step S3: For each candidate solution X in the candidate solution set S i : Calculate X i The energy consumption optimization target value f Env (X i ); said f Env (X i ) is the solution of X under the optimized environment Env i Compared with the sequence energy consumption improvement percentage corresponding to LLVM's -O2 level, that is, the percentage of energy consumption reduction; if f Env (X i )>0, that is, there is an energy consumption improvement effect, then update DB E , that is, let the transaction identifier tID increase by 1, and the option sequence transaction T with energy consumption improvement mark E (tID,X i ,f Env (X i ))Join DB E ;
[0076] Step S4: If the preset downtime or solution quality is not reached, go to the next step, otherwise go to step S8;
[0077] Step S5: Based on DB E Mining and generating frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E ;
[0078] Step S6: For each candidate solution X in the candidate solution set S i : Based on X i , prefix tree prefixTree E and postfixTree E Generate a new solution Y i , and calculate Y i The energy consumption optimization target value f Env (Y i ); if f Env (Y i )>f Env (X i ), then on the one hand, in DB E Find X in i Corresponding transaction T E , if it exists, use Y i and f Env (Y i ) replace T E X in i and f Env (X i ), on the other hand, the X in S i Use Y i replace;
[0079] Step S7, increment the number of iterations t by 1, and return to step S4 to continue judging and looping;
[0080] Step S8: output the optimal solution X.
[0081] In step S3, the initial DB is given E The construction of is shown in Table 1.
[0082] Table 1 Option sequence transaction database DB with energy consumption improvement annotation E Example
[0083]
[0084] Based on traditional serial transactions, DB E Each transaction T in E Added energy consumption improvement annotation f Env (X), thus quantitatively relating the sequence of options to their efficacy. It can be expressed as a triple T E (tid,X,f Env (X)) is used to represent T E Each element in represents the transaction ID, option sequence (solution) and energy consumption improvement label. Furthermore, in the iterative optimization process, DB E is continuously updated, as described in step S6. In addition, in step S5, the prefix tree prefixTree of the frequent option sequence is mined and output E and postfixTree E , and the generation of the new solution in step S6 will be explained in detail later.
[0085] 1 Frequent Option Sequence Mining Method with Improved Energy Consumption Annotation
[0086] The method for mining frequent option sequences with energy consumption improvement annotations includes a mining model and a representation method for option interaction information, and a frequent option sequence mining algorithm prefixspan with energy consumption improvement annotations + This method uses the frequent option sequence mining algorithm prefixspan+ with energy consumption improvement annotation to mine and generate the prefix tree prefixTree of frequent option sequences with energy consumption improvement annotation E and postfixTree E .
[0087] 1.1 Mining Model and Representation Method of Option Interaction Information
[0088] Figure 1 The mining model and representation method of option interaction information are given. It is based on the frequent option sequence transaction database DB with energy consumption improvement annotation in the optimization process. E , and adopt the proposed prefixspan + Algorithm mining generates frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E The mining model and representation method of option interaction information provide useful, comprehensive, efficient and timely heuristic information for new solution generation. Specifically:
[0089] (1) Usefulness
[0090] DB E Each business E (tid,X,f Env The option sequence X(solution) in (X)) has an energy improvement effect compared to the -O2 level, and the effect of X is also marked with energy improvement f Env (X) format is saved in T E In Figure 1 In order to capture the option interactions and their frequency and effectiveness in transactions with improved effects, the DB E Mining those recurring option subsequences β in the DB E The number of occurrences (support count) in β and the energy consumption improvement label at each occurrence are quantitatively associated with β, thereby forming a frequent option sequence with energy consumption improvement label (abbreviated as ).
[0091] Each Use a triple , where β captures which options interact in sequence. and E β They are used to represent the number of occurrences and efficacy of interactions, respectively; and E β Calculated by formula (1) and formula (2) respectively:
[0092]
[0093]
[0094] In the formula, X indicates that β is transaction T E is a subsequence of the option sequence X, and E β is the number of transactions that β participates in E The cumulative energy consumption improvement is calculated by Quantitatively characterize the average effectiveness of frequent option sequences β; by capturing option interactions in dominant solutions with the help of frequent option sequences with energy consumption improvement annotations, useful heuristic information is provided for the option sequence optimization process.
[0095] (2) Comprehensiveness and Efficient Usability
[0096] In order to E Capture the interaction of any number of options in prefixspan + The algorithm mines and stores complete frequent option sequences of various lengths. Considering the need to quickly locate a specific frequent option sequence in both positive and reverse order, a frequent option sequence prefix tree prefixTree with energy-saving improved annotation is used. E and postfixTree E Save all the frequent option sequences mined out simultaneously in the form of shared prefix sequences and shared suffix sequences respectively Figure 1 The lower rectangle shows the prefix tree prefixTree E and postfixTree E . prefixTree E and postfixTree E Each node in the tree corresponds to a frequent option sequence The arcs between parent and child nodes indicate the prefix or suffix relationship of the option sequence in the parent and child nodes. For example: Figure 1 prefixTree E The third node of the second layer of the tree and the sixth node of the third layer form a parent-child node relationship. These two nodes correspond to the frequent option sequences and The arc is marked with a sequence of single options α= <2> . Among them, the sequence γ=β°α in the child node is formed by taking the sequence β in the parent node as a prefix and connecting the sequence α on the arc. Similarly, Figure 1 postfixTree E The second node of the second layer of the tree and the fourth node of the third layer form a parent-child node relationship. These two nodes correspond to the frequent option sequences and The arc is marked with a sequence of single options α= <3> Among them, the sequence γ=β°α in the child node is formed by using the sequence β in the parent node as a suffix and connecting the sequence α on the arc.
[0097] Any frequent option sequence You can either start from prefixTree in positive order E The root of the tree can also be in reverse order from postfixTree E The root of the tree is obtained by searching for matches along the arcs. Can be ordered from prefixTree E The roots begin to arc <3> → Arc <2> , or in reverse order from postfixTree E The roots begin to arc <2> → Arc <3> To improve the search and positioning in prefixTree E Tree and postfixTree E Finding frequent option sequences in a tree To improve the efficiency, two information fields are used to define nodes. One field is used to record the frequent option sequence represented by the node. The other domain is a hash table HT used to represent the arcs of the parent-child relationship. Each entry in HT consists of a key-value pair, where the key is the option corresponding to the order marked on the arc, and the value is a pointer to the child node.
[0098] Therefore, the frequent interactions of any number of options are represented using the frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E It can be expressed in the form of , thus providing comprehensive and efficiently usable heuristic information for the option sequence optimization process.
[0099] (3) Timeliness
[0100] Considering that the solution set obtained in the optimization process of the option sequence optimization algorithm is constantly changing, the current database DB is optimized according to the generated new solution. E Update to keep the better solution, Figure 1 The upper rectangular box shows the DB E The update process. Among them: the current DB E Transaction T indicated by medium gray background E Will be based on T E Generate and replace with a better new solution Y. Thus, from the ever-changing DB E The mined frequent option sequences with energy consumption annotations can provide the latest option interaction heuristic information for the iterative optimization process.
[0101] 1.2 Frequent Option Sequence Mining Algorithm with Energy Consumption Improvement Annotation prefixspan+
[0102] prefixspan + The mining algorithm adopts a recursive mining process of frequent sequences with increasing prefixes. Fig. 9 As shown, prefixspan + The mining algorithm specifically includes the following steps:
[0103] Step A1, input points to the prefix tree prefixTree E The node pointer ptr where the child node is to be inserted pre , pointing to the suffix tree postfixTree E Pointer to the root node ptr post , frequent option sequence β, minimum support count Sup min , and the projection database DB prefixed with β E | β ;
[0104] Step A2: Determine DB E | β Is the number of transactions in less than Sup? min If yes, then end, otherwise scan the database DB E | β , and during the scanning process, the sequence α corresponding to each option op is calculated according to formula (1) and formula (2) respectively. <op>Support count and energy consumption improvement mark E α , and generate a set of frequent option sequences
[0105] Step A3: For each Generate a sequence γ = β°α, which is used to represent a frequent option sequence generated by concatenation with β as the prefix and α as the suffix; set the support count of γ and energy consumption improvement mark E γ Set to and E α , construct a frequent option sequence With α, ptr pre and For input Insert into the prefix tree and assign the return value to ptr pre , with ptr post and For input Insert into the suffix tree to get the frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E ;
[0106] Step A4: Constructing the prefix projection database DB of γ E | γ , which is equal to (DB E | β )| α ;
[0107] Step A5: ptr pre 、ptr post ,γ,Sup min and DB E | γ Recursively call prefixspan with the value as parameter + algorithm.
[0108] Figure 2 Indicates prefixspan + The algorithm has a minimum support count Sup min =2, for Figure 1 After updating DB E The recursive mining process is used to improve Figure 2 For readability, the arcs of the recursive backtracking process are omitted.
[0109] prefixspan + The algorithm first converts Sup min With the projection database DB prefixed with β E | β Compared with the number of transactions in Sup min Return to the last recursion, otherwise get the database DB E | β Frequent option sequences The set S of (α is of length 1), such as prefixspan + The mining algorithm is shown in step A2; then each element in S is Perform the following four steps, as prefixspan + Mining algorithm steps A3-A5: Generate new frequent option sequences insert To prefix tree, insert To the suffix tree, and construct a new sequence The projection database with the prefix DB E | γ And make a recursive call. Figure 2 Explain prefixspan + The execution process of the algorithm.
[0110] Figure 2 Each node in represents the projection database DB with β as prefix E | β , the root node can be regarded as a projection database DB with an empty sequence as prefix E | <> (Abbreviated as DB E ). prefixspan + The algorithm from Figure 2 Start mining from the root node, and scan the DB E Find four frequent options 1, 2, 3 and 4, and accumulate the options in DB according to formula (1) and formula (2) respectively. E The number of occurrences in and the energy consumption of the transactions involved are improved, thereby generating 4 frequent option sequences of length 1 The set S of Figure 2 The annotations on the arcs between the root node and the four nodes in the second layer. ( <1> ,3,24%) as an example to give the 4 steps of this recursive process:
[0111] ① With β=<> as prefix and α= <1> Generate a new sequence for suffix connection γ=β°α= <1> At this time, γ = α, so the support count and energy consumption improvement mark of γ and α are the same;
[0112] ②Call the prefix tree insertion algorithm Insert the prefix tree. Specifically, first according to Generate a new node newNode, and then follow ptr pre Insert the newNode node into the prefix tree at the location indicated by (currently the root node), and finally modify ptr pre Let it point to the newNode node to indicate the next node to be inserted. After insertion, Figure 3 The prefix tree in the middle left;
[0113] ③Call the suffix tree insertion algorithm Insert the suffix tree. Since the root node of the current suffix tree has no child nodes, After generating a new node newNode, directly insert the newNode node under the root node. Figure 4 The suffix tree in the center left;
[0114] ④ With γ= <1> Build a database DB for the prefix E | <1> ,get Figure 2 The leftmost node of the second layer. Root node DB E With NodeDB E | <1> The arcs between them mark the frequent option sequences obtained by this recursive call. By DB E Get DB E | <1> The process is to convert the DB E Each business E Delete the continuous subsequence corresponding to the first occurrence of 1 from the option sequence of , and get a new sequence δ. If δ is not empty, then T E Transaction id, δ and T E Energy consumption improvement annotation as a new transaction T E | <1> Included in DB E | <1> Otherwise T E Not included in DB E | <1> It is worth noting that DB E | <1> Characterizes the frequent option sequence <1> Each transaction T that occurs E | <1> , so T E | <1> It comes from DB E Medium Affairs T E The energy consumption improvement is marked the same. E | <1> Enter prefixspan + The next recursive call.
[0115] ① With β= <1> is the prefix and α= <2> Generate a new sequence γ=β°α=<1,2> for suffix connection. DB E | <1> T E | <1> It is DB E China-Israel <1> Transactions prefixed with T E , so DB E The number of occurrences of the subsequence <1,2> (which indicates that option 1 appears before option 2, including but not necessarily in a close proximity relationship) must be the same as <2> In DB E | <1> In addition, T E | <1> T E The energy consumption improvement is the same, so γ in DB E Neutralize α in DB E | <1> The number of occurrences and energy consumption improvement marks in should be equal, so
[0116] ②Call the prefix tree insertion algorithm according to the current ptr pre The indicated position will Insert into the prefix tree. Figure 3 The left and right parts of Insertion into the prefix tree before and after the situation. Figure 3 In the right part, the nodes indicated by the dark background are the newly generated nodes for this insertion, and ptr pre Points to the next node to be inserted.
[0117] ③Call the suffix tree insertion algorithm Insert into the suffix tree. Since the suffix tree is organized in the form of shared sequence suffixes, and prefixspan + It is a recursive call based on the prefix, so when the suffix tree insertion algorithm inserts the elements in the frequent sequence γ in reverse order, it is necessary to perform a matching search for the sequence suffix. When elements 2 and 1 of γ are inserted in reverse order in the current suffix tree, no match is successful, so two new nodes are generated respectively and inserted into the specified position in sequence. The steps for generating new nodes are shown in step C5 in the suffix tree insertion algorithm. Each new node represents the suffix part of the frequent sequence γ, and they only change the representation of the frequent sequence, so their support count and energy consumption improvement are marked as 2 and 17%. Figure 4 The left and right parts of Before and after insertion into the suffix tree. Figure 4 The nodes indicated by the dark background are the newly generated nodes during this insertion process.
[0118] ④ Construct database DB with γ=<1,2> as prefix E | <1,2> ,get Figure 2 The leftmost node of the third layer. Node DB E | <1> and DB E | <1,2> The arcs between them mark the frequent option sequences obtained by this recursive call. Since the prefix projection operation is transitive, DB E | <1,2> Can be achieved through <2> Prefix in DB E | <1> Get the upper projection, such as prefixspan + Mining algorithm step A4. Constructing the completed DB E | <1,2> Then enter prefixspan + The next recursive call.
[0119] In this way, recursive mining is completed for all <1> The state when the frequent option sequence is prefixed by Figure 2 The first node DB in the fourth layer E | <1,3,2> Start tracing back to the root node DB. E After that, it will be ( <2> ,4,34%) began recursive mining with <2> is a frequent sequence of prefixes. The corresponding suffix tree is as follows Figure 5 It is worth noting that when inserting , suffix option 2 will be matched in the suffix tree. At this time, there is no need to generate a new node, but to The support count and energy consumption of the node are improved by updating the matching node. The prefixspan + However, frequent sequences are mined and output in a prefix incremental manner. In order to correctly update the support count and energy consumption improvement annotation of matching nodes, matching nodes and If the latter is larger than the former, then The corresponding elements of the matching nodes are updated with the values of the support count and energy consumption improvement annotations; otherwise, no elements in the matching nodes are modified. Figure 5 The left and right parts of Before and after insertion into the suffix tree. Figure 5 The node indicated in the left part is a matching node because its support count is less than 's support count, so it needs to be updated. Figure 5 The indicated node on the right gives the updated value in the matching node. Figure 2 After the mining process shown in is completed, you can get Figure 1 The prefix tree prefixTree in E and postfixTree E .
[0120] like Fig.10 As shown, the prefix tree insertion algorithm specifically includes the following steps:
[0121] Step B1: Input the sequence α of single options and point to the prefix tree prefixTree E The node pointer ptr where the child node is to be inserted pre , and frequent option sequences with energy consumption improvement annotations
[0122] Step B2: Based on Generate a new node newNode with an empty hash table and set ptr newNode Point to the node newNode;
[0123] Step B3: In ptr pre Add an entry to the hash table pointing to the node. The key value of the entry is the corresponding option α, and the value is the pointer ptr newNode ;
[0124] Step B4: Set the pointer ptr pre Points to ptr newNode ;
[0125] Step B5: Output and return the new pointer ptr of the node to be inserted pre .
[0126] like Fig.11 As shown, the suffix tree insertion algorithm specifically includes the following steps:
[0127] Step C1, input points to the suffix tree postfixTree E Pointer to the root node ptr post and frequent option sequences with energy efficiency improvements
[0128] Step C2: Assign i to the length len of the sequence γ and set the pointer ptr par Points to ptr post ;
[0129] Step C3, when i>0, go to the next step and insert the elements in γ in reverse order, otherwise end;
[0130] Step C4: Use γ[i] as the key in ptr par Look up the hash table pointing to the node and get the pointer ptr pointing to the matching child node chd ;
[0131] Step C5: If ptr chd is not empty, the match is successful, further judgment: if ptr chd The support count of the frequent sequence pointing to the node is less than Then update the label of the frequent sequence in the node, that is, ptr chd The support count and energy consumption improvement label of the frequent sequence corresponding to the pointing node are set as and E γ ; if ptr chd If it is empty, do the following: Let δ = <γ[i],…,γ[len]>, and set its support count and energy consumption improvement label to and E γ , construct a frequent suffix option sequence with energy consumption improvement annotation based on Generate a new node newNode with an empty hash table and set ptr newNode Points to the node newNode; in ptr par Add an entry to the hash table pointing to the node, the key value of the entry is the γ[i] option, and the value is the pointer ptr newNode ; Then the pointer ptr par Points to ptr newNode ;
[0132] Step C6, subtract 1 from i, and return to step C3 to continue judging and looping, otherwise end.
[0133] 2. New solution generation mechanism with energy-saving improved annotation of frequent option sequence assistance
[0134] New solution generation mechanism with energy-saving improved annotation of frequent option sequence help based on prefix tree prefixTree E and postfixTree E A set of rules related to the generation of new solutions are designed as heuristic information, and the specific new solution generation process is further defined.
[0135] 2.1 Rules related to the generation of new solutions
[0136] Below Figure 1 prefixTree E and postfixTree E , and the continuous subsequence α=<3,2> in the solution x=<5,6,3,2,7> as an example to explain the rules related to the generation of new solutions, such as prefix matching, suffix matching and probability selection.
[0137] Below Figure 1 prefixTree E and postfixTree E , and the continuous subsequence α=<3,2> in the solution x=<5,6,3,2,7> as an example to explain the rules related to the generation of new solutions, such as prefix matching, suffix matching and probability selection.
[0138] (1) Prefix matching rules
[0139] Solve X= <x1,x2,…,x n >The continuous subsequence α determined in <x strt ,x strt+1 ,…,x end >From the prefix tree prefixTree in positive order E The option rule sequence formed by the path starting from the root node is matched. If the match is successful, the child node set corresponding to the matching node is The option-average power set S defined by formula (3) op As a result of the match;
[0140]
[0141] If the match fails, an empty set As the matching result; in formula (3), chd.β[end-strt+2] represents the option op corresponding to the last element of the option sequence in the child node chd.
[0142] In this example, α=<3,2> Figure 1 Match the child node set S in the prefix tree chd ={(<3,2,1>,2,16%),(<3,2,4>,2,17%)}, such as Figure 1 The matching paths of the two nodes indicated in the dashed box are marked with arcs in the prefix tree. The matching result S calculated according to formula (3) is op ={(1,8%),(4,8.5%)}.
[0143] (2) Suffix matching rules
[0144] Solve X = <x1,x2,…,x n >The continuous subsequence α determined in <x strt ,x strt+1 ,…,x end > In reverse order from the suffix tree postfixTree E The option rule sequence formed by the path starting from the root node is matched. If the match is successful, the child node set corresponding to the matching node is The option-average power set S defined by formula (4) op As a result of the match;
[0145]
[0146] If the match fails, an empty set As the matching result; in formula (4), chd.γ[1] represents the option corresponding to the first element of the option sequence in the child node chd.
[0147] In this example, α=<3,2> Figure 1 Match the child node set S in the suffix tree chd ={(<1,3,2>,2,17%),(<4,3,2>,2,18%)}, such as Figure 1 The matching paths of the two nodes indicated in the dashed box are marked with arcs in the suffix tree. The matching result S calculated according to formula (4) is op ={(1,8.5%),(4,9%)}.
[0148] (3) Probabilistic selection rules
[0149] The probability selection operation is based on the matching result S of the prefix matching or suffix matching rule. op Select an option by probability. Specifically, if Then one is randomly selected from the n options provided by the optimization problem with equal probability; if Then the probability p defined by formula (5) j Select option j. In formula (5), j is S op The options that appear in avgUtil j is the average efficacy corresponding to option j.
[0150]
[0151] The matching result S of the suffix matching rule in the example op ={(1,8.5%),(4,9%)}, then the probability of choosing option 1 is p1 = 8.5% / (8.5%+9%) ≈ 48.6%, and the probability of choosing option 4 is p4 = 9% / (8.5%+9%) ≈ 51.4%.
[0152] 2.2 New solution generation process
[0153] Based on the three rules of prefix matching, suffix matching, and probabilistic selection designed above, the new solution generation algorithm gives the detailed steps of the new solution generation process. Step D3 of the new solution generation algorithm gives the new solution generation process based on prefix matching, while step D4 gives the new solution generation process based on suffix matching. In the example, X = <5, 6, 3, 2, 7>. If the starting position strt and the ending position end randomly generated in both the prefix matching and suffix matching new solution generation processes are 2 and 3 respectively, the matching results obtained by the former and the latter are S op ={(1, 8%), (4, 8.5%)}, S op ={(1, 8.5%), (4, 9%)}. Assuming that the option is selected with high probability according to the average efficacy, both the former and the latter will select option 4. Therefore, the new solution Y generated by the former is <5, 6, 3, 2, 4>, while the new solution Y corresponding to the latter is <5, 4, 3, 2, 7>.
[0154] As Fig.12 shown, the new solution generation algorithm specifically includes the following steps:
[0155] Step D1: Randomly generate 0 or 1 and assign it to i, and assign the solution X to the solution Y;
[0156] Step D2: If i == 0, go to step D3 to generate a new solution according to prefix matching, otherwise go to step D4 to generate a new solution according to suffix matching;
[0157] Step D3: Randomly generate the starting position strt and the ending position end, 1 ≤ strt ≤ end < n, and generate a continuous subsequence α = <x strt , x strt+1 , …, x end >; Apply the prefix matching rule and obtain the matching result S op , that is, the option-average efficacy set; Based on S op and apply the probabilistic selection rule to obtain the selected option j; Update the (end + 1)-th element in Y to j; Then go to step D5;
[0158] Step D4: Randomly generate the starting position strt and the ending position end, and generate a continuous subsequence α = <x strt , x strt+1 , …, x end >; Apply the suffix matching rule and obtain the matching result S op ; Based on S op and apply the probabilistic selection rule to obtain the selected option j; Update the (strt - 1)-th element in Y to j; Then go to step D5;
[0159] Step D5: Output the new solution Y and end.
[0160] This embodiment also provides an LLVM compile-time energy consumption optimization system assisted by frequent sequence mining, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the above-mentioned method steps can be implemented.
[0161] 3. Embodiment
[0162] 3.1 Introduction to the Implementation Example
[0163] By comprehensively considering the three elements of application field, source code structure characteristics and operation characteristics, the present invention selects 7 representative applications from BEEBS, an open source benchmark platform with the most applications for embedded system execution time and energy consumption optimization, as cases, as shown in Table 2. These cases cover four fields: security, network, automobile and consumption, and cover common source code structure characteristics such as function call, nested loop, bit operation, string operation, single loop and array access. At the same time, different source code operation characteristics such as integer operation intensity, floating point operation intensity, branch frequency and memory access frequency that affect runtime energy consumption are included as much as possible, and the intensity or frequency is graded as "low", "medium" and "high" in Table 2.
[0164] Table 2 Basic information of the embodiment
[0165]
[0166] 3.2 Statistical methods used
[0167] Considering the randomness of the evolutionary algorithm and the FHIA-FSM of this method, they were independently run 20 times in each embodiment and statistically tested. This embodiment uses the Wilcoxom rank sum test to statistically analyze the experimental data, and the confidence level α is set to 0.05. In order to further observe the difference degree (effect size) of the comparison data, this embodiment also uses Vargha-Delaney's As an intuitive variable of effect size, The value range of is [0,1], and the larger the value, the greater the difference.
[0168] 3.3 Experimental Installation
[0169] (1) Experimental environment
[0170] Table 3 gives the specific configuration of the experimental environment.
[0171] Table 3 Experimental environment configuration
[0172]
[0173] (2) Setting of algorithm parameters
[0174] Table 4 gives the parameter settings of the FHIA-FSM and GA algorithms of this method. The symbol NA means that the corresponding parameter is not included. The Georgiou algorithm does not contain any parameters.
[0175] Table 4 Parameter settings of FHIA-FSM and GA algorithms
[0176]
[0177] 3.4 Experimental Research Questions, Results, and Analysis
[0178] Considering that the Georgiou algorithm and the present method FHIA-FSM are both LLVM option sequence optimization methods based on design space search and oriented to minimizing energy consumption, the Georgiou algorithm is also a method that can obtain better solution quality the fastest among the current design space search methods. The genetic algorithm GA is a method recognized in the field of compilation optimization that can obtain high-quality solutions after evolving for a long enough time. Therefore, this embodiment uses the optimization time and solution quality of the Georgiou algorithm as the downtime benchmark time and benchmark solution quality, respectively, and conducts experimental research on the two issues of solution quality and convergence speed under 7 typical cases in 4 different fields as shown in Table 2.
[0179] (1) Question 1 (Solution Quality): Based on the baseline downtime, can the proposed method FHIA-FSM obtain a better option sequence than the Georgiou algorithm and the GA algorithm, so that the runtime energy consumption of the case application is lower? By answering this question, the usefulness of the FHIA-FSM algorithm can be verified.
[0180] Table 5 gives the statistical results of the best target values (the best energy consumption improvement percentage relative to the -O2 level) obtained by the three algorithms FHIA-FSM, GA and Georgiou for each case under the baseline downtime. The values in Table 5 where FHIA-FSM is better than both GA and Georgiou are indicated in bold. From the statistical results in Table 5, it can be seen that: the average value of the best target value of FHIA-FSM in 7 cases is better than that of GA and Georgiou; except for the fdct case, FHIA-FSM is also better than GA and Georgiou in the maximum value of the best target value of the other 6 cases; the minimum value of the best target value of FHIA-FSM in 7 cases is also better than GA. At the same time, the average and minimum values of the best target values of GA in 7 cases are inferior to those of Georgiou; except for the three cases of fdct, float_matmult and int_matmult, GA is also inferior to Georgiou in the maximum value of the best target value of the other 4 cases.
[0181] Table 5 Statistics of the best target values (percentage of energy consumption improvement relative to -O2 level) obtained by the three algorithms of this paper, FHIA-FSM, GA and Georgiou for each case under the baseline downtime
[0182]
[0183] Table 6 further gives the rank sum test results of the optimal target value (percentage of energy consumption improvement relative to -O2 level) of each case under the baseline downtime for the FHIA-FSM method, GA and Georgiou. The p-values in the second and fourth columns of Table 6 are far less than the confidence level of 0.05 in all 7 cases, which shows from a statistically significant perspective that the solution quality of FHIA-FSM is significantly better than that of GA and Georgiou under the baseline downtime. The p-values in the third and fifth columns of Table 6 are far less than the confidence level of 0.05 in all 7 cases. The values are greater than 0.8 in all 7 cases, which indicates that FHIA-FSM can obtain better solutions with greater probability than GA and Georgiou. Figure 6 The statistical box plots given also intuitively reach consistent conclusions.
[0184] Table 6 Rank sum test results of the optimal target value (percentage of energy consumption improvement relative to -O2 level) of each case under the baseline downtime for FHIA-FSM, GA and Georgiou
[0185]
[0186] To further quantify the improvement of solution quality by FHIA-FSM, Table 7 shows the average relative improvement percentage of solution quality of each case by FHIA-FSM compared with GA and Georgiou under the baseline downtime. As can be seen from Table 7, in each case, FHIA-FSM has a significant improvement in solution quality compared with GA and Georgiou, and the improvement relative to GA is more significant. The best average relative improvement in solution quality occurs in the blowfish case, where FHIA-FSM improves solution quality by 101.81% and 15.52% compared with GA and Georgiou, respectively.
[0187] Table 5, Table 6, Figure 6 The results in Table 7 show that the solution quality obtained by the GA algorithm without any heuristic information is often inferior to that of the present method and Georgiou, which use heuristic information for optimization. This verifies the importance of heuristic information for improving the solution quality of LLVM option sequence optimization methods such as design space search; in addition, the FHIA-FSM in this paper uses frequent option sequences with energy consumption improvement annotations to capture the heuristic information of option interactions, which is more effective than Georgiou using standard level implicit option dependencies as heuristic information to improve the solution quality. Therefore, under the benchmark downtime, the FHIA-FSM proposed in this paper can obtain a better compilation option sequence than GA and Georgiou in a statistical sense, making the running energy consumption of each case application lower.
[0188] Table 7 Average relative improvement percentage of solution quality (target value) of each case under the benchmark downtime of this method compared with GA and Georgiou
[0189]
[0190] (2) Question 2 (convergence speed): Can the proposed method FHIA-FSM achieve the benchmark quality solution in less computation time than the Georgiou algorithm and the GA algorithm? By answering this question, we can further verify the efficiency of the proposed method. In other words, can FHIA-FSM converge to the benchmark quality solution at a faster speed?
[0191] In order to avoid measurement noise and perform normalized comparison, the optimization time when the Georgiou algorithm reaches the benchmark solution quality is used as the benchmark time T0, and the calculation time improvement percentage I is defined Δt% As a metric, it is shown in formula (6). In formula (6), T is the computation time spent by FHIA-FSM or GA to achieve the benchmark solution quality.
[0192]
[0193] Table 8 shows the percentage improvement of the computation time of the three algorithms FHIA-FSM, GA and Georgiou for each case when reaching the benchmark solution quality. Δt% The statistical results of FHIA-FSM are shown in bold in Table 8. In addition, the optimization results of Georgiou are used as the benchmark downtime and benchmark solution quality in each case, so the I of Georgiou in Table 8 is Δt% The index values are all 0. From the statistical results in Table 8, we can see that FHIA-FSM is Δt% The average and maximum values of FHIA-FSM are better than those of GA and Georgiou. Δt% The minimum value of is also better than that of GA. At the same time, GA is better in all 7 cases. Δt% The average and minimum values of the two cases are worse than those of Georgiou; except for the cases of fdct, float_matmult and int_matmult, the other four cases I Δt% Table 9 further shows the percentage improvement of the calculation time of the FHIA-FSM method compared with GA and Georgiou for each embodiment when the benchmark solution quality is achieved. Δt% The p-values in the second and fourth columns of Table 9 are far less than the confidence level of 0.05 in all seven cases, which statistically indicates that the convergence speed of FHIA-FSM in this paper is significantly better than that of GA and Georgiou when reaching the benchmark solution quality. The values are larger than 0.8 in all 7 cases, which indicates that FHIA-FSM can reach the benchmark solution quality with a higher probability and less computation time than GA and Georgiou. Figure 7 The statistical box plots given also intuitively reach consistent conclusions.
[0194] In order to quantify the improvement of FHIA-FSM on convergence speed, Table 10 shows the average relative improvement percentage of FHIA-FSM in computing time when reaching the benchmark solution quality in each case compared with GA and Georgiou. It can be seen from Table 10 that FHIA-FSM has a significant improvement in convergence speed compared with GA and Georgiou in each case, and the improvement relative to GA is more significant. The best average relative improvement of FHIA-FSM in convergence speed compared with GA and Georgiou occurs in the blowfish and int_matmult cases, which are improved by 25.25% and 18% respectively.
[0195] Table 8 The percentage of improvement in computation time of the three algorithms of this paper, FHIA-FSM, GA and Georgiou, when reaching the benchmark solution quality for each case Δt% The statistical results of
[0196]
[0197] Table 9 The percentage of improvement in computing time of our FHIA-FSM compared with GA and Georgiou for each case when reaching the benchmark solution quality I Δt% The rank sum test results
[0198]
[0199]
[0200] Table 8, Table 9, Figure 7 The results of Table 10 show that: in the process of reaching the benchmark solution quality, the GA algorithm without any heuristic information consumes more computing time than the algorithms FHIA-FSM and Georgiou that use heuristic information for optimization. This shows that heuristic information plays an important role in improving the solution quality and accelerating the convergence speed for LLVM option sequence optimization methods such as design space search; in addition, the method FHIA-FSM uses frequent option sequences with energy consumption improvement annotations to capture the heuristic information of option interactions, which can more effectively improve the convergence speed than Georgiou uses standard level implicit option dependencies as heuristic information.
[0201] Table 10 Relative improvement percentage of computation time of our FHIA-FSM compared with GA and Georgiou when reaching the benchmark solution quality in each case
[0202]
[0203] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0204] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0205] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0206] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0207] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.< / op> < / op>
Claims
1. A method for optimizing energy consumption during LLVM compilation with the help of frequent sequence mining, characterized in that: First, an initial candidate solution set S is generated, and based on the candidate solution set S, an initial option sequence transaction database DB with energy consumption improvement annotations is constructed. E , then based on DB E Mining and generating frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E , then based on the prefix tree prefixTree E and postfixTree E Generate new solutions with energy consumption improvement annotations and help with frequent option sequences, evaluate and generate new solutions and update DB E ; Continuously generate new solutions until the preset downtime or solution quality is reached, and output the optimal solution in S; The method comprises the following steps: Step S1, input the initial solution set size N and the optimization environment Env; Step S2, assign an initial value of 1 to the number of iterations t; generate a candidate solution set S of size N = {X1, X2, ..., X i ,…,X N }, where 1≤i≤N, X i ∈Ω, N-1 candidate solutions are generated by Latin hypercube sampling, and the other solution is the solution corresponding to level -O2; the transaction identifier tID is initialized to 0, and DB E Initialize to an empty set Step S3: for each candidate solution X in the candidate solution set S i : Calculate X i The energy consumption optimization target value f Env (X i ); said f Env (X i ) is the solution of X under the optimized environment Env i Compared with the sequence energy consumption improvement percentage corresponding to LLVM's -O2 level, that is, the percentage of energy consumption reduction; if f Env (X i )>0, that is, there is an energy consumption improvement effect, then update DB E , that is, let the transaction identifier tID increase by 1, and the option sequence transaction T with energy consumption improvement mark E (tID,X i ,f Env (X i ))Join DB E ; Step S4: if the preset downtime or solution quality is not reached, go to the next step, otherwise go to step S8; Step S5: Based on DB E Mining and generating frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E ; Step S6: For each candidate solution X in the candidate solution set S i : Based on X i , prefix tree prefixTree E and postfixTree E Generate a new solution Y i , and calculate Y i The energy consumption optimization target value f Env (Y i ); if f Env (Y i )>f Env (X i ), then on the one hand, in DB E Find X in i Corresponding transaction T E , if it exists, use Y i and f Env (Y i ) replace T E X in i and f Env (X i ), on the other hand, the X in S i Use Y i replace; Step S7, increment the number of iterations t by 1, and return to step S4 to continue judging and looping; Step S8, output the optimal solution X; The prefixTree of frequent option sequences with energy consumption improvement annotations is mined through the frequent option sequence mining algorithm prefixspan+. E and postfixTree E , specifically including the following steps: Step A1, input points to the prefix tree prefixTree E The node pointer ptr where the child node is to be inserted pre , pointing to the suffix tree postfixTree E Pointer to the root node ptr post , frequent option sequence β, minimum support count Sup min , and the projection database DB prefixed with β E | β ; Step A2: Determine DB E | β Is the number of transactions in less than Sup? min If yes, then end, otherwise scan the database DB E | β , and calculate the sequence α corresponding to each option op during the scanning process <op>Support count and energy consumption improvement mark E α , and generate a set of frequent option sequences < / op> Step A3: For each Generate a sequence γ = β°α, which is used to represent a frequent option sequence generated by concatenation with β as the prefix and α as the suffix; set the support count of γ and energy consumption improvement mark E γ Set to and E α , construct a frequent option sequence With α, ptr pre and For input Insert into the prefix tree and assign the return value to ptr pre , with ptr post and For input Insert into the suffix tree to get the frequent option sequence prefix tree prefixTree with energy consumption improvement annotation E and postfixTree E ; Step A4: Constructing the prefix projection database DB of γ E | γ , which is equal to (DB E | β )| α ; Step A5: ptr pre 、ptr post ,γ,Sup min and DB E | γ Recursively call prefixspan with the value as parameter + algorithm.
2. The LLVM compile-time energy consumption optimization method assisted by frequent sequence mining according to claim 1, characterized in that: Each Use a triple , where β captures which options interact in sequence. and E β They are used to represent the number of occurrences and efficacy of interactions, respectively; and E β Calculated by formula (1) and formula (2) respectively: In the formula, Denote β as transaction T E is a subsequence of the option sequence X, and E β is the number of transactions that β participates in E The cumulative energy consumption improvement is calculated by Quantitatively characterize the average effectiveness of frequent option sequences β; by capturing option interactions in dominant solutions with the help of frequent option sequences with energy consumption improvement annotations, useful heuristic information is provided for the option sequence optimization process.
3. The LLVM compile-time energy consumption optimization method assisted by frequent sequence mining according to claim 1, characterized in that: With α, ptr pre and For input The specific method of inserting into the prefix tree is: Step B1: Input the sequence α of single options and point to the prefix tree prefixTree E The node pointer ptr where the child node is to be inserted pre , and frequent option sequences with energy consumption improvement annotations Step B2: Based on Generate a new node newNode with an empty hash table and set ptr newNode Point to the node newNode; Step B3: In ptr pre Add an entry to the hash table pointing to the node. The key value of the entry is the corresponding option α, and the value is the pointer ptr newNode ; Step B4: Set the pointer ptr pre Points to ptr newNode ; Step B5: Output and return the new pointer ptr of the node to be inserted pre .
4. The LLVM compile-time energy consumption optimization method assisted by frequent sequence mining according to claim 1, characterized in that: With ptr post and For input The specific method of inserting into the suffix tree is: Step C1, input points to the suffix tree postfixTree E Pointer to the root node ptr post and frequent option sequences with energy efficiency improvements Step C2: Assign i to the length len of the sequence γ and set the pointer ptr par Points to ptr post ; Step C3: when i>0, go to the next step, otherwise end; Step C4: Use γ[i] as the key in ptr par Look up the hash table pointing to the node and get the pointer ptr pointing to the matching child node chd ; Step C5: If ptr chd is not empty, the match is successful, further judgment: if ptr chd The support count of the frequent sequence pointing to the node is less than Then update the label of the frequent sequence in the node, that is, ptr chd The support count and energy consumption improvement label of the frequent sequence corresponding to the pointing node are set as and E γ ; if ptr chd If it is empty, do the following: Let δ = <γ[i],…,γ[len]>, and set its support count and energy consumption improvement label to and E γ , construct a frequent suffix option sequence with energy consumption improvement annotation based on Generate a new node newNode with an empty hash table and set ptr newNode Points to the node newNode; in ptr par Add an entry to the hash table pointing to the node, the key value of the entry is the γ[i] option, and the value is the pointer ptr newNode ; Then the pointer ptr par Points to ptr newNode ; Step C6, subtract 1 from i, and return to step C3 to continue judging and looping, otherwise end.
5. The LLVM compile-time energy consumption optimization method assisted by frequent sequence mining according to claim 1, characterized in that: Based on solution X, prefix tree prefixTree E and postfixTree E The specific method to generate a new solution Y is: Step D1, randomly generate 0 or 1 and assign it to i, and assign solution X to solution Y; Step D2: If i==0, go to step D3 to generate a new solution by prefix matching; otherwise, go to step D4 to generate a new solution by suffix matching; Step D3: Randomly generate a starting position strt and an ending position end, where 1 ≤ strt ≤ end < n, and generate a continuous subsequence α = <x strt , x strt+1 , …, x end >; Apply the prefix matching rule and obtain the matching result S op , that is, the option-average power set; Based on S op and apply the probability selection rule to obtain the selected option j; Update the (end + 1)-th element in Y to j; Then go to step D5; Step D4: Randomly generate a starting position strt and an ending position end to generate a continuous subsequence α= <x strt ,x strt+1 ,…,x end >; Apply suffix matching rules and obtain matching result S op Based on S op And apply the probability selection rule to obtain the selected option j; update the strt-1th element in Y to j; then go to step D5; Step D5, output the new solution Y and end.
6. The LLVM compile-time energy consumption optimization method assisted by frequent sequence mining according to claim 5, characterized in that: Apply prefix matching rules and obtain matching results S op The specific method is: Solve X = <x1,x2,…,x n >The continuous subsequence α determined in <x strt ,x strt+1 ,…,x end >From the prefix tree prefixTree in positive order E The option rule sequence formed by the path starting from the root node is matched. If the match is successful, the child node set corresponding to the matching node is The option-average power set S defined by formula (3) op As a result of the match; If the match fails, an empty set As the matching result; in formula (3), chd.β[end-strt+2] represents the option op corresponding to the last element of the option sequence in the child node chd.
7. The LLVM compile-time energy consumption optimization method assisted by frequent sequence mining according to claim 5, characterized in that: Apply the suffix matching rule and obtain the matching result S op The specific method is: Solve X = <x1,x2,…,x n >The continuous subsequence α determined in <x strt ,x strt+1 ,…,x end > In reverse order from the suffix tree postfixTree E The option rule sequence formed by the path starting from the root node is matched. If the match is successful, the child node set corresponding to the matching node is The option-average power set S defined by formula (4) op As a result of the match; If the match fails, an empty set As the matching result; in formula (4), chd.γ[1] represents the option corresponding to the first element of the option sequence in the child node chd.
8. A frequent sequence mining-assisted LLVM compile-time energy consumption optimization system, characterized in that: The method comprises a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the method steps as described in any one of claims 1 to 7 can be implemented.
