Sublimation compiler function inline optimization method based on boron platform, storage medium, equipment and computer program product

By using the Pareto method on the Kunpeng platform to classify and sort the probabilities of function basic blocks to determine whether to perform inline optimization, the problem of low compilation efficiency and register overflow in the existing technology is solved, and the performance of the Bisheng compiler is improved.

CN118567652APending Publication Date: 2024-08-30CHINA TELECOM DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410651892.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The existing Bisheng compiler function optimization technology uses probe statistics and frequently reads metadata, which affects compilation efficiency and increases computing resource requirements, increasing the risk of register overflow.

Method used

Using a method based on the Kunpeng platform, the Pareto method is used to classify metadata and meta-process data, calculate the probability of function basic blocks and sort them, and determine whether complex function basic blocks require inline optimization to avoid frequent reads and register overflows.

Benefits of technology

It improves compilation efficiency, reduces the overhead of function basic block calls, avoids the risk of register overflow, and improves the performance of Bisheng compiler.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567652A
    Figure CN118567652A
Patent Text Reader

Abstract

The invention discloses an inline optimization method, a storage medium, equipment and a computer program product for a graduation compiler function based on a Peng platform, and the method comprises the steps: obtaining metadata and meta-process data related to the compiling function of a to-be-graduated compiler from a knowledge base of the Peng platform, and carrying out the classification according to function basic blocks through a Pareto method, calculating the weight of each piece of metadata and each piece of meta-process data in the full knowledge base data and the weight of each piece of metadata and each piece of meta-process data in each function basic block in the corresponding function basic block; according to keywords in the current to-be-compiled function, finding out associated metadata and associated meta process data, and calculating the probability that each function basic block belongs to the current to-be-compiled function; and sorting the corresponding function basic blocks according to the probability from high to low, judging whether the function basic blocks are complex function basic blocks or not, and judging whether the function basic blocks need to be subjected to inline optimization or not according to the computing power consumption, so that the efficiency of compiling the function by the graduation compiler is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of compiler function optimization, and specifically, relates to a Bisheng compiler function inline optimization method, storage medium, device and computer program product based on Kunpeng platform. Background Art

[0002] The compilation optimization of the Bisheng compiler function on the Kunpeng platform is mainly based on static program analysis of the source code, which improves and optimizes program performance without actually executing the program. However, in many scenarios, the Bisheng compiler often uses some heuristic optimization algorithms to make some of the most likely guesses about code execution, so that the program can achieve better performance.

[0003] Among them, feedback optimization (Optimization, PGO) is a commonly used Bisheng compiler function optimization technology with good optimization effect. An executable program containing information is generated by compilation. The executable program inserts probes in each basic block of the compilation file. Each probe will count the number of times the current basic block is operated. If the basic block generates a divergent jump, the probe will record the direction of the branch jump. The compiler generally provides a stub compilation option. When the stub executable program is running, the stub program will generate a data file containing the execution count of the specific program operation process. The compiler reads the feedback data file and parses the detailed information of the program analysis and execution from the feedback data file to evaluate the control flow trajectory of the program, thereby guiding the Bisheng compiler to carry out a series of feedback optimizations. However, when the existing PGO uses probes to count the operation of the current basic block, it needs to insert more probes, and it needs to frequently read the metadata and meta-process data involved in the Bisheng compiler function, which affects the compilation efficiency of the Bisheng compiler, and requires higher computing power resources for the Bisheng compiler, increasing the risk of register overflow. Summary of the invention

[0004] In response to the problems existing in the prior art, the present invention provides a Bi Sheng compiler function inline optimization method, storage medium, device and computer program product based on the Kunpeng platform, so as to improve the compilation efficiency of the Bi Sheng compiler.

[0005] To achieve the above technical objectives, the present invention adopts the following technical solution: a Bisheng compiler function inline optimization method based on the Kunpeng platform, specifically comprising the following steps:

[0006] Step 1: Obtain metadata and meta-process data related to the function to be compiled by the Bisheng compiler from the knowledge base of the Kunpeng platform, and calculate the weight of each metadata and each meta-process data in the entire knowledge base data;

[0007] Step 2: Classify the obtained metadata and meta-process data according to the function basic blocks by using the Pareto method, and calculate the weight of each metadata and each meta-process data in each function basic block in the corresponding function basic block;

[0008] Step 3: According to the keywords in the current function to be compiled, find out the weights of the associated metadata and the associated meta-process data in the entire knowledge base data and the weights of the corresponding metadata and the corresponding meta-process data in the corresponding function basic blocks, and calculate the probability that each function basic block belongs to the current function to be compiled;

[0009] Step 4: Sort the corresponding function basic blocks according to the probability calculated in step 3 from high to low, and determine whether each function basic block in the top 50% is a complex function basic block. If it is a complex function basic block, determine whether the function basic block needs to be inline optimized based on the computing power consumption.

[0010] Furthermore, the calculation process of the probability that each function basic block belongs to the current function to be compiled in step 3 is:

[0011]

[0012] Among them, W i represents the probability that the i-th function basic block belongs to the current function to be compiled, B represents the number of metadata associated with the keywords in the current function to be compiled, b represents the index of B, represents the weight of the bth metadata associated with the keyword in the current function to be compiled in the i-th function basic block in the entire knowledge base data, represents the weight of the bth metadata associated with the keyword in the current function to be compiled in the i-th function basic block in the corresponding function basic block, C represents the number of meta-process data associated with the keyword in the current function to be compiled, c represents the index of C, represents the weight of the cth meta-process data in the i-th function basic block associated with the keyword in the current function to be compiled in the whole knowledge base data, Represents the weight of the cth meta-procedure data in the i-th function basic block associated with the keyword in the current function to be compiled in the corresponding function basic block.

[0013] Furthermore, the judgment process of the complex function basic block in step 4 is: searching for keywords in the function basic block, if the curly brackets {} in the func or function function compiled by the keywords contain other keywords, then the function basic block is a complex function basic block.

[0014] Furthermore, the calculation process of computing power consumption in step 4 is specifically as follows:

[0015]

[0016] Among them, C br represents the total computing power consumption of the basic block of the complex function, n is the number of logic operation chips, i is the index of n, f(a i ) is the mapping function of logical operation, α i is the mapping ratio coefficient of the i-th logic operation chip, q1 (TOPS) is the redundant computing power of the logic operation; m is the number of parallel computing chips, j is the index of m, f(b j ) is the mapping function for parallel computing, β j is the mapping ratio coefficient of the jth parallel computing chip, q2 (FLOPS) is the redundant computing power of parallel computing; p is the number of neural network acceleration chips, k is the index of p, and f(c k ) is the mapping function of neural network acceleration, γ k is the mapping ratio coefficient of the kth neural network acceleration chip, and q3 (FLOPS) is the redundant computing power of neural network acceleration.

[0017] Furthermore, the specific process of judging whether the function basic block needs to be inline optimized according to the computing power consumption in step 4 is as follows: if the calculated total computing power consumption of the complex function basic block is less than the computing power threshold of the complex function basic block, it means that the complex function basic block still has idle computing power when running the function, and there is no need to perform inline optimization on the complex function basic block; otherwise, according to the computing power difference value that the total computing power consumption of the complex function basic block exceeds the computing power threshold, a corresponding number of computing power chips are added to the complex function basic block to achieve inline optimization of the complex function basic block.

[0018] Furthermore, the present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the Bisheng compiler function inline optimization method based on the Kunpeng platform.

[0019] Furthermore, the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the Bisheng compiler function inlining optimization method based on the Kunpeng platform is implemented.

[0020] Furthermore, the present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the Bisheng compiler function inlining optimization method based on the Kunpeng platform.

[0021] Compared with the prior art, the present invention has the following beneficial effects: the present invention classifies the acquired metadata and meta-process data according to function basic blocks through the Pareto method based on the Bi Sheng compiler function inline optimization method of the Kunpeng platform, takes the function basic blocks as the classification target domain, and directly realizes the division of metadata and meta-process data, thereby avoiding the frequent reading of metadata and meta-process data affecting the compilation efficiency of the Bi Sheng compiler; the present invention calculates the probability that each function basic block belongs to the current function to be compiled. The higher the probability value, the higher the priority of using the function basic block to run the function to be compiled. The function basic blocks are sorted according to the probability, which can be To reduce the overhead of calling function basic blocks; the present invention innovatively calculates the probability that each function basic block belongs to the current function to be compiled according to the weights of the associated metadata and the associated meta-process data in the full knowledge base data and the weights of the corresponding metadata and the corresponding meta-process data in the corresponding function basic block, so that the calculated probability is more accurate; in addition, the present invention determines whether each function basic block in the top 50% of the ranking is a complex function basic block, and determines whether the complex function basic block needs to be inline optimized according to the computing power consumption, thereby avoiding the risk of register overflow and improving the compilation efficiency of the Bisheng compiler. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a flow chart of the Bisheng compiler function inline optimization method based on the Kunpeng platform of the present invention;

[0023] Figure 2 A schematic diagram of a basic block of a complex function. DETAILED DESCRIPTION

[0024] The technical solution of the present invention is further explained below in conjunction with the accompanying drawings.

[0025] like Figure 1 The flowchart of the Bisheng compiler function inline optimization method based on the Kunpeng platform of the present invention is as follows:

[0026] Step 1: Obtain metadata and meta-process data related to the function to be compiled by the Bisheng compiler from the knowledge base of the Kunpeng platform, and calculate the weight of each metadata and each meta-process data in the entire knowledge base data.

[0027] Step 2: Classify the obtained metadata and meta-process data according to the function basic block through the Pareto method. The function basic block is the classification target domain, which directly realizes the division of metadata and meta-process data to avoid frequent reading of metadata and meta-process data affecting the compilation efficiency of the Bisheng compiler. And calculate the weight of each metadata and each meta-process data in each function basic block in the corresponding function basic block.

[0028] Step 3: According to the keywords in the current function to be compiled, find out the weights of the associated metadata and the associated meta-process data in the entire knowledge base data and the weights of the corresponding metadata and the corresponding meta-process data in the corresponding function basic blocks, and calculate the probability that each function basic block belongs to the current function to be compiled. The present invention implements function basic block priority setting according to the business indicators of the current function to be compiled, so that the probability calculated subsequently is more accurate.

[0029] The calculation process of the probability that each function basic block belongs to the current function to be compiled in the present invention is:

[0030]

[0031] Among them, W i represents the probability that the i-th function basic block belongs to the current function to be compiled, B represents the number of metadata associated with the keywords in the current function to be compiled, b represents the index of B, represents the weight of the bth metadata associated with the keyword in the current function to be compiled in the i-th function basic block in the entire knowledge base data, represents the weight of the bth metadata associated with the keyword in the current function to be compiled in the i-th function basic block in the corresponding function basic block, C represents the number of meta-process data associated with the keyword in the current function to be compiled, c represents the index of C, represents the weight of the cth meta-process data in the i-th function basic block associated with the keyword in the current function to be compiled in the whole knowledge base data, Represents the weight of the cth meta-procedure data in the i-th function basic block associated with the keyword in the current function to be compiled in the corresponding function basic block.

[0032] Step 4. Sort the corresponding function basic blocks in order from high to low according to the probability calculated in step 3. The higher the probability value, the higher the priority of using the function basic block to run the function to be compiled. Sort the function basic blocks according to the probability to reduce the overhead of calling the function basic blocks. Limited by the static analysis capability of the Bisheng compiler, not all inline optimizations have positive benefits. Some may even lead to performance degradation, such as register overflow and complex functions caused by resource conditions. Therefore, each function basic block ranked in the top 50% is judged to be a complex function basic block. If it is a complex function basic block, whether the function basic block needs to be inline optimized is judged according to the computing power consumption. The computing power consumption is innovatively used to treat the object compiled by the Bisheng compiler this time as a computing power task to quantify the computing power required, and then calculate the idle computing power of the chip where the current Bisheng compiler is located to determine whether there is a possibility of register overflow due to insufficient resources. If this possibility is eliminated, the abnormal situation is caused by the complexity of the function or the irregularity of the rules.

[0033] The process of determining a complex function basic block in the present invention is as follows: searching for keywords in the function basic block, and if the curly brackets {} in the func or function function compiled with the keywords contain other keywords, then the function basic block is a complex function basic block. Figure 2 , the funcB function is also nested in the funcA function, so this function basic block is a complex function basic block.

[0034] The specific process of judging whether the function basic block needs to be inline optimized according to the computing power consumption is as follows: if the calculated total computing power energy consumption of the complex function basic block is less than the computing power threshold of the complex function basic block, it means that the complex function basic block still has idle computing power when running the function, and there is no need to perform inline optimization on the complex function basic block; otherwise, according to the computing power difference that the total computing power energy consumption of the complex function basic block exceeds the computing power threshold, a corresponding number of computing power chips are added to the complex function basic block to implement inline optimization of the complex function basic block, thereby avoiding the risk of register overflow and improving the compilation efficiency of the Bisheng compiler.

[0035] The calculation process of computing power consumption in the present invention is specifically as follows:

[0036]

[0037] Among them, C br represents the total computing power consumption of the basic block of the complex function, n is the number of logic operation chips, i is the index of n, f(a i ) is the mapping function of logical operation, α i is the mapping ratio coefficient of the i-th logic operation chip, q1 (TOPS) is the redundant computing power of the logic operation; m is the number of parallel computing chips, j is the index of m, f(b j ) is the mapping function for parallel computing, β j is the mapping ratio coefficient of the jth parallel computing chip, q2 (FLOPS) is the redundant computing power of parallel computing; p is the number of neural network acceleration chips, k is the index of p, and f(c k ) is the mapping function of neural network acceleration, γ k is the mapping ratio coefficient of the kth neural network acceleration chip, and q3 (FLOPS) is the redundant computing power of neural network acceleration.

[0038] In one technical solution of the present invention, a computer-readable storage medium is provided, storing a computer program, wherein the computer program enables the computer to implement the Bisheng compiler function inline optimization method based on the Kunpeng platform.

[0039] In one technical solution of the present invention, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the Bisheng compiler function inlining optimization method based on the Kunpeng platform is implemented.

[0040] In one technical solution of the present invention, a computer program product is provided, including a computer program, characterized in that when the computer program is executed by a processor, the Bisheng compiler function inlining optimization method based on the Kunpeng platform is implemented.

[0041] In the embodiments disclosed in the present application, the computer storage medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. The computer storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the above. More specific examples of computer storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above.

[0042] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0043] The above are only preferred embodiments of the present invention. The protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A Bisheng compiler function inline optimization method based on Kunpeng platform, characterized in that: The specific steps include: Step 1: Obtain metadata and meta-process data related to the function to be compiled by the Bisheng compiler from the knowledge base of the Kunpeng platform, and calculate the weight of each metadata and each meta-process data in the entire knowledge base data; Step 2: Classify the obtained metadata and meta-process data according to the function basic blocks by using the Pareto method, and calculate the weight of each metadata and each meta-process data in each function basic block in the corresponding function basic block; Step 3: According to the keywords in the current function to be compiled, find out the weights of the associated metadata and the associated meta-process data in the entire knowledge base data and the weights of the corresponding metadata and the corresponding meta-process data in the corresponding function basic blocks, and calculate the probability that each function basic block belongs to the current function to be compiled; Step 4: Sort the corresponding function basic blocks according to the probability calculated in step 3 from high to low, and determine whether each function basic block in the top 50% is a complex function basic block. If it is a complex function basic block, determine whether the function basic block needs to be inline optimized based on the computing power consumption.

2. According to a method for Bisheng compiler function inline optimization based on Kunpeng platform according to claim 1, it is characterized in that: The calculation process of the probability that each function basic block belongs to the current function to be compiled in step 3 is: Among them, W i represents the probability that the i-th function basic block belongs to the current function to be compiled, B represents the number of metadata associated with the keywords in the current function to be compiled, b represents the index of B, represents the weight of the bth metadata associated with the keyword in the current function to be compiled in the i-th function basic block in the entire knowledge base data, represents the weight of the bth metadata associated with the keyword in the current function to be compiled in the i-th function basic block in the corresponding function basic block, C represents the number of meta-process data associated with the keyword in the current function to be compiled, c represents the index of C, represents the weight of the cth meta-process data in the i-th function basic block associated with the keyword in the current function to be compiled in the whole knowledge base data, Represents the weight of the cth meta-procedure data in the i-th function basic block associated with the keyword in the current function to be compiled in the corresponding function basic block.

3. According to a method for Bisheng compiler function inline optimization based on Kunpeng platform according to claim 1, it is characterized in that: The judgment process of the complex function basic block in step 4 is: search for keywords in the function basic block, if the curly brackets {} in the func or function function compiled by the keywords contain other keywords, then the function basic block is a complex function basic block.

4. According to a method for Bisheng compiler function inline optimization based on Kunpeng platform according to claim 3, it is characterized in that: The calculation process of computing power consumption in step 4 is as follows: Among them, C br represents the total computing power consumption of the basic block of the complex function, n is the number of logic operation chips, i is the index of n, f(a i ) is the mapping function of logical operation, α i is the mapping ratio coefficient of the i-th logic operation chip, q1 (TOPS) is the redundant computing power of the logic operation; m is the number of parallel computing chips, j is the index of m, f(b j ) is the mapping function for parallel computing, β j is the mapping ratio coefficient of the jth parallel computing chip, q2 (FLOPS) is the redundant computing power of parallel computing; p is the number of neural network acceleration chips, k is the index of p, and f(c k ) is the mapping function of neural network acceleration, γ k is the mapping ratio coefficient of the kth neural network acceleration chip, and q3 (FLOPS) is the redundant computing power of neural network acceleration.

5. According to a method for Bisheng compiler function inline optimization based on Kunpeng platform according to claim 4, it is characterized in that: The specific process of judging whether the function basic block needs to be inline optimized according to the computing power consumption in step 4 is as follows: if the calculated total computing power energy consumption of the complex function basic block is less than the computing power threshold of the complex function basic block, it means that the complex function basic block still has idle computing power when running the function, and there is no need to perform inline optimization on the complex function basic block; otherwise, according to the computing power difference value that the total computing power energy consumption of the complex function basic block exceeds the computing power threshold, a corresponding number of computing power chips are added to the complex function basic block to achieve inline optimization of the complex function basic block.

6. A computer-readable storage medium storing a computer program, characterized in that: The computer program enables the computer to execute the Bisheng compiler function inline optimization method based on the Kunpeng platform as described in any one of claims 1-5.

7. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the Bisheng compiler function inline optimization method based on the Kunpeng platform as described in any one of claims 1 to 5 is implemented.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by the processor, the Bisheng compiler function inline optimization method based on the Kunpeng platform described in any one of claims 1-5 is implemented.