Multi-granularity data flow compiling system and data flow diagram compiling method

By providing multiple data flow guidance interfaces in the programming language library, supporting multi-grained parallel programming of tasks, loops and instructions, the problems of data flow programming in the prior art cannot effectively describe data dependence within operators and lack of fine-grained parallelism, and efficient program performance and hardware utilization improvement are achieved.

CN120122956APending Publication Date: 2025-06-10INST OF COMPUTING TECH CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510228404.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-28
Publication Date
2025-06-10

AI Technical Summary

Technical Problem

The prior art cannot effectively describe data dependence in operators in data flow programming, resulting in limited improvement in operator parallel performance and lack of programming interfaces such as fine-grained parallelism and control flow conversion, which affects program performance and hardware utilization.

Method used

A multi-grained data flow compilation system is proposed, and a variety of data flow guidance interfaces are provided through the programming language library, including inter-task data flow guidance interface, task priority guidance interface, hardware binding guidance interface, circular block data flow guidance interface, instruction data flow guidance interface and control flow conversion guidance interface, supporting multi-grained parallel programming of tasks, loops and instructions.

Benefits of technology

It realizes the parallelism of program execution from the multi-grained level of tasks, loops and instructions, provides a programming interface for converting if control flow into data flow, fully expresses the parallel characteristics of the application and task priority, and comprehensively improves program performance and hardware utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120122956A_ABST
    Figure CN120122956A_ABST
Patent Text Reader

Abstract

The invention provides a design scheme of a multi-granularity data flow compiling system, which only needs to carry out data flow guidance interface expansion on a programming language and add corresponding data dependence description in an original program code so as to configure data dependence among tasks, task priorities, binding of the tasks and hardware, and data dependence relationships among iterations and instructions. Task parallelism, loop parallelism and instruction parallelism are achieved, program execution parallelism is improved from the task, loop and instruction multi-granularity level, meanwhile, a programming interface for converting if control flow into data flow is provided in the scheme and used for reducing composition overhead, exposing more parallel opportunities and improving program execution efficiency. According to the method, the parallel characteristic, the task priority and the task mapping optimization scheme of the application can be fully expressed, so that the program performance and the hardware utilization rate are comprehensively improved, in addition, compared with an existing data flow programming method, the method does not need to greatly change original codes, and the usability is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer compilation technology. Specifically, it relates to the field of data flow compilation technology. More specifically, it relates to a multi-granularity data flow compilation system and a data flow graph compilation method. Background Art

[0002] In the current process of chip technology development, chip processes face many limitations, making it difficult for computer systems to significantly improve performance by simply increasing the main frequency. Against this background, multi-core parallel systems have gradually become a key approach to enhancing program performance. Whether it is a single-node multi-core architecture or a complex system composed of multiple nodes or clusters, they all rely on the parallel execution mechanism of programs to achieve performance improvement. In these systems, an efficient computing and processing method is particularly crucial. The data flow graph is an efficient parallel computing method based on data flow, where its nodes represent various computing tasks, and the edges of the data flow graph clearly represent the data dependency relationships between two nodes. Data is transmitted along the edges from one computing node to another. When a computing node receives the required data and has hardware resources available for allocation, the node can immediately initiate the computing task. Based on the advantages of the data flow graph, a series of data flow programming methods have been successively proposed in the industry. These methods enable users to simply focus on describing the dependency relationships between data during the programming process, without having to deeply understand the complex details of the underlying hardware and the specific implementation methods of computing tasks, and can easily complete the programming work and successfully achieve the parallel execution of the program, thereby effectively improving the overall performance of the system.

[0003] In the current technology, there are mainly two mainstream dataflow programming methods. One is the method of coarse-grained dataflow programming using the TensorFlow machine learning framework. The dataflow graph constructed by this method can only describe the dependencies between operators and cannot describe the data dependencies within an operator. This operator-level parallelism as the source of parallelism not only has limited improvement in program performance, but also for practical applications, the number of operators that can run independently on hardware is limited and cannot increase with the increase in data scale. Moreover, the sizes of tasks are usually not equal, making it difficult to ensure that all processors are always busy. In addition, for the loop operations within an operator, the number of loop iterations will increase with the increase in data, and the loop parallelism will also increase. The other is the CoStream dataflow programming method obtained by extending C language with dataflow. This method is designed by combining the dataflow programming model on the basis of C language. It converts a C language program into a program that conforms to the CoStream syntax rules and has high execution efficiency, but requires major modifications to the program. When there are multiple independent operators in the dataflow graph that can be scheduled simultaneously while the hardware resources are limited, scheduling the operators on the critical path of the schedule or the operators with data locality between operators can obtain better performance benefits, but the CoStream interface does not provide an interface for describing the operator priority. For a heterogeneous distributed system composed of multiple different processors (such as CPUs, GPUs, DPUs, etc.), each computing node is good at processing different applications. CoStream does not provide an interface for binding tasks to hardware and cannot specify the hardware to which the task is mapped during programming. For those scenarios that require finer-grained parallelism, such as parallelism between instructions, CoStream also does not provide the corresponding programming interface. In addition, for loops with if control flow in the loop, no programming interface for converting the control flow into a data flow is provided. Therefore, the data flow semantics expression of CoStream is not perfect, which will affect the parallel performance of the program.

[0004] In summary, the existing technologies mainly have the following problems. Since the coarse-grained dataflow programming method represented by TensorFlow cannot describe the data dependencies within an operator, relying on operator-level parallelism to improve performance is limited and restricted by hardware, making it difficult to fully utilize the advantages of loop blocking parallelism. Although CoStream extends C language with dataflow, it requires major modifications to the original program. At the same time, it also lacks programming interfaces for describing operator priority, task-hardware binding, fine-grained parallelism, and control flow conversion, resulting in problems such as limited improvement in program performance, low hardware utilization, and insufficient programming flexibility, thus unable to meet the diverse dataflow programming requirements. Therefore, there is an urgent need for a dataflow programming method that provides multi-granularity programming interfaces and supports converting if control flow into data flow, task priority configuration, and hardware binding.

[0005] It should be noted that: This background technology is only used to introduce relevant information of the present invention to facilitate understanding of the technical solution of the present invention, but it does not necessarily mean that the relevant information is prior art. Without evidence indicating that the relevant information was made public before the filing date of the present invention, the relevant information should not be regarded as prior art. Summary of the Invention

[0006] Therefore, the object of the present invention is to overcome the defects of the above-mentioned prior art and provide a multi-granularity data flow compilation system and a data flow graph compilation method.

[0007] The object of the present invention is achieved by the following technical solutions:

[0008] According to a first aspect of the present invention, a multi-granularity data flow compilation system is proposed. The system includes a programming language library and a compiler. The programming language library is used to provide programming interfaces and definitions of programming interfaces for program codes. The compiler is used to parse the data flow relationships in the program codes and construct a data flow graph based on this. Among them, the programming language library is configured with a variety of data flow guidance interfaces and definitions of each data flow guidance interface. Among them, the variety of data flow guidance interfaces include an inter-task data flow guidance interface, a task priority guidance interface, a hardware binding guidance interface, a loop block data flow guidance interface, an instruction data flow guidance interface, and a control flow conversion guidance interface. The compiler is a compiler that supports programming guidance technology, and is configured with parsing functions for parsing all data flow guidance interfaces in the programming language library. Among them, the parsing functions are used to parse the data flow guidance interfaces in the program codes to obtain the data flow relationships in the program codes.

[0009] Preferably, each data flow guidance interface is a programming interface extended based on programming guidance technology.

[0010] Preferably, the inter-task data flow guidance interface is used to construct the data flow relationship between task codes.

[0011] Preferably, the task priority guidance interface is used to configure the execution priority of task codes.

[0012] Preferably, the hardware binding guidance interface is used to configure the binding relationship between task codes and hardware.

[0013] Preferably, the loop block data flow guidance interface is used to split loop codes into multiple code blocks that are executed in parallel and construct the data flow dependency relationship between all code blocks.

[0014] Preferably, the instruction data flow guidance interface is used to establish the mapping between instruction codes and hardware instructions.

[0015] Preferably, the control flow conversion guidance interface is used to convert if control flow codes into data flows.

[0016] According to a second aspect of the present invention, there is provided a data flow graph compilation method based on any one of the multi-granularity data flow compilation systems in the first aspect of the present invention. The method is used to guide the modification of a specified program code and construct a data flow graph based on the modified program code. The method includes: Step S1, modifying the specified program code in a preset manner based on a programming language extension library, where the specified program code includes: task code, loop code, instruction code, and / or if control flow code; Step S2, compiling the modified program code into a program flow graph by using the multi-granularity data flow compilation system.

[0017] Preferably, the preset manner includes: modifying each piece of task code in the specified program code in the following manner: adding an inter-task data flow guidance interface to the task code, and configuring the parameters of the inter-task data flow guidance interface based on the data dependency relationship between the task code block and other task code blocks; adding a task priority guidance interface to the task code block, and configuring the parameters of the task priority guidance interface based on the execution priority of the task code; adding a hardware binding guidance interface to the task code, and configuring the parameters of the hardware binding guidance interface based on the hardware information for executing the task code; modifying the loop code in the specified program code in the following manner: adding a program block data flow guidance interface to the loop code, and configuring the parameters of the data flow guidance interface according to the data flow of the loop code and the user's requirement for splitting the loop code; modifying each piece of instruction code in the specified program code in the following manner: configuring the parameters of the instruction data flow guidance interface based on the operation parameters of the instruction code, the address information of the operation parameters, and the instruction type, and replacing the instruction code with the data flow guidance interface with the configured parameters; modifying each piece of if control flow code in the specified program code in the following manner: configuring the parameters of the control flow conversion guidance interface based on the conditional judgment statement and the branch execution statement of the if control flow code, and replacing the instruction code with the data flow control conversion guidance interface with the configured parameters.

[0018] Compared with the prior art, the advantages of the present invention are:

[0019] The present invention proposes a design scheme for a multi-granularity data stream programming system. This scheme only needs to extend the data stream guidance interface for the programming language and add corresponding data dependency descriptions to the original program code to configure the data dependencies between tasks, task priorities, task binding to hardware, data dependencies between iterations and instructions, so as to achieve task parallelism, loop parallelism and instruction parallelism, and improve the parallelism of program execution from multiple granularity levels of tasks, loops and instructions. At the same time, this scheme provides a programming interface for converting if control flow into data flow, which is used to reduce the composition overhead and expose more parallel opportunities, and can fully express the parallel characteristics, task priorities and task mapping optimization schemes of the application, thus comprehensively improving the program performance and hardware utilization rate. In addition, compared with the existing data stream programming methods, this method does not need to make major changes to the original code and has high usability. Description of the Drawings

[0020] The embodiments of the present invention will be further described below with reference to the accompanying drawings, where:

[0021] Figure 1 It is a pseudo-code example diagram of the data stream guidance interface between tasks according to an embodiment of the present invention;

[0022] Figure 2 It is a pseudo-code example diagram of the task priority guidance interface according to an embodiment of the present invention;

[0023] Figure 3 It is a pseudo-code example diagram of the hardware binding guidance interface according to an embodiment of the present invention;

[0024] Figure 4 It is a pseudo-code example diagram of the data stream guidance interface of the loop block according to an embodiment of the present invention;

[0025] Figure 5 It is a pseudo-code example diagram of the instruction data stream guidance interface according to an embodiment of the present invention;

[0026] Figure 6 It is a pseudo-code example diagram of the control flow conversion guidance interface according to an embodiment of the present invention;

[0027] Figure 7 It is an example diagram of the data stream graph compilation method according to an embodiment of the present invention;

[0028] Figure 8 It is a pseudo-code example diagram of configuring the data stream guidance interface between tasks according to an embodiment of the present invention;

[0029] Figure 9 It is an example diagram of the data stream after configuring the data stream guidance interface between tasks according to an embodiment of the present invention;

[0030] Figure 10Pseudo-code example diagram for configuring task priority guidance interface according to an embodiment of the present invention;

[0031] Figure 11 Pseudo-code for configuring hardware binding guidance interface according to an embodiment of the present invention;

[0032] Figure 12 Pseudo-code example diagram for configuring loop block data flow guidance interface according to an embodiment of the present invention;

[0033] Figure 13 Diagram for splitting example of loop code according to an embodiment of the present invention;

[0034] Figure 14 Pseudo-code example diagram for configuring instruction data flow guidance interface according to an embodiment of the present invention;

[0035] Figure 15 Diagram for instruction data flow example according to an embodiment of the present invention;

[0036] Figure 16 Pseudo-code example diagram for configuring control flow conversion guidance interface according to an embodiment of the present invention. Detailed implementation manners

[0037] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below through specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0038] As mentioned in the background art section, the existing technologies mainly have the following problems: Since the coarse-grained data flow programming method represented by TensorFlow cannot describe the data dependencies within operators, relying on operator-level parallelism to improve performance is limited and restricted by hardware, and it is difficult to fully utilize the advantages of loop block parallelism. Although CoStream performs data flow extension on C language, it requires substantial modification of the original program. In addition, CoStream also lacks functions such as describing operator priorities, task and hardware binding, fine-grained parallelism, and control flow conversion, resulting in problems such as limited improvement in program performance, low hardware utilization, and insufficient programming flexibility, and thus unable to meet the diverse data flow programming requirements.

[0039] To solve the above problems, the present invention proposes a design scheme for a multi-granularity data flow compilation system. This scheme only needs to perform guidance extension on the programming language and add corresponding data dependency descriptions to the original program code to configure the data dependencies between tasks, task priorities, task-to-hardware binding, data dependencies between iterations and instructions, so as to achieve task parallelism, loop parallelism and instruction parallelism, and improve the parallelism of program execution from the multi-granularity levels of tasks, loops and instructions. At the same time, this scheme provides a programming method for converting the if control flow into a data flow to reduce the graph construction overhead and expose more parallel opportunities, and can fully express the parallel characteristics, task priorities and task mapping optimization schemes of the application, thereby comprehensively improving the program performance and hardware utilization rate. In the embodiments of the present invention, C language is taken as an example for description, and other programming languages are similar.

[0040] To better understand the present invention, the following will specifically describe the present invention in conjunction with specific embodiments.

[0041] It should be noted that the purpose of this scheme is to propose a design scheme for a multi-granularity data flow compilation system applicable to various programming languages, and there is no limitation on the programming language used to write the program code. The programming language used can be C language or other programming languages. When the present invention describes specific embodiments, C language is used for description. The design scheme of the multi-granularity data flow compilation system implemented by other programming languages is similar and will not be repeated.

[0042] According to an embodiment of the present invention, the present invention proposes a multi-granularity data flow compilation system, which aims to provide a program compilation platform for users to compile specified program code into a data flow graph. Among them, the multi-granularity data flow compilation system includes a programming language library and a compiler. The programming language library provides a programming interface and the definition of the programming interface for the program code, and the compiler is used to parse the data flow relationship in the program code and construct a data flow graph based on this.

[0043] According to an embodiment of the present invention, the present invention uses programming guidance technology to extend the guiding semantics of the programming language library, so that the programming language library includes a variety of data flow guiding interfaces and the definition of each data flow guiding interface. Among them, the variety of data flow guiding interfaces include inter-task data flow guiding interfaces, task priority guiding interfaces, hardware binding guiding interfaces, loop block data flow guiding interfaces, instruction data flow guiding interfaces and control flow conversion guiding interfaces. These data flow guiding interfaces are used to be configured in the program code to describe the data dependencies at the task level, program block level and instruction level. When users write data flow code, they only need to add guiding statements representing data dependencies to the original program code to implement multi-granularity data flow programming. Compared with the prior art, the programming interface is simple and has high usability.

[0044] According to an embodiment of the present invention, the compiler adopted by the present invention is a compiler that supports programming guidance technology. In addition, the present invention also expands the functions of the compiler. Specifically, parsing functions corresponding to the data flow guidance interfaces in the programming language library are added to the compiler, so that the compiler has the function of parsing the data flow guidance interfaces in the program code and obtaining the data flow relationships in the program code.

[0045] To facilitate the understanding of the data flow guidance interfaces in the present invention and the parsing functions configured in the compiler for parsing each data flow guidance function, the inter-task data flow guidance interface, the task priority guidance interface, the hardware binding guidance interface, the loop block data flow guidance interface, the instruction data flow guidance interface, the control flow conversion guidance interface, and the parsing functions corresponding to each data flow guidance function will be described below with reference to the accompanying drawings in sequence.

[0046] The pseudo-code of the inter-task data flow programming interface is as Figure 1 shown. In the pseudo-code of the inter-task data flow programming interface shown in the figure, "#pragma task‘(’task_name‘)’" is the interface for configuring the task name of the current task code, and "#pragma dependence‘(’task_list‘)’" is the interface for configuring other tasks on which the current task code depends. Among them, task_list = task_name [,task_name]*, and the parameter "task_list" is the task list. "#pragmatask_end" is the instruction indicating the end of the current task and is placed at the end of the task code. The parsing functions corresponding to the inter-task data flow programming interface include "ParsetaskStatement()", "ParsedependenceStatement()", and "ParsetaskendStatement()". The compiler has pre-implemented the functions of these parsing functions, and these parsing functions are used to process the task names and task dependency relationship information in the parentheses of the inter-task data flow programming interface to obtain the inter-task dependency relationship and store the dependency relationship information into "std::map<string, std::vector <string>> For the "task_dependence" variable, when the compiler backend analyzes tasks, it reads the "task_dependence" variable and generates a data flow graph between tasks.

[0047] The pseudocode of the task priority guidance interface is as follows Figure 2 shown. In the figure, "#pragma priority ‘(’level,task_name‘)’" is the definition of the task priority guidance interface. Among them, "level" is the priority parameter, and "task_name" is the name of the task for which the priority needs to be configured. The parsing function corresponding to the task priority guidance interface is "ParsepriorityStatement()". The compiler has pre-implemented the function of this parsing function. This parsing function is used to process the task priority information in the parentheses of the task priority guidance interface, and store the task name and the corresponding priority in the "std::map<string, int>task_priority" variable for subsequent task scheduling.

[0048] The pseudocode of the hardware binding guidance interface is as follows Figure 3 shown. In the figure, "#pragma bind‘(’target,task_name‘)’" is the definition of the task priority guidance interface. Among them, "target" is the hardware information, and "task_name" is the name of the task that needs to be bound to the hardware. The parsing function corresponding to the hardware binding guidance interface is "ParsebindStatement()". The compiler has pre-implemented the function of this parsing function. This parsing function is used to process the task and the corresponding hardware information in the parentheses of the task priority guidance interface, and store the task name and the hardware information in the "std::map<string,string>task_bind" variable for subsequent task scheduling.

[0049] The pseudocode of the loop block data flow guidance interface is as follows Figure 4 As shown, in the pseudocode of the inter-task data flow programming interface shown in the figure, "#pragma basic_block" is usually added at the very front of the loop code to indicate the starting point of the loop code. "#pragma loop_split ‘(‘ loop_var: expr [,loop_var: expr]* ’)’" is the interface for configuring the loop code block splitting parameters. Multiple "loop_var: expr" parameters can be configured in this interface, and each "loop_var:expr" parameter indicates splitting the loop_var-th layer loop of the loop code into expr blocks. "#pragma read ‘(’var_list‘)’" is the interface for configuring the read variables in the loop code, and "var_list" in this interface represents the variables that read data in the loop code. "#pragma write ‘(’var_list‘)’" is the interface for configuring the write variables in the loop code, and "var_list" in this interface represents the variables that write data in the loop code. "#pragma basic_block_end" is usually added at the very end of the loop code to indicate the end point of the loop code. The parsing functions corresponding to the loop block data flow guidance interface include "ParsebasicblockStatement()", "ParseloopsplitStatement()", "ParsereadStatement()", "ParsewriteStatement()", "ParsebasicblockendStatement()". The compiler has pre-implemented the functions of these parsing functions, and these parsing functions are used to process the loop segmentation and variable read / write information in the parentheses of the loop block data flow guidance interface to obtain the data read / write relationship of the program block, and store the obtained read / write relationship into "std::map<string, std::map<string,std::vector <int>>> The compiler subsequently reads the "date_region" and "read_write" variables when analyzing the loop code, analyzes the data dependence relationship between loop blocks, and generates a data flow graph.

[0050] The pseudo-code of the instruction data flow guidance interface is as Figure 5 shown. The first line in the figure "#pragma inst ‘(‘inst_kind, array_name‘(‘dim_list’)’[,array_name ‘(‘dim_list’)’]*’)’ is the pseudo-code of the instruction data flow guidance interface, where "inst_kind" represents the hardware instruction, "array_name" represents the name of the operation parameter, and "dim_list" represents the address information of the operand. The parsing function corresponding to the instruction data flow guidance interface is "ParseinstStatement()". The compiler has pre-implemented the function of this parsing function, which is used for the instruction information in the parentheses of the instruction data flow guidance interface, generates an "intrinsic" function, and maps the "intrinsic" function to the hardware-supported instruction during the instruction generation stage.

[0051] The pseudo-code of the control flow conversion guidance interface is as Figure 6 As shown, the first line in the figure "#pragma condition‘(‘nodename,condition,branch[,branch]*’)’” is the definition of the instruction data flow guidance interface. Among them, "condition” is the judgment result of the conditional judgment statement in the if judgment statement. For example, in "if(a>b)”, the judgment result of "a>b”. "nodename” is the parameter used to receive the branch calculation result. "condition” is the result obtained by performing the operations under the branch where the judgment result is true. "branch” is the result obtained by performing the operations under the branches corresponding to other judgment results. Multiple "branch” parameters can be configured to apply to different types of if judgment statements. It should be understood that the if judgment statements in the program code include judgment statements with only one "else” participating, that is, binary conditional judgment statements with only two branches of true and false, and also multi-branch conditional judgment statements with multiple "else” participating. The parsing function corresponding to the control flow conversion guidance interface is "ParseconditionStatement()”. The compiler has pre-implemented the function of this parsing function. This parsing function is used for the conditional execution information in the parentheses of the control flow conversion guidance interface to generate an "intrinsic” function. In the instruction generation stage, corresponding conditional execution instructions are generated.

[0052] According to an embodiment of the present invention, based on the multi-granularity data flow compilation system, the present invention proposes a data flow graph compilation method for guiding the modification of specified program code and constructing a data flow graph based on the modified program code, as Figure 7 shown. The method shown in the figure includes: Step S1, modifying the specified program code in a preset manner based on the programming language extension library, where the specified program code includes: task code, loop code, instruction code, and / or if control flow code; Step S2, compiling the modified program code into a program flow graph using the multi-granularity data flow compilation system.

[0053] According to an embodiment of the present invention, in Step S1, the user configures the corresponding data flow guidance interface in the task code, loop code, instruction code, and / or if control flow code of the specified program code based on a preset method, and configures the data flow guidance interface based on the functions implemented by the code and the data dependency relationship between the codes, so as to modify the specified program code into data flow code without modifying the main structure of the original program code during the modification, so as to achieve low-cost multi-granularity data flow programming.

[0054] To facilitate understanding of the way of configuring the data flow guidance interface of the present invention, the following will classify according to the code types in the program code and describe the ways of configuring the data flow interface in the task code, loop code, instruction code, and if control flow code respectively.

[0055] I. Configuration Method of Data Flow Interface in Task Code

[0056] According to an embodiment of the present invention, in the present invention, an inter-task data flow guidance interface is added to the task code, and the parameters of the inter-task data flow guidance interface are configured based on the data dependency relationship between the task code blocks and other task code blocks. A task priority guidance interface is added to the task code block, and the parameters of the task priority guidance interface are configured based on the execution priority of the task code. A hardware binding guidance interface is added to the task code, and the parameters of the hardware binding guidance interface are configured based on the hardware information for executing the task code. Among them, the inter-task data flow programming interface is used to construct the data flow relationship between task codes, the task priority guidance interface is used to configure the execution priority of the task code, and the hardware binding guidance interface is used to configure the binding relationship between the task code and the hardware. The above three data flow interfaces are used to implement the data flow configuration at the task level in the program code. To facilitate the understanding of the method for configuring the data flow interface in the task code, the configuration methods of the inter-task data flow programming interface, the task priority guidance interface, and the hardware binding guidance interface will be described below through Example 1, Example 2, and Example 3 in sequence.

[0057] Example 1. Inter-task Data Flow Programming Interface

[0058] The configuration method of the inter-task data flow programming interface will be described in detail below in combination with a piece of pseudo-code. The pseudo-code is as Figure 8 shown. The figure shows the pseudo-code for adding an inter-task data flow programming interface to the "Sigmoid" task and the "Mul" task. Among them, lines 5 to 10 are the pseudo-code for adding an inter-task data flow programming interface to the "Sigmoid" task, and lines 12 to 17 are the pseudo-code for adding an inter-task data flow programming interface to the "Mul" task. Regarding the "Sigmoid" task, this task depends on the "Conv" task, that is, the "Sigmoid" task depends on the data in the "Conv" task during execution, and the "Mul" task depends on the "Sigmoid" task, that is, the "Mul" task depends on the data in the "Sigmoid" task during execution. During the compilation of the compiler, the compiler can obtain the data flow diagrams of the three tasks by parsing the data dependency relationship between the "Conv" task, the "Sigmoid" task, and the "Mul" task. Figure 9 shown. The data flow of the "Conv" task shown in the figure points to the "Sigmoid" task and the "Mul" task respectively, and the data flow of the "Sigmoid" task points to the "Mul" task.

[0059] Example 2. Task Priority Guidance Interface

[0060] To better understand the way of adding a task priority guidance interface in the program code of the present invention, the configuration method of the task priority guidance interface will be described in detail below in combination with a piece of pseudocode, as Figure 10 shown, the figure shows the pseudocode for configuring the task priority guidance interface for the task code "Sigmiod". It can be seen from the third line of code that the priority of the "Sigmiod" task code is configured as "1". During the execution of the program code, when the "Sigmiod" task code is executed, it will follow the setting standard with a priority of "1".

[0061] Example 3: Hardware binding guidance interface

[0062] To better understand the way of adding a hardware binding guidance interface in the program code of the present invention, it will be described in detail below in combination with a piece of pseudocode, as Figure 11 shown, the figure shows the pseudocode for adding a hardware binding guidance interface in the task code "Sigmiod". It can be seen from the fourth line of code that the "Sigmiod" task code is bound to the "GPU" hardware so that the "Sigmiod" task code can only be executed on the hardware referred to by "GPU".

[0063] II. Configuration method of data flow guidance interface in loop code

[0064] According to an embodiment of the present invention, in the present invention, a program block data flow guidance interface is added to the loop code of the specified program code, and the parameters of the data flow guidance interface are configured according to the data flow of the loop code and the user's requirement for splitting the loop code, so as to split the loop code into multiple loop code blocks that can be executed in parallel, and realize the data flow configuration at the program block level in the program code. To facilitate understanding of the configuration method of the loop block data flow guidance interface in the loop code, it will be described below in combination with Example 4.

[0065] Example 4

[0066] To better understand the way of adding the parameters of the loop block data flow guidance interface in the program code of the present invention, the configuration method of the loop block data flow guidance interface will be described in detail below in combination with a piece of pseudocode, and the pseudocode is as Figure 12 As shown, this section of pseudocode demonstrates the configuration method of splitting the three-layer for loop code into 4 loop blocks. Specifically, it can be seen from the code lines 6 to 12 in the figure that this section of code includes three layers of loops. Among them, in each loop, the code line 9 "compute[i1][i2][i3]=(1.000000e + 00f / (1.000000e + 00f + expf((0.000000e +00f - p0[i1][i2][i3]))))” is executed. The main function of this line of code is to first read the data in the P0 array and perform corresponding calculations, and then write the calculation results into the compute array. In the lines 2 to 5 of the pseudocode in the figure, the "#pragma read‘(’var_list‘)’” interface is configured as "#pragma read(p0)”, and the "#pragma write ‘(’var_list‘)‘” interface is configured as "#pragma write(compute)” to configure the read and write parameters of the loop code. At the same time, the "#pragma loop_split ’(‘ loop_var: expr [,loop_var: expr]* ’)’” interface is configured as "#pragma loop_split(i1:4,i2:1,i3:1)” to achieve the function of splitting the outermost loop into four parts and not splitting the inner loops. Finally, four loop blocks are obtained. The split loop blocks are as Figure 13 shown. The four loop blocks shown in the figure respectively execute 1 / 4 of the calculation operations in the original loop code. Splitting the loop code into multiple loop blocks and executing them in parallel can effectively improve the parallelism of the code execution, thereby improving the code running efficiency.

[0067] III. Configuration Method of Data Flow Guided Interface in Instruction Code

[0068] According to an embodiment of the present invention, in the present invention, based on the operation parameters, address information of the operation parameters, and instruction type in the instruction code of the specified program code, the parameters of the instruction data flow guided interface are configured, and the instruction code in the specified program code is replaced with the data flow guided interface with the configured parameters to convert the instruction code into the corresponding hardware instruction during compilation. To facilitate understanding of the method of configuring the instruction data flow guided interface in the instruction code, the following will be described in combination with Example 5.

[0069] Example 5

[0070] The pseudocode for configuring the parameters of the instruction data flow guided interface is as Figure 14 As shown, the code from line 1 to line 6 in the figure shows the instruction code written in C language. It should be understood that the instruction code written in C language is well-known technology to those skilled in the art and will not be elaborated here. Lines 8 to 11 show the instruction statements written using the instruction data flow guidance interface to achieve the same calculation function as the code from line 1 to line 6. Among them, in line 9, "vector_add" represents the hardware instruction corresponding to the operator "+" in line 4, "vector_mul" represents the hardware instruction corresponding to the operator "*" in line 4, and "a[0:32]", "b[0:32]", "c[0:32]" represent the operation parameters a, b, c and the address information of each parameter. The compiler Figure 8 for the code from line 8 to line 11 in Figure 15 is as shown. The figure shows that the value of operation parameter a and the value of operation parameter b are calculated using the "vector_add" hardware instruction to obtain the value of operation parameter c, and the value of operation parameter c and the value of operation parameter d are calculated using the "vector_mul" hardware instruction to obtain the value of operand e.

[0071] III. Configuration Method of Data Flow Guidance Interface in if Control Flow Code

[0072] According to an embodiment of the present invention, in the present invention, based on the conditional judgment statement and the branch execution statement of the if control flow code, the parameters of the control flow conversion guidance interface are configured, and the instruction code is replaced with the control flow conversion guidance interface with the configured parameters to reduce the overhead of dynamic graph construction. To facilitate the understanding of the method of configuring the instruction data flow guidance interface in the if control flow code, it will be described below in combination with Example 6.

[0073] Example 6. Control Flow Conversion Guidance Interface

[0074] The pseudo-code for configuring the control flow conversion guidance interface is as Figure 16 shown. The code from line 9 to line 11 in the figure is the original control statement code. In this section of code, if the judgment condition of the if judgment statement is satisfied, line 10 of the code will be executed to change the value of the "tmp" variable. Conversely, if the judgment condition of the if judgment statement is not satisfied, it will not be changed. It should be understood that during the execution of the program code, there are two or more branches in the if judgment statement. When constructing the data flow graph corresponding to the control flow code, it will increase the overhead of dynamic graph construction and reduce the parallelism of code execution. The present invention converts the control dependence into a programming interface of data dependence by configuring the control flow conversion guidance interface, eliminates the control dependence in the loop, and exposes more parallel opportunities. With Figure 16 Taking the code from line 13 to line 18 as an example, the "tmp_then" variable corresponds to the value to be added to "tmp" when the judgment condition is met. The value of the "tmp_else" variable is 0, which is the value to be added to "tmp" when the judgment condition is not met. "pred" is the judgment result of the if judgment condition, and "conditionresult" is the value that will be added to the "tmp" variable finally. That is, when "pred" is 0, the judgment condition is not met, and the value of "conditionresult" is the same as that of "tmp_else". When "pred" is 1, the judgment condition is met, and the value of "conditionresult" is the same as that of "tmp_then". The present invention converts the if control statement into a data flow statement by configuring the control flow conversion guidance interface, so that when the if control statement is executed, there is no need to perform synchronization or branching operations at the control node, thereby reducing the composition overhead and improving the program performance.

[0075] According to an embodiment of the present invention, the present invention provides a multi-granularity data flow programming scheme. This scheme only needs to extend the data flow guidance interface for the programming language and add corresponding data dependency descriptions to the original program code to configure the data dependencies between tasks, task priorities, task-to-hardware bindings, data dependencies between iterations and instructions, so as to achieve task parallelism, loop parallelism and instruction parallelism, and improve the parallelism of program execution from multiple granularity levels of tasks, loops and instructions. At the same time, this scheme provides a programming interface for converting the if control flow into a data flow, which is used to reduce the composition overhead and expose more parallel opportunities, and can fully express the parallel characteristics, task priorities and task mapping optimization schemes of the application, thereby comprehensively improving the program performance and hardware utilization rate. In addition, compared with the existing data flow programming methods, this method does not need to make major changes to the original code and has high usability.

[0076] It should be noted that although the above steps are described in a specific order, it does not mean that the steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even in a different order, as long as the required functions can be achieved.

[0077] The present invention can be a system, a method and / or a computer program product. The computer program product can include a computer-readable storage medium, on which computer-readable program instructions for causing a processor to implement various aspects of the present invention are uploaded.

[0078] A computer-readable storage medium can be a tangible device that retains and stores instructions for use by an instruction execution device. A computer-readable storage medium may include, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punched card or raised structures in grooves having instructions stored thereon, and any suitable combination of the foregoing.

[0079] The embodiments of the present invention have been described above. The above description is exemplary and not exhaustive, and is also not limited to the disclosed embodiments. Many modifications and variations are obvious to those of ordinary skill in the art in the technical field without departing from the scope and spirit of the described embodiments. The selection of the terms used herein is intended to best explain the principles of the embodiments, the practical application, or the improvement of the technology in the market, or to enable other ordinary skill in the art in the technical field to understand the embodiments disclosed herein.< / int> < / string>

Claims

1. A multi-granularity data flow compilation system, the system comprising a programming language library and a compiler, the programming language library is used to provide a programming interface and a definition of the programming interface for a program code, the compiler is used to parse the data flow relationship in the program code and construct a data flow graph based on it, wherein: The programming language library is configured with a plurality of data flow guidance interfaces and the definition of each data flow guidance interface, wherein the plurality of data flow guidance interfaces include an inter-task data flow guidance interface, a task priority guidance interface, a hardware binding guidance interface, a loop block data flow guidance interface, an instruction data flow guidance interface and a control flow conversion guidance interface; The compiler is a compiler supporting programming guidance technology, and is configured with a parsing function for parsing all data flow guidance interfaces in a programming language library, wherein the parsing function is used to parse the data flow guidance interface in the program code to obtain the data flow relationship in the program code.

2. The system according to claim 1, characterized in that Each data flow guidance interface is a programming interface extended based on the programming guidance technology.

3. The system according to claim 1, characterized in that The inter-task data flow steering interface is used to construct the data flow relationship between task codes.

4. The system according to claim 1, characterized in that The task priority guidance interface is used to configure the execution priority of the task code.

5. The system according to claim 1, characterized in that The hardware binding guidance interface is used to configure the binding relationship between the task code and the hardware.

6. The system according to claim 1, characterized in that The loop block data flow steering interface is used to split the loop code into multiple code blocks executed in parallel and to construct data flow dependencies between all code blocks.

7. The system according to claim 1, characterized in that The instruction data stream steering interface is used to establish a mapping between instruction codes and hardware instructions.

8. The system according to claim 1, characterized in that The control flow conversion guidance interface is used to convert the if control flow code into a data flow.

9. A data flow graph compiling method based on the multi-granularity data flow compiling system according to any one of claims 1 to 8, characterized in that: The method is used to guide the modification of a specified program code and construct a data flow graph based on the modified program code, and the method includes: Step S1, modifying a specified program code in a preset manner based on a programming language extension library, wherein the specified program code includes: a task code, a loop code, an instruction code and / or an if control flow code; Step S2: using the multi-granularity data flow compilation system to compile the modified program code into a program flow graph.

10. The method according to claim 9, characterized in that The preset methods include: Modify each task code in the specified program code as follows: Add an inter-task data flow guidance interface in the task code, and configure parameters of the inter-task data flow guidance interface based on the data dependency relationship between the task code block and other task code blocks; Add a task priority guidance interface in the task code block and configure the parameters of the task priority guidance interface based on the priority of task code execution; Add a hardware binding guidance interface in the task code, and configure parameters of the hardware binding guidance interface based on the hardware information of the task code; Modify the loop code in the specified program code as follows: Add a program block data flow guidance interface in the loop code, and configure the parameters of the data flow guidance interface according to the data flow of the loop code and the user's requirements for splitting the loop code; Modify each instruction code in the specified program code as follows: Configure the parameters of the instruction data flow steering interface based on the operation parameters of the instruction code, the address information of the operation parameters and the instruction type, and replace the instruction code with the data flow steering interface of the configured parameters; Modify each if control flow code in the specified program code as follows: The parameters of the control flow conversion guidance interface are configured based on the conditional judgment statement and the branch execution statement of the if control flow code, and the instruction code is replaced by the control flow conversion guidance interface with the number of configured parameters.