Custom instruction parallel selection method, distributed computing system, equipment and medium
Through the parallel selection method in the distributed computing system, the problem of inefficiency of serial methods in large-scale custom instruction selection is solved, and efficient and reliable custom instruction selection and acceleration ratio are improved.
Patent Information
- Application Number
- CN202411665503.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-11-20
AI Technical Summary
When the prior art deals with the problem of large-scale custom instruction selection, it is difficult to give the optimal design plan within a reasonable time by using serial methods, resulting in poor implementation results.
A custom instruction parallel selection method is proposed. Through a distributed computing system, the master node performs undirected graph segmentation and load balancing analysis, the first computing node performs subgraph execution time prediction and statistical feedback, and the second computing node performs subgraph optimization to filter candidate custom instructions.
It realizes efficient and reliable custom instruction selection, achieves an approximate linear acceleration ratio, and improves the ability to give the optimal design plan within a reasonable time.
Smart Images

Figure CN119806645A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for selecting a user-defined instruction in parallel, a distributed computing system, a device and a medium. Background Art
[0002] A dedicated instruction set processor is a processor designed with an extended instruction set. The custom instruction selection problem is one of the most critical problems that arise in the process of automatic generation of extended instruction sets. Currently, most of the research on the custom instruction selection problem considers using a serial method to solve it. However, when the problem scale is large, it is difficult to give the optimal design solution within a reasonable time using a serial method, or even it is impossible to give the optimal design solution, and the implementation effect is poor. Summary of the invention
[0003] The main purpose of this application is to propose a custom instruction parallel selection method, a distributed computing system, a device and a medium, which can use a parallel method to achieve efficient and reliable custom instruction selection.
[0004] To achieve the above object, one aspect of the present application provides a method for parallel selection of custom instructions, which is applied to a distributed computing system, wherein the distributed computing system includes a master node, multiple first computing nodes, and multiple second computing nodes, and the method includes:
[0005] Obtain an undirected graph through the master node, the undirected graph including a plurality of candidate custom instructions, divide the undirected graph into a plurality of subgraphs, each of the subgraphs representing a task, and then assign each of the subgraphs to any of the first computing nodes for management;
[0006] The multiple first computing nodes predict all execution times corresponding to all subgraphs managed by each of them and obtain a total execution time by counting the total execution time, and then feed back the counted total execution time to the master node;
[0007] Analyzing, by the master node, a plurality of 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;
[0008] When the master node detects that there is load balancing between the multiple second computing nodes, the multiple first computing nodes aggregate all subgraphs managed by each of them to generate a subgraph list, and then distribute the subgraph lists generated by each of them to at least two of the second computing nodes for management;
[0009] All optimal subgraphs are screened out from all subgraph lists managed by the multiple second computing nodes, and then all candidate custom instructions are acquired from all the optimal subgraphs screened out by the respective second computing nodes.
[0010] Furthermore, predicting all execution times corresponding to all subgraphs managed by the multiple first computing nodes includes:
[0011] For each of the first computing nodes and all the subgraphs it manages, the attribute parameters of each of the subgraphs are input into a preset time prediction model for analysis through the first computing node to predict the execution time corresponding to each of the subgraphs; wherein the time prediction model is constructed based on the data regression prediction principle of extreme random trees.
[0012] Further, analyzing the plurality of total execution times fed back by the plurality of first computing nodes through the master node to determine whether there is load balancing among the plurality of second computing nodes includes:
[0013] Filtering the maximum value and the minimum value from the multiple total execution times through the master node, and calculating the average value of the multiple total execution times;
[0014] Calculating, by the master node, a load balancing degree value between the plurality of second computing nodes according to the maximum value, the minimum value and the average value;
[0015] The master node detects whether the load balancing degree value is less than or equal to a preset load balancing degree threshold; if so, it is determined that there is load balancing between the multiple second computing nodes; if not, it is determined that there is no load balancing between the multiple second computing nodes.
[0016] Furthermore, the method further comprises:
[0017] When the master node detects that there is no load balancing among the plurality of second computing nodes, all subgraphs whose execution time is greater than a preset time threshold are screened out from all subgraphs managed by the plurality of first computing nodes;
[0018] The multiple first computing nodes are used to split each subgraph screened out into multiple new subgraphs for management, and the multiple first computing nodes are used to predict all execution times corresponding to all subgraphs managed by each of them and calculate the total execution time, and then the total execution time calculated by each is fed back to the main node.
[0019] Furthermore, the step of dividing each of the subgraphs screened out by the plurality of first computing nodes into a plurality of new subgraphs includes:
[0020] For each of the first computing nodes and each subgraph filtered out thereof, the first computing node rounds up the quotient between the execution time corresponding to the subgraph and the preset time threshold to obtain the number of divisions, and then divides the subgraph according to the number of divisions to obtain multiple new subgraphs.
[0021] Furthermore, the filtering out all optimal subgraphs from the list of all subgraphs managed by the multiple second computing nodes includes:
[0022] For each of the second computing nodes and all subgraph lists managed by the node, performing isomorphic matching processing on all subgraphs included in all subgraph lists by the second computing node to obtain a plurality of reorganized subgraph lists;
[0023] The second computing node performs optimal screening in the plurality of reorganized subgraph lists according to a preset mathematical programming model to obtain all optimal subgraphs.
[0024] Furthermore, the mathematical programming model includes an objective function and subgraph screening constraints, wherein the objective function is constructed with the goal of maximizing the operating performance achieved by the multiple reorganized subgraph lists, and the subgraph screening constraints include constraints on the operating resources occupied by the multiple reorganized subgraph lists and subgraph non-overlap constraints and subgraph non-circular constraints between every two reorganized subgraph lists; the second computing node performs optimal screening in the multiple reorganized subgraph lists according to the preset mathematical programming model to obtain all optimal subgraphs including:
[0025] The objective function is optimized and solved by the second computing node according to the multiple reorganized subgraph lists and the subgraph screening constraints, so as to screen out all optimal subgraphs from the multiple reorganized subgraph lists.
[0026] To achieve the above object, another aspect of the present application provides a distributed computing system, the distributed computing system comprising a master node, a plurality of first computing nodes and a plurality of second computing nodes;
[0027] The master node is used to obtain an undirected graph, the undirected graph includes a plurality of candidate custom instructions, divide the undirected graph into a plurality of subgraphs, each of the subgraphs represents a task, and then assign each of the subgraphs to any of the first computing nodes for management;
[0028] The multiple first computing nodes are used to predict all execution times corresponding to all subgraphs managed by each of them and obtain the total execution time by counting, and then feed back the total execution time counted by each of them to the master node;
[0029] The master node is further used to analyze the multiple total execution times fed back by the multiple first computing nodes to determine whether there is load balance among the multiple second computing nodes;
[0030] When the master node detects that there is load balancing between the plurality of second computing nodes, the plurality of first computing nodes are further configured to aggregate all subgraphs managed by each of them to generate a subgraph list, and then distribute the subgraph list generated by each of them to at least two of the second computing nodes for management;
[0031] The multiple second computing nodes are used to filter out all optimal subgraphs from all subgraph lists managed by each of them, and then obtain all candidate custom instructions from all the optimal subgraphs filtered out by each of them.
[0032] To achieve the above objective, another aspect of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above method when executing the computer program.
[0033] To achieve the above objective, another aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0034] The present application includes at least the following beneficial effects: by introducing a distributed computing system including a main node, multiple first computing nodes and multiple second computing nodes, the main node is used to implement undirected graph partitioning, subgraph allocation and load balancing analysis among multiple second computing nodes, each first computing node is used to implement prediction and statistical feedback of subgraph execution time, subgraph summary allocation under load balancing and subgraph partitioning under load imbalance, each second computing node is used to implement subgraph optimization to further complete the screening of candidate custom instructions, thereby achieving efficient and reliable custom instruction selection using a parallel method and achieving an approximately linear acceleration ratio. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a flowchart of a method for parallel selection of custom instructions provided in an embodiment of the present application;
[0036] Figure 2 It is a schematic diagram of the composition of a distributed computing system provided by an embodiment of the present application in an application scenario;
[0037] Figure 3 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the 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 the embodiments of the present application. They are only examples of systems and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0039] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0040] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0041] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0042] An Application Specific Instruction Set Processor (ASIP) is a processor designed with an extended instruction set (also known as a custom instruction set). It mainly recognizes custom instructions and executes the computationally intensive code in the application in the hardware implementation of the custom instructions - the custom function unit (CFU). The custom instructions executed on the CFU encapsulate a set of basic instructions and improve performance through parallelization and chaining between the basic instructions. Encapsulating multiple basic instructions into custom instructions can effectively reduce the number of instruction calls and the number of data transfers between registers and the processor, thereby significantly reducing power consumption. By using the same custom instruction set for different applications in the same field, the dedicated instruction set processor can have a certain degree of flexibility.
[0043] The problem of automatic generation of extended instruction sets is one of the most critical issues in the design process of dedicated instruction set processors. The specific process for solving the problem of automatic generation of extended instruction sets is as follows: using the corresponding source code of the application as input, calling the compilation front end to compile and optimize the source code; calling the program performance analyzer to determine the computationally intensive code blocks in each application, and generating corresponding data flow graphs for the computationally intensive code blocks; in the custom instruction enumeration stage, enumerate all candidate custom instructions that meet the constraints from the generated intermediate representation-data flow graph; in the custom instruction selection stage, according to the given constraints and design objectives, use the logic synthesis tool to give the area and delay information corresponding to the custom instructions, and efficiently select some custom instructions from the candidate custom instruction set to form the final domain-shared extended instruction set; according to the generated extended instruction set, convert the source code into new code containing the selected custom instructions through pattern matching and selection and code replacement and generation.
[0044] The custom instruction selection problem is one of the most critical issues that arise in the process of automatic generation of extended instruction sets. Currently, most of the research on the custom instruction selection problem considers using a serial method to solve it. However, when the problem scale is large, the serial method is difficult to give the optimal design solution within a reasonable time, or even impossible to give the optimal design solution, and the implementation effect is poor.
[0045] In view of this, an embodiment of the present application provides a method for parallel selection of custom instructions, a distributed computing system, a device and a medium. The scheme introduces a distributed computing system including a main node, multiple first computing nodes and multiple second computing nodes, uses the main node to implement undirected graph partitioning, subgraph allocation and load balancing analysis between multiple second computing nodes, uses each first computing node to implement prediction and statistical feedback of subgraph execution time, subgraph summary allocation under load balancing conditions and subgraph partitioning under load imbalance conditions, and uses each second computing node to implement subgraph optimization to further complete the screening of candidate custom instructions. This makes it possible to use a parallel method to complete efficient and reliable custom instruction selection and achieve an approximately linear acceleration ratio.
[0046] Figure 1 is an optional flow chart of a method for selecting a custom instruction in parallel provided in an embodiment of the present application. Figure 1 The method is applied to a distributed computing system, the distributed computing system 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 an undirected graph through a master node, divide the undirected graph into multiple subgraphs, and then assign each subgraph to any first computing node for management;
[0048] Step S102: predict all execution times corresponding to all subgraphs managed by each of the multiple first computing nodes and obtain a total execution time by counting the total execution time, and then feed back the total execution time counted by each to the master node;
[0049] Step S103: Analyze the total execution times fed back by the plurality of first computing nodes through the master node to determine whether there is load balancing among the plurality of second computing nodes;
[0050] Step S104: When the master node detects that there is no load balancing among the plurality of second computing nodes, the plurality of first computing nodes filter out all subgraphs whose execution time is greater than a preset time threshold from all subgraphs managed by the respective first computing nodes, and then divide each of the filtered subgraphs into a plurality of new subgraphs for management, and return to the above step S102;
[0051] Step S105: When the master node detects that there is load balancing among the plurality of second computing nodes, the plurality of first computing nodes aggregate all subgraphs managed by the plurality of first computing nodes to generate a subgraph list, and then distribute the generated subgraph lists to at least two second computing nodes for management;
[0052] Step S106: Filter out all optimal subgraphs from all subgraph lists managed by each of the multiple second computing nodes, and then obtain all candidate custom instructions from all the optimal subgraphs filtered out by each of the multiple second computing nodes.
[0053] In some embodiments, the distributed computing system is preferably built based on the MapReduce model in the field of cloud computing, and the master node controls the task allocation in the Map phase and the task allocation in the Reduce phase. The task allocation in the Map phase refers to controlling each first computing node to receive part of the subgraph to complete the execution time prediction and the fine-grained division of the subgraph, and in the Map phase, the master node is also required to detect the load balancing situation among multiple second computing nodes. The task allocation in the Reduce phase refers to controlling each second computing node to receive part of the subgraph list finally generated by the first computing node to complete the optimization of candidate custom instructions; and the number of multiple first computing nodes and the number of multiple second computing nodes can be set and adjusted according to the complexity of the implementation task, and the present application does not limit this.
[0054] In step S101 of some embodiments, the undirected graph contains several candidate custom instructions, and the several candidate custom instructions are usually generated in the custom instruction enumeration stage; the undirected graph can be understood as being constructed based on the overlapping relationship and the cyclic relationship between the several candidate custom instructions, each candidate custom instruction serves as a node in the undirected graph, and the edge formed between every two nodes contained in the undirected graph represents the overlapping relationship or the cyclic relationship between the two candidate custom instructions referred to by the two nodes; the undirected graph can be regarded as a complex task formed by several candidate custom instructions, and 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 will not actually affect the candidate custom instructions themselves.
[0055] In step S101 of some embodiments, it is preferred to adopt a fine-grained partitioning strategy to Figure 1 The sub-graphs are divided into multiple sub-graphs, which are expressed by the following expressions:
[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 is the node contained in the undirected graph, G t For the node v t is the reference node and the subgraph obtained by segmenting the undirected graph G, t=1, 2, ..., k, ..., |V|-1, |V|-1 is the number of multiple subgraphs obtained by segmenting the undirected graph, and N(x, y) represents all neighbor nodes related to node y in graph x; it should be noted that in the subgraph G obtained by segmentation t For the corresponding reference node v t Mark the subgraph G so that tAll new subgraphs obtained by further splitting can contain the marked reference node v t .
[0062] In step S102 of some embodiments, multiple first computing nodes are used to predict all execution times corresponding to all subgraphs managed by each of them. The specific implementation method includes: for each first computing node and all subgraphs managed by it, the attribute parameters of each subgraph managed by it are input into a preset time prediction model for analysis to predict the execution time corresponding to the subgraph.
[0063] Among them, the attribute parameters of the subgraph include the number of nodes and edges covered by the subgraph, the density of the subgraph, and the area constraint corresponding to the subgraph. The density of the subgraph refers to the ratio between the number of edges covered by the subgraph and the maximum number of edges that may exist in the subgraph. The maximum number of edges that may exist in the subgraph is [n(n-1)] / 2, where n is the number of nodes contained in the subgraph. The area constraint corresponding to the subgraph refers to the operating resources occupied by the subgraph. The time prediction model is mainly based on the data regression prediction principle of the extreme random tree and is constructed in a black box manner. The mean square error loss function is introduced during the training process for parameter optimization. Compared with other machine learning methods, the time prediction model has stronger generalization ability and is more stable due to the complete randomness of the extreme random tree in feature selection.
[0064] In some embodiments, the specific implementation of the above-mentioned step S103 includes: filtering out the minimum value and the maximum value from the multiple total execution times fed back by the 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 between the multiple second computing nodes according to the minimum value, the maximum value and the average value through the master node; judging whether the load balancing degree value is less than or equal to a preset load balancing degree threshold through the master node; if so, determining that there is load balancing between the multiple second computing nodes; if not, determining that there is no load balancing between the multiple second computing nodes.
[0065] The load balancing degree value between the multiple second computing nodes is preferably calculated using the following expression:
[0066] γ=(T l -T s ) / T e ;
[0067] Where γ is the load balancing degree between multiple second computing nodes, T l is the maximum value, T s is the minimum value, T e is the average value.
[0068] In the present application, the purpose of determining whether there is load balancing 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 subgraph filtered out by each of the plurality of first computing nodes is split into a plurality of new subgraphs. The specific implementation method includes: for each first computing node and each subgraph filtered out by the first computing node, the quotient between the execution time corresponding to the subgraph and the preset time threshold is rounded up by the first computing node to obtain the number of splits, and then the subgraph is split according to the number of splits to obtain a plurality of new subgraphs.
[0070] Among them, it is preferred to adopt a fine-grained partitioning strategy to further partition the subgraph into a plurality of new subgraphs adapted to the number of partitions, which is 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 is the subgraph filtered out by the first computing node, V t For this subgraph G tThe set of all the benchmark nodes that have been marked, n s For this subgraph G t The nodes contained in G t,s For the node n s is the reference node and from this subgraph G t The new subgraph obtained by segmentation is s = 1, 2, ..., q, ..., P, where P is the subgraph G t The corresponding number of splits, 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 by segmentation can be t,s For the corresponding reference node n s Mark it so that the new subgraph G t,s All new subgraphs obtained by further partitioning can contain the marked reference node n s and the set V t .
[0078] For example, the master node performs a one-time partitioning of the undirected graph to obtain a subgraph G k , a first computing node is responsible for managing the subgraph G k , when the master node determines that there is no load balancing among the plurality of second computing nodes, the first computing node detects that the subgraph G k The corresponding execution time is greater than the preset time threshold, and the subgraph G is determined k The corresponding number of divisions is m, and the subgraph G k The only marked reference node included in k , the subgraph G is expressed as follows k Split 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 contained in G k,r For the node w r is the reference node and from this subgraph G k The new subgraph obtained by segmentation is r = 1, 2, ..., l, ..., m, and in general, the subgraph G k The execution time corresponding to the first m-1 new subgraphs obtained by segmentation is greater than the preset time threshold, and only the execution time corresponding to the first m-1 new subgraphs obtained by segmentation is greater than the preset time threshold. k The final new subgraph G obtained by segmentation k,m The corresponding execution time is less than or equal to the preset time threshold; it should be noted that the new subgraph G obtained by segmentation can be k,r For the corresponding reference node w r Mark it so that the new subgraph G k,r All new subgraphs obtained by further partitioning can contain the marked reference node w r and the node v k .
[0086] It should be noted that in the above step S104, 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 the subgraph splitting operation, and directly aggregates all the subgraphs it manages to generate a subgraph list and distributes it to at least two second computing nodes for management; if only a part of the first computing nodes detects that the execution time corresponding to each subgraph it manages is less than or equal to the preset time threshold, then this part of the first computing nodes does not need to perform the subgraph splitting operation, and directly aggregates all the subgraphs it manages to generate a subgraph list and distributes it to at least two second computing nodes for management. At the same time, this part of the first computing nodes must also cooperate in feeding back the total execution time obtained by its most recent statistics to the main node for load balancing detection, or this part of the first computing nodes can re-predict the subgraph execution time and statistical feedback.
[0087] In step S106 of some embodiments, multiple second computing nodes are used to screen out all optimal subgraphs from all subgraph lists managed by each of them. The specific implementation method includes: for each second computing node and all subgraph lists managed by it, all subgraphs included in all subgraph lists managed by it are processed by the second computing node for isomorphic matching to obtain multiple reorganized subgraph lists, that is, there is an isomorphic relationship between every two subgraphs included in each reorganized subgraph list, and then optimal screening is performed in the multiple reorganized subgraph lists according to a preset mathematical programming model to obtain all optimal subgraphs.
[0088] The mathematical programming model includes subgraph screening constraints and objective functions, which are described as follows:
[0089] (1) The objective function is constructed with the goal of maximizing the running performance achieved by multiple reorganized subgraph lists, and can be expressed as follows:
[0090]
[0091] Where F is the objective function, N is the number of multiple reorganized subgraph lists, M is the number of all subgraphs contained in the i-th reorganized subgraph list, and a i,j is a binary variable. i,j = 1, it means that the jth subgraph contained in the i-th reorganized subgraph list is selected, and when a i,j = 0, indicating that the jth subgraph included in the i-th reorganized subgraph list is not selected, T i The operating performance achieved by the ith reorganized sub-graph list alone can be understood as the operating time or operating speed required for the hardware implementation corresponding to the ith reorganized sub-graph list.
[0092] (2) The subgraph screening constraints include constraints on the operating resources occupied by multiple reorganized subgraph lists and subgraph acyclic constraints and subgraph non-overlapping constraints between every two reorganized subgraph lists.
[0093] The constraints on the running resources occupied by multiple reorganized subgraph lists can be expressed as follows:
[0094]
[0095] In the formula, l i is a binary variable, when l i = 1, it means that at least one subgraph in the list of reorganized subgraphs after the i-th reorganization is selected. i = 0, it means that no subgraph is selected in the list of reorganized subgraphs after the i-th reorganization. i are the operating resources required for the hardware implementation corresponding to the i-th reorganized sub-graph list, which determines the size and cost of the chip. A0 is the preset upper limit threshold of the operating resources. The constraint on the operating resources occupied by multiple reorganized sub-graph lists can be understood as the area constraint considered when solving the custom instruction selection problem.
[0096] The subgraph non-overlap constraint between every two reorganized subgraph lists can be expressed as follows:
[0097]
[0098] In the formula, S i,j is the jth subgraph contained in the i-th reorganized subgraph list, a i,j =1 indicates that the jth subgraph S i,j Selected, S i′,j′ is the j′th subgraph contained in the i′th reorganized subgraph list, a i′,j′ =1 indicates the j′th subgraph S i′,j′ Selected; in the present application, if two subgraphs overlap, it means that there are common nodes between the two subgraphs. If the two subgraphs are allowed to overlap, the program solution time can sometimes be improved, but it is likely to unnecessarily increase power consumption and make it difficult to generate new code later. Therefore, in the present application, it is specified that no overlap is allowed between the two selected subgraphs.
[0099] The subgraph acyclic constraint between each two reorganized subgraph lists can be expressed as follows:
[0100]
[0101] or:
[0102]
[0103] Where Pred(S i′,j′ ) is the j′th subgraph S contained in the i′th reorganized subgraph list i′,j′ The predecessor node set, Succ(S i′,j′ ) is the j′th subgraph S i′,j′ The set of successor nodes; in the present application, the existence of a loop between two subgraphs means that the two subgraphs can provide data to each other, resulting in a deadlock between the candidate custom instructions contained in one subgraph and the candidate custom instructions contained in the other subgraph. Therefore, in the present application, it is stipulated that no loop is allowed between the two selected subgraphs.
[0104] On this basis, the second computing node performs optimal screening in multiple reorganized subgraph lists according to a preset mathematical programming model to obtain all optimal subgraphs. The specific implementation method includes: the second computing node performs optimal solution to the objective function according to multiple reorganized subgraph lists and the subgraph screening constraints to screen out all optimal subgraphs from the multiple reorganized subgraph lists; that is, all the screened out optimal subgraphs can make the objective function achieve the maximum value, and according to the reorganized subgraph list to which each screened out optimal subgraph belongs, all the screened out optimal subgraphs can satisfy the subgraph screening constraints.
[0105] A method for parallel selection of custom instructions proposed in an embodiment of the present application introduces a distributed computing system including a main node, multiple first computing nodes and multiple second computing nodes, uses the main node to implement undirected graph partitioning, subgraph allocation and load balancing analysis between multiple second computing nodes, uses each first computing node to implement prediction and statistical feedback of subgraph execution time, subgraph summary allocation under load balancing and subgraph partitioning under load imbalance, and uses each second computing node to implement subgraph optimization to further complete the screening of candidate custom instructions, thereby achieving efficient and reliable custom instruction selection using a parallel method and achieving an approximately linear acceleration ratio.
[0106] An embodiment of the present 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, so as to ensure that each first computing node and each second computing node can play a certain role in solving the custom instruction selection problem.
[0107] In specific applications, each type of node included in the 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 a number of candidate custom instructions, and each subgraph can be regarded as a relatively simple task decomposed from the complex task;
[0109] The multiple first computing nodes are used to: predict all execution times corresponding to all subgraphs managed by each of them and obtain a total execution time by statistics, and then feed back the total execution time calculated by each of them to the main node;
[0110] The master node is further used to: analyze the multiple total execution times fed back by the multiple first computing nodes to determine whether there is load balance among the multiple second computing nodes;
[0111] The multiple first computing nodes are further used to: when the master node detects that there is load balancing between the multiple second computing nodes, aggregate all subgraphs managed by each of them to generate a subgraph list, and then distribute the subgraph list generated by each of them to at least two second computing nodes for management;
[0112] The multiple second computing nodes are used to: filter out all optimal subgraphs from all subgraph lists managed by each of them, and then obtain all candidate custom instructions from all optimal subgraphs filtered out by each of them.
[0113] In addition, the multiple first computing nodes are also used to: when the main node detects that there is no load balancing among the multiple second computing nodes, filter out all subgraphs whose execution time is greater than a preset time threshold from all subgraphs managed by each of them, and then split each filtered subgraph into multiple new subgraphs for management, and then re-perform the prediction and statistical feedback operations of the 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, which mainly records some data flows between different types of nodes contained in the distributed computing system. The distributed computing system includes a master node, three first computing nodes and four second computing nodes. The three first computing nodes are respectively recorded as first computing node 1, first computing node 2 and first computing node 3, and the four second computing nodes are respectively recorded as second computing node 1, second computing node 2, second computing node 3 and second computing node 4.
[0115] The custom instruction parallel selection process implemented based on the distributed computing system specifically includes the following:
[0116] After receiving an undirected graph, the master node divides it into five subgraphs, which are denoted as subgraphs. Figure 1 ,son Figure 2 ,son Figure 3 , sub-graph 4 and sub-graph 5, and then Figure 1 And the child Figure 2 Assigned to the first computing node 1 for management, 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 Figure 1 The corresponding execution time and Figure 2 The corresponding execution time is predicted, and then the sub Figure 1 The corresponding execution time and 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 Figure 3 The corresponding execution time is predicted for the execution time of subgraph 5, and then the subgraph Figure 3 The corresponding execution time is added to the execution time corresponding to the subgraph 5 to obtain a total execution time, which is then fed back to the main node; the first computing node 3 predicts the execution time corresponding to the subgraph 4 and then feeds it back to the main node; it should be noted that the data feedback actions generated by these three first computing nodes to the main node are Figure 2 Not marked in.
[0118] The master node analyzes the three total execution times fed back by the three first computing nodes. If it is detected that there is no load balance among the four second computing nodes, a subgraph splitting instruction can be sent to each of the three first computing nodes. If it is detected that there is load balance between the four second computing nodes, a subgraph summary instruction can be sent to each of the three first computing nodes.
[0119] When the three first computing nodes receive the subgraph segmentation instruction respectively: if the first computing node 1 detects the subgraph Figure 1 And the child Figure 2 At least one of the subgraphs has an execution time greater than a preset time threshold. The subgraph with an execution time greater than the preset time threshold is split into multiple new subgraphs for management. Then, the subgraph execution time prediction and statistical feedback operations are performed again. If the subgraph is detected Figure 1 The corresponding execution time and 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 aggregation action is performed directly; if the first computing node 2 detects that the subgraph Figure 3If the execution time of at least one subgraph in the subgraph 5 is greater than the preset time threshold, the subgraph with the execution time greater than the preset time threshold is split into multiple new subgraphs for management, and then the subgraph execution time prediction and statistical feedback operation are performed again. Figure 3 If the corresponding execution time and the execution time corresponding to the subgraph 5 are both 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 corresponding to the subgraph 4 is greater than the preset time threshold, the subgraph 4 is segmented to obtain multiple new subgraphs for management, and then the subgraph execution time prediction and statistical feedback operations are performed again. If it is detected that the execution time corresponding to the subgraph 4 is 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 respectively receive the subgraph aggregation instruction: 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 filters out all the optimal subgraphs from the subgraph list 1 and the subgraph list 2 and further obtains all the candidate custom instructions therefrom, the second computing node 2 filters out all the optimal subgraphs from the subgraph list 2 and further obtains all the candidate custom instructions therefrom, the second computing node 3 filters out all the optimal subgraphs from the subgraph list 1 and the subgraph list 3 and further obtains all the candidate custom instructions therefrom, the second computing node 4 filters out all the optimal subgraphs from the subgraph list 2 and the subgraph list 3 and further obtains all the candidate custom instructions therefrom, and then all the candidate custom instructions obtained by the four second computing nodes can be summarized and deduplicated.
[0122] It can be understood that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments 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.
[0123] The embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned custom instruction parallel selection method when executing the computer program. The electronic device may include any intelligent terminal such as a tablet computer and a car computer.
[0124] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments 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] See also Figure 3 , Figure 3 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0126] The processor 201 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an 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 the present application;
[0127] The memory 202 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 202 can store an operating system and other application programs. When the technical solution provided in the embodiment of the present application is implemented by software or firmware, the relevant program code is stored in the memory 202, and the processor 201 calls and executes the technical solution provided in the embodiment of the present application;
[0128] Input / output interface 203, used to implement information input and output;
[0129] The communication interface 204 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0130] Bus 205 , which 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 , the memory 202 , the input / output interface 203 and the communication interface 204 are connected to each other in communication within the device via the bus 205 .
[0132] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned custom instruction parallel selection method is implemented.
[0133] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments 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.
[0134] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0135] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0136] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0137] The system embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0138] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0139] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0140] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0141] In the several embodiments provided in the present 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 only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0142] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0143] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0144] If the integrated unit is implemented in the form of 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 the present application, 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, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0145] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for parallel selection of user-defined instructions, characterized in that: Applied to a distributed computing system, the distributed computing system includes a master node, a plurality of first computing nodes, and a plurality of second computing nodes, the method includes: Obtain an undirected graph through the master node, the undirected graph including a plurality of candidate custom instructions, divide the undirected graph into a plurality of subgraphs, each of the subgraphs representing a task, and then assign each of the subgraphs to any of the first computing nodes for management; The multiple first computing nodes predict all execution times corresponding to all subgraphs managed by each of them and obtain a total execution time by counting the total execution time, and then feed back the counted total execution time to the master node; Analyzing, by the master node, a plurality of 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 between the multiple second computing nodes, the multiple first computing nodes aggregate all subgraphs managed by each of them to generate a subgraph list, and then distribute the subgraph lists generated by each of them to at least two of the second computing nodes for management; All optimal subgraphs are screened out from all subgraph lists managed by the multiple second computing nodes, and then all candidate custom instructions are acquired from all the optimal subgraphs screened out by the respective second computing nodes.
2. The method for parallel selection of custom instructions according to claim 1, characterized in that: The predicting of all execution times corresponding to all subgraphs managed by the multiple first computing nodes includes: For each of the first computing nodes and all the subgraphs it manages, the attribute parameters of each of the subgraphs are input into a preset time prediction model for analysis through the first computing node to predict the execution time corresponding to each of the subgraphs; wherein the time prediction model is constructed based on the data regression prediction principle of extreme random trees.
3. The method for parallel selection of user-defined instructions according to claim 1, characterized in that: The analyzing, by the master node, the plurality of 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 comprises: Filtering the maximum value and the minimum value from the multiple total execution times through the master node, and calculating the average value of the multiple total execution times; Calculating, by the master node, a load balancing degree value between the plurality of second computing nodes according to the maximum value, the minimum value and the average value; The master node detects whether the load balancing degree value is less than or equal to a preset load balancing degree threshold; if so, it is determined that there is load balancing between the multiple second computing nodes; if not, it is determined that there is no load balancing between the multiple second computing nodes.
4. The method for parallel selection of user-defined instructions according to claim 1, characterized in that: The method further comprises: When the master node detects that there is no load balancing among the plurality of second computing nodes, all subgraphs whose execution time is greater than a preset time threshold are screened out from all subgraphs managed by the plurality of first computing nodes; The multiple first computing nodes are used to split each subgraph screened out into multiple new subgraphs for management, and the multiple first computing nodes are used to predict all execution times corresponding to all subgraphs managed by each of them and calculate the total execution time, and then the total execution time calculated by each is fed back to the main node.
5. The method for parallel selection of user-defined instructions according to claim 4, characterized in that: The step of dividing each of the subgraphs screened out by the plurality of first computing nodes into a plurality of new subgraphs comprises: For each of the first computing nodes and each subgraph filtered out thereof, the first computing node rounds up the quotient between the execution time corresponding to the subgraph and the preset time threshold to obtain the number of divisions, and then divides the subgraph according to the number of divisions to obtain multiple new subgraphs.
6. The method for parallel selection of user-defined instructions according to claim 1, characterized in that: The step of filtering out all optimal subgraphs from the list of all subgraphs managed by the plurality of second computing nodes comprises: For each of the second computing nodes and all subgraph lists managed by the node, performing isomorphic matching processing on all subgraphs included in all subgraph lists by the second computing node to obtain a plurality of reorganized subgraph lists; The second computing node performs optimal screening in the plurality of reorganized subgraph lists according to a preset mathematical programming model to obtain all optimal subgraphs.
7. The method for parallel selection of user-defined instructions according to claim 6, characterized in that: The mathematical programming model includes an objective function and subgraph screening constraints, wherein the objective function is constructed with the goal of maximizing the operating performance achieved by the multiple reorganized subgraph lists, and the subgraph screening constraints include constraints on operating resources occupied by the multiple reorganized subgraph lists and a subgraph non-overlap constraint and a subgraph non-circular constraint between every two of the reorganized subgraph lists; The second computing node performs optimal screening in the plurality of reorganized subgraph lists according to a preset mathematical programming model to obtain all optimal subgraphs including: The objective function is optimized and solved by the second computing node according to the multiple reorganized subgraph lists and the subgraph screening constraints, so as to screen out all optimal subgraphs from the multiple reorganized subgraph lists.
8. A distributed computing system, characterized in that: The distributed computing system includes a master node, a plurality of first computing nodes, and a plurality of second computing nodes; The master node is used to obtain an undirected graph, the undirected graph includes a plurality of candidate custom instructions, divide the undirected graph into a plurality of subgraphs, each of the subgraphs represents a task, and then assign each of the subgraphs to any of the first computing nodes for management; The multiple first computing nodes are used to predict all execution times corresponding to all subgraphs managed by each of them and obtain the total execution time by counting, and then feed back the total execution time counted by each of them to the master node; The master node is further used to analyze the multiple total execution times fed back by the multiple first computing nodes to determine whether there is load balance among the multiple second computing nodes; When the master node detects that there is load balancing between the plurality of second computing nodes, the plurality of first computing nodes are further configured to aggregate all subgraphs managed by each of them to generate a subgraph list, and then distribute the subgraph list generated by each of them to at least two of the second computing nodes for management; The multiple second computing nodes are used to filter out all optimal subgraphs from all subgraph lists managed by each of them, and then obtain all candidate custom instructions from all the optimal subgraphs filtered out by each of them.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
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
Method for real time optimization and parallel computing of model prediction control based on computing chart
US20220327388A1