A method for solving polyhedral vectorization scheduling based on iteration layering

By using an iterative, hierarchical, polyhedral vectorized scheduling solution method, cross-dimensional constraints are decomposed into hierarchical constraints, solving large-scale integer linear programming problems in existing technologies and achieving a significant improvement in compilation efficiency, especially in complex dependent code.

CN116578302BActive Publication Date: 2026-06-05ZHEJIANG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG UNIV
Filing Date
2023-05-24
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing polyhedral vectorization compilers suffer from large-scale integer linear programming problems and long solution times in loop vectorization, especially in code with complex dependencies, which limits compilation performance and application scenarios.

Method used

An iterative hierarchical approach is adopted to decompose cross-dimensional vectorized constraints into hierarchical constraints, and small-scale solutions are obtained using integer linear programming tools. Combined with the iterative approach of dependency graphs, the scheduling process is optimized.

Benefits of technology

It significantly improves compilation efficiency, shortens solution time, and enhances compilation performance, with an efficiency improvement of up to 140 times.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116578302B_ABST
    Figure CN116578302B_ABST
Patent Text Reader

Abstract

The application discloses a kind of polyhedral vectorization scheduling solving methods based on iterative stratification, this method simplifies the vectorization constraint across dimension, by approximate segmentation to each dimension;Then in each dimension solving process, for the information of statement and current solving dimension, specific constraint is added in each dimension subproblem to solve;Finally, the method of iteration is used to search the solution under the feasible scheduling space.The application solves the integer linear programming problem containing cross-dimension vectorization constraint by stratified solving, avoids the problem of large problem size and long solving time caused by overall solving;Can effectively improve the compiling efficiency of polyhedral vectorization compiler, with good application scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of vectorized compilation optimization, and in particular relates to a vectorized scheduling solution method for polyhedra based on iterative layering. Background Technology

[0002] Automatic vectorization is an important method for code compilation optimization, which can greatly improve program performance by utilizing Single Instruction Multiple Data (SIMD) and vectorized extension units. However, loop vectorization, as an important branch of automatic vectorization technology, still lags significantly behind manual optimization in mainstream compilers due to two main problems: First, while mainstream compilers employ various vectorization optimization methods, the scattered and statement-based coarse-grained analysis misses many vectorization opportunities. Second, loop vectorization involves various loop transformations, and the type and order of these transformations directly affect vectorization performance.

[0003] Polyhedral compilers possess powerful abstract representation capabilities, able to abstract loops and various influencing factors into mathematical representations and express multiple transformations in a unified form. This allows for fine-grained joint consideration of multiple factors in problem-solving, yielding better optimization results. Therefore, in recent years, they have attracted attention and are widely used in various mainstream compilers and deep learning compilers, such as GCC's Graphite module, LLVM's Polly module, and Tensorflow's XLA. These compilers, as crucial components of software systems, are key factors affecting the runtime and power consumption of computer applications, especially in fields such as digital signal processing, big data, artificial intelligence, and high-performance computing.

[0004] However, due to the requirement for continuous code memory access in vectorization, most existing polyhedral vectorization compilers use cross-dimensional constraint modeling methods and global solution approaches to find feasible code transformations. Therefore, they also suffer from the problems of large problem size and long solution time for integer linear programming. For code with complex dependencies, the problem size and solution time increase exponentially. These problems significantly impact the compilation performance and application scenarios of polyhedral vectorization compilation technology. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by providing a vectorized scheduling solution method for polyhedra based on iterative hierarchical layering.

[0006] The objective of this invention is achieved through the following technical solution: a vectorized scheduling solution method for polyhedra based on iterative hierarchical layering, comprising the following steps:

[0007] (1) The compiler performs lexical analysis and syntax analysis on the input code, parses the identifiers and meanings of each symbol in the input code, finds the static control unit identified by the user, and adds it to the candidate optimization list;

[0008] (2) Perform dependency analysis on the static control units in the candidate optimization list and extract their polyhedral features; the polyhedral features include iteration space, scheduling information and memory access mapping information;

[0009] (3) Based on the polyhedral feature information, find the optimal schedule for the code of the static control unit and add legality constraints, linear independence constraints, block constraints and vectorization constraints; then simplify the cross-dimensional vectorization constraints by approximating them to each dimension and splitting them into hierarchical constraints.

[0010] (4) For the system of inequality equations consisting of all constraints, the integer linear programming tool is used to solve the problem based on the pre-set objective function, and the scheduling solution of the static control segment is obtained.

[0011] (5) Based on the scheduling solution obtained in step (4), and combined with the polyhedral feature information of the input code, the source code representation is regenerated from the intermediate polyhedral representation.

[0012] Furthermore, in step (3), the cross-dimensional vectorized constraint is the innermost continuous vectorized constraint; the hierarchical constraint is specifically divided into three categories according to the dimension it is in, including the innermost layer, the next innermost layer, and others.

[0013] Furthermore, step (4) includes the following sub-steps:

[0014] (4.1) Perform dependency analysis based on the input code and maintain a global dependency graph;

[0015] (4.2) In the process of solving each dimension, construct an integer linear programming problem based on the dimension information, traverse all unsatisfied dependencies, check the source and destination statements of the dependencies, and then decide whether to add vectorized hierarchical constraints based on the nested loop depth and vectorization state of the statement.

[0016] (4.3) After solving each dimension, update the global dependency graph and mark the dependencies that the current dimension scheduling satisfies;

[0017] (4.4) Use an iterative method to synchronize global information and search for feasible scheduling solutions; assume that the current statement is vectorizable in each iteration and determine its final state based on whether there is a solution in the current iteration; obtain the optimal solution after iterating through all statements;

[0018] (4.5) Use the optimal solution obtained in step (4.4) as the final vectorized scheduling transformation.

[0019] Furthermore, in step (4.2), the construction of the integer linear programming problem requires analyzing the information of each statement; when a statement is set to need to be vectorized in the global state, different hierarchical constraints are added according to its dimension.

[0020] Compared with existing technologies, the beneficial effects of this invention are: This invention can expand the vectorization solution space of existing polyhedral vectorization techniques and effectively improve the compilation efficiency of polyhedral vectorization compilers. Existing polyhedral-based vectorization techniques only support coarse-grained vectorization of dependent statements at the innermost loop level, lacking support for fine-grained vectorized constraint modeling and code scheduling for statements with data dependencies, thus reducing the vectorization solution space. Meanwhile, current integer linear programming algorithms have exponential complexity; as the number of constraints and unknowns in the problem increases, the solution time also increases exponentially. This invention uses a hierarchical iterative approach to solve cross-dimensional vectorized constraints, breaking down large-scale problems into multiple smaller-scale integer linear programming problems, and effectively reducing the number of iterations by combining dependency-based iteration, avoiding the problems of large problem size and long solution time caused by overall solution; compared with methods using cross-dimensional constraints and overall solution, it can achieve up to 140 times improvement in compilation efficiency. Attached Figure Description

[0021] Figure 1 This is a flowchart of the polyhedron compiler process;

[0022] Figure 2 This is a schematic diagram illustrating the implementation process of the vectorized scheduling solution method for polyhedra based on iterative layering according to the present invention. Detailed Implementation

[0023] The present invention will now be described in detail with reference to the accompanying drawings. Unless otherwise specified, the features of the following embodiments and implementations can be combined with each other.

[0024] This invention replaces the overall solution approach with a hierarchical solution method, proposing a polyhedron vectorized scheduling solution method based on iterative hierarchical solution. It decomposes cross-dimensional constraints into hierarchical constraints and uses an iterative method to solve the dependencies between layers. It solves integer linear programming problems with cross-dimensional constraints through multiple small-scale solutions, thereby improving the compilation efficiency of the polyhedron vectorized compiler and expanding its application scenarios.

[0025] like Figure 1As shown, the general processing flow of a polyhedron compiler can be mainly divided into three stages: abstraction analysis, scheduling transformation, and code generation. This invention's polyhedron vectorization compiler adds vectorization constraints and related processing to this foundation. Based on the pre-compilation directives provided by the user in the input code, it optimizes the multiple nested loop code.

[0026] This invention provides a vectorized scheduling solution method for polyhedra based on iterative hierarchical layering, such as... Figure 2 As shown, it includes the following steps:

[0027] (1) Front-end analysis: The compiler performs lexical and syntactic analysis on the input code, parses the identifiers and meanings of each symbol in the input code, finds the static control part (SCoP) identified by the user, and adds it to the candidate optimization list. Specifically, the static control part (SCoP) is a nested loop code segment in the input code wrapped by the user using pre-compiled identifiers.

[0028] (2) Abstraction analysis: Dependency analysis is performed on the static control unit in the candidate optimization list to extract polyhedral features. The polyhedral feature information includes iteration space, scheduling information and memory access mapping; the statement examples under nested loops are abstracted into spatial polyhedra under boundary constraints.

[0029] (3) Constraint Construction: Based on the polyhedral feature information, the optimal schedule is found for the code of the static control unit. During this process, legality constraints need to be added to ensure that the semantics of the code remain unchanged before and after scheduling. In addition, other constraints, such as linear independence constraints, block constraints, and vectorization constraints, are added to ensure the correctness and better performance of the scheduled code. The cross-dimensional vectorized constraints are simplified by approximating them across various dimensions, breaking them down into hierarchical constraints. Specifically: d represents the nested loop depth of the analyzed statement, and j is the index of the unknown scheduling coefficient.

[0030] (3.1) When the solution dimension k is less than d-1, add constraint Θ to the scheduling coefficient. k,j ≥0;

[0031] (3.2) When solving for dimension k equals d-1, iterate through the d-2 coefficients corresponding to the previously obtained dimensions; if there is a non-zero coefficient, add constraint Θ. k,h ≥0, otherwise add constraint Θ k,j ≥1.

[0032] Furthermore, in step (3), the cross-dimensional vectorization constraint is the innermost continuous vectorization constraint; the hierarchical constraint is divided into three categories according to the specific dimension it is in, including the innermost layer, the next innermost layer, and others.

[0033] (4) Scheduling Solution: For the system of inequality equations formed by all constraints, the scheduling solution of the static control unit is obtained by using integer linear programming tools based on the pre-set objective function of the integer linear programming problem. Specifically:

[0034] (4.1) Perform dependency analysis based on the input code and maintain a global dependency graph.

[0035] (4.2) During the solution process for each dimension, an integer linear programming (ILP) problem is constructed based on the dimension information. All unsatisfied dependencies are traversed, and the source and destination statements of the dependencies are checked. Then, based on the nesting depth of the statement and the vectorization state, it is determined whether to add vectorized hierarchical constraints. The construction of the integer linear programming (ILP) problem requires the analysis of information for each statement. When a statement is set to need to be vectorized in the global state, different hierarchical constraints are added based on its dimension.

[0036] (4.3) After solving each dimension, update the global dependency graph and mark the dependencies satisfied by the current dimension's scheduling. Ideally, each statement is analyzed separately in each dimension, thus allowing for more granular information analysis and scheduling compared to the global solution method.

[0037] (4.4) The iterative method is used to synchronize global information and search for feasible scheduling solutions. To reduce the iteration complexity from exponential to linear, the method of this invention combines dependency graphs to analyze the vectorization of each statement; the vectorization relationship between statements can be continuously divided into multiple independent strongly connected components (SCCs) for vectorization analysis as the dependencies in the solution dimension are satisfied. Due to the dependency relationship, the vectorization relationship of the statement also corresponds to a series of SCCs in the dependency graph. By dividing the SCCs, the vectorization state of the statement can be divided into independent groups during the hierarchical solution process. Therefore, in each iteration, the current statement is assumed to be vectorizable, and its final state is determined based on whether there is a solution in the current iteration; the optimal solution is obtained after iterating through all statements.

[0038] (4.5) Use the optimal solution obtained in step (4.4) as the final vectorized scheduling transformation.

[0039] (5) Code generation: Based on the scheduling solution obtained in step (4), the code generation module combines the iterative space, scheduling information and memory access mapping and other polyhedral feature information abstracted from the input code to regenerate the source code representation from the polyhedral intermediate representation.

[0040] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

[0041] The above embodiments are only used to illustrate the design concept and features of the present invention, and their purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, all equivalent changes or modifications made based on the principles and design ideas disclosed in the present invention are within the protection scope of the present invention.

Claims

1. A vectorized scheduling solution method for polyhedra based on iterative hierarchical layering, characterized in that, Includes the following steps: (1) The compiler performs lexical analysis and syntax analysis on the input code, parses the identifiers and meanings of each symbol in the input code, finds the static control unit identified by the user, and adds it to the candidate optimization list; (2) Perform dependency analysis on the static control units in the candidate optimization list and extract their polyhedral features; the polyhedral features include iteration space, scheduling information and memory access mapping information; (3) Based on the polyhedral feature information, find the optimal schedule for the code of the static control unit and add legality constraints, linear independence constraints, block constraints and vectorization constraints; then simplify the cross-dimensional vectorization constraints by approximating them to each dimension and splitting them into hierarchical constraints; the cross-dimensional vectorization constraints are the innermost continuous vectorization constraints; the hierarchical constraints are divided into three categories according to the dimension they are in, including the innermost layer, the second innermost layer and others; (4) For the system of inequality equations consisting of all constraints, the integer linear programming tool is used to solve the problem based on the pre-set objective function, and the scheduling solution of the static control segment is obtained. (4.1) Perform dependency analysis based on the input code and maintain a global dependency graph; (4.2) In the process of solving each dimension, construct an integer linear programming problem based on the dimension information, traverse all unsatisfied dependencies, check the source and destination statements of the dependencies, and then decide whether to add vectorized hierarchical constraints based on the nested loop depth and vectorization state of the statement. (4.3) After solving each dimension, update the global dependency graph and mark the dependencies that the current dimension scheduling satisfies; (4.4) Use an iterative method to synchronize global information and search for feasible scheduling solutions; assume that the current statement is vectorizable in each iteration and determine its final state based on whether there is a solution in the current iteration; obtain the optimal solution after iterating through all statements; (4.5) Use the optimal solution obtained in step (4.4) as the final vectorized scheduling transformation; (5) Based on the scheduling solution obtained in step (4), and combined with the polyhedral feature information of the input code, the source code representation is regenerated from the intermediate polyhedral representation.

2. The polyhedron vectorized scheduling solution method based on iterative hierarchical layering according to claim 1, characterized in that, In step (4.2), the construction of the integer linear programming problem requires analysis of each statement information; when a statement is set to need to be vectorized in the global state, different hierarchical constraints are added according to its dimension.