Compilation optimization method and system and storage medium
By generating a topological sorting graph and compiling an optimization method for the optimal scheduling strategy, the problem of poor code reusability on heterogeneous platforms of smart cars is solved, cross-platform algorithm optimization is achieved, and development efficiency and system performance are improved.
Patent Information
- Application Number
- CN202510834393.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-28
AI Technical Summary
Due to the poor code reusability caused by the heterogeneity of the computing platforms of smart cars, developers need to rewrite code, resulting in low development efficiency and difficulty in reducing costs.
By obtaining the original code and optimization parameters, a topology sorting graph is generated. The optimal scheduling strategy is obtained using a backtracking algorithm. Header files and library files are generated to mask hardware differences and achieve cross-platform algorithm optimization.
It improves algorithm optimization efficiency, reduces development costs, avoids repeated tuning on different hardware platforms, and improves system performance and resource utilization.
Smart Images

Figure CN120848890A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of intelligent driving technology, specifically relating to a compilation optimization method, system, and storage medium. Background Technology
[0002] Intelligent vehicles primarily rely on technologies such as artificial intelligence, computer vision, and radar to enable them to autonomously perceive, make decisions, and plan and control their environment. Currently, the most challenging aspect for intelligent vehicles is achieving real-time and accurate perception of the traffic environment. To address this, intelligent vehicles are often equipped with radar, sensors, and other devices for precise environmental perception. Perception algorithms, as the core of intelligent vehicle perception, currently employ a mainstream approach of converting images acquired by multiple intelligent agents into a Bird's Eye View (BEV). The BEV representation of the environment contains rich semantic information, accurate localization information, and absolute scale information, which can be used for downstream tasks such as path planning and behavior prediction. Furthermore, the BEV can serve as an interpretable platform for fusing multi-view, multi-sensor, and temporal information.
[0003] With the evolution of perception technology from traditional image processing to deep learning, especially the introduction of deep network models such as BEVs, driving technology has been significantly advanced. However, in practical applications, the storage and processing capabilities of in-vehicle systems are limited, which may not be able to fully meet the computational needs of the models, resulting in the models and algorithms not performing at their full potential and failing to reach their optimal state. To meet different user needs and diverse computing platforms, the same algorithm needs to be adapted to various heterogeneous platforms such as ARM (Advanced RISC Machines), RISC-V processors (Reduced Instruction Set Computer - Five), DSP (Digital Signal Processor), and NPU (Neural Processing Unit). Because these platforms differ significantly in computing units and memory allocation, and their programming models are inconsistent, code reusability is poor, requiring developers to repeatedly write code, resulting in low development efficiency and difficulty in cost reduction. Summary of the Invention
[0004] To address the aforementioned technical problems, this application proposes a compilation optimization method, system, and storage medium that can reduce the workload of developers in optimizing code, shield hardware differences, and effectively improve system performance.
[0005] Specifically, this application proposes a compiler optimization method, including: Obtain the original code and pre-configured optimization parameters.
[0006] A topological sorting graph is generated based on the optimized parameters and the original code.
[0007] The optimal scheduling strategy for each node in the topological sorting graph is obtained by using a backtracking algorithm.
[0008] Furthermore, based on the optimal scheduling strategy, a generator is used to generate header files and library files, and a compiler is used to compile the original code, header files, and library files into executable files.
[0009] In the above technical solution, the header file and library file are generated by the generator based on the obtained optimal scheduling strategy. This does not require the participation of the coder and effectively optimizes and improves the code. The header file and library file generated by the optimization strategy are compiled into an executable file, realizing cross-platform algorithm optimization. This shields the differences between different hardware platforms and avoids programmers from repeatedly tuning the same algorithm on different hardware platforms, effectively improving the efficiency of algorithm optimization and reducing development costs.
[0010] As one implementation method, generating a topological sorting graph based on the optimized parameters and the original code includes: The original code is parsed based on the optimization parameters to obtain data flow information.
[0011] The data stream information is encapsulated into multiple nodes, and edges between the nodes are established based on the optimization parameters to generate a topological sorting graph.
[0012] By encapsulating the data flow information parsed from the original code into multiple nodes to generate a topology sorting graph, the original code is structured, enabling precise dependency modeling. The topology sorting graph clearly defines the execution order between nodes, ensuring effective handling of dependencies and thus improving code execution efficiency. Based on this topology sorting graph, computing resources can be rationally allocated, avoiding resource conflicts and redundant computations, thereby improving the overall resource efficiency of the system.
[0013] Furthermore, obtaining the optimal scheduling strategy for each node in the topological sorting graph using a backtracking algorithm includes: The decomposition factor and vectorization length are set by a backtracking algorithm, and the decomposition factor and vectorization length are adjusted based on historical scheduling strategies; the optimal scheduling strategy is obtained based on the adjusted decomposition factor and vectorization length, and the optimal scheduling strategy is recorded.
[0014] By analyzing and optimizing the decomposition factors and vectorized length using a backtracking algorithm, the optimal scheduling strategy is obtained, ensuring that each node in the code execution process receives optimal resource allocation and execution path. The optimized scheduling strategy reduces the total program execution time and effectively minimizes waiting time, improving the overall system efficiency. It also enables more precise partitioning of computational tasks, avoiding excessive or insufficient resource allocation.
[0015] Furthermore, the step of obtaining the optimal scheduling strategy based on the adjusted decomposition factor and vectorized length also includes: No scheduling is performed when the node consists only of constant values.
[0016] When the node is a node with no in-degree, the node is scheduled based on its order of arrival.
[0017] If the node is not a node with no in-degree, then the node is directly scheduled.
[0018] Specifically, when nodes contain only constant values, no scheduling is performed, thus avoiding unnecessary scheduling operations and effectively reducing system resource consumption. Scheduling nodes with no in-degree based on their order of arrival improves system parallelism, reduces unnecessary waiting, and fully utilizes idle computing resources. Proper scheduling of nodes with no in-degree helps reduce the overall execution time.
[0019] Furthermore, the scheduling of the node includes: Based on the computing characteristics of the node, a corresponding scheduling strategy is adopted; wherein, the computing characteristics include at least computing dimension, race conditions, and cache space.
[0020] By calculating the dimensionality, targeted scheduling strategies can be adopted based on the dimensionality level. In parallel computing or multi-task scheduling, race conditions refer to resource conflicts caused by multiple tasks or threads vying for shared resources. By considering race conditions during scheduling, the execution order of tasks can be rationally arranged to avoid race conditions, thereby preventing performance degradation or execution errors.
[0021] Furthermore, the scheduling strategy based on the computing characteristics of the node includes: When a node is in a race condition, the parallelization scheduling strategy and the unfolding scheduling strategy are determined by the computational dimension.
[0022] When there is no race condition at a node, the data is cached in the cache space, and a parallel scheduling strategy or a vectorized scheduling strategy is enabled.
[0023] By employing parallel scheduling and unfolded scheduling strategies, the negative impact of race conditions can be effectively reduced, ensuring smooth task execution, improving resource utilization and computational efficiency in multi-core processors or distributed computing environments, reducing task waiting time and resource contention, and minimizing computational latency, thereby enhancing system response speed. In the absence of race conditions, data is cached using a cache space; proper cache space management avoids frequent memory accesses, improving data processing speed and enhancing system performance.
[0024] Furthermore, determining the parallelization scheduling strategy and the unfolded scheduling strategy through the computational dimension includes: When the computation dimension is one-dimensional, no parallel scheduling strategy is implemented.
[0025] When the computation dimension is two-dimensional, a parallel scheduling strategy is applied to the row dimension.
[0026] When the computation dimension is three-dimensional, an expansion scheduling strategy is applied to the third dimension, and a parallelization scheduling strategy is applied to the second dimension.
[0027] By adopting different scheduling strategies for nodes with different computational dimensions, the efficiency of the scheduling process is effectively improved. When the computational dimension is one-dimensional, no parallel scheduling strategy is used, effectively avoiding unnecessary resource waste and reducing the complexity of scheduling management. When the computational dimension is two-dimensional, a parallel scheduling strategy is applied to the row dimension. Since row-dimensional computations are usually relatively independent, dependencies and conflicts between tasks can be effectively avoided. Parallelizing row-dimensional computations can significantly accelerate the computational dimension. When the computational dimension is three-dimensional, different scheduling strategies are adopted for different dimensions, effectively allocating computational resources, avoiding resource waste, and a reasonable scheduling strategy can effectively avoid computational bottlenecks and improve processing efficiency.
[0028] Furthermore, after the original code, header files, and library files are compiled into an executable file by the compiler, the process also includes: The executable file is subjected to performance testing, and the test results are obtained so as to adjust the optimal scheduling strategy based on the test results.
[0029] By performing performance tests on executable files, potential defects can be detected. Based on the detection results, the optimal scheduling strategy can be adjusted, which effectively improves the overall execution efficiency, reduces system resource waste, and enhances the system's flexibility and adaptability.
[0030] Based on the same inventive concept, this application also proposes a system for a compiler optimization method, the system comprising: The data acquisition module is used to acquire the original code and pre-configured optimization parameters.
[0031] The topology graph generation module is used to generate a topology sorting graph based on the optimization parameters and the original code.
[0032] The strategy optimization module is used to obtain the optimal scheduling strategy for each node in the topology sorting graph through a backtracking algorithm.
[0033] In addition, a compilation module is used to generate header files and library files using a generator based on the optimal scheduling strategy, and to compile the original code, header files and library files into an executable file using a compiler.
[0034] Based on the same inventive concept, this application also proposes a computer-readable storage medium storing computer-executable instructions that can be executed by a control processor to implement the compilation optimization method.
[0035] Compared with the prior art, this application has at least the following beneficial effects: The method provided in this application effectively solves the technical problems of poor code reusability caused by the different computing platforms with varying user needs, significant differences in computing units and memory allocation, and inconsistent programming models. This necessitates developers repeatedly writing code, resulting in low development efficiency and difficulty in cost reduction. By using an optimal scheduling strategy, a generator produces header and library files without the need for coders, effectively optimizing and improving the code. The header and library files generated by the optimization strategy are compiled into executable files, achieving cross-platform algorithm optimization. This shields the differences in algorithms across different hardware platforms, avoiding the need for programmers to repeatedly fine-tune the same algorithm on different hardware platforms, effectively improving algorithm optimization efficiency and reducing development costs. Attached Figure Description
[0036] Figure 1 This is a flowchart illustrating the compilation optimization method in an embodiment of this application.
[0037] Figure 2 This is a schematic diagram of a compiler optimization system shown in an embodiment of this application. Detailed Implementation
[0038] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0039] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices. Example 1:
[0040] Please refer to Figure 1 The compilation optimization method mainly includes steps S100 to S400.
[0041] Step S100 includes: obtaining the original code and pre-configured optimization parameters. The pre-configured optimization parameters may include at least target platform parameters, execution hardware parameters, maximum number of threads, maximum vector processing length, and cache space size. Those skilled in the art can configure other optimization parameters according to actual needs, and are not limited to these.
[0042] Step S200 includes: generating a topological sorting graph based on the optimized parameters and the original code. By parsing the original code, data flow information is obtained, such as input data, parameters, output data, function data, and the domain of restoration. This data flow information is encapsulated into nodes of the topological sorting graph. Edges between nodes can be established based on the relationships between them, thereby parsing the original code into a topologically sorted directed acyclic graph.
[0043] Step S300 includes: obtaining the optimal scheduling strategy for each node in the topological sorting graph through a backtracking algorithm. This mainly involves multiplying the current decomposition factor and vectorized length by 2 based on the backtracking algorithm and recording them in the scheduling stack. After performance testing, if the running time is reduced or remains the same while memory consumption is reduced, the scheduling is considered optimal; otherwise, the previous round of scheduling strategy is backtracked and set as the optimal scheduling strategy for the current node. After processing all nodes, the optimal scheduling strategy is obtained.
[0044] Furthermore, step S400 includes: generating header files and library files using a generator based on the optimal scheduling strategy, and compiling the original code, header files, and library files into an executable file using a compiler.
[0045] Specifically, optimization parameters such as target platform parameters, execution hardware parameters, maximum number of threads, maximum vector processing length, and cache space are pre-configured. These optimization parameters and the original code are uploaded to the agent. Upon receiving the optimization parameters and the original code, the agent parses the original code to obtain data flow information, such as input data, parameters, output data, functions, and restoration domains. This data is then encapsulated into nodes of a topological sorting graph. Edges of the topological sorting graph are then established based on the dependencies between nodes to construct the topological sorting graph. A backtracking algorithm is used to set the current decomposition factor and vectorization length for each node. After testing, the test results are compared with the results of the previous round of decomposition factor and vectorization length testing. If the test results show a shorter running time or the same running time with reduced memory consumption, the current schedule is designated as the optimal schedule. Based on this optimal scheduling strategy, a generator is used to generate the corresponding header files and library files. According to the compilation script, the compiler compiles the original code, header files, and library files into an executable file.
[0046] In some embodiments, generating a topology sorting graph based on the optimization parameters and the original code includes: The original code is parsed based on the optimization parameters to obtain data flow information.
[0047] The data stream information is encapsulated into multiple nodes, and edges between the nodes are established based on the optimization parameters to generate a topological sorting graph.
[0048] The data flow information can include at least inputs, parameters, outputs, functions, and a domain of restoration. Those skilled in the art can select other data flow information based on the actual situation, and are not limited to this. The data flow information can be obtained by scanning the `Generate` computation method and parsing the original code. The `Generate` computation method is a computational method that generates a specific output result through a series of inputs, outputs, parameters, and function calls. The inputs are the starting point of the computation method, the outputs are the final results of the computation, the parameters are factors that regulate the computation method, the functions are the specific functions that implement the computation, and the domain of restoration is the range or field that limits the computational operation.
[0049] Preferably, obtaining the optimal scheduling strategy for each node in the topological sorting graph using a backtracking algorithm includes: The decomposition factor and vectorization length are set by a backtracking algorithm, and the decomposition factor and vectorization length are adjusted based on historical scheduling strategies; the optimal scheduling strategy is obtained based on the adjusted decomposition factor and vectorization length, and the optimal scheduling strategy is recorded.
[0050] Among these factors, the decomposition factor and vectorization length have the greatest impact on the performance of the final executable file. These factors can be set according to the backtracking algorithm. The decomposition factor can be set to a power of 2. The scheduling strategy is recorded in the scheduling stack as a preliminary scheduling strategy. After generating the executable file based on the preliminary scheduling strategy, the next round multiplies the decomposition factor and vectorization length by 2 and records them in the scheduling stack. After performance testing, if the running time is less or the running time remains the same, the scheduling strategy of this round is considered to be the optimal scheduling strategy; otherwise, the previous round of scheduling is backtracked until the optimal scheduling strategy is obtained.
[0051] Preferably, the step of obtaining the optimal scheduling strategy based on the adjusted decomposition factor and vectorized length further includes: No scheduling is performed when the node consists only of constant values.
[0052] When the node is a node with no in-degree, the node is scheduled based on its order of arrival.
[0053] If the node is not a node with no in-degree, then the node is directly scheduled.
[0054] In practice, when a node only calculates a constant number of values, it is not scheduled. When a node is a node with no in-degree, since the scheduling order of nodes with no in-degree does not affect performance, the node can be scheduled according to its order in the topology sorting graph.
[0055] Preferably, scheduling the node includes: Based on the computing characteristics of the node, a corresponding scheduling strategy is adopted; wherein, the computing characteristics include at least computing dimension, race conditions, and cache space.
[0056] The computational characteristics mainly include computational dimension, race condition, and cache space. Those skilled in the art can choose other computational characteristics according to the actual situation, and are not limited to these. For example, computational characteristics can also include the restoration domain dimension.
[0057] Preferably, the scheduling strategy based on the computing characteristics of the node includes: When a node is in a race condition, the parallelization scheduling strategy and the unfolding scheduling strategy are determined by the computational dimension.
[0058] When there is no race condition at a node, the data is cached in the cache space, and a parallel scheduling strategy or a vectorized scheduling strategy is enabled.
[0059] In other words, when nodes experience race conditions or data dependencies, vectorization and parallelization scheduling strategies are not activated. Instead, the computational dimension is used, with the vectorization length and decomposition factor determined by the node's actual loop variable and its range. Based on this decomposition factor and vectorization length, the parallelization and unpacking scheduling strategies are determined using the computational dimension. When nodes do not experience race conditions, data input is cached in a buffer space, preventing repeated readings of computational data when input is needed, achieving high locality. By activating parallelization or vectorization scheduling strategies, computation time is shortened, achieving both high parallelism and reasonable multithreading to avoid significant overhead.
[0060] The vectorized scheduling strategy primarily converts scalar computations within loops into vector computations, leveraging SIMD (Single Instruction, Multiple Data) instructions to improve computational efficiency. The unrolling scheduling strategy expands the loop into multiple parallel statements, reducing loop control overhead and optimizing access to shared data. The parallelization scheduling strategy utilizes the parallel computing capabilities of multi-core CPUs or GPUs to distribute each iteration of the loop to multiple threads or processors, significantly improving computational speed.
[0061] Preferably, determining the parallelization scheduling strategy and the unfolding scheduling strategy through the computational dimension includes: When the computation dimension is one-dimensional, no parallel scheduling strategy is implemented.
[0062] When the computation dimension is two-dimensional, a parallel scheduling strategy is applied to the row dimension.
[0063] When the computation dimension is three-dimensional, an expansion scheduling strategy is applied to the third dimension, and a parallelization scheduling strategy is applied to the second dimension.
[0064] When the computation dimension is one-dimensional, meaning the computational data is linearly ordered, efficiency cannot be improved through parallel scheduling, therefore no parallel scheduling strategy is implemented. When the computation dimension is two-dimensional, a parallel scheduling strategy is applied to the row dimension, enabling multiple threads to process simultaneously. When the computation dimension is three-dimensional, the three-dimensional computational data can be such as a color image or a three-dimensional color space; the third dimension is expanded and scheduled, while the second dimension is parallelized. For example, the depth dimension data can be divided into multiple sub-blocks, each processed in parallel by different threads or computational units; the height dimension can be divided into multiple parts, with multiple threads processing different regions in parallel.
[0065] Preferably, after the original code, header files, and library files are compiled into an executable file by a compiler, the method further includes: The executable file is subjected to performance testing, and the test results are obtained so as to adjust the optimal scheduling strategy based on the test results.
[0066] After the executable file is compiled by the compiler, the performance of the executable file is tested through the testing platform, and the performance test results are fed back to the agent. The agent adjusts the scheduling strategy of the algorithm based on the test feedback results. Example 2:
[0067] Please refer to Figure 2 This application also proposes a system employing the compilation optimization method described in Embodiment 1, the system comprising: a data acquisition module, a topology graph generation module, a strategy optimization module, and a compilation module.
[0068] The data acquisition module is used to acquire the original code and pre-configured optimization parameters. These pre-configured optimization parameters may include at least target platform parameters, execution hardware parameters, maximum number of threads, maximum vector processing length, and cache space. Those skilled in the art can select other optimization parameters based on actual circumstances, and are not limited to these.
[0069] A topology graph generation module is used to generate a topology sorting graph based on the optimization parameters and the original code. In this module, the original code is parsed to obtain input data, output data, parameters, functions, and the domain of restoration. The parsed data is then encapsulated into nodes for the topology sorting graph. Edges between the nodes are generated based on their dependencies, thus producing the topology sorting graph.
[0070] The strategy optimization module is used to obtain the optimal scheduling strategy for each node in the topological sorting graph through a backtracking algorithm. This mainly involves setting an initial decomposition factor and vectorization length based on the data in the node. Typically, the decomposition factor can be set to multiple powers of 2, and the vectorization length is set as the decomposition factor. Based on the backtracking algorithm, the current decomposition factor and vectorization length are multiplied by 2 and recorded in the scheduling stack. After performance testing, if the running time is less or the running time remains the same compared to the previous round of testing, and memory consumption is reduced, then the scheduling is considered optimal. Otherwise, the previous round of scheduling strategy is backtracked and set as the optimal scheduling strategy for the current node. After processing all nodes, the optimal scheduling strategy is obtained.
[0071] In addition, a compilation module is used to generate header files and library files using a generator based on the optimal scheduling strategy, and to compile the original code, header files and library files into an executable file using a compiler. Example 3:
[0072] This application also provides a computer-readable storage medium, the computer-readable storage medium comprising: The computer-readable storage medium stores computer-executable instructions.
[0073] When the computer-executable instructions are executed by the control processor, the compilation optimization method described in Embodiment 1 is implemented.
[0074] The computer-readable storage medium can be implemented entirely or partially by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in the computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0075] In summary, the method provided in this application effectively solves the technical problems of poor code reusability caused by the different computing platforms with varying user needs, significant differences in computing units and memory allocation, and inconsistent programming models. This necessitates developers repeatedly writing code, resulting in low development efficiency and difficulty in cost reduction. By using the obtained optimal scheduling strategy to generate header and library files without the need for coders, the method effectively optimizes and improves the code. The header and library files generated by the optimization strategy are compiled into executable files, achieving cross-platform algorithm optimization. This shields the differences in algorithms across different hardware platforms, avoids programmers repeatedly tuning the same algorithm on different hardware platforms, effectively improves algorithm optimization efficiency, and reduces development costs.
[0076] In the several embodiments provided in this application, it will be understood that each block in the flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the figures. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved.
[0077] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0078] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this application. It should be understood that the above descriptions are merely specific embodiments of this application and are not intended to limit the scope of protection of this application. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application for those skilled in the art.
Claims
1. A compiler optimization method, characterized in that, include: Obtain the original code and pre-configured optimization parameters; A topological sorting graph is generated based on the optimized parameters and the original code; The optimal scheduling strategy for each node in the topological sorting graph is obtained by using a backtracking algorithm; Furthermore, based on the optimal scheduling strategy, a generator is used to generate header files and library files, and a compiler is used to compile the original code, header files, and library files into executable files.
2. The compilation optimization method according to claim 1, characterized in that, The process of generating a topology sorting graph based on the optimized parameters and the original code includes: The original code is parsed based on the optimization parameters to obtain data flow information; The data stream information is encapsulated into multiple nodes, and edges between the nodes are established based on the optimization parameters to generate a topological sorting graph.
3. The compilation optimization method according to claim 2, characterized in that, The step of obtaining the optimal scheduling strategy for each node in the topological sorting graph using a backtracking algorithm includes: The decomposition factor and vectorization length are set by a backtracking algorithm, and the decomposition factor and vectorization length are adjusted based on historical scheduling strategies. The optimal scheduling strategy is obtained based on the adjusted decomposition factor and vectorized length, and the optimal scheduling strategy is recorded.
4. The compilation optimization method according to claim 3, characterized in that, The method for obtaining the optimal scheduling strategy based on the adjusted decomposition factor and vectorized length also includes: When the node consists of only a few constant values, no scheduling is performed; When the node is a node with no in-degree, the node is scheduled based on its order. If the node is not a node with no in-degree, then the node is directly scheduled.
5. The compilation optimization method according to claim 4, characterized in that, The scheduling of the node includes: Based on the computing characteristics of the node, a corresponding scheduling strategy is adopted; wherein, the computing characteristics include at least computing dimension, race conditions, and cache space.
6. The compilation optimization method according to claim 5, characterized in that, The scheduling strategy based on the computing characteristics of the node includes: When a node is in a race condition, the parallelization scheduling strategy and the unfolding scheduling strategy are determined by the computational dimension. When there is no race condition at a node, the data is cached in the cache space, and a parallel scheduling strategy or a vectorized scheduling strategy is enabled.
7. The compilation optimization method according to claim 6, characterized in that, The step of determining the parallelization scheduling strategy and the unfolding scheduling strategy through the computational dimension includes: When the computation dimension is one-dimensional, no parallel scheduling strategy is implemented; When the computation dimension is two-dimensional, a parallel scheduling strategy is applied to the row dimension. When the computation dimension is three-dimensional, an expansion scheduling strategy is applied to the third dimension, and a parallelization scheduling strategy is applied to the second dimension.
8. The compilation optimization method according to claim 7, characterized in that, After the compiler compiles the original code, header files, and library files into an executable file, it also includes: The executable file is subjected to performance testing, and the test results are obtained so as to adjust the optimal scheduling strategy based on the test results.
9. A system based on the compiler optimization method according to any one of claims 1-8, characterized in that, The system includes: The data acquisition module is used to acquire the original code and pre-configured optimization parameters; A topology graph generation module is used to generate a topology sorting graph based on the optimization parameters and the original code; The strategy optimization module is used to obtain the optimal scheduling strategy for each node in the topology sorting graph through a backtracking algorithm; In addition, a compilation module is used to generate header files and library files using a generator based on the optimal scheduling strategy, and to compile the original code, header files and library files into an executable file using a compiler.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that can control a processor to execute in order to implement the compilation optimization method as described in any one of claims 1-8.