Custom instruction parallel selection method, distributed computing system, device and medium
By segmenting and filtering custom instructions using master nodes and compute nodes in a distributed computing system, the problem of selecting large-scale custom instructions is solved, and an efficient and reliable parallel selection method is implemented, improving the efficiency and speed of custom instruction selection.
Patent Information
- Application Number
- CN202411665503.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-11-20
AI Technical Summary
Existing technologies struggle to provide optimal design solutions within a reasonable timeframe for large-scale custom instruction selection problems, and serial methods are ineffective.
A distributed computing system is adopted, which includes a master node, multiple first computing nodes and multiple second computing nodes. The master node divides the undirected graph and allocates subgraphs. The first computing nodes are used to predict and count the execution time and analyze the load balance. The second computing nodes are used to select the optimal subgraph and realize parallel custom instruction selection.
It achieves efficient and reliable custom instruction selection, reaching a near-linear speedup ratio, and improves the efficiency and reliability of custom instruction selection.
Smart Images

Figure CN119806645B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for parallel selection of custom instructions, a distributed computing system, an apparatus, and a medium. Background Technology
[0002] A dedicated instruction set processor is a processor designed with an extended instruction set. The problem of custom instruction selection is one of the most critical issues that arises during the automatic generation of extended instruction sets. Currently, most research on the custom instruction selection problem considers using a serial approach to solve it. However, when the problem is large in scale, the serial approach is difficult to provide an optimal design solution within a reasonable time, or even fails to provide an optimal design solution, resulting in poor implementation performance. Summary of the Invention
[0003] The main purpose of this application is to propose a method for parallel selection of custom instructions, a distributed computing system, a device and a medium that can achieve efficient and reliable selection of custom instructions using a parallel approach.
[0004] To achieve the above objectives, one aspect of this application proposes a custom instruction parallel selection method applied to a distributed computing system, the distributed computing system including a master node, multiple first computing nodes, and multiple second computing nodes, the method comprising:
[0005] An undirected graph is obtained through the master node. The undirected graph contains several candidate custom instructions. The undirected graph is divided into multiple subgraphs. Each subgraph represents a task. Each subgraph is then assigned to any of the first computing nodes for management.
[0006] The multiple first computing nodes predict and calculate the total execution time for all execution times corresponding to all subgraphs under their management, and then feed back the total execution time calculated by each node to the master node.
[0007] The master node analyzes the total execution times reported by the multiple first computing nodes to determine whether load balancing exists among the multiple second computing nodes.
[0008] When the master node detects that there is load balancing among the multiple second computing nodes, it aggregates all the subgraphs managed by each of the multiple first computing nodes to generate a subgraph list, and then distributes the generated subgraph list to at least two second computing nodes for management.
[0009] The multiple second computing nodes filter out all optimal subgraphs from their respective lists of all subgraphs, and then obtain all candidate custom instructions from all the optimal subgraphs they have selected.
[0010] Furthermore, the prediction of all execution times corresponding to all subgraphs managed by the plurality of first computing nodes includes:
[0011] For each of the first computing nodes and all the subgraphs it manages, the attribute parameters of each subgraph are input into a preset time prediction model through the first computing node for analysis, so as to predict the execution time corresponding to each subgraph; wherein, the time prediction model is constructed based on the data regression prediction principle of extreme random trees.
[0012] Furthermore, the step of analyzing the total execution times fed back by the multiple first computing nodes through the master node to determine whether load balancing exists among the multiple second computing nodes includes:
[0013] The master node filters out the maximum and minimum values from the multiple total execution times and calculates the average of the multiple total execution times;
[0014] The master node calculates the load balancing degree value among the plurality of second computing nodes based on the maximum value, the minimum value, and the average value.
[0015] The master node detects whether the load balancing level value is less than or equal to a preset load balancing level threshold; if yes, it determines that there is load balancing among the multiple second computing nodes; if no, it determines that there is no load balancing among the multiple second computing nodes.
[0016] Furthermore, the method also includes:
[0017] When the master node detects that there is no load balancing among the plurality of second computing nodes, it filters out all subgraphs whose execution time is greater than a preset time threshold from all subgraphs managed by the plurality of first computing nodes.
[0018] The multiple first computing nodes divide each selected subgraph into multiple new subgraphs for management, and return the steps of predicting and calculating the total execution time for all subgraphs managed by the multiple first computing nodes, and then feeding back the total execution time calculated by each node to the master node.
[0019] Furthermore, the step of dividing each selected subgraph into multiple new subgraphs through the plurality of first computing nodes includes:
[0020] For each of the first computing nodes and each of the subgraphs selected, the quotient between the execution time of the subgraph and the preset time threshold is rounded up to obtain the number of segments. Then, the subgraph is divided into multiple new subgraphs according to the number of segments.
[0021] Furthermore, the step of selecting all optimal subgraphs from the list of all subgraphs managed by each of the plurality of second computing nodes includes:
[0022] For each second computing node and all subgraph lists it manages, isomorphic matching is performed on all subgraphs contained in the all subgraph lists through the second computing node to obtain multiple recombined subgraph lists;
[0023] The second computing node performs optimization and screening on the list of multiple recombined subgraphs according to a preset mathematical programming model to obtain all the optimal subgraphs.
[0024] Furthermore, the mathematical programming model includes an objective function and subgraph selection constraints. The objective function is constructed with the goal of maximizing the runtime performance of the multiple recombined subgraph lists. The subgraph selection constraints include constraints on the runtime resources occupied by the multiple recombined subgraph lists, as well as constraints on non-overlapping subgraphs and non-cyclic subgraphs between any two recombined subgraph lists. The process of using the second computing node to perform optimization and selection on the multiple recombined subgraph lists according to the preset mathematical programming model to obtain all optimal subgraphs includes:
[0025] The second computing node optimizes the objective function based on the list of multiple recombined subgraphs and the subgraph selection constraints, so as to select all the optimal subgraphs from the list of multiple recombined subgraphs.
[0026] To achieve the above objectives, another aspect of this application proposes a distributed computing system, which includes a master node, multiple first computing nodes, and multiple second computing nodes.
[0027] The master node is used to obtain an undirected graph containing several candidate custom instructions, divide the undirected graph into multiple subgraphs, each subgraph represents a task, and then assign each subgraph to any of the first computing nodes for management.
[0028] The multiple first computing nodes are used to predict and calculate the total execution time for all execution times corresponding to all subgraphs under their management, and then feed back the total execution time calculated by each node to the master node.
[0029] The master node is also used to analyze the total execution times fed back by the plurality of first computing nodes to determine whether there is load balancing among the plurality of second computing nodes;
[0030] When the master node detects that there is load balancing among the plurality of second computing nodes, the plurality of first computing nodes are also used to aggregate all the subgraphs they manage to generate a subgraph list, and then distribute the subgraph list they generate to at least two second computing nodes for management;
[0031] The multiple second computing nodes are used to filter out all optimal subgraphs from the list of all subgraphs they manage, and then obtain all candidate custom instructions from all the optimal subgraphs they have filtered out.
[0032] To achieve the above objectives, another aspect of this application proposes an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0033] To achieve the above objectives, another aspect of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0034] This application includes at least the following beneficial effects: by introducing a distributed computing system comprising a master node, multiple first computing nodes, and multiple second computing nodes, the master node is used to perform undirected graph partitioning, subgraph allocation, and load balancing analysis among multiple second computing nodes; each first computing node is used to perform subgraph execution time prediction and statistical feedback, subgraph aggregation and allocation under load balancing conditions, and subgraph partitioning under load imbalance conditions; and each second computing node is used to perform subgraph optimization to further complete the screening of candidate custom instructions. Thus, a parallel approach can be used to complete the selection of efficient and reliable custom instructions, achieving an approximately linear speedup. Attached Figure Description
[0035] Figure 1 This is a flowchart illustrating a custom instruction parallel selection method provided in an embodiment of this application;
[0036] Figure 2 This is a schematic diagram of the composition of the distributed computing system provided in this application embodiment in an application scenario;
[0037] Figure 3 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of systems and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.
[0039] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”
[0040] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.
[0041] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0042] An Application Specific Instruction Set Processor (ASIP) is a processor designed using an extended instruction set (also known as a custom instruction set). It primarily works by recognizing custom instructions and executing computationally intensive code from applications within hardware implementations of these custom instructions—custom function units (CFUs). The custom instructions executed on a CFU encapsulate a set of basic instructions, and performance is improved through parallelization and chaining between these basic instructions. Encapsulating multiple basic instructions into custom instructions effectively reduces the number of instruction fetches and data transfers between registers and the processor, significantly reducing power consumption. By using the same custom instruction set for different applications within the same domain, ASIP processors offer a degree of flexibility.
[0043] The automatic generation of extended instruction sets is one of the most critical issues in the design of dedicated instruction set processors. The specific process for solving this problem is as follows: Using the corresponding source code as input, a compiler frontend is invoked to perform compilation optimization on the source code; a program performance analyzer is invoked to identify computationally intensive code blocks in each application, and corresponding data flow graphs are generated for these blocks; in the custom instruction enumeration phase, all candidate custom instructions that satisfy the constraints are enumerated from the generated intermediate representation-data flow graph; in the custom instruction selection phase, based on the given constraints and design objectives, logic synthesis tools are used to provide information such as the area and latency of the custom instructions, and a subset of custom instructions is efficiently selected from the candidate set to form the final domain-shared extended instruction set; based on the generated extended instruction set, the source code is converted into new code containing the selected custom instructions through pattern matching and selection, code replacement, and generation.
[0044] Custom instruction selection is one of the most critical issues in the automatic generation of extended instruction sets. Most current research on custom instruction selection considers using a serial approach to solve it. However, when the problem is large in scale, the serial approach is difficult to provide an optimal design solution within a reasonable time, or even fails to provide an optimal design solution, resulting in poor implementation performance.
[0045] In view of this, embodiments of this application provide a method for parallel selection of custom instructions, a distributed computing system, a device, and a medium. This solution introduces a distributed computing system comprising a master node, multiple first computing nodes, and multiple second computing nodes. The master node is used to perform undirected graph partitioning, subgraph allocation, and load balancing analysis among the multiple second computing nodes. Each first computing node is used to predict and statistically feedback the execution time of the subgraph, perform subgraph aggregation and allocation under load balancing, and perform subgraph partitioning under unbalanced load. Each second computing node is used to perform subgraph optimization to further complete the screening of candidate custom instructions. Thus, a parallel method can be used to complete the selection of efficient and reliable custom instructions, achieving an approximately linear speedup.
[0046] Figure 1 This is an optional flowchart illustrating a custom instruction parallel selection method provided in an embodiment of this application. Figure 1 The method described above is applied to a distributed computing system, which includes a master node, multiple first computing nodes, and multiple second computing nodes. The method may include, but is not limited to, steps S101 to S106:
[0047] Step S101: Obtain the undirected graph through the master node, divide the undirected graph into multiple subgraphs, and then assign each subgraph to any first computing node for management;
[0048] Step S102: The total execution time is predicted and calculated for all execution times corresponding to all subgraphs managed by multiple first computing nodes, and then the total execution time calculated by each node is fed back to the master node.
[0049] Step S103: Analyze the total execution times fed back by multiple first computing nodes through the master node to determine whether there is load balancing among multiple second computing nodes;
[0050] Step S104: When the master node detects that there is no load balancing among multiple second computing nodes, it filters out all subgraphs with execution times greater than a preset time threshold from all subgraphs managed by multiple first computing nodes, and then divides each of the filtered subgraphs into multiple new subgraphs for management, and returns to the above step S102.
[0051] Step S105: When the master node detects that there is load balancing between multiple second computing nodes, it aggregates all the subgraphs managed by the multiple first computing nodes to generate a subgraph list, and then assigns the generated subgraph list to at least two second computing nodes for management.
[0052] Step S106: Select all optimal subgraphs from the list of all subgraphs managed by each of the multiple second computing nodes, and then obtain all candidate custom instructions from the list of all optimal subgraphs selected by each node.
[0053] In some embodiments, the distributed computing system is preferably built based on the MapReduce model in the cloud computing field. The master node manages the task allocation in the Map phase and the task allocation in the Reduce phase. The task allocation in the Map phase refers to managing each first computing node to receive a portion of the subgraph to complete the execution time prediction and fine-grained partitioning of the subgraph. In addition, the master node also needs to detect the load balancing among multiple second computing nodes in the Map phase. The task allocation in the Reduce phase refers to managing each second computing node to receive a portion of the subgraph list finally generated by the first computing nodes to complete the optimization of candidate custom instructions. Furthermore, the number of multiple first computing nodes and multiple second computing nodes can be set and adjusted according to the complexity of the implementation task, and this application does not limit this.
[0054] In step S101 of some embodiments, the undirected graph contains several candidate custom instructions, and these candidate custom instructions are usually generated during the custom instruction enumeration stage. The undirected graph can be understood as being constructed based on the overlapping and cyclic relationships between the candidate custom instructions. Each candidate custom instruction is a node in the undirected graph, and the edge formed between any two nodes in the undirected graph represents the overlapping or cyclic relationship between the two candidate custom instructions referred to by these two nodes. The undirected graph can be regarded as a complex task formed by several candidate custom instructions. Dividing the undirected graph into multiple subgraphs is equivalent to dividing the complex task into multiple relatively simple tasks. That is, each subgraph represents a relatively simple task, and the subgraph division operation only involves the reorganization and division between multiple candidate custom instructions, and does not actually affect the candidate custom instructions themselves.
[0055] In step S101 of some embodiments, a fine-grained partitioning strategy is preferably used to divide the undirected... Figure 1 The image is divided into multiple subgraphs in one step, as represented by the following expression:
[0056] G1 = v1∪N(G, v1),
[0057] G2 = v2∪N(G-{v1}, v2),
[0058] G k =v k ∪N(G-{v1, v2, ..., v k-1}, v k ),
[0059] ...,
[0060] G |V|-1 =v |V|-1 ∪N(G-{v1, v2, ..., v |V|-2}, v |V|-1 );
[0061] In the formula, G is the undirected graph, v t For the nodes contained in this undirected graph, G t For the node v t Let G be the base node and the subgraph obtained by partitioning the undirected graph G, where t = 1, 2, ..., k, ..., |V|-1, |V|-1 is the number of subgraphs obtained by partitioning the undirected graph, and N(x, y) represents all neighboring nodes of node y in graph x. It should be noted that the subgraph G can be partitioned... t The corresponding reference node v t Make a mark so that subsequent operations on this subgraph G tAll new subgraphs obtained when making further segmentations can contain the marked baseline node v t .
[0062] In step S102 of some embodiments, multiple first computing nodes predict all execution times corresponding to all subgraphs managed by each node. Specifically, for each first computing node and all subgraphs managed by it, the attribute parameters of each subgraph managed by the first computing node are input into a preset time prediction model for analysis in order to predict the execution time corresponding to the subgraph.
[0063] The subgraph's attribute parameters include the number of nodes and edges it contains, its density, and its area constraint. The density refers to the ratio between the number of edges and the maximum possible number of edges, which is [n(n-1)] / 2, where n is the number of nodes. The area constraint refers to the runtime resources required for the subgraph. This time prediction model is primarily based on the data regression prediction principle of extreme random trees and is constructed in a black-box manner. A mean squared error loss function is introduced during training to optimize the parameters. Compared to other machine learning methods, the complete randomness of feature selection in extreme random trees makes this time prediction model more generalizable and stable.
[0064] In some embodiments, the specific implementation of step S103 above includes: filtering out the minimum and maximum values from the multiple total execution times fed back by multiple first computing nodes through the master node, and calculating the average value of the multiple total execution times; calculating the load balancing degree value among multiple second computing nodes through the master node based on the minimum value, the maximum value and the average value; determining through the master node whether the load balancing degree value is less than or equal to a preset load balancing degree threshold; if yes, determining that there is load balancing among the multiple second computing nodes; if no, determining that there is no load balancing among the multiple second computing nodes.
[0065] The load balancing value among multiple second computing nodes is preferably calculated using the following expression:
[0066] γ=(T l -T s ) / T e ;
[0067] In the formula, γ is the load balancing value among multiple second computing nodes, and T l For this maximum value, T s For this minimum value, T e This is the average value.
[0068] In this application, the purpose of determining whether load balancing exists among multiple second computing nodes is to ensure that the tasks subsequently assigned to each second computing node have similar complexity, so as to further improve the implementation efficiency of the custom instruction selection process.
[0069] In step S104 of some embodiments, each selected subgraph is divided into multiple new subgraphs by multiple first computing nodes. The specific implementation includes: for each first computing node and each selected subgraph, the quotient between the execution time of the subgraph and the preset time threshold is rounded up to obtain the number of divisions, and then the subgraph is divided into multiple new subgraphs according to the number of divisions.
[0070] Preferably, a fine-grained partitioning strategy is adopted to further divide the subgraph into multiple new subgraphs that are appropriate for the number of partitions, specifically represented by the following expression:
[0071] G t,1 ={V t ,n1}∪N(G t -{V t},n1),
[0072] G t,2 ={V t ,n2}∪N(G t -{V t ,n1},n2),
[0073] ...,
[0074] G t,q ={V t n q}∪N(G t -{V t n1, ..., n q-1}, n q ),
[0075] ...,
[0076] G t,P ={V t n P}∪N(G t -{V t n1, ..., n P-1}, n P );
[0077] In the formula, G t V is the subgraph selected by the first computation node. t For this subgraph G tThe set of all marked reference nodes included, n s For this subgraph G t The nodes included, G t,s For the node n s As the reference node and from this subgraph G t The new subgraph obtained by partitioning G, s = 1, 2, ..., q, ..., P, where P is the subgraph G. t The corresponding number of segments, and T(G t ) is the subgraph G t The corresponding execution time, Δ, is the preset time threshold; it should be noted that the new subgraph G obtained from the segmentation can be... t,s For the corresponding reference node n s Make a mark so that subsequent operations on this new subgraph G t,s All new subgraphs obtained when making further partitions can contain the marked baseline node n. s and the set V t .
[0078] For example, the undirected graph can be partitioned in one step by the master node to obtain a subgraph G. k The subgraph G is managed by a first computing node. k If the master node determines that there is no load balancing among the multiple second computing nodes, the first computing node detects the subgraph G. k If the corresponding execution time is greater than the preset time threshold, then the subgraph G is determined to be... k The corresponding number of segments is m, and the subgraph G k The only tagged reference node included is node v. k The subgraph G is expressed using the following expression. k Divide into m new subgraphs:
[0079] G k,1 ={v k ,w1}∪N(G k -{v k},w1),
[0080] G k,2 ={v k ,w2}∪N(G k -{v k w q},w2),
[0081] ...,
[0082] G k,l ={v k w l}∪N(Gk -{v k w1, ..., w l-1}, w l ),
[0083] ...,
[0084] G k,m ={v k w m}∪N(G k -{v k w1, ..., w m-1}, w m );
[0085] In the formula, w r For this subgraph G k The nodes included, G k,r For the node w r As the reference node and from this subgraph G k The new subgraph obtained by partitioning the middle, r = 1, 2, ..., l, ..., m, and in general, by this subgraph G k The execution time of the first m-1 new subgraphs obtained from the segmentation is greater than the preset time threshold, and only the subgraph G is generated from this subgraph. k The last new subgraph G obtained from the segmentation k,m The corresponding execution time is less than or equal to the preset time threshold; it should be noted that this can be achieved in the new subgraph G obtained from the segmentation. k,r For the corresponding reference node w r Make a mark so that subsequent operations on this new subgraph G k,r All new subgraphs obtained when making further sub-segments can contain the marked reference node w. r and the node v k .
[0086] It should be noted that in step S104 above, if each first computing node detects that the execution time corresponding to each subgraph it manages is less than or equal to the preset time threshold, then each first computing node does not need to perform subgraph splitting operation. It can directly summarize all the subgraphs it manages to generate a subgraph list and distribute it to at least two second computing nodes for management. If only a portion of the first computing nodes detect that the execution time corresponding to each subgraph it manages is less than or equal to the preset time threshold, then these first computing nodes do not need to perform subgraph splitting operation. They can directly summarize all the subgraphs it manages to generate a subgraph list and distribute it to at least two second computing nodes for management. At the same time, these first computing nodes also need to cooperate by feeding back the total execution time obtained from the most recent statistics to the master node for load balancing detection. Alternatively, these first computing nodes can re-predict and statistically feed back the subgraph execution time.
[0087] In step S106 of some embodiments, all optimal subgraphs are selected from the list of all subgraphs managed by multiple second computing nodes. Specifically, for each second computing node and its list of all subgraphs managed, isomorphic matching is performed on all subgraphs contained in the list of all subgraphs managed by the second computing node to obtain multiple recombined subgraph lists. That is, there is an isomorphic relationship between every two subgraphs contained in each recombined subgraph list. Then, all optimal subgraphs are obtained by optimization and selection in the multiple recombined subgraph lists according to a preset mathematical programming model.
[0088] The mathematical programming model includes subgraph selection constraints and an objective function, as detailed below:
[0089] (1) The objective function is constructed with the goal of maximizing the runtime performance of multiple recombined subgraph lists, and can be expressed by the following expression:
[0090]
[0091] In the formula, F is the objective function, N is the number of multiple recombined subgraph lists, M is the number of all subgraphs contained in the i-th recombined subgraph list, and a i,j For a binary variable, when a i,j When a = 1, it means that the j-th subgraph contained in the i-th recombined subgraph list is selected, while when a i,j When T = 0, it means that the j-th subgraph contained in the i-th recombined subgraph list is not selected. i The performance achieved by the i-th reorganized subgraph list alone can be understood as the running time or speed required for the hardware implementation of the i-th reorganized subgraph list.
[0092] (2) The subgraph filtering constraints include constraints on the runtime resources occupied by multiple recombined subgraph lists, as well as subgraph non-cyclic constraints and subgraph non-overlapping constraints between every two recombined subgraph lists.
[0093] The constraints on runtime resources occupied by multiple reorganized subgraph lists can be represented by the following expression:
[0094]
[0095] In the formula, l i For a binary variable, when l i When l = 1, it means that at least one subgraph in the list of the i-th recombined subgraphs has been selected. i When A = 0, it means that no subgraph was selected in the list of the i-th recombined subgraphs. i The runtime resources required for the hardware implementation of the i-th recombined subgraph list determine the chip size and cost. A0 is a preset upper limit threshold for runtime resources. The constraints on the runtime resources occupied by multiple recombined subgraph lists can be understood as area constraints considered when solving the custom instruction selection problem.
[0096] The constraint that there is no overlap between any two reorganized subgraph lists can be expressed by the following expression:
[0097]
[0098] In the formula, S i,j Let a be the j-th subgraph contained in the i-th reorganized subgraph list. i,j =1 indicates that the j-th subgraph S i,j S was selected i′,j′ Let a be the j′-th subgraph contained in the i′-th reorganized subgraph list. i′,j′ =1 indicates that the j′-th subgraph S i′,j′ Selected; In this application, if two subgraphs overlap, it means that the two subgraphs have common nodes. If the two subgraphs are allowed to overlap, it may sometimes improve the solution time of the program, but it is very likely to unnecessarily increase power consumption and make it difficult to generate new code later. Therefore, in this application, it is restricted that the two selected subgraphs are not allowed to overlap.
[0099] The non-cyclic constraint of the subgraph between any two reorganized subgraph lists can be represented by the following expression:
[0100]
[0101] or:
[0102]
[0103] In the formula, Pred(S) i′,j′ ) represents the j′-th subgraph S contained in the list of the i′-th reorganized subgraphs. i′,j′ The set of predecessor nodes, Succ(S) i′,j′ ) represents the j′-th subgraph S i′,j′ The set of successor nodes; In this application, if there is a cycle between two subgraphs, it means that the two subgraphs can provide data to each other, which will cause a deadlock between the candidate custom instructions contained in one subgraph and the candidate custom instructions contained in the other subgraph. Therefore, in this application, it is restricted that there is no cycle between the two selected subgraphs.
[0104] Based on this, the second computing node performs optimization and selection on multiple recombined subgraph lists according to a preset mathematical programming model to obtain all optimal subgraphs. The specific implementation includes: the second computing node optimizes and solves the objective function according to the multiple recombined subgraph lists and the subgraph selection constraints to select all optimal subgraphs from the multiple recombined subgraph lists; that is, all the selected optimal subgraphs can maximize the objective function, and according to the recombined subgraph list to which each selected optimal subgraph belongs, all the selected optimal subgraphs can satisfy the subgraph selection constraints.
[0105] The proposed method for parallel selection of custom instructions in this application introduces a distributed computing system comprising a master node, multiple first computing nodes, and multiple second computing nodes. The master node performs undirected graph partitioning, subgraph allocation, and load balancing analysis among the multiple second computing nodes. Each first computing node performs subgraph execution time prediction and statistical feedback, subgraph aggregation and allocation under load balancing conditions, and subgraph partitioning under unbalanced load conditions. Each second computing node performs subgraph optimization to further complete the screening of candidate custom instructions. Thus, a parallel approach can be used to complete efficient and reliable selection of custom instructions, achieving an approximately linear speedup.
[0106] This application also provides a distributed computing system, which mainly includes a master node, multiple first computing nodes and multiple second computing nodes. The master node is connected to each first computing node for data transmission, each first computing node is connected to at least two second computing nodes for data transmission, and each second computing node is connected to at least one first computing node for data transmission, thereby ensuring that each first computing node and each second computing node can play a certain role in solving the custom instruction selection problem.
[0107] In practical applications, each type of node in this distributed computing system implements the following functions:
[0108] The master node is used to: obtain an undirected graph and divide it into multiple subgraphs, and then assign each subgraph to any first computing node for management; wherein, the undirected graph can be regarded as a complex task formed by several candidate custom instructions, and each subgraph can be regarded as a relatively simple task decomposed from the complex task;
[0109] Multiple first computing nodes are used to: predict and calculate the total execution time for all execution times corresponding to all subgraphs under their management, and then feed back the total execution time calculated by each node to the master node;
[0110] The master node is also used to analyze the total execution times reported by multiple first computing nodes to determine whether load balancing exists among multiple second computing nodes;
[0111] Multiple first computing nodes are also used to: when the master node detects that there is load balancing between multiple second computing nodes, aggregate all the subgraphs managed by each node to generate a subgraph list, and then distribute the generated subgraph list to at least two second computing nodes for management;
[0112] Multiple secondary computing nodes are used to: filter all optimal subgraphs from all subgraph lists managed by each node, and then obtain all candidate custom instructions from all the optimal subgraphs they have selected.
[0113] In addition, multiple first computing nodes are also used to: when the master node detects that there is no load balancing among multiple second computing nodes, select all subgraphs whose execution time is greater than a preset time threshold from all the subgraphs managed by each node, then divide each selected subgraph into multiple new subgraphs for management, and then re-perform the prediction and statistical feedback operation of subgraph execution time.
[0114] For example, Figure 2 A schematic diagram of the composition of the distributed computing system in an application scenario is provided. It mainly records the data flow between different types of nodes in the distributed computing system. The distributed computing system includes one master node, three first computing nodes and four second computing nodes. The three first computing nodes are referred to as first computing node 1, first computing node 2 and first computing node 3, respectively. The four second computing nodes are referred to as second computing node 1, second computing node 2, second computing node 3 and second computing node 4, respectively.
[0115] The custom instruction parallel selection process implemented based on this distributed computing system specifically includes the following:
[0116] After receiving an undirected graph, the master node partitions it into five subgraphs, which are denoted as sub-graphs. Figure 1 ,son Figure 2 ,son Figure 3 Subgraphs 4 and 5, and then the subgraphs 4 and 5. Figure 1 and the child Figure 2 Assign it to the first computing node 1 for management, and then... Figure 3 The subgraph 5 is assigned to the first computing node 2 for management, and the subgraph 4 is assigned to the first computing node 3 for management.
[0117] The first computing node 1 has this sub Figure 1 The corresponding execution time and the sub Figure 2 Predict the corresponding execution time, and then... Figure 1 The corresponding execution time and the sub Figure 2 The corresponding execution times are added together to obtain a total execution time, which is then fed back to the master node; the first computing node 2 then processes the execution time of the child node. Figure 3 The corresponding execution time is predicted, and then the execution time of sub-Figure 5 is predicted. Figure 3 The execution time corresponding to subgraph 5 is added together to obtain a total execution time, which is then fed back to the master node; the first computing node 3 predicts the execution time corresponding to subgraph 4 and then feeds it back to the master node; it should be noted that the data feedback actions generated by these three first computing nodes to the master node are... Figure 2 It is not marked in the text.
[0118] The master node analyzes the total execution time reported by the three first computing nodes. If it detects that there is no load balancing among the four second computing nodes, it can send a subgraph splitting instruction to each of the three first computing nodes. If it detects that there is load balancing among the four second computing nodes, it can send a subgraph aggregation instruction to each of the three first computing nodes.
[0119] When these three first computing nodes receive the subgraph segmentation instruction respectively: if the first computing node 1 detects the subgraph segmentation instruction... Figure 1 and the child Figure 2 If at least one subgraph in the dataset has an execution time exceeding a preset time threshold, then the subgraph with the execution time exceeding the preset time threshold is split into multiple new subgraphs for management. Subsequently, the subgraph execution time is predicted and statistically fed back again. If the subgraph is detected... Figure 1 The corresponding execution time and the sub Figure 2 If the corresponding execution time is less than or equal to the preset time threshold, no subgraph segmentation action is performed and the subgraph summarization action is performed directly; if the first computing node 2 detects the subgraph segmentation action, it will perform the subgraph summarization action. Figure 3If the execution time of at least one subgraph in subgraph 5 exceeds the preset time threshold, the subgraph with the execution time exceeding the preset time threshold is divided into multiple new subgraphs for management. Then, the subgraph execution time is predicted and statistically fed back again. If the subgraph is detected... Figure 3 If the execution time of the corresponding subgraph 5 is less than or equal to the preset time threshold, no subgraph segmentation action is performed and the subgraph aggregation action is performed directly. If the first computing node 3 detects that the execution time of the corresponding subgraph 4 is greater than the preset time threshold, the subgraph 4 is segmented to obtain multiple new subgraphs for management. Then, the subgraph execution time prediction and statistical feedback operation is performed again. If the execution time of the corresponding subgraph 4 is detected to be less than or equal to the preset time threshold, no subgraph segmentation action is performed and the subgraph aggregation action is performed directly.
[0120] When the three first computing nodes receive the subgraph aggregation instruction respectively: the first computing node 1 aggregates all the subgraphs it manages to generate a subgraph list 1, and then assigns the subgraph list 1 to the second computing node 1 and the second computing node 3 for management; the first computing node 2 aggregates all the subgraphs it manages to generate a subgraph list 2, and then assigns the subgraph list 2 to the second computing node 1, the second computing node 2 and the second computing node 4 for management; the first computing node 3 aggregates all the subgraphs it manages to generate a subgraph list 3, and then assigns the subgraph list 3 to the second computing node 3 and the second computing node 4 for management.
[0121] The second computing node 1 selects all optimal subgraphs from subgraph list 1 and subgraph list 2 and further obtains all candidate custom instructions from them. The second computing node 2 selects all optimal subgraphs from subgraph list 2 and further obtains all candidate custom instructions from them. The second computing node 3 selects all optimal subgraphs from subgraph list 1 and subgraph list 3 and further obtains all candidate custom instructions from them. The second computing node 4 selects all optimal subgraphs from subgraph list 2 and subgraph list 3 and further obtains all candidate custom instructions from them. Then, all candidate custom instructions obtained by these four second computing nodes can be summarized and deduplicated.
[0122] It is understood that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0123] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned custom instruction parallel selection method. This electronic device can include any smart terminal such as a tablet computer or an in-vehicle computer.
[0124] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0125] Please see Figure 3 , Figure 3 This illustrates the hardware structure of an electronic device according to another embodiment, the electronic device comprising:
[0126] The processor 201 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0127] The memory 202 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 202 can store the operating system and other applications. When the technical solutions provided in the embodiments of this application are implemented through software or firmware, the relevant program code is stored in the memory 202 and is called and executed by the processor 201.
[0128] Input / output interface 203 is used to implement information input and output;
[0129] The communication interface 204 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0130] Bus 205 transmits information between various components of the device (e.g., processor 201, memory 202, input / output interface 203, and communication interface 204);
[0131] The processor 201, memory 202, input / output interface 203 and communication interface 204 are connected to each other within the device via bus 205.
[0132] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described custom instruction parallel selection method.
[0133] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0134] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0135] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0136] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0137] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0138] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0139] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0140] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0141] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or units may be electrical, mechanical, or other forms.
[0142] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0143] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0144] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0145] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for parallel selection of custom instructions, characterized in that, Applied to a distributed computing system, the distributed computing system comprising a master node, multiple first computing nodes, and multiple second computing nodes, the method includes: An undirected graph is obtained through the master node. The undirected graph contains several candidate custom instructions. The undirected graph is divided into multiple subgraphs. Each subgraph represents a task. Each subgraph is then assigned to any of the first computing nodes for management. The multiple first computing nodes predict and calculate the total execution time for all execution times corresponding to all subgraphs under their management, and then feed back the total execution time calculated by each node to the master node. The master node analyzes the total execution times reported by the multiple first computing nodes to determine whether load balancing exists among the multiple second computing nodes. When the master node detects that there is load balancing among the multiple second computing nodes, it aggregates all the subgraphs managed by each of the multiple first computing nodes to generate a subgraph list, and then distributes the generated subgraph list to at least two second computing nodes for management. The multiple second computing nodes filter out all optimal subgraphs from the list of all subgraphs they manage, and then obtain all candidate custom instructions from all the optimal subgraphs they have selected. The step of predicting all execution times for all subgraphs managed by the plurality of first computing nodes includes: For each of the first computing nodes and all the subgraphs it manages, the attribute parameters of each subgraph are input into a preset time prediction model through the first computing node for analysis, so as to predict the execution time corresponding to each subgraph; the time prediction model is constructed based on the data regression prediction principle of extreme random trees.
2. The custom instruction parallel selection method according to claim 1, characterized in that, The step of analyzing the total execution times reported by the master node from the plurality of first computing nodes to determine whether load balancing exists among the plurality of second computing nodes includes: The master node filters out the maximum and minimum values from the multiple total execution times and calculates the average of the multiple total execution times; The master node calculates the load balancing degree value among the plurality of second computing nodes based on the maximum value, the minimum value, and the average value. The master node detects whether the load balancing level value is less than or equal to a preset load balancing level threshold; if yes, it determines that there is load balancing among the multiple second computing nodes; if no, it determines that there is no load balancing among the multiple second computing nodes.
3. The method for parallel selection of custom instructions according to claim 1, characterized in that, The method further includes: When the master node detects that there is no load balancing among the plurality of second computing nodes, it filters out all subgraphs whose execution time is greater than a preset time threshold from all subgraphs managed by the plurality of first computing nodes. The multiple first computing nodes divide each selected subgraph into multiple new subgraphs for management, and return the steps of predicting and calculating the total execution time for all subgraphs managed by the multiple first computing nodes, and then feeding back the total execution time calculated by each node to the master node.
4. The method for parallel selection of custom instructions according to claim 3, characterized in that, The step of dividing each selected subgraph into multiple new subgraphs through the multiple first computing nodes includes: For each of the first computing nodes and each of the subgraphs selected, the quotient between the execution time of the subgraph and the preset time threshold is rounded up to obtain the number of segments. Then, the subgraph is divided into multiple new subgraphs according to the number of segments.
5. The method for parallel selection of custom instructions according to claim 1, characterized in that, The step of selecting all optimal subgraphs from the list of all subgraphs managed by the multiple second computing nodes includes: For each second computing node and all subgraph lists it manages, isomorphic matching is performed on all subgraphs contained in the all subgraph lists through the second computing node to obtain multiple recombined subgraph lists; The second computing node performs optimization and screening on the list of multiple recombined subgraphs according to a preset mathematical programming model to obtain all the optimal subgraphs.
6. The method for parallel selection of custom instructions according to claim 5, characterized in that, The mathematical programming model includes an objective function and subgraph selection constraints. The objective function is constructed with the goal of maximizing the running performance achieved by the multiple recombined subgraph lists. The subgraph selection constraints include constraints on the running resources occupied by the multiple recombined subgraph lists, as well as constraints on non-overlapping subgraphs and non-cyclic subgraphs between any two recombined subgraph lists. The second computing node performs optimization and screening on the list of multiple recombined subgraphs according to a preset mathematical programming model to obtain all optimal subgraphs, including: The second computing node optimizes the objective function based on the list of multiple recombined subgraphs and the subgraph selection constraints, so as to select all the optimal subgraphs from the list of multiple recombined subgraphs.
7. A distributed computing system, characterized in that, The distributed computing system includes a master node, multiple first computing nodes, and multiple second computing nodes; The master node is used to obtain an undirected graph containing several candidate custom instructions, divide the undirected graph into multiple subgraphs, each subgraph represents a task, and then assign each subgraph to any of the first computing nodes for management. The multiple first computing nodes are used to predict and calculate the total execution time for all execution times corresponding to all subgraphs under their management, and then feed back the total execution time calculated by each node to the master node. The master node is also used to analyze the total execution times fed back by the plurality of first computing nodes to determine whether there is load balancing among the plurality of second computing nodes; When the master node detects that there is load balancing among the plurality of second computing nodes, the plurality of first computing nodes are also used to aggregate all the subgraphs they manage to generate a subgraph list, and then distribute the subgraph list they generate to at least two second computing nodes for management; The multiple second computing nodes are used to filter out all optimal subgraphs from all subgraph lists they manage, and then obtain all candidate custom instructions from all the optimal subgraphs they have filtered out. The plurality of first computing nodes are used to predict all execution times corresponding to all subgraphs under their respective management, including: For each of the first computing nodes and all the subgraphs it manages, the first computing node is used to input the attribute parameters of each subgraph into a preset time prediction model for analysis, so as to predict the execution time corresponding to each subgraph; the time prediction model is constructed based on the data regression prediction principle of extreme random trees.
8. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.
Citation Information
Patent Citations
Computing node determination method and device, equipment and storage medium
CN118606081A
Method and apparatus for processing a plurality of undirected graphs
US20190147617A1