CN110321116A - A kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization - Google Patents

A kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization Download PDF

Info

Publication number
CN110321116A
CN110321116A CN201910522358.3A CN201910522358A CN110321116A CN 110321116 A CN110321116 A CN 110321116A CN 201910522358 A CN201910522358 A CN 201910522358A CN 110321116 A CN110321116 A CN 110321116A
Authority
CN
China
Prior art keywords
individual
optimization
population
compiling
approximate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910522358.3A
Other languages
Chinese (zh)
Other versions
CN110321116B (en
Inventor
江贺
高国军
任志磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dalian University of Technology
Original Assignee
Dalian University of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Dalian University of Technology filed Critical Dalian University of Technology
Priority to CN201910522358.3A priority Critical patent/CN110321116B/en
Publication of CN110321116A publication Critical patent/CN110321116A/en
Application granted granted Critical
Publication of CN110321116B publication Critical patent/CN110321116B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/37Compiler construction; Parser generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The present invention provides a kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization, is a kind of solution for calculating cost restricted problem for it, belongs to Compiler Optimization field.Compiling optimization is carried out binary coding first and designs fitness function by this method, new population is generated using crossover operation and selection operation iteration, to obtain optimal solution.In this iterative process, approximate proxy function is constructed using compiling optimization and corresponding fitness value, substitutes the individual for individual local search each in population, and using locally optimal solution, and then improve efficiency of evolution.The present invention can be effectively the optimal compiling optimization of procedure selection to be compiled, and accelerate iteration speed, improve algorithm operational efficiency.

Description

A kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization
Technical field
It is a kind of for calculating cost constraint in compiling optimization selection the invention belongs to Compiler Optimization technical field Solution to the problem.
Background technique
Compiler is a kind of very important master tool in software development process, is write with high-level [computer Source program is as input, by morphological analysis, syntactic analysis, semantic analysis, intermediate code generation, code optimization, object code It generates, finally obtains executable target machine code.Target machine code needs during actual development, after compiling With more satisfactory performance, for example executable code small scale, to execute speed fast and low in energy consumption etc..Therefore, compiler mentions A large amount of compiling optimization option is supplied, developer needs that one group of compiling optimization option is selected to form compiling according to the actual situation excellent Change sequence and carrys out compiler.Meanwhile compiler provide some predefined standards compiling optimizations (- O1 ,-O2 ,-O3 ,- Os etc.).However, practical application scene is complicated and changeable, same set compiles optimization, because of program to be compiled, translation and compiling environment And the difference of compiling target, compiler can generate different effect of optimization.Therefore, for different programs to be compiled, individual character The compiling optimization of change has stronger advantage relative to criteria optimization sequence.
Modern compiler provides numerous compilings and optimizes option, and therefrom the suitable optimization option of selection constitutes personalization Compiling optimization brings multiple shot array problem, and artificial selection will be taking time and effort for a task.Using genetic algorithm as generation The heuristic search algorithm of table has been provided a kind of reasonable thinking, is that procedure selection to be compiled is high using the thought evolved The compiling optimization of effect.But there is calculating cost restricted problem in this solution.For example, in genetic algorithm, every wheel Need to calculate the effect of optimization of each compiling optimization in population in iterative process, i.e. compiler needs excellent using each Change sequence is treated compiler and is once compiled, and executes program to obtain effect of optimization, this makes the execution time of algorithm Expense is very huge, is brought with this and calculates cost restricted problem.
In order to solve this problem, this programme is by a kind of cultural gene method based on agency, in an iterative process simultaneously Do not carry out compiler using each compiling optimization, it is approximate between construction compiling optimization and effect of optimization Proxy function obtains the corresponding locally optimal solution of individual in population by approximate function, to calculate these locally optimal solutions pair The effect of optimization of optimization should be compiled, and then improves efficiency of evolution, reduces entire Riming time of algorithm.
Summary of the invention
The purpose of the present invention is provide one kind based on agency to calculate cost restricted problem in compiling optimization selection Cultural gene method, the efficiency of evolution of genetic algorithm is improved using approximate proxy function and local search.
Technical solution of the present invention:
A kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization, steps are as follows:
Step 1: coding
Using binary coding, i.e., the candidate in problem space is indicated by 0,1 character string of { 0,1 } character set generation Solution;Compiling optimization option is two-value type, i.e., with or without the use of the option, remaining numeric type optimization option does not consider;At this In binary-coded character string, 0 indicates not using the optimization option of corresponding position, and 1 indicates to use the optimization option of corresponding position; Compiling optimization because of this method for GCC compiler selects, therefore uses the properer we of binary coding of permanent order Two-value type involved in method optimize option, while encode, decoding operate it is simple and easy, intersect etc. genetic manipulations be easy to implement, accord with Close minimum character set encoding principle.
Step 2: initialization population
Initial population is generated using random device;Because it is complicated to compile optimum organization situation, can not be according to intrinsic priori Knowledge knows distributing position of the optimal solution in problem space, and help improves initialization efficiency, therefore generating initial population at random is A kind of relatively reasonable mode.
Step 3: fitness function construction
This method is optimized for target machine code scale after compiling, if after being compiled using compiling optimization Obtained program size is Si, it is S that the program size obtained after any compiling optimization is compiled, which is not used,0, then fitness Function is defined as (S0-Si)/S0;In this way, corresponding fitness value will if a certain compiling optimization effect of optimization is more preferable It is bigger.
Step 4: approximate proxy function construction
After random initializtion population, for each corresponding compiling optimization of individual in population, these volumes are used Optimization compiler is translated, obtains and corresponds to compiling effect, is then used as by these corresponding options of compiling optimization from change Amount is corresponded to the fitness value of effect of optimization as dependent variable, and then constructs multiple linear regression model;In error sum of squares Under the premise of the smallest, regression parameters are solved with least square method, the multiple linear regression model is i.e. as this The approximate proxy function of method.In addition to this, other numbers are used according to actual needs during constructing approximate proxy function Model is learned to do approximate fits.
Step 5: local search
The process of local search is that each corresponding local optimum of individual in population is searched for using approximate proxy function, And use the original individual in its corresponding local optimum individual substitution population.Because this method uses binary coding, therefore by neighborhood Action definition is reversion wherein one, to obtain neighbours' solution, these neighbours' Xie Zucheng neighborhood spaces;It is individual for each, The approximate fitness value of its each neighbours' solution is calculated using approximate proxy function, if some neighbour solution pair in this neighborhood space The fitness value answered is maximum, and is greater than the individual, then is solved using this neighbour and replace the individual, the continuous iteration process, finally The individual is substituted using the locally optimal solution of the individual.After carrying out local search for each individual, then new population is obtained;
Step 6: evolutional operation
Evolutional operation is crossing operation in this method;Crossover operation is to the individual being mutually paired in population according to certain side Formula switching part gene, and then form two new individuals.This programme carries out crossover operation using the mode of single point crossing, that is, exists It is randomly provided a crosspoint in the corresponding binary coding string of individual in population, the part for then exchanging two pairing individuals is compiled Sequence.
Step 7: with as step 5, local search being carried out to individual newly generated in step 6, uses its locally optimal solution Substitute the individual.
Step 8: selection operation
The purpose of selection is individual outstanding in population to be genetic directly to next-generation or generated by pairing intersection new The next generation is hereditary to after individual.For this programme using the next-generation individual of roulette method choice, this is a kind of playback formula stochastical sampling Method, select some individual into follow-on probability be in its fitness value and entire population all ideal adaptation angle value it The ratio of sum, the probability that the higher individual of fitness value is selected in this selection mode is bigger, this is also complied with fitness value It is higher, that is, compile the better optimization of effect of optimization and be genetic to follow-on demand.
Step 9: updating approximate proxy function;
Ideal adaptation angle value in new population is calculated, new population and all compiling optimization effect of optimization of original population are merged Data, and then update approximate proxy function.
Step 10: judging whether to reach stopping criterion for iteration, i.e., algorithm runs to specified time or algorithm runs to finger Determine the number of iterations.If having reached termination condition, iteration is terminated;Otherwise, step 6 is gone to, iterative process is continued.
Step 11: iteration ends regard the maximum individual of fitness value in population as optimal solution, to obtain journey to be compiled The optimal compiling optimization of sequence.
Beneficial effects of the present invention: the present invention can be effectively the optimal compiling optimization of procedure selection to be compiled, make It is replaced in practical fitness value and every wheel iterative process with the approximate fitness value for acting on behalf of approximate function acquisition using in population The corresponding local optimum individual of each individual replaces the individual, forms new population, reduces practical programs and compiles number, and then accelerates Iteration speed reduces Riming time of algorithm, improves algorithm operational efficiency.
Detailed description of the invention
Fig. 1 is the compiling optimization selection main process of the cultural gene algorithm based on agency.
Fig. 2 is local search process in this programme.
Specific embodiment
This programme is deployed on a server, the compiling needed for needing to install according to compiling optimization select permeability Device.Method is by coded program, approximate proxy function constructor, local search program, evolutional operation program, program compiler It constitutes.
As shown in Figure 1, being carried out for the optimal compiling optimization of procedure selection to be compiled by following process.Optimize in compiling In sequence selection iterative process, in addition to the determination factor specified in translation and compiling environment, other factors, such as population scale, iteration are whole Only condition, crossover operator etc. are configured all in accordance with concrete condition.
Step 1: coding.This programme uses binary coding strategy, is 0,1 generated by binary character set { 0,1 } Character string indicates the candidate solution in problem space.In this programme compiling optimization option be two-value type, i.e., using or do not make With the option, remaining numeric type optimize option temporarily not this programme the considerations of in.In the binary-coded character string, 0 table Show the optimization option without using corresponding position, 1 indicates to use the optimization option of corresponding position.
Step 2: initialization population.Initial population is generated using random device.Because it is complicated to compile optimum organization situation, no Its distribution situation is easily analyzed, when can not set initial population using its intrinsic priori knowledge, while calculate optimum individual consuming Between, therefore generating initial population at random is a kind of relatively reasonable mode.
Step 3: fitness function construction.This programme is optimized for target machine code scale after compiling, if using The program size that compiling optimization obtains after being compiled is Si, it is not used after any compiling optimization is compiled and obtains Program size be S0, then fitness function is defined as (S0-Si)/S0.In this way, if a certain compiling optimization effect of optimization more Good, corresponding fitness value will be bigger.
Step 4: approximate proxy function construction.It is corresponding for each individual in population after random initializtion population Optimization is compiled, compiles optimization compiler using these, corresponding compiling effect is obtained, is then optimized by these compilings The corresponding option of sequence is corresponded to the fitness value of effect of optimization as dependent variable, is joined by solving model as independent variable Number, and then multiple linear regression model is constructed, as the approximate proxy function in this programme.In addition to this, close in construction Like approximate fits can be done using other mathematical models according to actual needs during proxy function.
Step 5: local search.The process of local search is right using each individual in approximate proxy function search population The local optimum answered, and use the original individual in its corresponding local optimum individual substitution population.As shown in Fig. 2, because this Scheme uses binary coding strategy, therefore is reversion wherein one by neighborhood action definition, to obtain neighbours' solution, these neighbours Solution composition neighborhood space.For each individual, its each the approximate of neighbours' solution is calculated using approximate proxy function and adapts to Angle value if the corresponding approximate fitness value of some neighbour solution is maximum in this neighborhood space, and is greater than the individual, then adjacent using this It occupies solution and replaces the individual, the continuous iteration process finally substitutes the individual using the locally optimal solution of the individual.For each After individual all carries out local search, then new population is obtained.
Step 6: evolutional operation.Evolutional operation is crossover operation in this programme.This programme using single point crossing mode into Row crossover operation is randomly provided a crosspoint in the corresponding binary coding string of individual that is, in population, then exchanges two Match the code segment string of individual.
Step 7: local search equally being carried out to newly generated individual with step 5, substitutes this using its locally optimal solution Body.
Step 8: selection operation.For this programme using the next-generation individual of roulette method choice, this is that a kind of playback formula is random The method of sampling, selecting some individual to enter follow-on probability is all individual adaptation degrees in its fitness value and entire population The ratio of the sum of value, the probability that the higher individual of fitness value is selected in this selection mode is bigger, this, which is also complied with, to adapt to Angle value is higher, that is, the compiling better optimization of effect of optimization is genetic to follow-on demand.
Step 9: updating approximate proxy function.Ideal adaptation angle value in new population is calculated, new population and original population are merged All compiling optimization effect of optimization data, and then update approximate proxy function.
Step 10: judging whether to reach stopping criterion for iteration, i.e., algorithm runs to specified time or algorithm runs to finger Determine the number of iterations.If having reached termination condition, iteration is terminated;Otherwise, step 6 is gone to, iterative process is continued.
Step 11: iteration ends, the maximum individual of fitness value is used as optimal solution in population, to obtain program to be compiled Optimal compiling optimization.

Claims (1)

1. a kind of towards the effectively optimizing method for calculating cost restricted problem in compiling optimization, it is characterised in that use approximate agency Functional value replaces practical fitness value with saving-algorithm runing time, and steps are as follows:
Step 1: coding
Using binary coding, i.e., the candidate solution in problem space is indicated by 0,1 character string of { 0,1 } character set generation;It compiles Translating optimization option is two-value type, i.e., with or without the use of the option, remaining numeric type optimization option does not consider;In the binary system In coded string, 0 indicates not using the optimization option of corresponding position, and 1 indicates to use the optimization option of corresponding position;Because of we Method is selected for the compiling optimization of GCC compiler, therefore using being related in the properer this method of the binary coding of permanent order And two-value type optimize option;
Step 2: initialization population
Initial population is generated using random device;
Step 3: fitness function construction
It is optimized for target machine code scale after compiling, if the program obtained after being compiled using compiling optimization Size is Si, it is S that the program size obtained after any compiling optimization is compiled, which is not used,0, then fitness function is defined as (S0-Si)/S0
Step 4: approximate proxy function construction
After random initializtion population, for each corresponding compiling optimization of individual in population, optimized using these compilings Sequence compilation programs obtain corresponding compiling effect, then by these corresponding options of compiling optimization as independent variable, by it The fitness value of corresponding effect of optimization constructs multiple linear regression model as dependent variable;It is the smallest in error sum of squares Under the premise of, regression parameters are solved with least square method, which is used as this method Approximate proxy function;
Step 5: local search
The process of local search is each corresponding local optimum of individual in population to be searched for using approximate proxy function, and make With the original individual in its corresponding local optimum individual substitution population;Because this method uses binary coding, therefore neighborhood is acted It is defined as reversion wherein one, to obtain neighbours' solution, these neighbours' Xie Zucheng neighborhood spaces;For each individual, utilize The approximate fitness value of its each neighbours' solution is calculated in approximate proxy function, if some neighbour solution is corresponding in this neighborhood space Fitness value is maximum, and is greater than the individual, then is solved using this neighbour and replace the individual, and the continuous iteration process is final to use The locally optimal solution of the individual substitutes the individual;After carrying out local search for each individual, then new population is obtained;
Step 6: evolutional operation
Evolutional operation is crossing operation in this method;Crossover operation is handed over according to certain way the individual being mutually paired in population Portion gene is changed, and then forms two new individuals;This method carries out crossover operation using the mode of single point crossing, i.e., in population It is randomly provided a crosspoint in the corresponding binary coding string of middle individual, then exchanges the code segments of two pairing individuals String;
Step 7: with step 5, local search being carried out to individual newly generated in step 6, substitutes this using its locally optimal solution Body;
Step 8: selection operation
The purpose of selection is after individual outstanding in population being genetic directly to the next generation or intersecting generation new individual by pairing It is hereditary to the next generation;This bill is a kind of playback formula stochastical sampling method using the next-generation individual of roulette method choice, selection Some individual enters the ratio that follow-on probability is the sum of all ideal adaptation angle value in its fitness value and entire population;
Step 9: updating approximate proxy function
Ideal adaptation angle value in new population is calculated, new population and all compiling optimization effect of optimization numbers of original population are merged According to, and then update approximate proxy function;
Step 10: judging whether to reach stopping criterion for iteration, i.e., algorithm runs to specified time or algorithm runs to specified change Generation number;If having reached termination condition, iteration is terminated;Otherwise, step 6 is gone to, iterative process is continued;
Step 11: iteration ends regard the maximum individual of fitness value in population as optimal solution, to obtain program to be compiled Optimal compiling optimization.
CN201910522358.3A 2019-06-17 2019-06-17 Efficient optimization method for calculation cost constraint problem in compilation optimization Active CN110321116B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910522358.3A CN110321116B (en) 2019-06-17 2019-06-17 Efficient optimization method for calculation cost constraint problem in compilation optimization

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910522358.3A CN110321116B (en) 2019-06-17 2019-06-17 Efficient optimization method for calculation cost constraint problem in compilation optimization

Publications (2)

Publication Number Publication Date
CN110321116A true CN110321116A (en) 2019-10-11
CN110321116B CN110321116B (en) 2021-04-20

Family

ID=68119756

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910522358.3A Active CN110321116B (en) 2019-06-17 2019-06-17 Efficient optimization method for calculation cost constraint problem in compilation optimization

Country Status (1)

Country Link
CN (1) CN110321116B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035116A (en) * 2020-08-26 2020-12-04 大连理工大学 Agent modeling method for multi-target compiling optimization sequence selection
CN113407185A (en) * 2021-03-10 2021-09-17 天津大学 Compiler optimization option recommendation method based on Bayesian optimization
CN116521176A (en) * 2023-05-06 2023-08-01 东莞理工学院 Compilation optimization option optimization method and device, intelligent terminal and storage medium
CN117130622A (en) * 2023-10-26 2023-11-28 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) Distributed online code compiling and running method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050198627A1 (en) * 2004-03-08 2005-09-08 Intel Corporation Loop transformation for speculative parallel threads
CN102622260A (en) * 2012-02-27 2012-08-01 中国科学院计算技术研究所 Optimization method and optimization system of on-line iteration compiling
CN104796158A (en) * 2015-05-05 2015-07-22 大连理工大学 LDPC (low density parity check code) coding and decoding system platform for fixed information length

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050198627A1 (en) * 2004-03-08 2005-09-08 Intel Corporation Loop transformation for speculative parallel threads
CN102622260A (en) * 2012-02-27 2012-08-01 中国科学院计算技术研究所 Optimization method and optimization system of on-line iteration compiling
CN104796158A (en) * 2015-05-05 2015-07-22 大连理工大学 LDPC (low density parity check code) coding and decoding system platform for fixed information length

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
徐秀娟: "编译原理立体化教学体系建设探索", 《计算机教育》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035116A (en) * 2020-08-26 2020-12-04 大连理工大学 Agent modeling method for multi-target compiling optimization sequence selection
CN112035116B (en) * 2020-08-26 2021-07-16 大连理工大学 Agent modeling method for multi-target compiling optimization sequence selection
CN113407185A (en) * 2021-03-10 2021-09-17 天津大学 Compiler optimization option recommendation method based on Bayesian optimization
CN116521176A (en) * 2023-05-06 2023-08-01 东莞理工学院 Compilation optimization option optimization method and device, intelligent terminal and storage medium
CN116521176B (en) * 2023-05-06 2023-12-29 东莞理工学院 Compilation optimization option optimization method and device, intelligent terminal and storage medium
CN117130622A (en) * 2023-10-26 2023-11-28 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) Distributed online code compiling and running method and system
CN117130622B (en) * 2023-10-26 2024-01-12 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) Distributed online code compiling and running method and system

Also Published As

Publication number Publication date
CN110321116B (en) 2021-04-20

Similar Documents

Publication Publication Date Title
CN110321116A (en) A kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization
CN112035116B (en) Agent modeling method for multi-target compiling optimization sequence selection
Fahringer Automatic performance prediction of parallel programs
Kennedy et al. Automatic data layout for distributed-memory machines
CN101044457B (en) System, method and apparatus for dependency chain processing
CN104662513A (en) Method and system for automated improvement of parallelism in program compilation
CN106844827A (en) A kind of six-degree-of-freedom parallel connection mechanism optimization method
Singh et al. SWAPPER: A framework for automatic generation of formula simplifiers based on conditional rewrite rules
Zhang et al. Hidp: A hierarchical data parallel language
Fan et al. Graph algorithms: parallelization and scalability
US8117604B2 (en) Architecture cloning for power PC processors
Schulte Neutral networks of real-world programs and their application to automated software evolution
Han et al. COX: Exposing CUDA warp-level functions to CPUs
CN110929850A (en) Deep learning operator automatic optimization system and method based on Shenwei processor
Zakian et al. Incrementalization of vertex-centric programs
Du et al. Species tree and reconciliation estimation under a duplication-loss-coalescence model
CN100559344C (en) A kind of disposal route of supporting with regular record variables access special register group
Liou et al. Genetic improvement of GPU code
Zhao et al. Moses: Efficient exploitation of cross-device transferable features for tensor program optimization
CN102855191B (en) Embedded basic software code branch coverage testing data inheritance searching method
Nisbet GAPS: Iterative feedback directed parallelisation using genetic algorithms
Chen et al. A framework for neural network architecture and compile co-optimization
CN112558977A (en) Polyhedron optimization method for heterogeneous many-core rear-end cost-based model
CN116842992A (en) Operator fusion method and system for image recognition depth neural network
Mustafa et al. Portable section-level tuning of compiler parallelized applications

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant