Program compilation method, compiler, device and storage medium

By preprocessing and splitting the source code of the compiled program, source code suitable for different programmable chips is generated, which solves the problems of high labor costs and long time in the existing technology, and realizes the function of writing networks on a unified platform Efficient development of programs.

CN114281339BActive Publication Date: 2024-11-22ALIBABA (CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111602625.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-24
Publication Date
2024-11-22
Estimated Expiration
2041-12-24

AI Technical Summary

Technical Problem

In the prior art, the problem of high labor costs and long development time is that, especially when offloading network functions from CPU chips to programmable chips of smart network cards, programs on different platforms need to be manually split and written.

Method used

By preprocessing, instruction analysis and code splitting the source code of the compiled program, the source code suitable for the first programmable chip and the second programmable chip can be automatically generated, so that the two can handle network traffic together, reducing the developers' different situations Work on the programming platform.

Benefits of technology

It realizes writing overall programs on a unified programming platform, reducing development labor costs and time, avoiding the splitting of network function solutions and multi-platform programming, and improving development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114281339B_ABST
    Figure CN114281339B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a program compilation method, compiler, device and storage medium. The method includes: preprocessing the source code of the program to be compiled to obtain the preprocessed source code, the program to be compiled is a program written by a developer to implement network functions; performing instruction analysis on the preprocessed source code to generate corresponding analysis results to obtain an intermediate representation including the analysis results and the preprocessed source code; performing code splitting based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled, the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic. The method can reduce the development labor and shorten the development time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a program compiling method, compiler, device and storage medium. Background Art

[0002] With the continuous development of Internet technology, the performance improvement of programmable chips such as central processing unit (CPU) chips has not kept up with the growth of demand. The emergence and popularization of technologies that assist programmable chips in processing network traffic (such as smart network cards) have enabled many network functions (such as attack detection, traffic statistics, and firewalls) that were originally implemented by a certain programmable chip to be offloaded to other programmable chips for execution, while reducing the computing burden of the programmable chip, improving the throughput of data packet processing and reducing forwarding delays.

[0003] Take the example of the network function originally implemented by the CPU chip being offloaded to the programmable chip in the smart network card. Usually, developers need to split the overall solution corresponding to the network function that needs to be implemented by the computing device into the CPU solution and the smart network card solution based on the functional characteristics of the smart network card. Developers need to write programs for the CPU chip and the smart network card on the corresponding programming platform based on the CPU solution and the smart network card solution respectively. However, this method has the problems of high development labor costs and long development time. Summary of the invention

[0004] The embodiments of the present application provide a program compilation method, a compiler, a device and a storage medium to solve the problems of high development labor cost and long development time in the prior art.

[0005] In a first aspect, an embodiment of the present application provides a program compiling method, comprising:

[0006] Preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function;

[0007] Performing instruction analysis on the preprocessed source code to generate corresponding analysis results, so as to obtain an intermediate representation including the analysis results and the preprocessed source code;

[0008] Code splitting is performed based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled, wherein the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, and the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

[0009] In a second aspect, an embodiment of the present application provides a compiler, including:

[0010] A preprocessing module, used for preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function;

[0011] An analysis module, configured to perform instruction analysis on the preprocessed source code and generate corresponding analysis results to obtain an intermediate representation including the analysis results and the preprocessed source code;

[0012] A splitting module is used to perform code splitting based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled, wherein the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, and the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

[0013] In a third aspect, an embodiment of the present application further provides a computing device, including: a first programmable chip and a second programmable chip, wherein the first programmable chip is used to assist the second programmable chip in processing network traffic; an executable code on the first programmable chip is generated based on a first source code, and an executable code on the second programmable chip is generated based on a second source code;

[0014] The first source code and the second source code are obtained by performing the following processing on the program to be compiled: preprocessing the source code of the program to be compiled to obtain the preprocessed source code, and the program to be compiled is a program written by a developer to implement a network function; performing instruction analysis on the preprocessed source code to generate a corresponding analysis result to obtain an intermediate representation including the analysis result and the preprocessed source code; performing code splitting based on the intermediate representation to obtain the first source code and the second source code of the program to be compiled.

[0015] In a fourth aspect, an embodiment of the present application provides a computer device, comprising: a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement a method as described in any one of the first aspects.

[0016] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed, the method as described in any one of the first aspects is implemented.

[0017] An embodiment of the present application further provides a computer program, which, when executed by a computer, is used to implement the method as described in any one of the first aspects.

[0018] In an embodiment of the present application, preprocessing, instruction analysis and code splitting are performed in sequence based on the source code of a program (hereinafter referred to as a program to be compiled) written by a developer to implement a network function, and a first source code for generating an executable code of the program to be compiled on a first programmable chip and a second source code for generating an executable code of the program to be compiled on a second programmable chip are obtained. This achieves that in a scenario where the first programmable chip needs to assist the second programmable chip in processing network traffic, the source code corresponding to the first programmable chip (i.e., the first source code) and the source code corresponding to the second programmable chip (i.e., the second source code) can be automatically split based on the source code of the same program to be compiled, so that developers do not need to split the network function solution, nor do they need to write programs for the first programmable chip (e.g., the programmable chip in the smart network card) and the second programmable chip (e.g., the CPU chip) on different programming platforms respectively. They only need to write the entire program to be compiled on a unified programming platform, thereby reducing the development labor and shortening the development time. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 A schematic diagram of an application scenario of the program compilation method according to an embodiment of the present application;

[0021] Figure 2 A flowchart of a program compilation method provided in one embodiment of the present application;

[0022] Figure 3 A code snippet provided for an embodiment of the present application;

[0023] Figure 4 A schematic diagram of the structure of a compiler system provided in one embodiment of the present application;

[0024] Figure 5 A schematic diagram of the structure of a compiler provided in one embodiment of the present application;

[0025] Figure 6 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms of "a", "said", and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two, but does not exclude the inclusion of at least one.

[0028] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0029] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0030] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a product or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such a product or system. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the product or system including the elements.

[0031] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.

[0032] Figure 1 Schematic diagram of application scenario of the program compilation method of the present application embodiment, such as Figure 1As shown, the application scenario may include a first device 11 and a second device 12. The first device 11 may be any type of device capable of program compilation, and exemplarily, the first device may include a computer device. The second device may be any type of device that needs to provide network functions based on the first programmable chip and the second programmable chip, and exemplarily, the second device may include a computing device (e.g., a physical server or a cloud server).

[0033] The first device 11 can execute the program compilation method provided in the embodiment of the present application to obtain the first source code and the second source code of the program to be compiled, wherein the first source code can be used to generate the executable code of the program to be compiled on the first programmable chip, and the second source code can be used to generate the executable code of the program to be compiled on the second programmable chip. The executable code of the program to be compiled on the first programmable chip can be loaded and executed by the first programmable chip of the second device 12, and the executable code of the program to be compiled on the second programmable chip can be loaded and executed by the second programmable chip 12B of the second device 12.

[0034] Optionally, the first programmable chip may be located in a network card, and such a network card may be called a smart network card. For example, taking the case where a smart network card assists a CPU chip in processing network traffic as an example, the first programmable chip may include a programmable chip in a smart network card, and the second programmable chip may include a CPU chip. Taking the case where a smart network card assists a field programmable gate array (FPGA) in processing network traffic as an example, the first programmable chip may include a programmable chip in a smart network card, and the second programmable chip may include an FPGA chip. Taking the case where a smart network card assists a graphics processing unit (GPU) in processing network traffic as an example, the first programmable chip may include a programmable chip in a smart network card, and the second programmable chip may include a GPU chip.

[0035] And / or optionally, the first programmable chip may be located outside the network card, and such a network card may be called a non-intelligent network card. For example, taking the example of a programmable chip (such as an FPGA chip) connected to a non-intelligent network card assisting a CPU chip in processing network traffic, the first programmable chip may include the programmable chip, and the second programmable chip may include a CPU chip. Taking the example of a programmable chip connected to a non-intelligent network card assisting an FPGA in processing network traffic, the first programmable chip may include the programmable chip, and the second programmable chip may include an FPGA chip. Taking the example of a programmable chip connected to a non-intelligent network card assisting a GPU in processing network traffic, the first programmable chip may include the programmable chip, and the second programmable chip may include a GPU chip.

[0036] Taking the smart network card + CPU chip as an example, usually, developers need to manually split the CPU solution and the smart network card solution, and write the programs for the CPU chip and the smart network card separately on the corresponding programming platform. However, this method has the problems of high development labor costs and long development time.

[0037] In order to solve the technical problems of high development labor cost and long development time, in the embodiments of the present application, Figure 1 As shown, the first device 11 performs preprocessing, instruction analysis and code splitting in sequence based on the source code of the program (hereinafter referred to as the program to be compiled) written by the developer for realizing the network function, and obtains the first source code for generating the executable code of the program to be compiled on the first programmable chip and the second source code for generating the executable code of the program to be compiled on the second programmable chip. This realizes that in the scenario where the first programmable chip needs to assist the second programmable chip in processing network traffic, the source code corresponding to the first programmable chip (i.e., the first source code) and the source code corresponding to the second programmable chip (i.e., the second source code) can be automatically split based on the source code of the same program to be compiled, so that the developer does not need to split the network function solution, nor does he need to write the first programmable chip (e.g., the programmable chip in the smart network card) and the second programmable chip (e.g., the CPU chip) separately on different programming platforms. He only needs to write the entire program to be compiled on a unified programming platform, thereby reducing the development labor and shortening the development time.

[0038] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0039] Figure 2 This is a flow chart of a program compilation method provided in an embodiment of the present application. The execution subject of this embodiment may be Figure 1 The first device 11 in Figure 2 As shown, the method of this embodiment may include:

[0040] Step 21, preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function;

[0041] Step 22, performing instruction analysis on the preprocessed source code to generate corresponding analysis results, so as to obtain an intermediate representation including the analysis results and the preprocessed source code;

[0042] Step 23, performing code splitting based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled, wherein the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, and the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

[0043] Among them, the program to be compiled can be written by a developer on a unified programming platform of the first programmable chip + the second programmable chip (for example, a unified programming platform of the CPU + smart network card), and the network functions implemented by the program to be compiled can be, for example, one or more of attack detection, traffic statistics, firewall, etc. Of course, in other embodiments, the network functions implemented by the program to be compiled can also be other functions, and this application does not limit this.

[0044] For the source code of the program to be compiled, a series of preprocessing such as syntax checking, semantic checking, and expanding complex instructions can be performed first. By preprocessing the source code of the program to be compiled, the preprocessed source code can be obtained. It should be noted that the implementation method of the preprocessing can be referred to the specific description in the related art, which will not be repeated here.

[0045] After obtaining the preprocessed source code, the preprocessed source code can be subjected to instruction analysis to generate corresponding analysis results. The analysis results may include all the information required to split the first source code and the second source code and obtained through analysis. The specific content of the analysis results may be related to the specific method used for code splitting. Exemplarily, the analysis results may include dependency information. Optionally, the analysis results may also include state analysis results, and further optionally, the analysis results may also include conditional analysis results and / or target instructions corresponding to the state block. The specific method for analyzing and obtaining dependency information, state analysis results, conditional analysis results, and target instructions corresponding to the state block is specifically described in the following description.

[0046] Optionally, considering that the life cycle of some variables in the preprocessed source code is longer than a single data packet, such as variables used to count the number of data packets, such variables whose life cycle is longer than a single data packet are referred to as state variables in this application. Considering the characteristic that the life cycle of a state variable is longer than a single data packet, in order to avoid the problem that different instructions for updating the same state variable need to be executed by different programmable chips, resulting in complex split implementation and prone to errors, the instructions involving the same state variable in the preprocessed source code can be analyzed during instruction analysis. Based on this, in one embodiment, step 22 can specifically include the following steps 22A and 22B.

[0047] Step 22A, analyzing the dependency relationship between instructions in the preprocessed source code to obtain dependency relationship information;

[0048] Step 22B, analyzing the instructions involving the same state variable in the preprocessed source code, and merging the instructions involving the same state variable to obtain a state analysis result.

[0049] The dependency information may be any type of information that can be used to describe the dependency between instructions in the preprocessed source code. For example, the dependency information may be a dependency graph or a dependency table. It should be noted that the implementation method for analyzing and obtaining the dependency information can be referred to the specific description in the related art, which will not be repeated here.

[0050] In one embodiment, instructions involving the same state variable can be combined into the same state block to obtain a state analysis result, so that the value of the state variable does not need to be transferred between different programmable chips, which is conducive to simplifying the splitting process.

[0051] In another embodiment, the target instructions in all instructions involving the same state variable can be merged into the same state block to obtain the state analysis result, wherein the target instructions are from the first instruction that performs a read operation on the same state variable to the last instruction that performs a write operation on the same state variable in all instructions involving the same state variable. This can reduce the granularity of the state block, which is conducive to increasing the probability of obtaining a better splitting method.

[0052] By executing step 22A and step 22B, the analysis result may include dependency information and a state analysis result, wherein the state analysis result may be empty, or the state analysis result may include at least one state block.

[0053] Optionally, the status block in the code segment with very small traffic may not be analyzed, which is helpful to reduce the workload of analysis. Based on this, in one embodiment, step 22 may also include:

[0054] Step 22C, analyze the instructions that need to be executed under the same condition in the preprocessed source code, and based on the dependency information, package the instructions that need to be executed under the same condition into the same control block according to the dependency relationship to obtain a conditional analysis result, which may include multiple control blocks.

[0055] Among them, step 22C can be after step 22A and before step 22B. By executing step 22C, the analysis result can also include the conditional analysis result. Figure 3 The code snippet shown is taken as an example, based on Figure 3The two if conditions in can be packaged into two control blocks (CB1 and CB2), based on Figure 3 The else if condition in can be packaged into a control block (CB3), based on Figure 3 The else condition in can be packaged into a control block (i.e. CB4).

[0056] Accordingly, step 22B may specifically include: identifying a target control block among the multiple control blocks, the target control block refers to a control block corresponding to a target conditional branch, the target conditional branch refers to a conditional branch whose execution result changes the judgment result of the corresponding judgment condition; and analyzing whether there are instructions involving state variables in the second other code, the second other code refers to other codes in the preprocessed source code except the target control block. The target control block can be understood as a control block that is not frequently accessed.

[0057] Figure 3 In the code snippet shown, lines 20-21 are a conditional branch, and the corresponding control block is Figure 3 CB4 in, assuming that the ConnTbl.insert function in CB4 completes the function of inserting ipv4.src_ip into MinDip(vip), and after the ConnTbl.insert function completes the function of inserting ipv4.src_ip into MinDip(vip), the judgment result of the judgment condition corresponding to the conditional branch (i.e., line 7) changes, then CB4 can be identified as the target control block. Figure 3 The variables DipCntr, MinDip and MinLoad in can be understood as state variables, the instructions in lines 10, 13 and 17 can be understood as instructions involving the state variable DipCntr, the instructions in lines 14, 16 and 21 can be understood as instructions involving the state variable MinDip, and the instructions in lines 13 and 17 can be understood as instructions involving the state variable MinLoad. After excluding CB4 and merging the target instructions in all instructions involving the same state variable into the same state block, we can get Figure 3 SB1 and SB2 in the figure, where the state variable corresponding to SB1 is DipCntr, and the state variables corresponding to SB2 are MinDip and MinLoad.

[0058] In an embodiment of the present application, the intermediate representation (IR) obtained by compiling the program to be compiled may include analysis results and preprocessed source code. After obtaining the intermediate representation, code splitting can be performed based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled.

[0059] Exemplarily, the instructions in the preprocessed source code that need to be executed by the first programmable chip (hereinafter referred to as the first chip instructions) can be first determined, and then the other instructions in the preprocessed source code except the first chip instructions can be used as instructions that need to be executed by the second programmable chip (hereinafter referred to as the second chip instructions), and finally the first source code and the second source code are obtained according to the first chip instructions and the second chip instructions.

[0060] In one embodiment, when the analysis result includes a status analysis result, step 23 may specifically include the following steps 23A to 23C.

[0061] Step 23A, based on the state analysis result, under the condition that the resource restriction of the first programmable chip is met, determining the first chip instruction that needs to be executed by the first programmable chip in the preprocessed source code;

[0062] Step 23B, taking other instructions in the preprocessed source code except the first chip instructions as second chip instructions to be executed by the second programmable chip;

[0063] Step 23C, based on the dependency information, add a first extended instruction on the basis of the first chip instruction, and add a second extended instruction on the basis of the second chip instruction, so as to obtain a first source code and a second source code.

[0064] Among them, the first extension instruction can be used to expand the first chip instruction into a complete source code that is suitable for the first programmable chip and can transfer data with other programmable chips other than the first programmable chip on demand; the second extension instruction is used to expand the second chip instruction into a complete source code that is suitable for the second programmable chip and can transfer data with other programmable chips other than the second programmable chip on demand.

[0065] by Figure 3 For example, assuming that the first chip instruction includes Figure 3 In SB1, the second chip instructions include Figure 3 SB2 in, the first extended instruction may include Figure 3 The first extended instruction may also include instructions for putting the execution results of lines 7-8 into the header of the data packet and passing it to the second programmable chip, and the second extended instruction may include instructions for parsing the header of the data packet sent by the first programmable chip to obtain the execution results of lines 7-8.

[0066] The following mainly describes how to determine the first chip instructions that need to be executed by the first programmable chip in the preprocessed source code.

[0067] In the embodiment of the present application, when the status analysis result includes a non-status block, the first chip instruction can be directly split out from the preprocessed source code. Considering that the data packet arrives at the first programmable chip first, based on this, in one embodiment, step 22A can specifically include: when the status analysis result does not include a status block, starting from the instruction arranged in the first position in the preprocessed source code, the current instruction belonging to the executable instruction range of the first programmable chip is sequentially determined as the first chip instruction that needs to be executed by the first programmable chip, until the resource limit of the first programmable chip is exceeded or all instructions are traversed.

[0068] Among them, instructions within the executable instruction range of a first programmable chip can be executed by the first programmable chip, and instructions that do not belong to the executable instruction range of a first programmable chip cannot be executed by the first programmable chip. Exemplarily, the first programmable chip may have a corresponding instruction blacklist, and when the current instruction is not in the blacklist, it can indicate that the instruction belongs to the executable instruction range of the first programmable chip, and when the current instruction is in the blacklist, it can indicate that the instruction does not belong to the executable instruction range of the first programmable chip. Exemplarily, resource restrictions may include computing resource restrictions and / or hardware resource restrictions, wherein computing resource restrictions may include, for example, the number of instructions, and hardware resource restrictions may include, for example, storage space size restrictions.

[0069] It should be noted that the number of the first programmable chips may be one or more. When there are multiple first programmable chips, the first chip instructions that need to be executed on each of the multiple first programmable chips may be determined in sequence.

[0070] For example, assuming that the number of first programmable chips is 2, namely, the first programmable chip x and the first programmable chip y, and the preprocessed source code is arranged in order from front to back with instructions 1 to instruction 1000. If the status analysis result does not include a status block, it can start from instruction 1. Under the premise that the resource limit of the first programmable chip x is not exceeded, instruction 1 is first determined as the first chip instruction of the first programmable chip x, and instruction 2 is then determined as the first chip instruction of the first programmable chip x. Then instruction 3 is determined as the first chip instruction of the first programmable chip x, and ..., further assuming that when the current instruction is instruction 301, if instruction 301 is determined as the first chip instruction of the first programmable chip x, the resource limit of the first programmable chip x will be exceeded, then it can start from instruction 301. On the premise that the resource limit of the first programmable chip y is not exceeded, instruction 301 is first determined as the first chip instruction of the first programmable chip y, instruction 302 is then determined as the first chip instruction of the first programmable chip y, and then instruction 303 is determined as the first chip instruction of the first programmable chip y, ..., further assuming that when the current instruction is instruction 701, if instruction 701 is determined as the first chip instruction of the first programmable chip y, it will exceed the resource limit of the first programmable chip y, then the process can be ended, so that instructions 1 to 300 can be determined as the first chip instructions of the first programmable chip y, instructions 301 to 700 can be determined as the first chip instructions of the first programmable chip y, and instructions 701 to 1000 can be determined as the second chip instructions of the second programmable chip.

[0071] It should be understood that when the end condition is to traverse all instructions, the first source code may be a preprocessed source code, and the second source code may be empty, that is, the network function provided by the program to be compiled may be independently provided by the first programmable chip.

[0072] When the state analysis result includes a state block, the first chip instruction can be determined based on the state block. Based on this, in one embodiment, step 23A can specifically include: when the state analysis result includes at least one state block, based on the at least one state block, under the condition that the resource restriction of the first programmable chip is satisfied, determining the first chip instruction that needs to be executed by the first programmable chip. Exemplarily, the resource restriction can include computing resource restriction and / or hardware resource restriction.

[0073] Optionally, the at least one status block can be directly sorted according to the order in the preprocessed source code, and starting from the status block ranked first, the current status blocks belonging to the executable instruction range of the first programmable chip are sequentially determined as the target status blocks that need to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all status blocks are traversed to obtain the first chip instruction that needs to be executed by the first programmable chip, and the first chip instruction includes the target status block.

[0074] For example, assuming that the number of first programmable chips is 2, namely the first programmable chip x and the first programmable chip y, and that state blocks 1 to 10 are arranged in order from front to back, then starting from state block 1, under the premise of not exceeding the resource limit of the first programmable chip x, state block 1 is first determined as the first chip instruction of the first programmable chip x, and then state block 2 is determined as the first chip instruction of the first programmable chip x, and then state block 3 is determined as the first chip instruction of the first programmable chip x..., further assuming that when the current state block is state block 4, if state block 4 is determined as the first chip instruction of the first programmable chip x, the resource limit of the first programmable chip x will be exceeded, then state block 3 is determined as the first chip instruction of the first programmable chip x. Starting from state block 4, under the premise of not exceeding the resource limit of the first programmable chip y, state block 4 is first determined as the first chip instruction of the first programmable chip y, and then state block 5 is determined as the first chip instruction of the first programmable chip y, and then state block 6 is determined as the first chip instruction of the first programmable chip y…, further assuming that when the current state block is state block 9, if state block 9 is determined as the first chip instruction of the first programmable chip y, it will exceed the resource limit of the first programmable chip y, then the process can be ended, so that state blocks 1 to 3 can be determined as the first chip instructions of the first programmable chip x, and state blocks 4-6 can be determined as the first chip instructions of the first programmable chip y.

[0075] Or optionally, when determining the target status block that needs to be executed by the first programmable chip, the ability of the first programmable chip to process data packets can be considered to improve the processing performance of the first programmable chip for data packets. Based on this, in one embodiment, based on the at least one status block, under the condition that the resource limitations of the first programmable chip are met, the first chip instructions that need to be executed by the first programmable chip are determined, which can specifically include the following steps A1 to D1.

[0076] Step A1, input each state block of the at least one state block into the performance model of the first programmable chip for processing, and obtain the data packet processing speed of each state block for the same element of the corresponding state variable.

[0077] Among them, the performance model can be used to determine the data packet processing speed of the state block for the same element of its corresponding state variable. The input of the performance model is the state block (i.e., one or more instructions), and the output of the performance model can be the data packet processing speed. The data packet processing speed obtained by inputting a state block into the performance model for processing can be used to characterize the program performance of the state block, that is, the upper limit of the processing speed that the state block can support. Different types of first programmable chips can be modeled accordingly to analyze the main factors affecting program performance under different types of first programmable chips (such as: the impact of Netronome network card multi-level storage and locks, and the impact of FPGA network card time-consuming operations on the pipeline), so that program performance can be predicted more accurately.

[0078] It should be understood that the performance model of the same type of first programmable chip can be the same performance model, for example, the performance model of the FPGA chips in two FPGA network cards can be the same performance model, and the performance model of the FPGA chip in an FPGA network card and the programmable chip in a Netronome network card can be different performance models.

[0079] It should be understood that the same state variable can have multiple elements, e.g. Figure 3 The state variable DipCntr corresponding to SB1 shown has 4096 elements. Figure 3 The state variables MinLoad and MinDip corresponding to SB2 shown in the figure each have 4 elements.

[0080] Step B1, estimate the maximum flow size per unit time of the same element of the state variable corresponding to each state block.

[0081] Among them, the maximum flow size per unit time of the same element of the state variable corresponding to each state block can be estimated based on the flow characteristics that the program to be compiled needs to process. Exemplarily, the flow characteristics that the program to be compiled needs to process can be described in the form of source IP address and / or target IP address. Of course, in other embodiments, the flow characteristics that the program to be compiled needs to process can also be described by port, MAC address or other characteristics, and this application does not limit this.

[0082] For example, the maximum flow size per unit time of the same element of the state variable corresponding to each state block can be estimated based on the flow size per unit time of each flow feature history in the flow feature that needs to be processed by the compiled program and the flow characteristics involved in the elements of the state variable corresponding to the state block.

[0083] Based on this, optionally, the aforementioned step 22 may also include: step 22D, based on the dependency information, determining a target instruction for creating an index of a state variable corresponding to each state block. Figure 3In SB2, the indexes of the corresponding state variables MinLoad and MinDip are both "vip", and the target instruction for creating vip is Figure 3 The analysis result may also include the target instruction corresponding to the status block or the identifier of the target instruction.

[0084] Further optionally, step B1 may specifically include: determining the traffic characteristics corresponding to each element of the state variable corresponding to each state block based on the target instruction of the index of the state variable corresponding to each state block, estimating the traffic size of each element of the state variable corresponding to each state block per unit time based on the unit time traffic size of each traffic characteristic history in the traffic characteristics that need to be processed by the compiled program, and the traffic characteristics corresponding to each element of the state variable corresponding to each state, and taking the maximum traffic size of each element of the state variable corresponding to each state block per unit time as the maximum traffic size of the same element of the state variable corresponding to each state block per unit time.

[0085] For example, for Figure 3 SB2 in , its corresponding state variables are MinLoad and MinDip, and MinLoad and MinDip both include four elements: element 0, element 1, element 2, and element 3. The flow size of element i of MinLoad per unit time can be estimated based on the flow size per unit time of each flow feature history in a set of flow features corresponding to element i of MinLoad. Specifically, the flow size of element i of MinLoad per unit time can be equal to the sum of the flow sizes per unit time of a set of flow feature history corresponding to element i of MinLoad, and the flow size of element i of MinDip per unit time can be estimated based on the flow size per unit time of each flow feature history in a set of flow features corresponding to element i of MinDip. Specifically, the element of MinDip The flow size of element i in unit time can be equal to the sum of the flow sizes per unit time of a group of flow feature histories corresponding to element i of MinDip; then, the estimated flow size of element 0 of MinLoad in unit time, the flow size of element 1 of MinLoad in unit time, the flow size of element 2 of MinLoad in unit time, the flow size of element 3 of MinLoad in unit time, the flow size of element 0 of MinDip in unit time, the flow size of element 1 of MinDip in unit time, the flow size of element 2 of MinDip in unit time and the flow size of element 3 of MinDip in unit time can be used as the maximum flow size of the same element of the state variable corresponding to state block 1 in unit time.

[0086] Among them, i is equal to 0, 1, 2, 3; according to the target instruction of the index of the state variable corresponding to SB2, it can be known that a group of traffic characteristics corresponding to element 0 of MinLoad and MinDip are all traffic characteristics in which the last two binary bits of the destination IP address in the traffic characteristics that the program to be compiled needs to process are "00", a group of traffic characteristics corresponding to element 1 of MinLoad and MinDip are all traffic characteristics in which the last two binary bits of the destination IP address in the traffic characteristics that the program to be compiled needs to process are "01", a group of traffic characteristics corresponding to element 2 of MinLoad and MinDip are all traffic characteristics in which the last two binary bits of the destination IP address in the traffic characteristics that the program to be compiled needs to process are "10", and a group of traffic characteristics corresponding to element 3 of MinLoad and MinDip are all traffic characteristics in which the last two binary bits of the destination IP address in the traffic characteristics that the program to be compiled needs to process are "11".

[0087] It can be seen that due to Figure 3 The indexes of the state variables MinLoad and MinDip corresponding to SB2 in are both "vip", so the traffic characteristics corresponding to element i of MinLoad are the same as the traffic characteristics corresponding to element i of MinDip. Therefore, the estimated traffic size of element i of MinLoad per unit time can be the same as the traffic size of element i of MinDip per unit time.

[0088] Therefore, in order to reduce calculations, for any state block, it is not necessary to estimate the flow size per unit time for each element of each state variable corresponding to the state block separately, but it is possible to estimate the flow size per unit time for each flow feature group corresponding to the state block separately to obtain the maximum flow size per unit time for the same element of the state variable corresponding to the state block.

[0089] Based on this, alternatively, step B1 may specifically include: based on the target instruction of the index of the state variable corresponding to each state block, determining at least one traffic feature group of the state variable corresponding to each state block, taking the sum of the unit time traffic size of each traffic feature history in each traffic feature group of the state variable corresponding to each state block as the traffic size of each traffic feature group of the state variable corresponding to each state block within unit time, and taking the maximum traffic size of each traffic feature group of the state variable corresponding to each state block within unit time as the maximum traffic size of the same element of the state variable corresponding to each state block within unit time.

[0090] For any state block, the traffic features involved can be merged into different traffic feature groups. The basis for the merger can be that the same traffic feature group can access the same element of the state variable corresponding to any state block. If there are multiple state variables corresponding to any state block, the same traffic feature group can access the same element of each state variable in the multiple state variables. When a state block corresponds to multiple state variables, the traffic features corresponding to the elements of the multiple state variables can be considered uniformly. It should be understood that the traffic feature group can include one or more traffic features that need to be processed by the compiled program.

[0091] When the indexes of multiple state variables corresponding to a state block are the same, the flow feature group corresponding to the state variable of the state block may include a set of characteristic flows corresponding to each element of any state variable of the state block. Figure 3 SB2 in, based on the target instruction corresponding to SB2, it can be determined that there can be four traffic feature groups corresponding to SB2, among which, the traffic features whose last two binary bits of the destination IP address are "00" in the traffic features that the program to be compiled needs to process can form a traffic feature group, the traffic features whose last two binary bits of the destination IP address are "01" in the traffic features that the program to be compiled needs to process can form a traffic feature group, the traffic features whose last two binary bits of the destination IP address are "10" in the traffic features that the program to be compiled needs to process can form a traffic feature group, and the traffic features whose last two binary bits of the destination IP address are "11" in the traffic features that the program to be compiled needs to process can form a traffic feature group.

[0092] When the indexes of multiple state variables corresponding to a certain state block are different, the flow feature group corresponding to the state variables of the state block may include a superset of a set of characteristic flows corresponding to each element of each state variable of the state block. For example, suppose that a certain state block corresponds to two state variables, namely, state variable X and state variable Y, and both state variable X and state variable Y include four elements, and a set of flow features corresponding to element 0 of state variable X is (flow feature 1, flow feature 2, flow feature 3, and flow feature 4), a set of flow features corresponding to element 1 of state variable X is (flow feature 5, flow feature 6, flow feature 7, and flow feature 8), a set of flow features corresponding to element 2 of state variable X is (flow feature 9), a set of flow features corresponding to element 3 of state variable X is (flow feature 10), and a set of flow features corresponding to element 0 of state variable Y is (Flow feature 1 and flow feature 2), a group of flow features corresponding to element 1 of the state variable Y is (flow feature 3 and flow feature 4), a group of flow features corresponding to element 2 of the state variable Y is (flow feature 5, flow feature 6, flow feature 7, flow feature 8 and flow feature 9), and a group of flow features corresponding to element 3 of the state variable Y is (flow feature 10). Then the flow feature groups corresponding to the state variables of the state block can be three groups, namely (flow feature 1, flow feature 2, flow feature 3 and flow feature 4), (flow feature 5, flow feature 6, flow feature 7, flow feature 8 and flow feature 9) and (flow feature 10).

[0093] Step C1, based on the maximum flow size per unit time of each state block and the data packet processing speed of each state block obtained by processing the performance model of the first programmable chip, determine from the at least one state block a candidate state block whose data packet processing speed can meet the maximum flow size requirement per unit time, so as to obtain a candidate state block set of the first programmable chip.

[0094] Among them, since the data packet processing speed of each state block obtained by processing the performance model of a first programmable chip can characterize the program performance of the first programmable chip in executing the state block, that is, the upper limit of the processing speed that the first programmable chip can support in executing the state block, therefore, by determining from the at least one state block a candidate state block whose data packet processing speed can meet its maximum flow size requirement, so as to obtain a set of candidate state blocks of the first programmable chip, it is possible to avoid the problem that the first programmable chip's processing performance on the data packet is poor due to the first programmable chip's processing speed on the data packet failing to meet the flow requirement, thereby facilitating improving the data packet processing performance.

[0095] Step D1, based on the candidate state block set of the first programmable chip, under the condition that the resource limitation of the first programmable chip is met, determine the target state block that needs to be executed by the first programmable chip to obtain the first chip instruction that needs to be executed by the first programmable chip, and the first chip instruction includes the target state block.

[0096] Optionally, the candidate state blocks with larger maximum flow sizes may be determined as first chip instructions to be executed by the first programmable chip, which is beneficial to reduce the computational burden of the second programmable chip and save processing resources of the second programmable chip.

[0097] Based on this, in one embodiment, when the number of the first programmable chip is one and the candidate state block set of the first programmable chip is not empty, step D1 may specifically include the following steps D11 and D12.

[0098] Step D11, sorting the candidate state blocks in the candidate state block set of the first programmable chip in descending order according to the maximum flow size;

[0099] Step D12, starting from the candidate state block ranked first, the current state blocks belonging to the executable instruction range of the first programmable chip are determined in sequence as the target state blocks that need to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all candidate state blocks are traversed.

[0100] Among them, when there are instructions that do not belong to the executable instruction range of the first programmable chip in the current state block, it can be indicated that the current state block does not belong to the executable instruction range of the first programmable chip; when there are no instructions that do not belong to the executable instruction range of the first programmable chip in the current state block, it can be indicated that the current state block belongs to the executable instruction range of the first programmable chip. It should be noted that, regarding the resource limitations and executable instruction range of the first programmable chip, please refer to the relevant description of the aforementioned embodiment, which will not be repeated here.

[0101] It should be understood that when the termination condition is to traverse all candidate state blocks, all candidate state blocks in the candidate state set of the first programmable chip can be used as first chip instructions; when the termination condition is to exceed the resource limitation of the first programmable chip, some candidate state blocks in the candidate state set of the first programmable chip can be used as first chip instructions.

[0102] In another embodiment, when there are multiple first programmable chips and the candidate state sets of the multiple first programmable chips are non-empty, step D1 may specifically include the following steps D13 to D16.

[0103] Step D13, determining a union of candidate state sets of the plurality of first programmable chips;

[0104] Step D14, sorting the candidate state blocks in the union set in descending order according to the maximum flow size;

[0105] Step D15, for each chip sequence in the multiple chip sequences corresponding to the multiple first programmable chips, starting from the candidate state block ranked first and the first programmable chip ranked first, the current candidate state blocks that belong to the executable instruction range of the current first programmable chip and belong to the candidate state block set of the current first programmable chip are sequentially matched to the current first programmable chip until any first programmable chip resource limit is exceeded or all candidate state blocks are traversed, so as to obtain a correspondence relationship between multiple feasible candidate state blocks and the first programmable chip;

[0106] Step D16, based on the performance specification, select a feasible correspondence between the candidate state blocks and the first programmable chip from the multiple feasible correspondences between the candidate state blocks and the first programmable chip to determine the target state blocks that need to be executed by the multiple first programmable chips respectively.

[0107] Assuming that the number of candidate state blocks is 8 and the number of first programmable chips is 2, one chip order among the multiple chip orders may be, for example, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, and the first programmable chip 1 may be, for example, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, and the first programmable chip 1 may be, for example, the first programmable chip 1 ...… and all possible chip orders may be traversed.

[0108] Further, assuming that the eight candidate state blocks are sorted from candidate state block 1 to candidate state block 8 in descending order of maximum flow size, the first programmable chip 1 and the second programmable chip 2 both include the eight candidate state blocks, and the eight candidate state blocks all belong to the executable instruction range of the first programmable chip 1 and the first programmable chip 2. Taking the chip sequence of the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2, the first programmable chip 1, the first programmable chip 2 as an example, then starting from candidate state block 1 and the first programmable chip 1, within the range of not exceeding any first programmable chip Under the premise of programming chip resource limitation, candidate state block 1 is first matched to the first programmable chip 1, then candidate state block 2 is matched to the first programmable chip 2, then candidate state block 3 is matched to the first programmable chip 1, and then candidate state block 4 is matched to the first programmable chip 2, ..., further assuming that when the current candidate state block is candidate state block 8, if matching candidate state block 8 to the first programmable chip 2 will exceed the resource limitation of the first programmable chip 2, then the process can be ended, so that a feasible correspondence relationship can be obtained in which candidate state blocks 1, 3, 5 and 7 correspond to the first programmable chip 1, and candidate state blocks 2, 4 and 6 correspond to the first programmable chip 2.

[0109] It should be noted that the performance specification can be flexibly implemented according to requirements. For example, the performance specification may be that the more state blocks that can be deployed on the first programmable chip, the better.

[0110] By executing steps D13 to D16, it is possible to obtain multiple feasible methods according to multiple chip orders (i.e., the ordering methods of multiple first programmable chips), and select one feasible method from the multiple feasible methods to obtain a better splitting method.

[0111] In an embodiment of the present application, for a first programmable chip whose candidate state set is empty, a first chip instruction that needs to be executed by the first programmable chip can be determined from other codes outside the state block. Based on this, in one embodiment, the aforementioned determination of the first chip instruction that needs to be executed by the first programmable chip based on the at least one state block under the condition that the resource limit of the first programmable chip is met may also include: starting from the instruction ranked first in the first other code, the current instruction belonging to the executable instruction range of the first programmable chip is sequentially determined as the first chip instruction that needs to be executed by the first programmable chip, until the resource limit of the first programmable chip is exceeded or all instructions are traversed, and the first other code refers to other codes in the preprocessed source code except the at least one state block.

[0112] Optionally, based on the aforementioned target state block that needs to be executed by the first programmable chip, other instructions that can be executed by the first programmable chip can be further determined to achieve the goal of placing as many instructions as possible on the first programmable chip for execution. Based on this, in one embodiment, after the aforementioned determination of the target state block that needs to be executed by the first programmable chip, it can also include: starting from the instruction ranked first in the first other code, the current instruction belonging to the executable instruction range of the first programmable chip is sequentially determined as the first chip instruction that needs to be executed by the first programmable chip, until the resource limit of the first programmable chip is exceeded or all instructions are traversed, and the first other code refers to other codes in the preprocessed source code except the at least one state block.

[0113] Optionally, after the first source code and the second source code are split, the first source code and the second source code can be compiled respectively to obtain the target code of the first source code and the target code of the second source code, and the target codes of the first source code and the second source code can be linked respectively to obtain the executable code of the first source code and the executable code of the second source code. The executable code of the first source code obtained is the executable code of the aforementioned program to be compiled on the first programmable chip, and the executable code of the second source code obtained is the executable code of the aforementioned program to be compiled on the second programmable chip. Thus, the executable code that can be used for execution on the programmable chip can be directly obtained.

[0114] It should be understood that when there are multiple first programmable chips, multiple first source codes can be obtained, and the multiple first source codes can be compiled respectively to obtain target codes of the multiple first source codes, and then executable codes of the multiple first source codes can be obtained. It should be noted that the implementation of compilation and code linking can be referred to the specific description in the relevant technology, which will not be repeated here.

[0115] Alternatively, optionally, after the first source code and the second source code are split, when the programming language of the first source code is not a programming language supported by the compiler of the first programmable chip, the programming language of the first source code can be converted into a programming language supported by the compiler of the first programmable chip, and when the programming language of the second source code is not a programming language supported by the compiler of the second programmable chip, the programming language of the second source code can be converted into a programming language supported by the compiler of the second programmable chip. It should be understood that the programming languages ​​of the first source code and the second source code are the same, and are both programming languages ​​used by developers when writing source codes of programs to be compiled.

[0116] For example, assuming that the second programmable chip is a CPU chip, and the programming language supported by the compiler of the CPU chip is C language, but the programming language of the second source code is not C language, the programming language of the second source code can be converted into C language, so as to obtain the second source code whose programming language is C language. By further using the compiler of the CPU chip on the second source code whose programming language is C language, the executable code of the program to be compiled on the second programmable chip can be obtained.

[0117] For example, assuming that the first programmable chip is an FPGA chip, and the programming language supported by the compiler of the FPGA chip is Verilog (a language of FPGA), and the programming language of the first source code is not Verilog, the programming language of the first source code can be converted into Verilog, so as to obtain the first source code whose programming language is Verilog. By further using the compiler of the first programmable chip to process the first source code whose programming language is Verilog, the executable code of the program to be compiled on the first programmable chip can be obtained.

[0118] In one embodiment, the compiler system of the server unified programming platform provided in the embodiment of the present application can be as follows: Figure 4 As shown, Figure 4 In the example, traffic sampling, high-level language programs, and performance specifications can be used as inputs to the compiler system, and the first source code whose programming language is supported by the compiler of the first programmable chip and the second source code whose programming language is supported by the compiler of the second programmable chip can be used as outputs of the compiler system, wherein the high-level language program corresponds to the source code of the aforementioned program to be compiled, and traffic sampling can obtain the unit time traffic size of each traffic feature history in the traffic features that need to be processed by the program to be compiled. Figure 4 As shown, the compiler system can include three parts: front-end, middle-end and back-end.

[0119] The front end may be used to preprocess the high-level language program to obtain the preprocessed high-level language program (corresponding to the aforementioned preprocessed source code).

[0120] The middle end can perform instruction dependency analysis, control flow analysis, state block analysis and state index analysis on the preprocessed high-level language program, wherein the instruction dependency analysis can obtain an instruction dependency graph (corresponding to the aforementioned dependency information), the control flow analysis can obtain a control block (corresponding to the aforementioned conditional analysis result), the state block analysis can obtain a state block (corresponding to the aforementioned state analysis result), and the state index analysis can obtain an index table (corresponding to the aforementioned target instruction), thereby obtaining an intermediate representation including instruction expansion, instruction dependency graph, control block, state block and index table, wherein the instruction expansion corresponds to the aforementioned preprocessed source code.

[0121] The back-end compilation algorithm can combine the performance model, hardware / computing constraints, specification constraints, and traffic sampling results to split the intermediate representation and generate a first source code and a second source code, wherein the role of the hardware / computing constraints can correspond to the resource limitations of the aforementioned first programmable chip, and the specification constraints can correspond to the aforementioned selection of one from a plurality of feasible corresponding relationships. It should be understood that when there are multiple first programmable chips, a corresponding first source code can be generated for each of the multiple first programmable chips.

[0122] The back-end translator a can convert the programming language of the first source code into a programming language supported by the translator of the first programmable chip, and the back-end translator b can convert the programming language of the second source code into a programming language supported by the translator of the second programmable chip.

[0123] The program compilation method provided in this embodiment performs preprocessing, instruction analysis and code splitting in sequence based on the source code of the program written by the developer for realizing the network function (hereinafter referred to as the program to be compiled), so as to obtain a first source code for generating an executable code of the program to be compiled on the first programmable chip and a second source code for generating an executable code of the program to be compiled on the second programmable chip. In this way, in a scenario where the first programmable chip needs to assist the second programmable chip in processing network traffic, the source code corresponding to the first programmable chip (i.e., the first source code) and the source code corresponding to the second programmable chip (i.e., the second source code) can be automatically split based on the source code of the same program to be compiled, so that the developer does not need to split the network function solution, nor does he need to write the programs of the first programmable chip (e.g., the programmable chip in the smart network card) and the second programmable chip (e.g., the CPU chip) on different programming platforms respectively. Instead, the developer only needs to write the entire program to be compiled on a unified programming platform, thereby reducing the development labor and shortening the development time.

[0124] Figure 5 A schematic diagram of the structure of a compiler provided in one embodiment of the present application; see Attachment Figure 5 As shown, this embodiment provides a compiler, which can execute the method provided in the above embodiment. Specifically, the compiler may include:

[0125] A preprocessing module 51 is used to preprocess the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function;

[0126] An analysis module 52, configured to perform instruction analysis on the preprocessed source code and generate corresponding analysis results to obtain an intermediate representation including the analysis results and the preprocessed source code;

[0127] The splitting module 53 is used to perform code splitting based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled, wherein the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, and the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

[0128] Optionally, the analysis module 52 is specifically used for:

[0129] Analyzing dependencies between instructions in the preprocessed source code to obtain dependency information;

[0130] Instructions involving the same state variable in the preprocessed source code are analyzed, and the instructions involving the same state variable are merged to obtain a state analysis result.

[0131] Optionally, the analysis module 52 is used to merge instructions involving the same state variable to obtain a state analysis result, including:

[0132] The target instructions among all the instructions involving the same state variable are merged into the same state block to obtain a state analysis result, wherein the target instructions are from the first instruction that performs a read operation on the same state variable to the last instruction that performs a write operation on the same state variable among all the instructions involving the same state variable.

[0133] Optionally, the splitting module 53 is specifically used for:

[0134] Based on the state analysis result, under the condition that the resource restriction of the first programmable chip is satisfied, determining a first chip instruction in the preprocessed source code that needs to be executed by the first programmable chip;

[0135] Using other instructions in the preprocessed source code except the first chip instructions as second chip instructions to be executed by the second programmable chip;

[0136] Based on the dependency information, a first extended instruction is added on the basis of the first chip instruction, and a second extended instruction is added on the basis of the second chip instruction, so as to obtain the first source code and the second source code.

[0137] Optionally, the splitting module 53 is used to determine, based on the state analysis result and under the condition that resource restrictions of the first programmable chip are met, a first chip instruction in the preprocessed source code that needs to be executed by the first programmable chip, including:

[0138] When the state analysis result includes at least one state block, based on the at least one state block, determining a first chip instruction that needs to be executed by the first programmable chip under the condition that resource restrictions of the first programmable chip are met;

[0139] When the status block is not included in the status analysis result, starting from the instruction arranged first in the preprocessed source code, the current instruction belonging to the executable instruction range of the first programmable chip is determined as the first chip instruction that needs to be executed by the first programmable chip in sequence until the resource limit of the first programmable chip is exceeded or all instructions are traversed.

[0140] Optionally, the splitting module 53 is used to determine, based on the at least one status block and under the condition that resource restrictions of the first programmable chip are met, a first chip instruction that needs to be executed by the first programmable chip, including:

[0141] Inputting each state block of the at least one state block into the performance model of the first programmable chip for processing, respectively, to obtain a data packet processing speed of each state block for the same element of the corresponding state variable;

[0142] Estimate the maximum flow size per unit time of the same element of the state variable corresponding to each state block;

[0143] According to the maximum flow size per unit time of each state block and the data packet processing speed of each state block obtained by processing the performance model of the first programmable chip, a candidate state block whose data packet processing speed can meet the maximum flow size requirement per unit time is determined from the at least one state block, so as to obtain a candidate state block set of the first programmable chip;

[0144] According to the candidate state block set of the first programmable chip, under the condition that the resource limitation of the first programmable chip is met, a target state block that needs to be executed by the first programmable chip is determined to obtain a first chip instruction that needs to be executed by the first programmable chip, and the first chip instruction includes the target state block.

[0145] Optionally, when the candidate state set of the first programmable chip is empty, the splitting module 53 is used to determine the first chip instruction that needs to be executed by the first programmable chip based on the at least one state block and under the condition that the resource restriction of the first programmable chip is met, and further includes:

[0146] If there is no candidate status block in the at least one status block whose data packet processing speed can meet its maximum traffic size requirement, starting from the instruction ranked first in the first other code, the current instruction belonging to the executable instruction range of the first programmable chip is determined in sequence as the first chip instruction that needs to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all instructions are traversed, and the first other code refers to other codes in the preprocessed source code except the at least one status block.

[0147] Optionally, when the number of the first programmable chip is one and the candidate state block set of the first programmable chip is not empty, the splitting module 53 is used to determine the target state block that needs to be executed by the first programmable chip according to the candidate state block set of the first programmable chip and under the condition that the resource restriction of the first programmable chip is met, including:

[0148] Sort the candidate state blocks in the candidate state block set of the first programmable chip in descending order according to the maximum flow size;

[0149] Starting from the first candidate state block, the current candidate state blocks belonging to the executable instruction range of the first programmable chip are determined in sequence as target state blocks that need to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all candidate state blocks are traversed.

[0150] Optionally, when there are multiple first programmable chips and the candidate state block sets of the multiple first programmable chips are not empty, the splitting module 53 is used to determine the target state block that needs to be executed by the first programmable chip according to the candidate state block set of the first programmable chip and under the condition that the resource restriction of the first programmable chip is met, including:

[0151] Determine a union of candidate state block sets of the plurality of first programmable chips;

[0152] Sort the candidate state blocks in the union set in descending order according to the maximum flow size;

[0153] For each chip order in the multiple chip orders corresponding to the multiple first programmable chips, starting from the candidate state block arranged in the first position and the first programmable chip arranged in the first position, the current candidate state blocks that belong to the executable instruction range of the current first programmable chip and belong to the candidate state block set of the current first programmable chip are sequentially matched to the current first programmable chip until any first programmable chip resource limit is exceeded or all candidate state blocks are traversed, so as to obtain a correspondence relationship between multiple feasible candidate state blocks and the first programmable chip;

[0154] Based on the performance specification, a feasible correspondence relationship between the candidate state blocks and the first programmable chip is selected from the plurality of feasible correspondence relationships between the candidate state blocks and the first programmable chip to determine a target state block that needs to be executed by the plurality of first programmable chips respectively.

[0155] Optionally, the splitting module 53 is further used for:

[0156] Starting from the instruction ranked first in the first other code, the current instruction belonging to the executable instruction range of the first programmable chip is determined in sequence as the first chip instruction that needs to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all instructions are traversed. The first other code refers to other codes in the preprocessed source code except the at least one status block.

[0157] Optionally, the analysis module 52 is further used to: determine a target instruction for creating an index of a state variable corresponding to each state block based on the dependency information;

[0158] The splitting module 53 is used to estimate the maximum flow size per unit time of the same element of the state variable corresponding to each state block, including:

[0159] Determine at least one flow feature group corresponding to the state variables of each state block, take the sum of the flow sizes per unit time of each flow feature history in each flow feature group corresponding to the state variables of each state block as the flow size per unit time of each flow feature group corresponding to the state variables of each state block, and take the maximum flow size among the flow sizes per unit time of each flow feature group corresponding to the state variables of each state block as the maximum flow size per unit time of the same element of the state variables corresponding to each state block.

[0160] Optionally, the analysis module 52 is further used to: analyze the instructions that need to be executed under the same condition in the preprocessed source code, and based on the dependency information, pack the instructions that need to be executed under the same condition and have dependencies between them into the same control block to obtain a conditional analysis result, wherein the conditional analysis result includes multiple control blocks;

[0161] The analysis module 52 is used to analyze whether there are instructions involving state variables in the preprocessed source code, including:

[0162] Identifying a target control block among the plurality of control blocks, the target control block being a control block corresponding to a target conditional branch, the target conditional branch being a conditional branch whose execution result changes a judgment result of a corresponding judgment condition;

[0163] Analyze whether there are instructions involving state variables in the second other code, where the second other code refers to other codes in the preprocessed source code except the target control block.

[0164] Optionally, the compiler further includes a compiling and linking module, which is used to compile the first source code and the second source code respectively to obtain the object code of the first source code and the object code of the second source code, and to link the object codes of the first source code and the second source code respectively to obtain the executable code of the first source code and the executable code of the second source code;

[0165] Alternatively, the compiler also includes a translation module for converting the programming language of the first source code into a programming language supported by the compiler of the first programmable chip when the programming language of the first source code is not a programming language supported by the compiler of the first programmable chip, and for converting the programming language of the second source code into a programming language supported by the compiler of the second programmable chip when the programming language of the second source code is not a programming language supported by the compiler of the second programmable chip.

[0166] Figure 5 The compiler shown can execute Figure 2 The method provided in the embodiment shown in the figure, for the part not described in detail in this embodiment, please refer to Figure 2 The implementation process and technical effects of this technical solution refer to Figure 2 The description in the illustrated embodiment will not be repeated here.

[0167] In one possible implementation, Figure 5 The structure of the compiler shown can be implemented as a computer device. Figure 6 As shown, the computer device may include: a processor 61 and a memory 62. The memory 62 is used to store the computer device to execute the above Figure 2 The processor 61 is configured to execute the program stored in the memory 62 according to the method provided in the illustrated embodiment.

[0168] The program includes one or more computer instructions, wherein when the one or more computer instructions are executed by the processor 61, the following steps can be implemented:

[0169] Preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function;

[0170] Performing instruction analysis on the preprocessed source code to generate corresponding analysis results, so as to obtain an intermediate representation including the analysis results and the preprocessed source code;

[0171] Code splitting is performed based on the intermediate representation to obtain a first source code and a second source code of the program to be compiled, wherein the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, and the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

[0172] Optionally, the processor 61 is further configured to execute the aforementioned Figure 2 All or part of the steps in the illustrated embodiments.

[0173] The structure of the computer device may further include a communication interface 63 for the computer device to communicate with other devices or a communication network.

[0174] In addition, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the method described in the above method embodiment is implemented.

[0175] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative labor.

[0176] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0177] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer instructions. These computer instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processor of the computer or other programmable device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0178] These computer instructions may also be stored in a computer-readable memory that can direct a computer or other programmable device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0179] These computer instructions may also be loaded onto a computer or other programmable device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide the means for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0180] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0181] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0182] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, linked lists, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A program compiling method, It is characterized in that include: Preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function; Performing instruction analysis on the preprocessed source code to generate corresponding analysis results, so as to obtain an intermediate representation including the analysis results and the preprocessed source code; The instruction analysis of the preprocessed source code includes: analyzing the dependency relationship between instructions in the preprocessed source code to obtain dependency information; analyzing the instructions involving the same state variable in the preprocessed source code, merging target instructions in all instructions involving the same state variable into the same state block to obtain a state analysis result, wherein the target instructions are from the first instruction that performs a read operation on the same state variable to the last instruction that performs a write operation on the same state variable in all instructions involving the same state variable; Based on the state analysis result, under the condition that the resource restriction of the first programmable chip is met, determining the first chip instruction in the preprocessed source code that needs to be executed by the first programmable chip; Using other instructions in the preprocessed source code except the first programmable chip instructions as second chip instructions to be executed by a second programmable chip; Based on the dependency information, a first extension instruction is added to the first chip instruction, and a second extension instruction is added to the second chip instruction to obtain a first source code and a second source code of the program to be compiled, wherein the first source code is used to generate an executable code of the program to be compiled on a first programmable chip, and the second source code is used to generate an executable code of the program to be compiled on a second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

2. The method according to claim 1, It is characterized in that The determining, based on the state analysis result and under the condition that resource restrictions of the first programmable chip are met, a first chip instruction in the preprocessed source code that needs to be executed by the first programmable chip includes: When the state analysis result includes at least one state block, based on the at least one state block, determining a first chip instruction that needs to be executed by the first programmable chip under the condition that resource restrictions of the first programmable chip are met; When the status block is not included in the status analysis result, starting from the instruction arranged first in the preprocessed source code, the current instruction belonging to the executable instruction range of the first programmable chip is determined as the first chip instruction that needs to be executed by the first programmable chip in sequence until the resource limit of the first programmable chip is exceeded or all instructions are traversed.

3. The method according to claim 2, It is characterized in that The determining, based on the at least one status block and under the condition that resource restrictions of the first programmable chip are met, a first chip instruction that needs to be executed by the first programmable chip comprises: Inputting each state block of the at least one state block into the performance model of the first programmable chip for processing, respectively, to obtain a data packet processing speed of each state block for the same element of the corresponding state variable; Estimate the maximum flow size per unit time of the same element of the state variable corresponding to each state block; According to the maximum flow size per unit time of each state block and the data packet processing speed of each state block obtained by processing the performance model of the first programmable chip, a candidate state block whose data packet processing speed can meet the maximum flow size requirement per unit time is determined from the at least one state block, so as to obtain a candidate state block set of the first programmable chip; According to the candidate state block set of the first programmable chip, under the condition that the resource limitation of the first programmable chip is met, a target state block that needs to be executed by the first programmable chip is determined to obtain a first chip instruction that needs to be executed by the first programmable chip, and the first chip instruction includes the target state block.

4. The method according to claim 3, It is characterized in that When the candidate state set of the first programmable chip is empty, determining the target state block to be executed by the first programmable chip under the condition that the resource restriction of the first programmable chip is satisfied includes: Starting from the instruction ranked first in the first other code, the current instruction belonging to the executable instruction range of the first programmable chip is determined in sequence as the first chip instruction that needs to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all instructions are traversed. The first other code refers to other codes in the preprocessed source code except the at least one status block.

5. The method according to claim 3, It is characterized in that When the number of the first programmable chip is one and the candidate state block set of the first programmable chip is not empty, determining the target state block to be executed by the first programmable chip according to the candidate state block set of the first programmable chip and under the condition that the resource restriction of the first programmable chip is satisfied, includes: Sort the candidate state blocks in the candidate state block set of the first programmable chip in descending order according to the maximum flow size; Starting from the first candidate state block, the current candidate state blocks belonging to the executable instruction range of the first programmable chip are determined in sequence as target state blocks that need to be executed by the first programmable chip until the resource limit of the first programmable chip is exceeded or all candidate state blocks are traversed.

6. The method according to claim 4, It is characterized in that In a case where there are multiple first programmable chips and candidate state block sets of the multiple first programmable chips are not empty, determining a target state block that needs to be executed by the first programmable chip according to the candidate state block set of the first programmable chip and under the condition that resource restrictions of the first programmable chip are met, includes: Determine a union of candidate state block sets of the plurality of first programmable chips; Sort the candidate state blocks in the union set in descending order according to the maximum flow size; For each chip order in the multiple chip orders corresponding to the multiple first programmable chips, starting from the candidate state block arranged in the first position and the first programmable chip arranged in the first position, the current candidate state blocks that belong to the executable instruction range of the current first programmable chip and belong to the candidate state block set of the current first programmable chip are sequentially matched to the current first programmable chip until any first programmable chip resource limit is exceeded or all candidate state blocks are traversed, so as to obtain a correspondence relationship between multiple feasible candidate state blocks and the first programmable chip; Based on the performance specification, a feasible correspondence relationship between the candidate state blocks and the first programmable chip is selected from the plurality of feasible correspondence relationships between the candidate state blocks and the first programmable chip to determine a target state block that needs to be executed by the plurality of first programmable chips respectively.

7. The method according to claim 1, It is characterized in that After performing code splitting based on the intermediate representation to obtain the first source code and the second source code of the program to be compiled, the method further includes: Compiling the first source code and the second source code respectively to obtain the object code of the first source code and the object code of the second source code, and linking the object codes of the first source code and the second source code respectively to obtain the executable code of the first source code and the executable code of the second source code; or, When the programming language of the first source code is not a programming language supported by the compiler of the first programmable chip, the programming language of the first source code is converted into a programming language supported by the compiler of the first programmable chip; when the programming language of the second source code is not a programming language supported by the compiler of the second programmable chip, the programming language of the second source code is converted into a programming language supported by the compiler of the second programmable chip.

8. A compiler, It is characterized in that include: A preprocessing module, used for preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer to realize a network function; An analysis module, configured to perform instruction analysis on the preprocessed source code and generate corresponding analysis results to obtain an intermediate representation including the analysis results and the preprocessed source code; The instruction analysis of the preprocessed source code includes: analyzing the dependency relationship between instructions in the preprocessed source code to obtain dependency information; analyzing the instructions involving the same state variable in the preprocessed source code, merging target instructions in all instructions involving the same state variable into the same state block to obtain a state analysis result, wherein the target instructions are from the first instruction that performs a read operation on the same state variable to the last instruction that performs a write operation on the same state variable in all instructions involving the same state variable; A splitting module is used to determine, based on the status analysis result and under the condition that the resource limitation of the first programmable chip is met, the first chip instructions in the preprocessed source code that need to be executed by the first programmable chip; use other instructions in the preprocessed source code except the first programmable chip instructions as second chip instructions that need to be executed by the second programmable chip; based on the dependency information, add a first extended instruction on the basis of the first chip instruction, and add a second extended instruction on the basis of the second chip instruction, so as to obtain the first source code and the second source code of the program to be compiled, the first source code is used to generate the executable code of the program to be compiled on the first programmable chip, the second source code is used to generate the executable code of the program to be compiled on the second programmable chip, and the first programmable chip is used to assist the second programmable chip in processing network traffic.

9. A computing device, It is characterized in that include: a first programmable chip and a second programmable chip, wherein the first programmable chip is used to assist the second programmable chip in processing network traffic; The executable code on the first programmable chip is generated based on a first source code, and the executable code on the second programmable chip is generated based on a second source code; The first source code and the second source code are obtained by performing the following processing on the program to be compiled: preprocessing the source code of the program to be compiled to obtain the preprocessed source code, wherein the program to be compiled is a program written by a developer for realizing network functions; performing instruction analysis on the preprocessed source code to generate corresponding analysis results to obtain an intermediate representation including the analysis results and the preprocessed source code; the instruction analysis on the preprocessed source code includes: analyzing the dependency relationship between instructions in the preprocessed source code to obtain dependency relationship information; analyzing the instructions involving the same state variable in the preprocessed source code, merging the target instructions in all instructions involving the same state variable into the same state block to obtain a state analysis result, wherein the target The instructions are from the first instruction for performing a read operation on the same state variable to the last instruction for performing a write operation on the same state variable among all the instructions involving the same state variable; based on the state analysis result, under the condition that the resource limitation of the first programmable chip is met, the first chip instructions that need to be executed by the first programmable chip in the preprocessed source code are determined; other instructions in the preprocessed source code except the first programmable chip instructions are used as second chip instructions that need to be executed by the second programmable chip; based on the dependency information, a first extended instruction is added on the basis of the first chip instruction, and a second extended instruction is added on the basis of the second chip instruction, so as to obtain the first source code and the second source code of the program to be compiled.

10. A computer device, It is characterized in that include: A memory, a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method as described in any one of claims 1 to 7.

11. A computer-readable storage medium, It is characterized in that A computer program is stored thereon, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.