Computing resource allocation method and device
By evaluating the marginal cost of candidate nodes in the directed acyclic graph and allocating resources in the order of marginal cost, the problem that leaf node depth and number of successor nodes in the prior art is difficult to accurately reflect the scheduling cost, and efficient computing resource allocation is achieved and the approximately optimal scheduling effect.
Patent Information
- Application Number
- CN202411281454.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-01-03
AI Technical Summary
In the computing resource allocation, it is difficult to accurately reflect the scheduling cost only considering the depth of leaf nodes and the number of successor nodes, making it difficult to ensure that the scheduling cost is minimized each time.
By determining leaf nodes as candidate nodes in a directed acyclic graph, and evaluating the marginal cost of each candidate node based on predetermined measurement indicators such as Δmakespan, EST_diff and Successor_Num, computing resources are allocated in order of marginal cost from large to small. , ensure the efficiency and accuracy of resource allocation.
A close optimal resource allocation under any number of computing resources is achieved, which improves the efficiency and accuracy of computing resource allocation, and ensures that the impact on the overall completion time of DAG after each allocation is minimized.
Smart Images

Figure CN119248482A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a computing resource allocation method and device. Background Art
[0002] For a set of interdependent computing tasks, when there is no circular dependency, their dependency relationship can be represented by DAG (Directed Acyclic Graph). It is often difficult to optimally allocate computing resources for such computing tasks, because the allocation of predecessor tasks will affect the earliest allocation time of the subsequent tasks, and the algorithm for calculating the optimal solution has been proven to be of NP (Non-Deterministic Polynomial) complexity. Therefore, when allocating resources online, due to the need to quickly complete the allocation task, the heuristic List algorithm is often used to achieve the purpose of calculating the approximate optimal solution to the resource allocation problem in a relatively short time.
[0003] The optimal allocation of resources in each time slot of the heuristic List algorithm is to allocate leaf nodes in the DAG. However, when the number of leaf nodes that can be allocated exceeds the number of computing resources, scheduling of leaf nodes is necessary.
[0004] Therefore, different heuristic algorithms design different cost evaluation functions for the problem of scheduling candidate leaf nodes. The main method is to comprehensively consider the depth of the leaf node and the number of successor nodes. Generally speaking, it is believed that for leaf nodes of the same depth, the more successor nodes they have, the greater the scheduling cost, so computing resources are allocated first.
[0005] However, it is difficult to accurately reflect the scheduling cost of each leaf node by only considering the depth of the leaf node and the number of successor nodes, and thus it is difficult to ensure that the leaf node with the minimum scheduling cost is obtained each time. Summary of the invention
[0006] The present invention provides a computing resource allocation method and device to solve the defect in the prior art that only considering the depth of leaf nodes and the number of successor nodes is difficult to accurately reflect the scheduling cost of each leaf node, and realize a computing resource allocation method with better allocation efficiency.
[0007] The present invention provides a computing resource allocation method, comprising: Determine leaf nodes in the directed acyclic graph of the computing tasks to be assigned in the current time period, and use leaf nodes corresponding to computing tasks whose dependent tasks have been completed as candidate nodes; When the number of candidate nodes is greater than the number of available computing resources, the marginal cost of each candidate node is evaluated based on a predetermined measurement index, where the measurement index is a relevant index for optimizing the efficiency of task scheduling in a directed acyclic graph; Computing resources are allocated to the candidate nodes in descending order of the marginal costs.
[0008] According to a computing resource allocation method provided by the present invention, after the step of allocating computing resources to the candidate nodes in descending order of the marginal costs, the method further includes: Deleting the nodes to which computing resources have been allocated and the edges connected to the nodes to which computing resources have been allocated in the directed acyclic graph of the current time period; The remaining directed acyclic graph of the current time period is updated to the directed acyclic graph of the next time period.
[0009] According to a computing resource allocation method provided by the present invention, the measurement indicators include Δmakespan, EST_diff and Successor_Num: The Δmakespan represents the change value of makespan after scheduling any candidate node; The EST_diff represents the number of nodes whose EST changes after scheduling any candidate node; The Successor_Num represents the number of successor nodes of any candidate node.
[0010] According to a computing resource allocation method provided by the present invention, the step of evaluating the marginal cost of each candidate node based on a predetermined measurement index specifically includes: Based on the earliest start time of each remaining node in the directed acyclic graph when all the candidate nodes do not need to be scheduled, calculate the corresponding Δmakespan, EST_diff and Successor_Num when scheduling each candidate node; The calculated values of Δmakespan, EST_diff and Successor_Num corresponding to scheduling each candidate node are used as the marginal cost of each candidate node.
[0011] According to a computing resource allocation method provided by the present invention, the step of allocating computing resources to the candidate nodes in descending order of the marginal costs specifically includes: For each candidate node, when its Δmakespan is 1, determine its scheduling priority as level 3; Otherwise, determine its EST_diff, and if its EST_diff is greater than 0, determine its scheduling priority as level 2; Otherwise, its scheduling priority is determined to be level one; Allocate computing resources to the candidate nodes with scheduling priority level 3 in descending order of EST_diff; If there are still computing resources left after the candidate nodes with the third priority are allocated, the computing resources are allocated to the candidate nodes with the second priority in descending order of EST_diff. If there are still computing resources remaining after the candidate nodes with the second priority are allocated, the computing resources are allocated to the candidate nodes with the first priority in descending order of Successor_Num; After all computing resources are allocated, the computing resource allocation for the current time period ends.
[0012] According to a computing resource allocation method provided by the present invention, the step of evaluating the marginal cost of each candidate node based on a predetermined measurement index specifically includes: Based on the earliest start time of each remaining node in the directed acyclic graph when all the candidate nodes do not need to be scheduled, calculate the corresponding Δmakespan, EST_diff and Successor_Num when scheduling each candidate node; For each candidate node, the corresponding Δmakespan is used as the first position, the corresponding EST_diff is used as the second position, and the corresponding Successor_Num is used as the last position to construct a cost scalar; The constructed cost scalar is used as the marginal cost of each candidate node.
[0013] The present invention also provides a computing resource allocation device, comprising: A determination module, used to determine leaf nodes in the directed acyclic graph of the computing tasks to be assigned in the current time period, and to use leaf nodes corresponding to computing tasks whose dependent tasks have been completed as candidate nodes; A computing module, configured to evaluate the marginal cost of each candidate node based on a predetermined measurement index when the number of candidate nodes is greater than the number of available computing resources, wherein the measurement index is a relevant index for optimizing the efficiency of task scheduling in a directed acyclic graph; The allocation module is used to allocate computing resources to the candidate nodes in descending order of the marginal cost.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the computing resource allocation methods described above is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the computing resource allocation method described in any one of the above is implemented.
[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the computing resource allocation methods described above.
[0017] The computing resource allocation method and device provided by the present invention determine the marginal cost of scheduling each candidate node by determining a measurement index, and allocate computing resources to the candidate nodes in descending order of marginal cost, thereby achieving approximately optimal allocation under any number of computing resource restrictions. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is one of the flow charts of the computing resource allocation method provided by the present invention; Figure 2 It is a DAG schematic diagram in the computing resource allocation method provided by the present invention; Figure 3 It is a schematic diagram of a process for determining the scheduling priority of candidate nodes in the computing resource allocation method provided by the present invention; Figure 4 It is a schematic diagram of a process of allocating computing resources based on scheduling priorities in the computing resource allocation method provided by the present invention; Figure 5 It is a structural schematic diagram of the computing resource allocation device provided by the present invention; Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] Combine the following Figures 1 to 4 The computing resource allocation method of the present invention is introduced as follows: Figure 1 As shown, including: Step 101, determining leaf nodes in a directed acyclic graph of computing tasks to be assigned in the current time period, and taking leaf nodes corresponding to computing tasks whose dependent tasks have been completed as candidate nodes; First, determine the directed acyclic graph of the computing tasks to be assigned in the current time period, where the current time period refers to the time period of this assignment.
[0022] Optionally, the computing tasks to be allocated, such as heterogeneous computing tasks, are modeled as a directed acyclic graph, that is, the dependency relationship and execution order between the computing tasks are represented by a directed acyclic graph. Each node in the directed acyclic graph corresponds to a computing task, and the dependency relationship between the computing tasks is represented by the directed edges between the nodes, and the edge length represents the number of clock cycles required from the start of the execution of the dependent instruction to the availability of the dependent instruction result.
[0023] Specifically, a dot file describing the dependency relationship of the computing tasks to be assigned is read, and the dot file is read as a graph structure using NetworkX to obtain a directed acyclic graph of the computing tasks to be assigned in an initial time period.
[0024] In the process of allocating computing resources for the first time, the directed acyclic graph of the initial time period is the directed acyclic graph of the computing tasks to be allocated in the current time period.
[0025] Furthermore, leaf nodes are determined in the directed acyclic graph of the current time period, and leaf nodes corresponding to computing tasks whose dependent tasks have been completed are used as candidate nodes.
[0026] It can be understood that the computing tasks whose dependent tasks have been completed are computing tasks that can be executed immediately after the computing resources are allocated; the computing tasks whose dependent tasks have not been completed can be executed only after the dependent tasks are completed.
[0027] Such leaf nodes are used as candidate nodes for the current time period, so that the computing tasks corresponding to each candidate node can be executed immediately after being allocated computing resources, thereby maximizing efficiency.
[0028] Step 102, when the number of candidate nodes is greater than the number of available computing resources, the marginal cost of each candidate node is evaluated based on a predetermined measurement index, where the measurement index is a related index for optimizing the efficiency of task scheduling in a directed acyclic graph; When allocating computing resources, if the number of candidate nodes is less than the number of available computing resources, each candidate node can be directly allocated to computing resources, so there is no need to schedule the candidate nodes.
[0029] When the number of candidate nodes is greater than the number of available computing resources, it is necessary to determine the candidate nodes that can be allocated computing resources in this time period, that is, to schedule the candidate nodes. The candidate nodes can be added to the candidate group and the marginal cost of each node in the candidate group can be calculated.
[0030] Specifically, the present application evaluates the marginal cost of each candidate node through a measurement indicator to determine the candidate nodes that need to be scheduled and the candidate nodes that can be allocated computing resources.
[0031] The marginal cost of each candidate node represents the impact of scheduling the candidate node on the overall time or efficiency of the computing task corresponding to the directed acyclic graph in the current time period. The higher the marginal cost of the candidate node, the greater the impact of scheduling the candidate node on the overall time or efficiency, and the candidate node needs to be allocated computing resources first; otherwise, the candidate node needs to be scheduled first.
[0032] Optionally, the measurement indicators are related indicators for optimizing the efficiency of task scheduling in a directed acyclic graph, including but not limited to the total time required to complete the computing task corresponding to the node, the earliest time when the computing task corresponding to the node can start execution, the number of subsequent nodes of the node, the total number of nodes in the DAG, the resource consumption required to execute the computing task corresponding to the node, the priority of the computing task corresponding to the node, etc.
[0033] One or more measurement indicators are selected in advance, and the marginal cost of each candidate node is quantified based on the measurement indicators, so as to determine the priority of allocating computing resources to the candidate nodes according to the quantified marginal costs.
[0034] Alternatively, the measurement indicator can be determined empirically.
[0035] Alternatively, reinforcement learning can be used to train reinforcement learning parameters by using the resource allocation results on the required test set as the true value, that is, obtaining the actual measurement indicators through machine learning. Specifically, it can be based on classic algorithms such as ant colony algorithm, genetic algorithm and simulated annealing algorithm, or it can be based on the recent sota (state-of-the-art) reinforcement learning method.
[0036] Step 103: Allocate computing resources to the candidate nodes in descending order of the marginal cost.
[0037] It is understandable that for DAG resource allocation, the optimal allocation scheme is to allocate leaf nodes each time. If all leaf nodes cannot be allocated, pushing the leaf node backward means pushing back all nodes after the leaf node.
[0038] This application determines the marginal cost of scheduling each candidate node by evaluating the impact of scheduling each candidate node on the overall completion time of the DAG, and allocates computing resources to the candidate nodes in order from large to small marginal costs, so as to minimize the impact on the overall completion time of the DAG after each allocation.
[0039] It should be noted that although the existing method of using the depth of leaf nodes and the number of successor nodes also takes into account the scheduling cost of each leaf node to a certain extent, for some special DAGs, it is difficult to filter out the leaf node with the smallest scheduling cost only by the depth of leaf nodes and the number of successor nodes.
[0040] Take a specific example as an example, Figure 2 As shown in the provided DAG, Figure 2 The DAG in has 5 leaf nodes, but only 4 computing resources can be allocated. Therefore, a leaf node needs to be selected for scheduling.
[0041] For this specific scheduling problem, most one-step greedy algorithms determine the scheduling cost of each leaf node by balancing the depth and the number of subsequent nodes of each leaf node. Figure 2 In the DAG shown, the depths of Instr2 and Instr4 are both 5, while Instr4 has 4 successor nodes and Instr2 has only 3 successor nodes. Therefore, for this type of scheduling, Instr2 will be scheduled first because it has fewer successor nodes.
[0042] However, when scheduling Instr4, since the dependency edge from the dominant node Instr7 to Instr3 is 2, pushing Instr4 back one time period will not affect the earliest start time of Instr7, and therefore, will not affect the earliest start time of all successor nodes of Instr7. In other words, scheduling Instr4 has no effect on the earliest start time of its successor nodes. At the same time, scheduling Instr2 will affect the earliest start time of Instr6. Therefore, the marginal cost of scheduling Instr2 is greater than the marginal cost of scheduling Instr4.
[0043] By determining the marginal cost of scheduling each candidate node, scheduling Instr4 will be chosen instead of scheduling Instr2.
[0044] The present invention determines the marginal cost of scheduling each candidate node by determining a measurement index, and allocates computing resources to the candidate nodes in descending order of marginal cost, thereby achieving approximately optimal allocation under any number of computing resource constraints.
[0045] In the computing resource allocation method of the present invention, after the step of allocating computing resources to the candidate nodes in descending order of the marginal cost, the method further includes: Deleting the nodes to which computing resources have been allocated and the edges connected to the nodes to which computing resources have been allocated in the directed acyclic graph of the current time period; The remaining directed acyclic graph of the current time period is updated to the directed acyclic graph of the next time period.
[0046] After completing the allocation of computing resources for each time period, all nodes to which computing resources have been allocated and the edges connected to such nodes are deleted from the DAG of the current time period.
[0047] The remaining DAG of the current time period is updated to the DAG of the next time period. In the computing resource allocation of the next time period, the updated DAG becomes the DAG of the current time period. The candidate nodes in the updated DAG include the candidate nodes scheduled in the allocation of the previous time period.
[0048] In the computing resource allocation method of the present invention, the measurement indicators include Δmakespan, EST_diff and Successor_Num: The Δmakespan represents the change value of makespan after scheduling any candidate node; The EST_diff represents the number of nodes whose EST changes after scheduling any candidate node; The Successor_Num represents the number of successor nodes of any candidate node.
[0049] Optionally, Δmakespan, EST_diff, and Successor_Num are used as measurement indicators for evaluating the marginal cost of each candidate node.
[0050] Among them, Δmakespan, EST_diff, and Successor_Num are all defined according to EST (Earliest Start Time).
[0051] Among them, EST is a recursive definition, and the distance of the longest path from a node in the DAG to all updated leaf nodes is taken as the EST of the node, which can be expressed as: ; In the formula, n i Represents a node in the DAG, n j Represents a leaf node in the DAG.
[0052] Specifically, makespan is defined as the earliest start time of the pseudo-root node, which represents the total time to complete the computing task and can be expressed as: ; In the formula, PseudoRoot Represents a pseudo-root node.
[0053] On this basis, Δmakespan is defined as the change value relative to the benchmark makespan after a scheduling, which is 0 or 1. If Δmakespan is 0, it means that the critical path after a scheduling remains unchanged; if Δmakespan is 1, it means that the critical path after a scheduling increases by 1. Among them, the critical path is the critical node, that is, the longest path from the starting node to the ending node.
[0054] EST_diff is defined as the number of nodes whose EST changes after scheduling any candidate node.
[0055] Successor_Num is defined as the number of successor nodes of any candidate node.
[0056] The present invention selects the three indicators Δmakespan, EST_diff and Successor_Num as measurement indicators, so as to more accurately evaluate the marginal cost of scheduling each candidate node.
[0057] In the computing resource allocation method of the present invention, the step of evaluating the marginal cost of each candidate node based on a predetermined measurement index specifically includes: Based on the earliest start time of each remaining node in the directed acyclic graph when all the candidate nodes do not need to be scheduled, calculate the corresponding Δmakespan, EST_diff and Successor_Num when scheduling each candidate node; When calculating the marginal cost of each candidate node based on the measurement indicator, a time benchmark needs to be determined first.
[0058] Optionally, assuming that all candidate nodes do not need to be scheduled, the marginal cost of each candidate node is determined based on the EST of the remaining nodes in the DAG in this case as the time reference.
[0059] On this time basis, for each candidate node, the impact of scheduling the candidate node on the EST of other remaining nodes in the DAG is calculated, and Δmakespan, EST_diff and Successor_Num are generated for each node based on the EST.
[0060] That is, for each candidate node, after calculating and scheduling the candidate node, its Δmakespan, EST_diff and Successor_Num are determined according to the EST of each remaining node at this time and the EST of each remaining node on the time base.
[0061] For example, for a candidate node Instr3, after scheduling Instr3, the EST of 4 of the remaining nodes has changed, then the EST_diff value of Instr3 is 4; after scheduling Instr3, the makespan is increased by 1 compared to the criticalpath at the time base, then the Δmakespan value of Instr3 is 1; there are 4 successor nodes after Instr3, then the Successor_Num value of Instr3 is 4.
[0062] The calculated values of Δmakespan, EST_diff and Successor_Num corresponding to scheduling each candidate node are used as the marginal cost of each candidate node.
[0063] Optionally, the calculated values of Δmakespan, EST_diff, and Successor_Num of each candidate node are used as the marginal cost of each candidate node to determine the priority of computing resource allocation.
[0064] It can be understood that the marginal cost at this time is a three-dimensional vector.
[0065] In the computing resource allocation method of the present invention, the step of allocating computing resources to the candidate nodes in descending order of the marginal cost specifically includes: For each candidate node, when its Δmakespan is 1, determine its scheduling priority as level 3; Otherwise, determine its EST_diff, and if its EST_diff is greater than 0, determine its scheduling priority as level 2; Otherwise, its scheduling priority is determined to be level one; In order to determine the priority order for the marginal cost in vector form with the lowest possible complexity, a method for determining the scheduling priority is provided in this embodiment.
[0066] Specifically, Figure 3 As shown, for each candidate node, when its Δmakespan is 1, its scheduling priority is determined to be level three (III).
[0067] Otherwise, its EST_diff is determined, and if its EST_diff is greater than 0, its scheduling priority is determined to be level II (II).
[0068] Otherwise, its scheduling priority is determined to be level one (I).
[0069] Through the above method, the scheduling priority level of each candidate node can be determined.
[0070] Allocate computing resources to the candidate nodes with scheduling priority level 3 in descending order of EST_diff; If there are still computing resources left after the candidate nodes with the third priority are allocated, the computing resources are allocated to the candidate nodes with the second priority in descending order of EST_diff. If there are still computing resources remaining after the candidate nodes with the second priority are allocated, the computing resources are allocated to the candidate nodes with the first priority in descending order of Successor_Num; After all computing resources are allocated, the computing resource allocation for the current time period ends.
[0071] Then, computing resources are allocated to each candidate node based on the scheduling priority level of each candidate node.
[0072] Alternatively, if Figure 4 As shown, first, computing resources are allocated to the candidate nodes with the third priority level in descending order of EST_diff. If all computing resources are allocated during the allocation process, the allocation task of the current time period is terminated, and the DAG is updated and waits for the next allocation.
[0073] If there are still remaining computing resources after all the candidate nodes with the third priority are allocated, they will be allocated to the candidate nodes with the second priority in descending order according to EST_diff. If all computing resources are allocated during the allocation process, the allocation task of the current time period will be terminated, and the DAG will be updated and wait for the next allocation.
[0074] If there are still remaining computing resources after all the candidate nodes with the second priority are allocated, they will be allocated to the candidate nodes with the first priority in descending order of Successor_Num until all computing resources are allocated.
[0075] In the computing resource allocation method of the present invention, the step of evaluating the marginal cost of each candidate node based on a predetermined measurement index specifically includes: Based on the earliest start time of each remaining node in the directed acyclic graph when all the candidate nodes do not need to be scheduled, calculate the corresponding Δmakespan, EST_diff and Successor_Num when scheduling each candidate node; For each candidate node, the corresponding Δmakespan is used as the first position, the corresponding EST_diff is used as the second position, and the corresponding Successor_Num is used as the last position to construct a cost scalar; The constructed cost scalar is used as the marginal cost of each candidate node.
[0076] In this implementation manner, the method of calculating Δmakespan, EST_diff and Successor_Num of each candidate node is the same as above, and thus will not be described in detail.
[0077] The difference is that in this embodiment, the marginal cost of the candidate node is determined by constructing a cost scalar by taking the Δmakespan corresponding to each candidate node as the first position, the EST_diff corresponding to each candidate node as the second position, and the Successor_Num corresponding to each candidate node as the last position.
[0078] Take the five candidate nodes shown in Table 1 below as an example: Table 1 Marginal cost table of candidate nodes
[0079] For candidate node Instr1, the constructed marginal cost is 003; for candidate node Instr2, the constructed marginal cost is 013; for candidate node Instr3, the constructed marginal cost is 144; for candidate node Instr4, the constructed marginal cost is 004; for candidate node Instr5, the constructed marginal cost is 122.
[0080] Therefore, it is considered that the marginal costs of the five candidate nodes are Instr3, Instr5, Instr2, Instr4 and Instr1 in descending order. In the case that there are four allocatable computing resources in this round, computing resources are allocated to Instr3, Instr5, Instr2 and Instr4 in turn, and Instr1 is scheduled.
[0081] The present invention determines the marginal cost of candidate nodes after a computational prediction process with lower complexity by constructing a scalar, thereby achieving approximately optimal allocation under any number of computational resource constraints.
[0082] The computing resource allocation device provided by the present invention is described below. The computing resource allocation device described below and the computing resource allocation method described above can be referenced to each other.
[0083] like Figure 5 As shown, the computing resource allocation device includes a determination module 501, a calculation module 502 and an allocation module 503: A determination module 501 is used to determine leaf nodes in the directed acyclic graph of the computing tasks to be assigned in the current time period, and to use leaf nodes corresponding to computing tasks whose dependent tasks have been completed as candidate nodes; First, determine the directed acyclic graph of the computing tasks to be assigned in the current time period, where the current time period refers to the time period of this assignment.
[0084] Optionally, the computing tasks to be allocated, such as heterogeneous computing tasks, are modeled as a directed acyclic graph, that is, the dependency relationship and execution order between the computing tasks are represented by a directed acyclic graph. Each node in the directed acyclic graph corresponds to a computing task, and the dependency relationship between the computing tasks is represented by the directed edges between the nodes, and the edge length represents the number of clock cycles required from the start of the execution of the dependent instruction to the availability of the dependent instruction result.
[0085] Specifically, a dot file describing the dependency relationship of the computing tasks to be assigned is read, and the dot file is read as a graph structure using NetworkX to obtain a directed acyclic graph of the computing tasks to be assigned in an initial time period.
[0086] In the process of allocating computing resources for the first time, the directed acyclic graph of the initial time period is the directed acyclic graph of the computing tasks to be allocated in the current time period.
[0087] Furthermore, leaf nodes are determined in the directed acyclic graph of the current time period, and leaf nodes corresponding to computing tasks whose dependent tasks have been completed are used as candidate nodes.
[0088] It can be understood that the computing tasks whose dependent tasks have been completed are computing tasks that can be executed immediately after the computing resources are allocated; the computing tasks whose dependent tasks have not been completed can be executed only after the dependent tasks are completed.
[0089] Such leaf nodes are used as candidate nodes for the current time period, so that the computing tasks corresponding to each candidate node can be executed immediately after being allocated computing resources, thereby maximizing efficiency.
[0090] A computing module 502, configured to evaluate the marginal cost of each candidate node based on a predetermined measurement index when the number of candidate nodes is greater than the number of available computing resources, wherein the measurement index is a relevant index for optimizing the efficiency of task scheduling in a directed acyclic graph; When allocating computing resources, if the number of candidate nodes is less than the number of available computing resources, each candidate node can be directly allocated to computing resources, so there is no need to schedule the candidate nodes.
[0091] When the number of candidate nodes is greater than the number of available computing resources, it is necessary to determine the candidate nodes that can be allocated computing resources in this time period, that is, to schedule the candidate nodes. The candidate nodes can be added to the candidate group and the marginal cost of each node in the candidate group can be calculated.
[0092] Specifically, the present application evaluates the marginal cost of each candidate node through a measurement indicator to determine the candidate nodes that need to be scheduled and the candidate nodes that can be allocated computing resources.
[0093] The marginal cost of each candidate node represents the impact of scheduling the candidate node on the overall time or efficiency of the computing task corresponding to the directed acyclic graph in the current time period. The higher the marginal cost of the candidate node, the greater the impact of scheduling the candidate node on the overall time or efficiency, and the candidate node needs to be allocated computing resources first; otherwise, the candidate node needs to be scheduled first.
[0094] Optionally, the measurement indicators are related indicators for optimizing the efficiency of task scheduling in a directed acyclic graph, including but not limited to the total time required to complete the computing task corresponding to the node, the earliest time when the computing task corresponding to the node can start execution, the number of subsequent nodes of the node, the total number of nodes in the DAG, the resource consumption required to execute the computing task corresponding to the node, the priority of the computing task corresponding to the node, etc.
[0095] One or more measurement indicators are selected in advance, and the marginal cost of each candidate node is quantified based on the measurement indicators, so as to determine the priority of allocating computing resources to the candidate nodes according to the quantified marginal costs.
[0096] Alternatively, the measurement indicator can be determined empirically.
[0097] Alternatively, reinforcement learning can be used to train reinforcement learning parameters by using the resource allocation results on the required test set as the true value, that is, obtaining the actual measurement indicators through machine learning. Specifically, it can be based on classic algorithms such as ant colony algorithm, genetic algorithm and simulated annealing algorithm, or it can be based on the recent sota (state-of-the-art) reinforcement learning method.
[0098] The allocation module 503 is used to allocate computing resources to the candidate nodes in descending order of the marginal cost.
[0099] It is understandable that for DAG resource allocation, the optimal allocation scheme is to allocate leaf nodes each time. If all leaf nodes cannot be allocated, pushing the leaf node backward means pushing back all nodes after the leaf node.
[0100] This application determines the marginal cost of scheduling each candidate node by evaluating the impact of scheduling each candidate node on the overall completion time of the DAG, and allocates computing resources to the candidate nodes in order from large to small marginal costs, so as to minimize the impact on the overall completion time of the DAG after each allocation.
[0101] The present invention determines the marginal cost of scheduling each candidate node by determining a measurement index, and allocates computing resources to the candidate nodes in descending order of marginal cost, thereby achieving approximately optimal allocation under any number of computing resource constraints.
[0102] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the computing resource allocation method, which includes: determining leaf nodes in the directed acyclic graph of the computing tasks to be allocated in the current time period, and taking the leaf nodes corresponding to the computing tasks whose dependent tasks have been completed as candidate nodes; when the number of the candidate nodes is greater than the number of available computing resources, evaluating the marginal cost of each candidate node based on a predetermined measurement index, the measurement index is a related index for optimizing the task scheduling efficiency in the directed acyclic graph; and allocating computing resources to the candidate nodes in descending order of the marginal cost.
[0103] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the 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 a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0104] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the computing resource allocation method provided by the above methods, which method includes: determining leaf nodes in a directed acyclic graph of the computing tasks to be allocated in the current time period, and taking the leaf nodes corresponding to the computing tasks whose dependent tasks have been completed as candidate nodes; when the number of candidate nodes is greater than the number of available computing resources, evaluating the marginal cost of each candidate node based on a predetermined measurement indicator, and the measurement indicator is a related indicator for optimizing the task scheduling efficiency in the directed acyclic graph; allocating computing resources to the candidate nodes in order of the marginal costs from large to small.
[0105] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the computing resource allocation method provided by the above-mentioned methods, the method comprising: determining leaf nodes in a directed acyclic graph of the computing tasks to be allocated in the current time period, and taking the leaf nodes corresponding to the computing tasks whose dependent tasks have been completed as candidate nodes; when the number of candidate nodes is greater than the number of available computing resources, evaluating the marginal cost of each candidate node based on a predetermined measurement indicator, the measurement indicator being a related indicator for optimizing the task scheduling efficiency in the directed acyclic graph; and allocating computing resources to the candidate nodes in order of the marginal costs from large to small.
[0106] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0107] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A computing resource allocation method, characterized in that: include: Determine leaf nodes in the directed acyclic graph of the computing tasks to be assigned in the current time period, and use leaf nodes corresponding to computing tasks whose dependent tasks have been completed as candidate nodes; When the number of candidate nodes is greater than the number of available computing resources, the marginal cost of each candidate node is evaluated based on a predetermined measurement index, where the measurement index is a relevant index for optimizing the efficiency of task scheduling in a directed acyclic graph; Computing resources are allocated to the candidate nodes in descending order of the marginal costs.
2. The computing resource allocation method according to claim 1, characterized in that: After the step of allocating computing resources to the candidate nodes in descending order of the marginal costs, the method further includes: Deleting the nodes to which computing resources have been allocated and the edges connected to the nodes to which computing resources have been allocated in the directed acyclic graph of the current time period; The remaining directed acyclic graph of the current time period is updated to the directed acyclic graph of the next time period.
3. The computing resource allocation method according to claim 1 or 2, characterized in that: The measurement indicators include Δmakespan, EST_diff and Successor_Num: The Δmakespan represents the change value of makespan after scheduling any candidate node; The EST_diff represents the number of nodes whose EST changes after scheduling any candidate node; The Successor_Num represents the number of successor nodes of any candidate node.
4. The computing resource allocation method according to claim 3, characterized in that: The step of evaluating the marginal cost of each candidate node based on a predetermined measurement index specifically includes: Based on the earliest start time of each remaining node in the directed acyclic graph when all the candidate nodes do not need to be scheduled, calculate the corresponding Δmakespan, EST_diff and Successor_Num when scheduling each candidate node; The calculated values of Δmakespan, EST_diff and Successor_Num corresponding to scheduling each candidate node are used as the marginal cost of each candidate node.
5. The computing resource allocation method according to claim 4, characterized in that: The step of allocating computing resources to the candidate nodes in descending order of the marginal costs specifically includes: For each candidate node, when its Δmakespan is 1, determine its scheduling priority as level 3; Otherwise, determine its EST_diff, and if its EST_diff is greater than 0, determine its scheduling priority as level 2; Otherwise, its scheduling priority is determined to be level one; Allocate computing resources to the candidate nodes with scheduling priority level 3 in descending order of EST_diff; If there are still computing resources left after the candidate nodes with the third priority are allocated, the computing resources are allocated to the candidate nodes with the second priority in descending order of EST_diff. If there are still computing resources remaining after the candidate nodes with the second priority are allocated, the computing resources are allocated to the candidate nodes with the first priority in descending order of Successor_Num; After all computing resources are allocated, the computing resource allocation for the current time period ends.
6. The computing resource allocation method according to claim 3, characterized in that: The step of evaluating the marginal cost of each candidate node based on a predetermined measurement index specifically includes: Based on the earliest start time of each remaining node in the directed acyclic graph when all the candidate nodes do not need to be scheduled, calculate the corresponding Δmakespan, EST_diff and Successor_Num when scheduling each candidate node; For each candidate node, the corresponding Δmakespan is used as the first position, the corresponding EST_diff is used as the second position, and the corresponding Successor_Num is used as the last position to construct a cost scalar; The constructed cost scalar is used as the marginal cost of each candidate node.
7. A computing resource allocation device, characterized in that: include: A determination module, used to determine leaf nodes in the directed acyclic graph of the computing tasks to be assigned in the current time period, and to use leaf nodes corresponding to computing tasks whose dependent tasks have been completed as candidate nodes; A computing module, configured to evaluate the marginal cost of each candidate node based on a predetermined measurement index when the number of candidate nodes is greater than the number of available computing resources, wherein the measurement index is a relevant index for optimizing the efficiency of task scheduling in a directed acyclic graph; The allocation module is used to allocate computing resources to the candidate nodes in descending order of the marginal cost.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the computing resource allocation method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computing resource allocation method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computing resource allocation method according to any one of claims 1 to 6 is implemented.
