Resource allocation method and apparatus, computer device, and storage medium
Patent Information
- Application Number
- CN202110475134.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-29
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2041-04-29
AI Technical Summary
相关技术中,存在众核系统的核心资源利用率低的缺点
[0013] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the resource allocation method as described in any of the embodiments of the present invention.
Smart Images

Figure CN115269164B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of artificial intelligence, and in particular to a resource allocation method, apparatus, computer equipment and storage medium. Background Technology
[0002] In recent years, with the rapid development of artificial intelligence-related applications and technologies, the requirements for computing power and power efficiency have been increasing. Among related technologies, many-core systems suffer from low core resource utilization. Summary of the Invention
[0003] This invention provides a resource allocation method, apparatus, computer device, and storage medium.
[0004] In a first aspect, embodiments of the present invention provide a resource allocation method applied to a many-core system, wherein the many-core system includes allocable core resources, including:
[0005] Obtain an operator graph group, the operator graph group including at least one operator graph of the resource to be allocated;
[0006] Obtain the resource allocation type, and determine the target core resource from the allocable core resources based on the resource allocation type;
[0007] The target core resources are allocated to the operator graph set.
[0008] Secondly, embodiments of the present invention also provide a resource allocation device configured in a many-core system, the many-core system including allocable core resources, including:
[0009] The operator graph group acquisition module is used to acquire an operator graph group, wherein the operator graph group includes at least one operator graph of the resource to be allocated;
[0010] The target core resource determination module is used to obtain the resource allocation type and determine the target core resource among the core resources based on the allocable resource allocation type.
[0011] The resource allocation module is used to allocate the target core resources to the operator graph set.
[0012] Thirdly, embodiments of the present invention also provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the resource allocation method as described in any of the embodiments of the present invention.
[0013] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the resource allocation method as described in any of the embodiments of the present invention.
[0014] This invention, through configuring resource allocation types and allocating resources among the allocatable core resources for each operator graph in an operator graph group according to the resource allocation types, can allocate partial resources to each operator graph group. It can rationally allocate resources to each operator graph, solving the problem of wasting core resources caused by allocating full resources for each operator graph in the prior art. It can rationally allocate core resources and allocate resources in a targeted manner, thereby improving the utilization rate of core resources and reducing waste of core resources. Attached Figure Description
[0015] Figure 1 This is a flowchart of a resource allocation method according to Embodiment 1 of the present invention;
[0016] Figure 2 This is a schematic diagram of the structure of a resource allocation device according to Embodiment 2 of the present invention;
[0017] Figure 3 This is a schematic diagram of the structure of a computer device according to Embodiment 3 of the present invention. Detailed Implementation
[0018] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0019] Example 1
[0020] Figure 1 This is a flowchart of a resource allocation method according to Embodiment 1 of the present invention. This embodiment is applicable to the situation where resources are allocated to an operator graph based on the operational requirements information of the operator graph. This method can be executed by the resource allocation device provided in this embodiment of the present invention. This device can be implemented in software and / or hardware, and is generally integrated into a computer device. Figure 1 As shown, the method in this embodiment includes:
[0021] Any embodiment of the present invention is applied to a many-core system, which includes allocable core resources.
[0022] In this context, allocatable core resources refer to the cores allocated to the operator graph. A core is an independently schedulable unit with complete computing capabilities, possessing its own storage and computational resources. In addition to allocatable core resources, the resources of a computer device also include core resources allocated to programs outside the operator graph to run other programs. Computer devices executing resource allocation methods include many-core systems, which are used to run multiple operator graphs simultaneously. Many cores consist of a large number (potentially hundreds or thousands in the future) of various types of cores connected together in a pre-defined manner, possessing high-performance parallel processing capabilities.
[0023] S110, Obtain an operator graph group, the operator graph group including at least one operator graph of the resource to be allocated.
[0024] The operator graph group includes at least one operator graph. An operator graph includes at least one operator; optionally, when an operator graph includes at least two operators, the output of the preceding operator serves as the input of the adjacent following operator. Operators can refer to algorithms such as convolution, addition, subtraction, multiplication, division, or matrix addition and multiplication. The operator graph is used to implement specific functions and can refer to high-performance computing algorithms. Operator graphs can include, but are not limited to, AI algorithms, machine learning algorithms, and general scientific computing algorithms. For example, an operator graph can be the whole or a part of one or more deep learning models; or, for instance, an operator graph can be the whole or a part of one or more neural networks.
[0025] There can be multiple operator graphs for which resources are to be allocated. At least two operator graphs can be independent or have a dependency relationship. A dependency relationship means that the output of the first operator graph serves as the input of the second. Operator graphs require resources to run. Core resources are allocated to the operator graphs to run them, compute the input data, obtain the output data, and thus achieve specific functions.
[0026] S120, obtain the resource allocation type, and determine the target core resource from the allocable core resources according to the resource allocation type.
[0027] Resource allocation type serves as the basis for allocating core resources to operator graphs and can be used to determine the resource allocation strategy for each operator graph in an operator graph group. The resource allocation type determines the method for allocating core resources; different resource allocation types correspond to different core resource allocation methods. Typically, different operator graphs in an operator graph group have the same resource allocation type, meaning they correspond to the same core resource allocation method. The target core resource can refer to the sum of resources allocated to all operator graphs in the operator graph group.
[0028] In one possible implementation, based on the resource allocation type, at least one candidate sub-core resource can be determined sequentially for each operator graph in the operator graph group from the core resources. This is equivalent to determining at least one candidate core resource for the operator graph group from the core resources, and then allocating each candidate core resource to the operator graph group. The running performance of the operator graphs is determined, and the candidate core resources allocated in the resource allocation method with the best running performance are determined as the target core resources. When the core resource is a core, the sum of the core counts of the target core resources allocated to each operator graph is less than or equal to the core count of the allocable core resources.
[0029] In one possible implementation, multiple operator graph groups can exist, forming an operator graph set. Each operator graph group includes at least one operator graph stored in on-chip storage at the same time. The operator graphs in different operator graph groups are located in on-chip storage at different times. Before obtaining the resource allocation type and determining the target core resource, it can be determined whether the chip can store the operator graph set. For example, it can be determined whether the chip's on-chip storage is greater than or equal to the storage size of the data associated with the operator graph set. The associated data can be configuration data. On-chip storage can refer to the chip's memory, which is configured with allocable storage resources for storing the data associated with the operator graph group. The occupied space of the operator graph set can refer to the storage resources occupied by the data associated with the operator graph set. If the on-chip storage is greater than or equal to the occupied space of the operator graph set, then the operator graph set can be determined as an operator graph group; if the on-chip storage is less than the occupied space of the operator graph set, then the operator graph set is divided into multiple operator graph groups, and the occupied space of each operator graph group is less than or equal to the on-chip storage.
[0030] Optionally, resource allocation types include: high-performance, energy-saving, or balanced. Chip power consumption primarily depends on data transfer, core computation, and resource scheduling. The power consumption of these three varies under different conditions. For example, all other things being equal, the greater the amount of data transferred per unit time, the greater the power consumption; all other things being equal, the more cores used for computation per unit time, the greater the power consumption; and all other things being equal, the more resource scheduling instructions issued per unit time, the greater the power consumption of the scheduler.
[0031] S130, the target core resources are allocated to the operator graph group.
[0032] In some optional embodiments, target core resources are allocated to an operator graph group. This involves assigning multiple cores to an operator graph group consisting of at least one operator graph. Specifically, the core resources allocated to each operator graph in the group can be determined individually, thereby identifying the target core resources for the group. The target core resources are then allocated to the operator graph group according to the core resources allocated to each operator graph. After the core resources of the operator graphs are allocated, the core resources corresponding to each operator graph can be further subdivided and allocated to the operators within that operator graph. The allocation method for the core resources of the operators can be set according to actual conditions, and this embodiment of the invention does not impose specific limitations on this.
[0033] Optionally, the operator graph includes: a neural network model or at least one network included in the neural network model.
[0034] In this context, an operator graph can be the entirety or a part of a neural network model. It can be understood as an operator graph used to implement a complete specific function, or a portion of a specific function. For example, an operator graph can be a neural network model, or a collection of networks consisting of at least one network within a neural network model.
[0035] In some optional embodiments, the operator graph may include a model formed by an image detection network and a speech recognition network, or the operator graph may only include an image detection network, or the operator graph may only include a speech recognition network. Similarly, the operator graph may include a model formed by an image detection network and an object recognition network, or the operator graph may only include an image detection network, or the operator graph may only include an object recognition network.
[0036] By configuring the operator graph as the entire model or as a part of the network included in the model, the application scenarios of the operator graph that the chip can execute can be enriched, as well as the business models of the operator graph, while improving the utilization rate of core resources.
[0037] Optionally, the on-chip storage stores the configuration information of the operator graph group at the same time.
[0038] The on-chip storage simultaneously storing the configuration information of the operator graph group means that, at any given time, the on-chip storage can hold the configuration information of all operator graphs in the operator graph group. If the configuration information of all operator graphs cannot be moved to the on-chip storage at the same time, a few operator graphs can be placed. After these few operator graphs have finished running, their configuration information is moved out of the on-chip storage and the configuration information of the remaining operator graphs is placed in, and so on, until all operator graphs have been run in the on-chip storage. In this embodiment of the invention, the resource allocation object can be multiple operator graphs stored on the on-chip storage at the same time.
[0039] At the same time, the operator graphs located in on-chip storage are allocated resources according to the available core resources; and at the next time, resources are reallocated to the multiple operator graphs located in on-chip storage at the same time according to the available core resources.
[0040] Optionally, determining the target core resource from the allocable core resources according to the resource allocation type includes: determining the target sub-core resources corresponding to each operator graph in the operator graph group in sequence from the allocable core resources according to the resource allocation type, and determining the sum of the target sub-core resources as the target core resource.
[0041] In this context, the target sub-core resource is the core resource allocated to the operator graph. The sum of the target sub-core resources is the target core resource. The target sub-core resource is less than or equal to the target core resource, and the target core resource is less than or equal to the allocable core resource. Resource allocation for an operator graph group can refer to allocating resources sequentially for each operator graph in the group, obtaining the target sub-core resource for each operator graph, and ultimately determining the target core resource for the entire operator graph group. The target sub-core resources of each operator graph are adjusted so that the sum of the target sub-core resources obtained from the operator graph resource allocation, i.e., the target core resource, matches the resource allocation type.
[0042] By sequentially allocating resources to each operator graph in the operator graph group, the sum of the target sub-core resources allocated to each operator graph is determined as the target core resource, thereby improving the level of resource allocation, rationally allocating resources, and improving resource utilization.
[0043] Optionally, the resource allocation type includes high-performance type, energy-saving type, or balanced type.
[0044] High-performance resource allocation methods can be understood as maximizing chip computing performance. Throughput, timing, and serial-parallel scheduling are all configured to maximize the utilization of core computing power. Performance can be expressed as chip computing performance. Energy-saving resource allocation methods can be understood as maintaining extreme energy efficiency under certain performance conditions. In this case, power loss due to frequent data transfer becomes a constraint, so data transfer should be minimized. Related scheduling instructions, core computing, throughput, latency, timing, and serial-parallel relationships are all configured to reduce the amount of data transferred over a period of time to meet the power reduction requirements under certain performance conditions. Balanced allocation can be seen as an intermediate type between the two, aiming to obtain the optimal power consumption ratio under certain conditions. It requires comprehensive consideration of the above factors and a measurement of the core computing power and data transfer scheduling power consumption of the above resource allocation methods to obtain the optimal energy consumption ratio. The energy consumption ratio is used to evaluate the ratio of performance to power consumption.
[0045] In this scenario, the on-chip storage space is greater than or equal to the space occupied by the operator graph set. In this case, the on-chip storage can hold the data associated with that operator graph set, and all operator graphs can form an operator graph group, reducing the impact of data movement on chip computing performance. Any of the high-performance, energy-saving, or balanced resource allocation methods can be used to achieve this.
[0046] If the on-chip storage space is smaller than the space occupied by the operator graph set, then the on-chip storage can hold a portion of the operator graphs associated with that set. This portion of the operator graphs constitutes an operator graph group. After the operator graphs in the operator graph group have finished running, the remaining data needs to be moved to the on-chip storage to run the remaining operator graphs, requiring data transfer. In this case, it is incompatible with the energy-saving resource allocation method. Therefore, when the on-chip storage space is smaller than the space occupied by the operator graph set, the energy-saving resource allocation method is not configured.
[0047] By configuring resource allocation types and the application scenarios applicable to each resource allocation type, resource allocation methods can be flexibly configured, and the flexibility of resource allocation methods can be improved to adapt to the application scenarios of the chip's executable operator graph, thereby increasing the rationality of resource allocation.
[0048] Optionally, the resource allocation type includes: high-performance type; the step of determining the target core resource in the core resources according to the resource allocation type includes: traversing each operator graph in the operator graph group, taking each operator graph in the operator graph group as the target operator graph in turn, and determining the target sub-core resource that satisfies the condition of the fastest processing speed of each target operator graph through a binary search method.
[0049] The binary search method refers to repeatedly dividing a resource range in half until it narrows down to a specific core resource, ensuring the running operator graph meets the fastest processing speed condition. This fastest processing speed condition identifies the sub-core resource that yields the best performance. Specifically, it specifies that when the operator graph is run with a certain number of sub-core resources, its processing speed is faster than when run with any other sub-core resource. The fastest processing speed condition can be that running the operator graph with the target sub-core resource results in the fastest chip processing speed for that operator graph.
[0050] For example, multiple sub-core resources can be identified within the core resources. For instance, the core resources may have four cores, and the number of cores in the sub-core resources can be one, two, three, or four. The target core resource that satisfies the condition of fastest processing speed indicates that, compared to other sub-core resources, the chip processes the operator graph fastest when using this target sub-core resource.
[0051] By identifying the sub-core resources that meet the conditions for the fastest processing speed as target sub-core resources, the core resources that meet the high-performance operation requirements can be accurately determined, thereby maximizing the chip's computing performance and satisfying the resource allocation method for high-performance types.
[0052] Optionally, determining the target sub-core resources that satisfy the condition of the fastest processing speed of the target operator graph using the bisection method includes: determining a range of core numbers based on the current remaining core resources and a preset minimum core resource, and calculating the median of the core number range, where the current remaining core resources, the minimum core resource, and the median are all integers; running the target operator graph using the current remaining core resources, the minimum core resource, and the median respectively, eliminating the slowest processing numbers, and determining the remaining two numbers as the target numbers; redetermining the median and target numbers based on the two target numbers, until there is no median within the core number range, and determining the fastest processing number within the current core number range as the target sub-core resources that satisfy the condition of the fastest processing speed of the target operator graph.
[0053] The current remaining core resources can be understood as the core resources that can currently be allocated to the target operator graph. Optionally, the current remaining core resources are the maximum number of core resources that can currently be allocated to the target operator graph. The minimum core resources are the minimum number of core resources that can currently be allocated to the target operator graph; for example, the minimum core resource is 1 core resource. When the current remaining core resources are equal to the minimum core resources, the number of core resources with the fastest processing speed is either the current remaining core resources or the minimum core resources, which is the target sub-core resource of the target operator graph. If the current remaining core resources are greater than or equal to the minimum core resources, the current remaining core resources and the minimum core resources determine the core quantity range. This means that the current remaining core resources and the minimum core resources are respectively the endpoints of the core quantity range, with the current remaining core resources being the upper limit of the core quantity range in the bisection method, and the minimum core resources being the lower limit of the core quantity range in the bisection method. The median of the core quantity range in the bisection method can refer to the median between the current remaining core resources and the minimum core resources.
[0054] The operator graph is run using three different core resource sets. The slowest-processing core resource is removed, and the two remaining core resource sets are the fastest-processing core resource sets, which are then determined as target core resource sets. The core resource range is redefined based on these two target core resource sets. The larger of the two target core resource sets the upper limit of the new core resource range, and the smaller of the two target core resource sets the lower limit of the new core resource range. Typically, the target core resource set is the sum of the current remaining core resource set and the median, or the sum of the minimum core resource set and the median. Therefore, the redefined core resource range is smaller than the range defined by the current remaining core resource set and the minimum core resource set, thus narrowing the core resource range. If there is no integer median within the core resource range, it means there are no integers between the two endpoints of the current core resource range; in this case, the two endpoints are adjacent integers. The core resource set with the fastest processing speed is then selected as the target sub-core resource.
[0055] For example, the resource range corresponding to the core resource can be the range of the core quantity between 1 (or 0) and the core quantity corresponding to the core resource. Since the core is the smallest allocatable core resource unit and cannot be further divided, the core quantity can only take integer values. The resource range is continuously narrowed using a bisection method. The fastest processing quantity is determined as the target sub-core resource that satisfies the condition of the fastest processing speed of the target operator graph. This can be achieved by: presetting a second quantity, such as 0 or 1; designating the core quantity corresponding to the core resource as the first quantity; and using the median of the core quantity range determined by the first and second quantities as the third quantity. The operator graph group is then run using the first, second, and third quantities respectively, selecting the two fastest processing quantities. The resource range is then redefined, with the two ends of the resource range redefined as the first quantity (upper limit) and the second quantity (lower limit), and the median of the redefined resource range as the third quantity. The operator graph group is then run using all three quantities, selecting the two fastest processing quantities, and the resource range is redefined again. This process is repeated until the resource range includes at most two quantities, and the fastest processing quantity among them is selected as the target sub-core resource that satisfies the condition of the fastest processing speed of the target operator graph. At this point, the fastest processing quantity among the at most two quantities is also the fastest processing quantity in the initial resource range corresponding to the core resource.
[0056] For example, first allocate 1 core, 1 / 2 of all cores (round up if not an integer), and all cores respectively to determine the processing speed of the operator graph group. For instance, if the processing speed of 1 / 2 of all cores and all cores is faster than that of 1 core, then a number can be selected between 1 / 2 of all cores and all cores, such as 3 / 4 of all cores, to determine the processing speed. This process continues until the target number of cores that is fastest to process the above multiple operator graphs is determined.
[0057] Furthermore, regardless of whether the on-chip storage can hold the data associated with the operator graph group, the target sub-core resource matching the maximum processing speed can be determined using a binary search method.
[0058] By using the bisection method, the operating cost of running operator graph groups one by one can be reduced, the target core resources can be quickly determined, the determination cost of target core resources can be reduced, and the determination efficiency of target core resources can be improved.
[0059] Optionally, the resource allocation type includes: energy-saving type; the step of sequentially determining the target sub-core resources corresponding to each operator graph in the operator graph group from the allocable core resources includes: traversing each operator graph in the operator graph group, and sequentially taking each operator graph in the operator graph group as a target operator graph; calculating the minimum sub-core resource corresponding to each target operator graph; for each target operator graph, accumulating resources at least once in the corresponding minimum sub-core resource to obtain at least one candidate sub-core resource, and selecting the candidate sub-core resource that meets the condition of fastest reduction in processing time from each candidate sub-core resource, and determining it as the target sub-core resource of the target operator graph.
[0060] In energy-saving resource allocation methods, the number of data transfers is minimized. In this case, on-chip storage can hold all the operator graphs to be run. The minimum sub-core resource can refer to the minimum core resource allocated to the operator graph while meeting its operational requirements.
[0061] For example, the minimum sub-core resource of the target operator graph is determined as follows: Based on the occupied space of the operator graph group (such as the size of the total configuration data) and the core storage size of the target operator graph, the quotient of the occupied space divided by the storage size of the target operator graph is calculated. The smallest integer greater than or equal to the quotient is determined as the minimum sub-core resource corresponding to the target operator graph. If the storage size of each target operator graph is the same, then the minimum sub-core resource corresponding to each target operator graph is the same.
[0062] A candidate sub-core resource is a core resource that is greater than the minimum sub-core resource and less than or equal to the allocable core resource. The minimum sub-core resource can be copied, and the same resource can be added multiple times to each minimum sub-core resource to obtain different candidate sub-core resources. For example, adding a set number of resources once results in one candidate sub-core resource, and adding the set number of resources twice results in another candidate sub-core resource. Different candidate sub-core resources have different numbers of cores. For example, by gradually increasing resources on the minimum core resource, multiple candidate sub-core resources can be obtained. For instance, if the minimum core resource has 3 cores, adding 1 core gradually results in 4, 5, 6, and 7 cores, all of which can be used as candidate sub-core resources.
[0063] The core resources that satisfy the condition of fastest reduction in processing time are those used by the chip to process the operator graph with the fastest reduction in processing time. For example, a relationship curve between the number of cores and processing time can be established, and the number of cores with the fastest reduction in processing time in the relationship curve can be identified as the target core resources.
[0064] Optionally, in the energy-saving resource allocation method, based on the total configuration data size of the operator graph group and the size of the on-chip storage, it is determined whether the on-chip storage can accommodate the total configuration of all operator graphs in the operator graph group. If it can, the target core resources under the energy-saving resource allocation method are determined. The target core resources determined by the energy-saving method are the minimum number of cores required to ensure that the configuration information of the operator graph group is not split.
[0065] By identifying the candidate sub-core resources that minimize processing time as the target core resources, the core resources that meet the energy-saving operation requirements can be accurately determined, thereby minimizing chip power consumption and satisfying the energy-saving resource allocation method.
[0066] Optionally, the step of accumulating resources at least once in the corresponding minimum sub-core resource to obtain at least one candidate sub-core resource, and selecting candidate sub-core resources that meet the condition of fastest processing time reduction from each candidate sub-core resource, includes: accumulating a unit resource in the minimum sub-core resource to obtain candidate sub-core resources, wherein the number of candidate sub-core resources is less than or equal to the number of core resources; running the target operator graph using the candidate sub-core resources and the minimum sub-core resource respectively, and obtaining the matching processing time; calculating the difference between the processing time matched by the candidate sub-core resource and the processing time matched by the minimum sub-core resource, and determining it as the processing time reduction value matched by the candidate sub-core resource; continuing to accumulate the unit resource in the minimum sub-core resource to obtain the next candidate sub-core resource, and calculating the processing time reduction value matched by the next candidate sub-core resource, until the difference between the processing time reduction values matched by two adjacent candidate sub-core resources is less than a set threshold; and determining the candidate sub-core resource with the larger number of adjacent candidate sub-core resources as the candidate sub-core resource that meets the condition of fastest processing time reduction.
[0067] Each accumulation can increase the set unit quantity, such as 10% or 20% of the core resources. The processing time for core resource matching refers to the time required to run the target operator graph and calculate the set input data using that core resource. The processing time reduction value is used to evaluate the extent to which the processing time decreases as the core resources increase. The processing time reduction value can be positive, representing a decrease in processing time with the increase of core resources; the processing time reduction value can be negative, representing an increase in processing time with the increase of core resources.
[0068] Continuing to accumulate resources within the minimum core resource means adding resources on top of the previously accumulated resources. This means the number of resources in the successively obtained candidate sub-core resources gradually increases, and in the generation sequence, the next candidate sub-core resource is greater than the previous one. If the difference between the processing time reduction values of matching two adjacent candidate sub-core resources in the generation sequence is less than a set threshold, it indicates that the processing time decreases sharply with the increase of core resources, meaning the reduction in processing time is significant. The processing time reduction value for matching a candidate sub-core resource is the difference between the processing time matched by that candidate sub-core resource and the processing time matched by the previous candidate sub-core resource. Here, resources are accumulated sequentially within the minimum sub-core resource; the previous candidate sub-core resource refers to the candidate sub-core resource obtained in the previous accumulation. The number of cores in a candidate sub-core resource is greater than that of the previous candidate sub-core resource. The candidate core resources with the largest number can be identified as the candidate core resources that meet the condition of the fastest reduction in processing time. Among them, the candidate core resource with the largest number is the next candidate core resource among two adjacent candidate core resources in the generation sequence.
[0069] By accumulating resources multiple times within the minimum core resource, multiple candidate sub-core resources are obtained. During the accumulation process, candidate sub-core resources with a sharp reduction in processing time are queried and identified as those that meet the condition of the fastest reduction in processing time. This reduces the running cost of running operator graph groups for each candidate sub-core resource, quickly determines the target core resource, lowers the cost of determining the target core resource, and improves the efficiency of determining the target core resource.
[0070] Optionally, the resource allocation type includes: a balanced type; the step of sequentially determining the target sub-core resources corresponding to each operator graph in the operator graph group from the allocable core resources includes: traversing each operator graph in the operator graph group, and sequentially taking each operator graph in the operator graph group as a target operator graph; determining at least one sub-core resource corresponding to each target operator graph based on the allocable core resources, wherein the number of each sub-core resource is less than or equal to the number of core resources; calculating the energy consumption ratio matched by each sub-core resource based on the processing time of the core resource, the calculation speed of the core resource, the power consumption of data transfer, and the power consumption of the core resource calculation; obtaining the sub-core resource matched by the maximum energy consumption ratio corresponding to each target operator graph, and determining it as the target sub-core resource corresponding to each target operator graph.
[0071] In some optional embodiments, the energy consumption ratio of the sub-core resource can be determined by formula (1) based on the processing time of the core resource, the computing speed of the core resource, the power consumption of data transfer, and the power consumption of core resource computation:
[0072]
[0073] In this context, "balanced allocation" refers to the resource allocation method that yields the best computational performance per unit of power consumption. Sub-core resources are the number of cores less than or equal to the number of core resources; different sub-core resources have different core counts. Determining the target sub-core resource can be done by finding the target sub-core resource that maximizes the energy efficiency ratio of the target operator graph. The variable in the formula is the core resource. Using different core resources, the energy efficiency ratio of the target operator graph is calculated for each graph, and the core resource with the highest energy efficiency ratio is selected as the target sub-core resource for that target operator graph.
[0074] Energy efficiency ratio (EER) represents computational performance per unit of power consumption. The processing time of core resources multiplied by their computational speed is used to evaluate computational load, while the power consumption for data transfer plus the power consumption for core resource computation is used to evaluate overall power consumption. The processing time of core resources multiplied by their computational speed equals the product of the core's clock speed and the power consumption of the sub-core resources. The power consumption for data transfer is calculated by considering the space occupied by the data associated with the operator graph group, the bandwidth, and the power consumption required for data transfer per unit time. For example, dividing the space occupied by the bandwidth yields the transfer time, and the product of the transfer time and the power consumption required for data transfer per unit time is the power consumption for data transfer. The power consumption for core resource computation is calculated by considering the computational load, sub-core resources, and the power consumption required for computation per unit time. For example, dividing the computational load by the sub-core resources yields the computation time, and the product of the computation time and the power consumption required for computation per unit time is the power consumption for core resource computation. The power consumption required for data transfer and computation per unit time are related to the hardware of the many-core system and can be determined experimentally.
[0075] Therefore, the energy consumption ratio formula only has the variable of sub-core resources. By inputting multiple sub-core resources into the formula, multiple energy consumption ratios can be obtained. The largest energy consumption ratio can be selected from these, and the sub-core resource used as input can be determined as the target core resource.
[0076] By identifying the sub-core resource with the highest energy consumption ratio as the target sub-core resource, the core resources that meet the balance requirements can be accurately determined, thereby maximizing the computing performance per unit power consumption of the chip and satisfying the resource allocation method of the balance type.
[0077] This invention, through configuring resource allocation types and allocating resources to operator graph groups within the allocable core resources according to these types, allows for the allocation of partial resources to each operator graph group. This enables the rational allocation of resources to each operator graph, solving the problem of wasted core resources caused by full resource allocation for each operator graph in existing technologies. It allows for the rational and targeted allocation of core resources, improving the utilization rate of core resources and reducing waste.
[0078] Example 2
[0079] Figure 2 This is a schematic diagram of a resource allocation device according to Embodiment 2 of the present invention. Embodiment 2 is a corresponding device for implementing the resource allocation method provided in the above embodiments of the present invention. This device can be implemented in software and / or hardware, and can generally be integrated into computer devices, specifically in many-core systems.
[0080] The operator graph group acquisition module 210 is used to acquire an operator graph group of resources to be allocated, wherein the operator graph group includes at least one operator graph.
[0081] The target core resource determination module 220 is used to obtain the resource allocation type and determine the target core resource from the allocable core resources according to the resource allocation type.
[0082] Resource allocation module 230 is used to allocate the target core resources to the operator graph group.
[0083] This invention, through configuring resource allocation types and allocating resources among the allocatable core resources for each operator graph in an operator graph group according to the resource allocation types, can allocate partial resources to each operator graph group. It can rationally allocate resources to each operator graph, solving the problem of wasting core resources caused by allocating full resources for each operator graph in the prior art. It can rationally allocate core resources and allocate resources in a targeted manner, thereby improving the utilization rate of core resources and reducing waste of core resources.
[0084] Furthermore, the target core resource determination module 220 includes: an operator graph resource determination unit, used to determine the target sub-core resources corresponding to each operator graph in the operator graph group in sequence from the allocable core resources according to the resource allocation type; and to determine the target core resources according to the sum of the target sub-core resources.
[0085] Furthermore, the resource allocation type includes: high-performance type; the operator graph resource determination unit includes: a maximum processing speed resource detection unit, used to traverse each operator graph in the operator graph group, sequentially take each operator graph in the operator graph group as the target operator graph, and determine the target sub-core resource that satisfies the condition of the fastest processing speed of the target operator graph through a binary search method.
[0086] Furthermore, the maximum processing speed resource detection unit is specifically used for: determining the current remaining core resources based on the allocable core resources and the pre-determined target sub-core resources; determining the core quantity range based on the current remaining core resources and the preset minimum core resources, and calculating the median of the core quantity range, wherein the current remaining core resources, the minimum core resources, and the median are all integers; running the target operator graph using the current remaining core resources, the minimum core resources, and the median respectively, eliminating the slowest processing speed quantity, and determining the remaining two quantities as the target quantity; redetermining the median and target quantity based on the two target quantities, until there is no integer median within the core quantity range, and determining the fastest processing speed quantity within the current core quantity range as the target sub-core resource that satisfies the condition of the fastest processing speed of the target operator graph.
[0087] Furthermore, the resource allocation type includes: energy-saving type; the operator graph resource determination unit includes: a resource detection unit for the fastest reduction in processing time, used to traverse each operator graph in the operator graph group, and sequentially take each operator graph in the operator graph group as a target operator graph; calculate the minimum sub-core resource corresponding to each target operator graph; for each target operator graph, accumulate different numbers of resources in the corresponding minimum sub-core resource to obtain at least one candidate sub-core resource, and select the candidate sub-core resource that meets the condition of the fastest reduction in processing time from each candidate sub-core resource, and determine it as the target sub-core resource corresponding to the target operator graph.
[0088] Furthermore, the resource detection unit for fastest processing time reduction is specifically used for: accumulating unit resources in the minimum sub-core resource to obtain candidate sub-core resources, wherein the number of candidate sub-core resources is less than or equal to the number of core resources; running the target operator graph using the candidate sub-core resources and the minimum sub-core resource respectively, and obtaining the matching processing time; calculating the difference between the processing time matched by the candidate sub-core resource and the processing time matched by the minimum sub-core resource, and determining it as the processing time reduction value matched by the candidate sub-core resource; continuing to accumulate unit resources in the minimum sub-core resource to obtain the next candidate sub-core resource, and calculating the processing time reduction value matched by the next candidate sub-core resource, until the difference between the processing time reduction values matched by two adjacent candidate sub-core resources is less than a set threshold; and determining the candidate sub-core resource with the larger number of adjacent candidate sub-core resources as the candidate sub-core resource that satisfies the condition of fastest processing time reduction.
[0089] Furthermore, the resource allocation type includes: balanced type; the operator graph resource determination unit includes: a resource detection unit with maximum energy consumption ratio, used to traverse each operator graph in the operator graph group and sequentially take each operator graph in the operator graph group as the target operator graph;
[0090] Based on the allocable core resources, at least one sub-core resource corresponding to each target operator graph is determined, and the number of each sub-core resource is less than or equal to the number of core resources.
[0091] Based on the processing time, computing speed, data transfer power consumption, and computing power consumption of the core resources, the energy consumption ratio matched to each of the sub-core resources is calculated:
[0092] Obtain the sub-core resources that match the maximum energy consumption ratio corresponding to each target operator graph, and determine them as the target sub-core resources corresponding to each target operator graph.
[0093] Furthermore, the resource allocation device further includes: a resource allocation type determination module, used to determine, before obtaining the resource allocation type, if the on-chip storage is greater than or equal to the occupied space of the operator graph set, that the resource allocation type includes a high-performance type, an energy-saving type, or a balanced type, and the operator graph set includes one operator graph group; if the on-chip storage is less than the occupied space of the operator graph set, then the resource allocation type includes a high-performance type or a balanced type, and the operator graph set includes at least two operator graph groups.
[0094] Furthermore, the on-chip storage stores the operator graph set at the same time.
[0095] The image generation apparatus described above can execute any of the resource allocation methods provided in the embodiments of the present invention, and has the corresponding functional modules and beneficial effects of the executed image generation method.
[0096] Example 3
[0097] Figure 3 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 3 A block diagram of an exemplary computer device 12 suitable for implementing embodiments of the present invention is shown. Figure 3 The computer device 12 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0098] like Figure 3As shown, the computer device 12 is represented in the form of a general-purpose computing device. Components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting different system components (including system memory 28 and processing units 16). The computer device 12 may be a device connected to a bus.
[0099] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MCA) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0100] Computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0101] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 3 Not shown; commonly referred to as a "hard drive mechanic"). Although Figure 3Not shown, a disk drive may be provided for reading and writing to removable non-volatile disks (e.g., "floppy disks"), and an optical disc drive may be provided for reading and writing to removable non-volatile optical discs (e.g., compact disc read-only memory (CD-ROM), digital video disc read-only memory (DVD-ROM), or other optical media). In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0102] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0103] Computer device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with the computer device 12, and / or with any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, computer device 12 can also communicate with one or more networks (e.g., local area network (LAN) or wide area network (WAN)) via network adapter 20. As shown, network adapter 20 communicates with other modules of computer device 12 via bus 18. It should be understood that although... Figure 3 As not shown, other hardware and / or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device movers, redundant processing units, external disk RAID (Redundant Arrays of Inexpensive Disks) systems, tape movers, and data backup storage systems.
[0104] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing a resource allocation method provided in any embodiment of the present invention.
[0105] Example 4
[0106] Embodiment 4 of the present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the resource allocation method provided in all embodiments of the present application:
[0107] That is, when the program is executed by the processor, it performs the following: obtaining an operator graph group, the operator graph group including at least one operator graph of resources to be allocated; obtaining a resource allocation type, and determining a target core resource among the allocable core resources according to the resource allocation type; and allocating the target core resource to the operator graph group.
[0108] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, RAM, read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable CD-ROM, optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0109] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0110] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, radio frequency (RF), etc., or any suitable combination thereof.
[0111] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as "C" or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LANs or WANs—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0112] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A resource allocation method, characterized in that, Applied to a many-core system, the many-core system including allocable core resources, the method includes: Obtain an operator graph group, the operator graph group including at least one operator graph of the resource to be allocated; Obtain the resource allocation type, and determine the target core resource from the allocable core resources according to the resource allocation type; wherein, the resource allocation type of each operator graph in the operator graph group is the same, and the resource allocation type is used to characterize the resource allocation strategy of each operator graph in the operator graph group; Allocate the target core resources to the operator graph group; Before obtaining the resource allocation type, the following is also included: If the on-chip storage is greater than or equal to the space occupied by the operator graph set, then the resource allocation type is determined to include high-performance type, energy-saving type or balanced type, and the operator graph set includes an operator graph group. If the on-chip storage is smaller than the space occupied by the operator graph set, then the resource allocation type is determined to include high-performance type or balanced type, and the operator graph set includes at least two operator graph groups; The step of determining the target core resource from the allocable core resources according to the resource allocation type includes: Based on the resource allocation type, the target sub-core resources corresponding to each operator graph in the operator graph group are determined sequentially from the allocable core resources; the target core resources are determined based on the sum of the target sub-core resources. Wherein, when the resource allocation type is the high-performance type, the step of sequentially determining the target sub-core resources corresponding to each operator graph in the operator graph group from the allocable core resources includes: Traverse each operator graph in the operator graph group, and take each operator graph in the operator graph group as the target operator graph in turn. Determine the current remaining core resources based on the allocable core resources and the predetermined target sub-core resources. Based on the current remaining core resources and the preset minimum core resources, determine the range of core quantity and calculate the median of the core quantity range, where the current remaining core resources, the minimum core resources, and the median are all integers; The target operator graph is run using the current remaining core resources, the minimum core resources, and the median, respectively. The slowest processing quantity is removed, and the remaining two quantities are determined as the target quantity. Based on the two target quantities, the median and target quantities are redefined until there is no median within the range of the core quantities. The fastest processing quantity within the current core quantity range is then determined as the target sub-core resource that satisfies the condition of the fastest processing speed of the target operator graph.
2. The method according to claim 1, characterized in that, When the resource allocation type is the energy-saving type; The step of sequentially determining the target sub-core resources corresponding to each operator graph in the operator graph group from the allocable core resources includes: Traverse each operator graph in the operator graph group, and take each operator graph in the operator graph group as the target operator graph in turn; Calculate the minimum subcore resource corresponding to each of the target operator graphs; For each target operator graph, at least one resource is accumulated in the corresponding minimum sub-core resource to obtain at least one candidate sub-core resource. Then, the candidate sub-core resource that meets the condition of the fastest reduction in processing time is selected from each candidate sub-core resource and determined as the target sub-core resource corresponding to the target operator graph.
3. The method according to claim 2, characterized in that, The step of accumulating resources at least once in the corresponding minimum sub-core resources to obtain at least one candidate sub-core resource, and selecting the candidate sub-core resource that satisfies the condition of the fastest reduction in processing time from each of the candidate sub-core resources, includes: Accumulate unit resources in the minimum sub-core resources to obtain candidate sub-core resources, wherein the number of candidate sub-core resources is less than or equal to the number of allocable core resources; The target operator graph is run using the alternative sub-core resources and the minimum sub-core resources respectively, and the matching processing time is obtained. Calculate the difference between the processing time of matching the candidate sub-core resources and the processing time of matching the minimum sub-core resources, and determine it as the reduction value of the processing time of matching the candidate sub-core resources; Continue to accumulate the unit resource in the smallest sub-core resource, obtain the next candidate sub-core resource, and calculate the processing time reduction value matched by the next candidate sub-core resource, until the difference between the processing time reduction values matched by two adjacent candidate sub-core resources is less than a set threshold. Among the two adjacent candidate sub-core resources, the candidate sub-core resource with the larger number is determined as the candidate sub-core resource that satisfies the condition of the fastest reduction in processing time.
4. The method according to claim 1, characterized in that, When the resource allocation type is the balanced type, the step of sequentially determining the target sub-core resource corresponding to each operator graph in the operator graph group from the allocable core resources includes: Traverse each operator graph in the operator graph group, and take each operator graph in the operator graph group as the target operator graph in turn; Based on the allocable core resources, at least one sub-core resource corresponding to each target operator graph is determined, and the number of each sub-core resource is less than or equal to the number of allocable core resources. Based on the processing time of the core resources, the computing speed of the core resources, the power consumption of data transfer, and the power consumption of core resource computing, the energy consumption ratio matched by each of the sub-core resources is calculated respectively. Obtain the sub-core resources that match the maximum energy consumption ratio corresponding to each target operator graph, and determine them as the target sub-core resources corresponding to each target operator graph.
5. The method according to any one of claims 1-4, characterized in that, The operator graph set is stored on-chip at the same time.
6. A resource allocation device, characterized in that, Configured in a many-core system, the many-core system including allocable core resources, the device includes: The operator graph group acquisition module is used to acquire an operator graph group, wherein the operator graph group includes at least one operator graph of the resource to be allocated; The target core resource determination module is used to obtain the resource allocation type and determine the target core resource from the allocable core resources according to the resource allocation type; wherein, the resource allocation type of each operator graph in the operator graph group is the same, and the resource allocation type is used to characterize the resource allocation strategy of each operator graph in the operator graph group; A resource allocation module is used to allocate the target core resources to the operator graph group; Before obtaining the resource allocation type, the device is further configured to: If the on-chip storage is greater than or equal to the space occupied by the operator graph set, then the resource allocation type is determined to include high-performance type, energy-saving type or balanced type, and the operator graph set includes an operator graph group. If the on-chip storage is smaller than the space occupied by the operator graph set, then the resource allocation type is determined to include high-performance type or balanced type, and the operator graph set includes at least two operator graph groups; The step of determining the target core resource from the allocable core resources according to the resource allocation type includes: Based on the resource allocation type, the target sub-core resources corresponding to each operator graph in the operator graph group are determined sequentially from the allocable core resources; the target core resources are determined based on the sum of the target sub-core resources. Wherein, when the resource allocation type is the high-performance type, the step of sequentially determining the target sub-core resources corresponding to each operator graph in the operator graph group from the allocable core resources includes: Traverse each operator graph in the operator graph group, and take each operator graph in the operator graph group as the target operator graph in turn. Determine the current remaining core resources based on the allocable core resources and the predetermined target sub-core resources. Based on the current remaining core resources and the preset minimum core resources, determine the range of core quantity and calculate the median of the core quantity range, where the current remaining core resources, the minimum core resources, and the median are all integers; The target operator graph is run using the current remaining core resources, the minimum core resources, and the median, respectively. The slowest processing quantity is removed, and the remaining two quantities are determined as the target quantity. Based on the two target quantities, the median and target quantities are redefined until there is no median within the range of the core quantities. The fastest processing quantity within the current core quantity range is then determined as the target sub-core resource that satisfies the condition of the fastest processing speed of the target operator graph.
7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the resource allocation method as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the resource allocation method as described in any one of claims 1-5.
Citation Information
Patent Citations
Resource allocation method and device, computer equipment and storage medium
CN112068957A