Compilation optimization option grouping method, computer device, and storage medium
By grouping the function call relationship information of the compiler, a target compilation optimization option group is formed, which solves the problem of too many compilation optimization options in the compiler, improves the search efficiency of the compilation optimization option tuning algorithm, and achieves more efficient program performance promote.
Patent Information
- Application Number
- PCT/CN2024/091704
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-29
- Filing Date
- 2024-05-08
- Publication Date
- 2024-12-05
AI Technical Summary
There are too many compiled optimization options in existing compilers, making it difficult to find a suitable combination of compiled optimization options in a short time, and the search efficiency of compiled optimization option tuning algorithms is low.
By obtaining the compiler's function call relationship information, all compile optimization options are grouped, multiple target compile optimization options groups are formed, and they are used as the compiler's target search space to reduce the search space and improve search efficiency.
It significantly improves the search efficiency of the compilation optimization option tuning algorithm, and can find the appropriate compilation optimization option combination more quickly, improving the program running performance.
Smart Images

Figure CN2024091704_05122024_PF_FP_ABST
Abstract
Description
Compilation optimization option grouping method, computer device and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the Chinese patent application with application number 202310617641.0 and application date of May 29, 2023, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to a compilation optimization option grouping method, a computer device, and a storage medium. Background Art
[0004] Compilers are one of the most critical pieces of basic software in the computer hardware and software ecosystem. After years of research and development, modern compilers have developed strong optimization capabilities. Compiler developers have designed and implemented a large number of compilation optimization options. The rational use of these compilation optimization options can fully improve program performance. However, the number of compilation optimization options is too large, making it difficult to rely on human labor to find a combination of compilation optimization options suitable for the target program. In related technologies, the compilation optimization option tuning algorithm is mainly used to select the most suitable compilation optimization option combination for the target program from the multiple compilation optimization options provided by the compiler. However, the number of compilation optimization options provided by the compiler is large, making it difficult to find a compilation optimization option combination suitable for the target program in a short period of time, and the search efficiency of the compilation optimization option tuning algorithm is low.
[0005] Summary of the Invention
[0006] Embodiments of the present application provide a compilation optimization option grouping method, a computer device, and a storage medium.
[0007] In a first aspect, an embodiment of the present application provides a method for grouping compilation optimization options, comprising: obtaining function call relationship information of a compiler; grouping all compilation optimization options in the compiler according to the function call relationship information to obtain multiple target compilation optimization option groups, wherein the target compilation optimization option groups include one or more of the compilation optimization options; and using the multiple target compilation optimization option groups as a target search space of the compiler, wherein the target search space includes multiple search objects, and one target compilation optimization option group corresponds to one search object.
[0008] In a second aspect, an embodiment of the present application further provides a computer device, comprising a processor, a memory, a computer program stored on the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the compilation optimization option grouping method described in the first aspect is implemented.
[0009] In a third aspect, an embodiment of the present application further provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the compilation optimization option grouping method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0011] FIG1 is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application;
[0012] FIG2 is a flow chart of a method for grouping compilation optimization options provided in an embodiment of the present application;
[0013] FIG3 is a schematic flow chart of the sub-steps of the compilation optimization option grouping method in FIG2 ;
[0014] FIG4 is a schematic diagram of the sub-step flow of the compilation optimization option grouping method in FIG2 ;
[0015] FIG5 is a schematic flow chart of the sub-steps of the compilation optimization option grouping method in FIG2 ;
[0016] FIG6 is a schematic flow chart of the sub-steps of the compilation optimization option grouping method in FIG2 ;
[0017] FIG. 7 is a schematic flow chart of the sub-steps of the method for grouping compilation optimization options in FIG. 2 . DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0019] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0020] It should be understood that the terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0021] Compilers are one of the most critical pieces of basic software in the computer hardware and software ecosystem. After years of research and development, modern compilers have developed strong optimization capabilities. Compiler developers have designed and implemented a large number of compilation optimization options. The rational use of these compilation optimization options can fully improve program performance. However, the number of compilation optimization options is too large, making it difficult to rely on human labor to find a combination of compilation optimization options suitable for the target program. In related technologies, the compilation optimization option tuning algorithm is mainly used to select the most suitable compilation optimization option combination for the target program from the multiple compilation optimization options provided by the compiler. However, the number of compilation optimization options provided by the compiler is large, making it difficult to find a compilation optimization option combination suitable for the target program in a short period of time, and the search efficiency of the compilation optimization option tuning algorithm is low.
[0022] To address the above issues, embodiments of the present application provide a compilation optimization option grouping method, computer device, and storage medium. By grouping all compilation optimization options in the compiler using the compiler's function call relationship information, multiple target compilation optimization option groups are obtained. These multiple target compilation optimization option groups are then used as the compiler's target search space. This significantly reduces the search space of the compilation optimization option tuning algorithm, thereby improving the search efficiency of the compilation optimization option tuning algorithm.
[0023] In the embodiments of the present application, the computer device may be a server or an electronic device. The server may be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The electronic device includes, but is not limited to, smartphones, tablet computers, laptops, desktop computers, personal digital assistants, and wearable devices.
[0024] The following embodiments of the present application are described in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments may be combined with each other.
[0025] Please refer to FIG1 , which is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0026] As shown in FIG1 , a computer device 100 includes a processor 101 and a memory 102 . The processor 101 and the memory 102 are connected via a bus 103 , such as an I 2 C (Inter-Integrated Circuit) bus.
[0027] In the embodiment of the present application, the processor 101 is used to provide computing and control capabilities to support the operation of the entire computer device. The processor 101 can be a central processing unit (CPU), and the processor 101 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0028] In the embodiment of the present application, the memory 102 can be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.
[0029] Those skilled in the art will understand that the structure shown in FIG1 is merely a block diagram of a portion of the structure related to the embodiment of the present application, and does not constitute a limitation on the computer device to which the embodiment of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0030] The processor 101 is configured to run a computer program stored in the memory 102 and implement any one of the compilation optimization option grouping methods provided in the embodiments of the present application when executing the computer program.
[0031] In one embodiment, the processor 101 is configured to run a computer program stored in the memory, and implement the following steps when executing the computer program:
[0032] Get the compiler's function call relationship information;
[0033] Grouping all compilation optimization options in the compiler according to the function call relationship information to obtain a plurality of target compilation optimization option groups, wherein the target compilation optimization option groups include one or more of the compilation optimization options;
[0034] The plurality of target compilation optimization option groups are used as a target search space of the compiler, wherein the target search space includes a plurality of search objects, and one target compilation optimization option group corresponds to one search object.
[0035] In one embodiment, the function call relationship information includes a function call relationship graph of the compiler and / or a function call stack recorded when each of the called compilation optimization options is called. When the processor 101 groups all compilation optimization options in the compiler according to the function call relationship information to obtain multiple target compilation optimization option groups, it is configured to implement:
[0036] All the compile optimization options in the compiler are grouped according to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called to obtain multiple target compile optimization option groups.
[0037] In one embodiment, when grouping all the compile optimization options in the compiler according to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called to obtain multiple target compile optimization option groups, the processor 101 is configured to implement:
[0038] Determining a first optimization process flow to which each of the compilation optimization options belongs according to the function call relationship graph and the function to which each of the compilation optimization options belongs;
[0039] grouping all the compile optimization options in the compiler according to the first optimization processing flow to which each compile optimization option belongs, to obtain a plurality of first compile optimization option groups;
[0040] and / or, determining the second optimization processing flow to which each of the called compilation optimization options belongs based on a function call stack recorded when each of the called compilation optimization options is called;
[0041] grouping all the compile optimization options in the compiler according to the second optimization process to which each of the called compile optimization options belongs, to obtain a plurality of second compile optimization option groups;
[0042] A target compile optimization option group of the compiler is determined according to each of the first compile optimization option groups and / or each of the second compile optimization option groups.
[0043] In one embodiment, when the processor 101 groups all the compile optimization options in the compiler according to the first optimization process to which each compile optimization option belongs to obtain multiple first compile optimization option groups, it is configured to implement:
[0044] Grouping all the compilation optimization options having the same first optimization process into a first compilation optimization option group;
[0045] If there are ungrouped compile optimization options, the ungrouped compile optimization options belonging to the same first optimization process flow are divided into a first compile optimization option group.
[0046] In one embodiment, after implementing grouping the ungrouped compile optimization options belonging to the same first optimization process flow into a first compile optimization option group, the processor 101 is further configured to implement:
[0047] If there are multiple compilation optimization options that are not grouped, then determining each of the ungrouped compilation optimization options as a compilation optimization option to be grouped;
[0048] Determining the common function to which each of the to-be-grouped compilation optimization options belongs according to the function call relationship graph and the function to which each of the to-be-grouped compilation optimization options belongs;
[0049] All the to-be-grouped compilation optimization options belonging to the same common function are divided into a new first compilation optimization option group.
[0050] In one embodiment, when determining the target compile optimization option group of the compiler according to each first compile optimization option group and / or each second compile optimization option group, the processor 101 is configured to implement:
[0051] Determining each of the first compile optimization option groups and / or each of the second compile optimization option groups as a target compile optimization option group of the compiler;
[0052] Alternatively, at least two of the first compilation optimization option groups that have an intersection among the plurality of first compilation optimization option groups are merged into one group to obtain a plurality of third compilation optimization option groups, and each of the third compilation optimization option groups is determined as a target compilation optimization option group for the compiler;
[0053] Alternatively, each of the third compilation optimization option groups and each of the second compilation optimization option groups are determined as target compilation optimization option groups of the compiler;
[0054] Alternatively, at least two of the second compile optimization option groups that have an intersection among the plurality of second compile optimization option groups are merged into one group to obtain a plurality of fourth compile optimization option groups, and each of the fourth compile optimization option groups is determined as a target compile optimization option group for the compiler;
[0055] Alternatively, each of the fourth compilation optimization option groups and each of the first compilation optimization option groups are determined as target compilation optimization option groups of the compiler;
[0056] Alternatively, each of the third compilation optimization option groups and each of the fourth compilation optimization option groups are determined as target compilation optimization option groups of the compiler.
[0057] In one embodiment, when determining the target compile optimization option group of the compiler according to each of the first compile optimization option groups and each of the second compile optimization option groups, the processor 101 is configured to implement:
[0058] Acquire an uncalled compile optimization option, where the uncalled compile optimization option is determined during dynamic debugging of a compile process of the compiler using a preset debugging tool;
[0059] Deleting the uncalled compiling optimization option from the first compiling optimization option group including the uncalled compiling optimization option, so as to update the first compiling optimization option group;
[0060] A target compile optimization option group of the compiler is determined according to each of the second compile optimization option groups and each of the updated first compile optimization option groups.
[0061] In one embodiment, when obtaining the function call relationship information of the compiler, the processor 101 is configured to implement:
[0062] Dynamically debugging the compilation process of the compiler using a preset debugging tool, and recording a function call stack of the called compilation optimization option during the dynamic debugging of the compilation process of the compiler;
[0063] When the dynamic debugging of the compilation process of the compiler ends, a function call stack of each of the called compilation optimization options is obtained.
[0064] In one embodiment, when obtaining the function call relationship information of the compiler, the processor 101 is configured to implement:
[0065] Obtaining source code analysis results of the compiler;
[0066] According to the source code analysis result, a function call relationship graph of the compiler is constructed.
[0067] In one embodiment, the processor 101 is further configured to implement the following steps:
[0068] Extracting variables used by each function from the source code analysis results, and obtaining variables corresponding to each of the compilation optimization options;
[0069] The function to which each compilation optimization option belongs is determined according to the variables used by each function and the variables corresponding to each compilation optimization option.
[0070] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the computer device described above can refer to the corresponding process in the following compilation optimization option grouping method embodiment, and will not be repeated here.
[0071] The following will describe in detail the compilation optimization option grouping method provided by the embodiment of the present application in conjunction with the computer device in Figure 1. It should be noted that the computer device in Figure 1 is only used to explain the compilation optimization option grouping method provided by the embodiment of the present application, but does not constitute a limitation on the application scenarios of the compilation optimization option grouping method provided by the embodiment of the present application.
[0072] Please refer to FIG2 , which is a flowchart of a compilation optimization option grouping method provided in an embodiment of the present application.
[0073] As shown in FIG2 , the compilation optimization option grouping method includes steps S101 to S103 .
[0074] Step S101: Obtain function call relationship information of the compiler.
[0075] In this embodiment, the function call relationship information of the compiler may include the function call relationship graph of the compiler and / or the function call stack recorded when each called compilation optimization option is called. The function call relationship graph of the compiler is used to describe the call relationship between each function in the source code of the compiler, and the function call stack corresponding to the called compilation optimization option is used to describe the call relationship between each function involved when the compilation optimization option is called. Among them, the compiler can be a GCC (GNU Compiler Collection) compiler, or it can be other compilers containing compilation optimization options, and the embodiments of the present application do not specifically limit this.
[0076] In some embodiments, as shown in FIG3 , step S101 includes sub-steps S1011 to S1012 .
[0077] Sub-step S1011: dynamically debugging the compilation process of the compiler using a preset debugging tool, and recording the function call stack of the called compilation optimization option during the dynamic debugging of the compilation process of the compiler.
[0078] In this embodiment, the preset debugging tool can be GDB (a debugging tool provided by the GNU software system community). Of course, the preset debugging tool can also be other debugging tools that can debug the compiler, and this embodiment of the application does not specifically limit this. In particular, a preset buffer can be used to record the function call stack of the called compilation optimization option.
[0079] In some embodiments, a preset debugging tool is used to dynamically debug the compilation process of a compiler. During the dynamic debugging of the compilation process of the compiler, a method for recording a function call stack of called compilation optimization options may be: setting each compilation optimization option of the compiler as a watchpoint of the preset debugging tool; selecting a compilation case from a preset compilation case library; starting the compiler to compile the compilation case, and starting the preset debugging tool to detect the compilation process of the compiler; during the compilation process of the compiler, if the started preset debugging tool detects a watchpoint, it is determined that the compilation optimization option corresponding to the watchpoint is called, and a function call stack of the called compilation optimization option is recorded; if there is a compilation optimization option that has not been called, then continue to select a compilation case from the preset compilation case library, and return to the steps of starting the compiler to compile the compilation case and starting the preset debugging tool to detect the compilation process of the compiler until each compilation case in the preset compilation case library is selected once or each compilation optimization option of the compiler is called; when each compilation case in the preset compilation case library is selected once or each compilation optimization option of the compiler is called, exit the preset debugging tool. Among them, the preset compilation use case library includes multiple compilation use cases, and each compilation use case in the preset compilation use case library can be set by the user based on actual conditions, and the embodiment of the present application does not make specific limitations on this.
[0080] In some embodiments, each compilation optimization option of the compiler is set as an observation point of the preset debugging tool by setting all compilation optimization options of the compiler as observation points of the preset debugging tool in batches. For example, if the compiler includes compilation optimization options A, compilation optimization option B, compilation optimization option C, compilation optimization option D, and compilation optimization option E, compilation optimization options A, compilation optimization option B, and compilation optimization option C can be first set as observation points a, observation point b, and observation point c of the preset debugging tool, respectively. After completing the detection of observation points a, observation point b, and observation point c, compilation optimization options D and compilation optimization option E can be set as observation points d and observation point e of the preset debugging tool, respectively.
[0081] Sub-step S1012: When the dynamic debugging of the compilation process of the compiler ends, obtain the function call stack of each called compilation optimization option.
[0082] In this embodiment, after the preset debugging tool exits, it can be determined that dynamic debugging of the compiler's compilation process has ended. At this time, the function call stack of each called compilation optimization option can be obtained. For example, when the dynamic debugging of the compiler's compilation process ends, the function call stack of each called compilation optimization option is obtained from the preset buffer. By dynamically debugging the compiler's compilation process, this embodiment can accurately record the function call stack of the called compilation optimization option during the dynamic debugging of the compiler's compilation process.
[0083] In some embodiments, as shown in FIG4 , step S101 includes sub-steps S1013 and S1014 .
[0084] Sub-step S1013: Obtain the source code analysis result of the compiler.
[0085] In this embodiment, the compiler source code analysis result is an analysis result of the compiler source code. Source code analysis tools such as Source Insight and Linux Cross Reference can be used to analyze the compiler source code to obtain the compiler source code analysis result.
[0086] Sub-step S1014: constructing a function call relationship diagram of the compiler according to the source code analysis result.
[0087] In this embodiment, by statically analyzing the source code of the compiler, a source code analysis result can be obtained, so that the function call relationship graph of the compiler can be accurately constructed based on the source code analysis result, thereby improving the accuracy of constructing the function call relationship body.
[0088] In some embodiments, a method for constructing a compiler's function call graph based on the source code analysis results may include: a computer device extracting each function from the compiler's source code based on the source code analysis results, and determining, based on the source code analysis results, the functions called by each function during execution; and constructing the compiler's function call graph based on each function and the functions called by each function during execution. The function call graph may be a directed graph.
[0089] It should be noted that the computer device may only execute sub-steps S1011 and S1012, or only execute sub-steps S1013 and S1014, or execute sub-steps S1013 and S1014 simultaneously with sub-steps S1011 and S1012. In other words, the computer device may only perform static analysis on the compiler and, based on the results of the static analysis, construct a function call graph of the compiler, or may only use a preset debugging tool to dynamically debug the compiler's compilation process and obtain a function call stack of the compilation optimization options called during the dynamic debugging of the compiler's compilation process. It is also possible that not only static analysis is performed on the compiler and, based on the results of the static analysis, constructs a function call graph of the compiler, but also a preset debugging tool is used to dynamically debug the compiler's compilation process and obtain a function call stack of the compilation optimization options called during the dynamic debugging of the compiler's compilation process. This embodiment of the present application does not specifically limit this.
[0090] Step S102: Group all compilation optimization options in the compiler according to the function call relationship information to obtain multiple target compilation optimization option groups.
[0091] In this embodiment, the target compilation optimization option group includes one or more compilation optimization options, that is, one compilation optimization option can be divided into a target compilation optimization option group, or multiple compilation optimization options can be divided into a target compilation optimization option group. This embodiment of the present application does not make any specific limitations on this.
[0092] In some embodiments, according to the function call relationship information, all the compilation optimization options in the compiler are grouped to obtain multiple target compilation optimization option groups. The method can be: the computer device groups all the compilation optimization options in the compiler according to the function call relationship diagram and / or the function call stack recorded when each compiled optimization option is called, to obtain multiple target compilation optimization option groups. This embodiment can quickly group the compilation optimization options by performing static analysis on the compiler, greatly improving the efficiency of the compilation optimization option grouping. Or this embodiment can accurately group the compilation optimization options by performing dynamic analysis on the compiler, greatly improving the accuracy of the compilation optimization option grouping. Or this embodiment can further improve the accuracy of the compilation optimization option grouping by performing static analysis and dynamic analysis on the compiler to group the compilation optimization options.
[0093] In some embodiments, as shown in FIG5 , step S102 includes sub-steps S1021 to S1023 .
[0094] Sub-step S1021: Determine the first optimization process flow to which each compilation optimization option belongs based on the function call relationship graph and the function to which each compilation optimization option belongs.
[0095] In this embodiment, the first optimization process (Pass) to which the compilation optimization option belongs can be one or more, and this embodiment of the application does not specifically limit this. Wherein, the function to which each compilation optimization option belongs is determined by the computer device based on the source code analysis result of the compiler.
[0096] In some embodiments, the variables used by each function are extracted from the source code analysis results of the compiler, and the variables corresponding to each compilation optimization option are obtained; based on the variables used by each function and the variables corresponding to each compilation optimization option, the function to which each compilation optimization option belongs is determined. This embodiment can accurately determine the function to which each compilation optimization option belongs through the variables used by each function in the source code analysis results and the variables corresponding to each compilation optimization option. For example, the source code analysis results of the compiler include function A, function B, function C, and function D, and the variables used by function A, function B, function C, and function D are variable a, variable b, variable c, and variable d, respectively. Suppose the variable corresponding to compilation optimization option F is variable c, then it can be determined that the function to which compilation optimization option F belongs is function C.
[0097] In some embodiments, based on the function call relationship graph and the function to which each compilation optimization option belongs, the method for determining the first optimization processing flow to which each compilation optimization option belongs can be: for each compilation optimization option, the function call relationship path containing the function to which the compilation optimization option belongs is determined in the function call relationship graph, and the tail function of the function call relationship path is a preset function; the optimization processing flow corresponding to the tail function of the function call relationship path is determined as the first optimization processing flow to which the compilation optimization option belongs. Wherein, the preset function is the execute function or the gate function, and the function call relationship path containing the function to which the compilation optimization option belongs can be one or more, and the embodiments of the present application do not make specific limitations on this. For example, the function to which the compilation optimization option G belongs is function E, and the function call relationship path containing function E determined in the function call relationship graph is function E→function F→function G→function H, function H is the tail function, and function H is the execute function of the optimization processing flow pass_rtl_pre, therefore, the first optimization processing flow to which the compilation optimization option G belongs is pass_rtl_pre.
[0098] Sub-step S1022: Group all the compile optimization options in the compiler according to the first optimization process to which each compile optimization option belongs, to obtain a plurality of first compile optimization option groups.
[0099] In this embodiment, the computer device may group all compilation optimization options that have the same first optimization process into a first compilation optimization option group; if ungrouped compilation optimization options exist, the ungrouped compilation optimization options belonging to the same first optimization process are grouped into a first compilation optimization option group; if no ungrouped compilation optimization options exist, the grouping is terminated. One first compilation optimization option group corresponds to one first optimization process.
[0100] For example, the compiler includes compilation optimization option N1, compilation optimization option N2, compilation optimization option N3, compilation optimization option N4, compilation optimization option N5 and compilation optimization option N6, and the first optimization processing flow to which compilation optimization option N1 belongs includes the first Pass1 and the first Pass2, the first optimization processing flow to which compilation optimization option N2 belongs is the first Pass2, the first optimization processing flow to which compilation optimization option N3 belongs is the first Pass3, the first optimization processing flow to which compilation optimization option N4 belongs is the first Pass3, the first optimization processing flow to which compilation optimization option N5 belongs is the first Pass4, and the first optimization processing flow to which compilation optimization option N6 belongs is the first Pass5.
[0101] Therefore, the compilation optimization options N1 and N2 that share the same first Pass 2 can be grouped into a first compilation optimization option group, and the compilation optimization options N3 and N4 that share the same first Pass 3 can be grouped into a first compilation optimization option group. If the compilation optimization options N5 and N6 remain ungrouped, then the compilation optimization option N5 can be grouped into a separate first compilation optimization option group, and the compilation optimization option N6 can be grouped into a separate first compilation optimization option group, resulting in four first compilation optimization option groups.
[0102] In some embodiments, if there are multiple ungrouped compilation optimization options, each ungrouped compilation optimization option is determined as a compilation optimization option to be grouped; based on the function call relationship graph and the function to which each compilation optimization option to be grouped belongs, the common function to which each compilation optimization option to be grouped belongs is determined; and all compilation optimization options to be grouped belonging to the same common function are grouped into a new first compilation optimization option group. This embodiment can further reduce the search space for compilation optimization options by grouping ungrouped compilation optimization options belonging to the same common function into a new first compilation optimization option group when there are compilation optimization options that cannot be grouped according to the first optimization processing flow.
[0103] For example, the compiler includes compilation optimization option N1, compilation optimization option N2, compilation optimization option N3, compilation optimization option N4, compilation optimization option N5 and compilation optimization option N6, and the first optimization processing flow to which compilation optimization option N1 belongs includes the first Pass1 and the first Pass2, the first optimization processing flow to which compilation optimization option N2 belongs includes the first Pass3 and the first Pass4, the first optimization processing flow to which compilation optimization option N3 belongs is the first Pass5, the first optimization processing flow to which compilation optimization option N4 belongs is the first Pass5, the first optimization processing flow to which compilation optimization option N5 belongs is the first Pass6, and the first optimization processing flow to which compilation optimization option N6 belongs is the first Pass7.
[0104] Therefore, the compilation optimization options N3 and N4 that have the same first Pass5 can be grouped into a first compilation optimization option group. If the compilation optimization options N1, N2, N5, and N6 remain ungrouped, then the compilation optimization option N5 can be grouped into a first compilation optimization option group, and the compilation optimization option N6 can be grouped into a first compilation optimization option group. Then, the common functions to which the compilation optimization option N1 belongs and the common functions to which the compilation optimization option N2 belongs are determined. If the common functions to which the compilation optimization option N1 belongs and the common functions to which the compilation optimization option N2 belongs are the same, then the compilation optimization options N1 and N2 can be grouped into a new first compilation optimization option group, thus obtaining four first compilation optimization option groups. If the common functions to which the compilation optimization option N1 belongs and the common functions to which the compilation optimization option N2 belongs are different, then the compilation optimization option N1 can be grouped into a new first compilation optimization option group, and the compilation optimization option N2 can be grouped into a new first compilation optimization option group, thus obtaining five first compilation optimization option groups.
[0105] Sub-step S1023: Determine a target compilation optimization option group of the compiler according to each first compilation optimization option group.
[0106] In this embodiment, each first compilation optimization option group can be determined as a target compilation optimization option group for the compiler. In some embodiments, at least two first compilation optimization option groups that have an intersection among the plurality of first compilation optimization option groups can be merged into one group to obtain a plurality of third compilation optimization option groups, and each third compilation optimization option group can be determined as a target compilation optimization option group for the compiler.
[0107] For example, there are five first compilation optimization option groups, namely the first compilation optimization option group P1, the first compilation optimization option group P2, the first compilation optimization option group P3, the first compilation optimization option group P4 and the first compilation optimization option group P5. Therefore, the first compilation optimization option group P1, the first compilation optimization option group P2, the first compilation optimization option group P3, the first compilation optimization option group P4 and the first compilation optimization option group P5 can all be used as the target compilation optimization option groups of the compiler, thereby obtaining five target compilation optimization option groups.
[0108] For another example, the first compilation optimization option group P4 and the first compilation optimization option group P5 have an intersection. Therefore, the first compilation optimization option group P4 and the first compilation optimization option group P5 in the first compilation optimization option group P1, the first compilation optimization option group P2, the first compilation optimization option group P3, the first compilation optimization option group P4, and the first compilation optimization option group P5 can be merged into one group, thereby obtaining a third compilation optimization option group Q1 (the same as the first compilation optimization option group P1), a third compilation optimization option group Q2 (the same as the first compilation optimization option group P2), a third compilation optimization option group Q3 (the same as the first compilation optimization option group P3), and a third compilation optimization option group Q4 (obtained by merging the first compilation optimization option group P4 and the first compilation optimization option group P5).
[0109] In some embodiments, as shown in FIG6 , step S102 includes sub-steps S1024 to S1026 .
[0110] Sub-step S1024: determining the second optimization process flow to which each called compilation optimization option belongs based on the function call stack recorded when each called compilation optimization option is called.
[0111] In this embodiment, for each compilation optimization option that is called, the computer device can generate a function call relationship path of the called compilation optimization option based on the function call stack recorded when the called compilation optimization option is called, and the tail function of the function call relationship path is a preset function; the optimization processing flow corresponding to the tail function of the function call relationship path is determined as the second optimization processing flow to which the called compilation optimization option belongs.
[0112] Sub-step S1025 : Group all the compile optimization options in the compiler according to the second optimization process to which each called compile optimization option belongs, to obtain a plurality of second compile optimization option groups.
[0113] In this embodiment, all compilation optimization options belonging to the same second optimization process flow can be grouped together to obtain multiple second compilation optimization option groups. For example, if a compiler includes 10 compilation optimization options, and these 10 compilation optimization options are all called during dynamic debugging of the compiler, a function call stack for each of the 10 compilation optimization options can be obtained. Based on the function call stack for each of the 10 compilation optimization options, the second optimization process flow to which each of the 10 compilation optimization options belongs can be determined.
[0114] If the second optimization processing flows to which compilation optimization options N1, N2, and N3 among the ten compilation optimization options belong are the same, and the second optimization processing flows to which compilation optimization options N4, N5, and N6 belong are the same, and the second optimization processing flows to which compilation optimization options N7, N8, N9, and N10 belong are the same, then compilation optimization options N1, N2, and N3 can be divided into one second compilation optimization option group, compilation optimization options N4, N5, and N6 can be divided into one second compilation optimization option group, and compilation optimization options N7, N8, N9, and N10 can be divided into one second compilation optimization option group, to obtain a total of three second compilation optimization option groups.
[0115] For another example, when dynamically debugging a compiler, compilation optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9 are all called, but compilation optimization option N10 is not called. Therefore, based on the function call stacks of compilation optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9, the second optimization process to which compilation optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9 belong can be determined.
[0116] If the second optimization processing flow to which compilation optimization option N1 and compilation optimization option N2 belong is the same, and the second optimization processing flow to which compilation optimization option N3, compilation optimization option N4 and compilation optimization option N5 belong is the same, and the second optimization processing flow to which compilation optimization option N6 and compilation optimization option N7 belong is the same, and the second optimization processing flow to which compilation optimization option N8 and compilation optimization option N9 belong is the same, then compilation optimization option N1 and compilation optimization option N2 can be divided into one second compilation optimization option group, compilation optimization option N3, compilation optimization option N4 and compilation optimization option N5 can be divided into one second compilation optimization option group, compilation optimization option N6 and compilation optimization option N7 can be divided into one second compilation optimization option group, and compilation optimization option N8 and compilation optimization option N9 can be divided into one second compilation optimization option group, and compilation optimization option N10 is not grouped.
[0117] Sub-step S1026: Determine a target compilation optimization option group of the compiler according to each second compilation optimization option group.
[0118] In this embodiment, the computer device can determine each second compilation optimization option group as the target compilation optimization option group of the compiler. In some embodiments, at least two second compilation optimization option groups that have an intersection in the plurality of second compilation optimization option groups can also be merged into one group to obtain a plurality of fourth compilation optimization option groups, and each fourth compilation optimization option group can be determined as the target compilation optimization option group of the compiler. For example, there are a total of five second compilation optimization option groups, namely, second compilation optimization option group T1, second compilation optimization option group T2, second compilation optimization option group T3, second compilation optimization option group T4, and second compilation optimization option group T5. Therefore, the second compilation optimization option group T1, second compilation optimization option group T2, second compilation optimization option group T3, second compilation optimization option group T4, and second compilation optimization option group T5 can all be used as the target compilation optimization option groups of the compiler, thereby obtaining five target compilation optimization option groups.
[0119] For another example, the second compilation optimization option group T1 and the second compilation optimization option group T2 have an intersection. Therefore, the second compilation optimization option group T1 and the second compilation optimization option group T2 in the second compilation optimization option group T1, the second compilation optimization option group T2, the second compilation optimization option group T3, the second compilation optimization option group T4, and the second compilation optimization option group T5 can be merged into a group to obtain a fourth compilation optimization option group Y1 (obtained by merging the second compilation optimization option group T1 and the second compilation optimization option group T2), a fourth compilation optimization option group Y2 (the same as the second compilation optimization option group T3), a fourth compilation optimization option group Y3 (the same as the second compilation optimization option group T4), and a fourth compilation optimization option group Y4 (the same as the second compilation optimization option group T5).
[0120] In some embodiments, as shown in FIG. 7 , step S102 further includes sub-step S1027 .
[0121] Sub-step S1027 : determining a target compilation optimization option group of the compiler according to each first compilation optimization option group and each second compilation optimization option group.
[0122] In this embodiment, the computer device can determine each first compilation optimization option group and each second compilation optimization option group as a target compilation optimization option group for the compiler. For example, there are five first compilation optimization option groups, namely, first compilation optimization option group P1, first compilation optimization option group P2, first compilation optimization option group P3, first compilation optimization option group P4, and first compilation optimization option group P5, and there are five second compilation optimization option groups, namely, second compilation optimization option group T1, second compilation optimization option group T2, second compilation optimization option group T3, second compilation optimization option group T4, and second compilation optimization option group T5. Therefore, the first compilation optimization option group P1, first compilation optimization option group P2, first compilation optimization option group P3, first compilation optimization option group P4, and first compilation optimization option group P5, as well as the second compilation optimization option groups T1, second compilation optimization option group T2, second compilation optimization option group T3, second compilation optimization option group T4, and second compilation optimization option group T5 can all be used as target compilation optimization option groups for the compiler, thereby obtaining ten target compilation optimization option groups.
[0123] In some embodiments, the computer device may combine at least two of the multiple first compilation optimization option groups that have an intersection into one group to obtain multiple third compilation optimization option groups; and determine each third compilation optimization option group and each second compilation optimization option group as the target compilation optimization option group of the compiler. Alternatively, at least two of the multiple second compilation optimization option groups that have an intersection into one group to obtain multiple fourth compilation optimization option groups; and determine each fourth compilation optimization option group and each first compilation optimization option group as the target compilation optimization option group of the compiler. Alternatively, each third compilation optimization option group and each fourth compilation optimization option group may be determined as the target compilation optimization option group of the compiler.
[0124] In some embodiments, a method for determining a target compilation optimization option group of a compiler based on each first compilation optimization option group and each second compilation optimization option group may include: obtaining uncalled compilation optimization options from a computer device, where the uncalled compilation optimization options are determined during dynamic debugging of the compilation process of the compiler using a preset debugging tool; deleting the uncalled compilation optimization options from a first compilation optimization option group including the uncalled compilation optimization options to update the first compilation optimization option group; and determining a target compilation optimization option group of the compiler based on each second compilation optimization option group and each updated first compilation optimization option group. This embodiment can reduce the search space by deleting the uncalled compilation optimization options from the first compilation optimization option group including the uncalled compilation optimization options.
[0125] For example, when dynamically debugging a compiler, compilation optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9 are all invoked, but compilation optimization option N10 is not invoked. There are five first compilation optimization option groups, namely, first compilation optimization option group P1, first compilation optimization option group P2, first compilation optimization option group P3, first compilation optimization option group P4, and first compilation optimization option group P5. If first compilation optimization option group P2 includes the uninvoked compilation optimization option N10, then the uninvoked compilation optimization option N10 can be deleted from first compilation optimization option group P2 to obtain an updated first compilation optimization option group P2.
[0126] Step S103: Using multiple target compilation optimization option groups as target search spaces of the compiler.
[0127] In this embodiment, the target search space includes multiple search objects, and one target compilation optimization option group corresponds to one search object. For example, if the compiler includes 100 compilation optimization options, then when using the compilation optimization option tuning algorithm without grouping, it is necessary to select compilation optimization options from these 100 compilation optimization options. However, through the compilation optimization option grouping method provided in the embodiment of the present application, after grouping these 100 compilation optimization options, 10 target compilation optimization option groups can be obtained. In this way, when using the compilation optimization option tuning algorithm, it is only necessary to select one or more target compilation optimization option groups from these 10 target compilation optimization option groups. This greatly reduces the search space of the compilation optimization option tuning algorithm, thereby improving the search efficiency of the compilation optimization option tuning algorithm.
[0128] An embodiment of the present application also provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any compilation optimization option grouping method provided in the description of the embodiment of the present application.
[0129] The storage medium may be an internal storage unit of the computer device described in the aforementioned embodiment, such as a hard disk or memory of the computer device. The storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device.
[0130] An embodiment of the present application provides a compilation optimization option grouping method, a computer device, and a storage medium. The embodiment of the present application groups all compilation optimization options in a compiler through the function call relationship information of the compiler to obtain multiple target compilation optimization option groups, and uses the multiple target compilation optimization option groups as the target search space of the compiler, which can greatly reduce the search space of the compilation optimization option tuning algorithm, thereby improving the search efficiency of the compilation optimization option tuning algorithm.
[0131] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware embodiment, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable, and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media generally embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0132] It should be understood that the term "and / or" used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system that includes a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system that includes the element.
[0133] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments. The above are only specific embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.
Claims
1. A method for grouping compilation optimization options. include: Get the compiler's function call relationship information; According to the function call relationship information, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups, wherein the target compile optimization option groups include one or more of the compile optimization options; The plurality of target compile optimization option groups are used as a target search space of the compiler, wherein the target search space includes a plurality of search objects, and one target compile optimization option group corresponds to one search object.
2. The method for grouping compilation optimization options according to claim 1, in, The function call relationship information includes a function call relationship graph of the compiler and / or a function call stack recorded when each of the called compile optimization options is called. According to the function call relationship information, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups, including: According to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups.
3. The method for grouping compilation optimization options according to claim 2, in, The method further comprises grouping all the compile optimization options in the compiler according to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called, to obtain a plurality of target compile optimization option groups, including: Determine a first optimization process flow to which each of the compile optimization options belongs according to the function call relationship graph and the function to which each of the compile optimization options belongs; According to the first optimization process to which each of the compile optimization options belongs, grouping all the compile optimization options in the compiler to obtain a plurality of first compile optimization option groups; and / or, determining the second optimization process flow to which each of the called compilation optimization options belongs according to the function call stack recorded when each of the called compilation optimization options is called; According to the second optimization process to which each of the called compilation optimization options belongs, all compilation optimization options in the compiler are grouped to obtain a plurality of second compilation optimization option groups; A target compile optimization option group of the compiler is determined according to each of the first compile optimization option groups and / or each of the second compile optimization option groups.
4. The method for grouping compilation optimization options according to claim 3, in, The step of grouping all the compile optimization options in the compiler according to the first optimization process to which each compile optimization option belongs, to obtain a plurality of first compile optimization option groups, includes: Dividing all the compile optimization options having the same first optimization process flow into a first compile optimization option group; If there are ungrouped compile optimization options, the ungrouped compile optimization options belonging to the same first optimization process flow are divided into a first compile optimization option group.
5. The method for grouping compilation optimization options according to claim 4, in, After the ungrouped compiling optimization options belonging to the same first optimization process flow are divided into a first compiling optimization option group, the method further includes: If there are multiple compiling optimization options that are not grouped, then each of the compiling optimization options that are not grouped is determined as a compiling optimization option to be grouped; According to the function call relationship graph and the function to which each of the to-be-grouped compilation optimization options belongs, determine each of the The public functions to which the optimization options to be compiled are grouped; All the to-be-grouped compile optimization options belonging to the same common function are divided into a new first compile optimization option group.
6. The method for grouping compilation optimization options according to claim 3, in, Determining the target compile optimization option group of the compiler according to each of the first compile optimization option groups and / or each of the second compile optimization option groups includes: Determine each of the first compile optimization option groups and / or each of the second compile optimization option groups as a target compile optimization option group of the compiler; Alternatively, at least two of the first compile optimization option groups that have an intersection among the plurality of the first compile optimization option groups are combined into one group to obtain a plurality of third compile optimization option groups, and each of the third compile optimization option groups is determined as a target compile optimization option group of the compiler; Alternatively, each of the third compiling optimization option groups and each of the second compiling optimization option groups are determined as target compiling optimization option groups of the compiler; Alternatively, at least two of the second compiling optimization option groups that have an intersection among the plurality of the second compiling optimization option groups are combined into one group to obtain a plurality of fourth compiling optimization option groups, and each of the fourth compiling optimization option groups is determined as a target compiling optimization option group of the compiler; Alternatively, each of the fourth compiling optimization option groups and each of the first compiling optimization option groups are determined as target compiling optimization option groups of the compiler; Alternatively, each of the third compiling optimization option groups and each of the fourth compiling optimization option groups are determined as target compiling optimization option groups of the compiler.
7. The method for grouping compilation optimization options according to claim 3, in, The step of determining a target compile optimization option group of the compiler according to each of the first compile optimization option groups and each of the second compile optimization option groups comprises: Acquire an uncalled compile optimization option, wherein the uncalled compile optimization option is determined in a process of dynamically debugging a compile process of the compiler using a preset debugging tool; Deleting the uncalled compiling optimization option from the first compiling optimization option group including the uncalled compiling optimization option, so as to update the first compiling optimization option group; A target compile optimization option group of the compiler is determined according to each of the second compile optimization option groups and each of the updated first compile optimization option groups.
8. The method for grouping compilation optimization options according to any one of claims 1 to 7, in, The obtaining of the function call relationship information of the compiler includes: Dynamically debugging the compilation process of the compiler using a preset debugging tool, and in the process of dynamically debugging the compilation process of the compiler, recording a function call stack of the called compilation optimization option; When the dynamic debugging of the compilation process of the compiler ends, the function call stack of each of the called compilation optimization options is obtained.
9. The method for grouping compilation optimization options according to any one of claims 1 to 7, in, The obtaining of the function call relationship information of the compiler includes: Obtaining a source code analysis result of the compiler; According to the source code analysis result, a function call relationship graph of the compiler is constructed.
10. The method for grouping compilation optimization options according to claim 9, further comprising: include: Extract the variables used by each function from the source code analysis results, and obtain the corresponding Variables; According to the variables used by each function and the variables corresponding to each of the compilation optimization options, the function to which each of the compilation optimization options belongs is determined.
11. A computer device, comprising a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the steps of the compilation optimization option grouping method as described in any one of claims 1 to 10 are realized.
12. A storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the method for grouping compilation optimization options according to any one of claims 1 to 10.
Citation Information
Patent Citations
Iterative compilation optimization method based on program characteristic analysis
CN107885503A
Compiling option tuning method and device, processor chip and server
CN112433706A
Automatic parameter adjusting method for compiler
CN115469851A
Build-time code section-specific compiler selection
US20190377559A1
