Resource allocation method, electronic device and computer readable storage medium
By determining priority based on the resource requirements of the tasks to be executed in the electronic device, the problems of low resource utilization and low task execution efficiency in the prior art are solved, and more efficient resource allocation and task execution are achieved.
Patent Information
- Application Number
- CN202210267345.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-03-17
AI Technical Summary
In the prior art, electronic devices have low resource utilization in multitasking situations, and processor cores are not efficient when performing multitasking, especially when a certain processor core executes a pipeline that requires strong or weak resources, improper resource allocation leads to inefficiency.
By setting up a resource management unit in the electronic device, the resources required by each task to be executed are determined according to each task to be executed, and the resource allocation priority of the task to be executed is determined based on the resource requirements, and then resources are allocated for each task to be executed.
This method can prioritize resources according to the requirements of the pending tasks for resources, avoid resource waste, improve resource utilization, and improve the execution efficiency of the pending tasks.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to computer architecture technology, and more particularly to a resource allocation method, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the improvement of computer architecture and the rapid development of microprocessor technology, computer performance has also been greatly improved. Electronic devices based on microprocessor technology usually allocate resources within the electronic device based on the processor core, so that each processor core in the electronic device can process tasks according to the allocated resources. Therefore, how to improve the resource utilization rate within the electronic device and the efficiency of the processor core when performing multiple tasks in the case of multi-tasking is the goal that microprocessor technology has always pursued. Summary of the invention
[0003] To solve at least the above technical problems in the prior art, the embodiments of the present disclosure provide a resource allocation method, an electronic device, and a computer-readable storage medium.
[0004] The technical solution of the embodiment of the present disclosure is implemented as follows:
[0005] In a first aspect, an embodiment of the present disclosure provides a resource allocation method, the method comprising: a resource management unit within an electronic device determines, according to each task to be executed, the resources required for a pipeline corresponding to the task to be executed; the resource management unit determines, based on the resources required for the pipeline corresponding to the task to be executed, a resource allocation priority for the pipeline corresponding to the task to be executed; and resources are allocated to the pipeline corresponding to each task to be executed according to the resource allocation priority, the resources being used by a processor core within the electronic device to execute the task to be executed.
[0006] In some embodiments, the resource management unit determines the resource allocation priority of the tasks to be executed based on the resources required for the tasks to be executed, including: for the same type of resources, determining the resource allocation priority of allocating this type of resources to the tasks to be executed according to the number of resources required for each of the tasks to be executed.
[0007] In some embodiments, the resource allocation priority for allocating this type of resources to the tasks to be executed is determined based on the number of resources required for each of the tasks to be executed, including: determining that the resource allocation priority for allocating this type of resources to the tasks to be executed that require the largest number of resources is the highest; and determining that the resource allocation priority for allocating this type of resources to the tasks to be executed that require the smallest number of resources is the lowest.
[0008] In some optional embodiments, the resource management unit determines the resource allocation priority of the tasks to be executed based on the resources required for the tasks to be executed, including: for the same type of resources, according to the number of resources in the available resources of the electronic device that can meet the requirements of each task to be executed, determining the resource allocation priority of allocating this type of resources to the tasks to be executed.
[0009] In some optional embodiments, the resource allocation priority for allocating this type of resources to the tasks to be executed is determined based on the number of resources required by each task to be executed in the available resources of the electronic device, including: determining that among the available resources of the electronic device, the task to be executed that can meet the largest number of required resources has the lowest resource allocation priority; and determining that among the available resources of the electronic device, the task to be executed that can meet the smallest number of required resources has the highest priority.
[0010] In a second aspect, an embodiment of the present disclosure provides an electronic device, comprising: a resource management unit and a processor core; the resource management unit is configured to determine the resources required for each pipeline corresponding to each task to be executed according to each task to be executed, and determine the resource allocation priority of the pipeline corresponding to the task to be executed based on the resources required for the pipeline corresponding to the task to be executed, and allocate resources to the pipeline corresponding to each task to be executed according to the resource allocation priority; the processor core is configured to execute the task to be executed according to the resources.
[0011] In some optional embodiments, the resource management unit is further configured to determine, for resources of the same type, a resource allocation priority for allocating resources of this type to the tasks to be executed according to the quantity of resources required by each of the tasks to be executed.
[0012] In some optional embodiments, the resource management unit is also configured to determine that the resource allocation priority for allocating this type of resources to the task to be executed that requires the largest number of resources is the highest; and determine that the resource allocation priority for allocating this type of resources to the task to be executed that requires the smallest number of resources is the lowest.
[0013] In some optional embodiments, the resource management unit is further configured to determine, for the same type of resources, a resource allocation priority for allocating resources of this type to the tasks to be executed based on the number of resources in the available resources of the electronic device that can meet the requirements of each task to be executed.
[0014] In some optional embodiments, the resource management unit is also configured to determine that among the available resources of the electronic device, the task to be executed that can meet the required number of resources has the lowest resource allocation priority; and to determine that among the available resources of the electronic device, the task to be executed that can meet the required number of resources has the highest priority.
[0015] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: a processor, a memory and a bus; the memory stores executable instructions; the processor communicates with the memory via the bus, and when the processor executes the executable instructions stored in the memory, the above-mentioned resource allocation method is implemented.
[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium storing executable instructions for implementing the above-mentioned resource allocation method when executed by a processor.
[0017] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, wherein the computer program product includes a computer program / instructions, and the computer program / instructions implement a resource allocation method when executed by a processor.
[0018] The resource allocation method provided by the embodiment of the present disclosure includes: a resource management unit in an electronic device determines the resources required for each task to be executed according to each task to be executed; the resource management unit determines the resource allocation priority of the task to be executed based on the resources required for the task to be executed; and resources are allocated to each task to be executed according to the resource allocation priority, and the resources are used by the processor core in the electronic device to execute the task to be executed. In this way, when there are multiple tasks to be executed, resources can be allocated according to the priority of the resource requirements of the tasks to be processed, which can not only avoid resource waste and improve resource utilization, but also improve the execution efficiency of the tasks to be executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0020] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0021] Figure 1 It is a schematic diagram of the processing flow of instructions in the related art;
[0022] Figure 2 This is a schematic diagram of an optional processing flow of the resource allocation method provided in an embodiment of the present disclosure;
[0023] Figure 3 It is a schematic diagram of a resource management unit determining a resource allocation priority of a task to be executed based on resources required by the task to be executed, provided by an embodiment of the present disclosure;
[0024] Figure 4 It is a schematic diagram of another resource management unit provided by an embodiment of the present disclosure determining the resource allocation priority of a task to be executed based on the resources required by the task to be executed;
[0025] Figure 5 is a schematic diagram of resource division in an electronic device provided by an embodiment of the present disclosure;
[0026] Figure 6 is a schematic diagram of dividing a sub-resource pool provided by an embodiment of the present disclosure;
[0027] Figure 7 is a schematic diagram of another method of dividing a sub-resource pool provided by an embodiment of the present disclosure;
[0028] Figure 8 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure;
[0029] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] In order to make the objectives, technical solutions and advantages of the present disclosure clearer, the present disclosure will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0031] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0032] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0034] It should be understood that in the various embodiments of the present disclosure, the size of the serial number of each implementation process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0035] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations.
[0036] 1) Processor core: It is the core part of the processor and can also be called the processor core.
[0037] 2) Processor: includes one or more processor cores, as well as other components or devices such as memory.
[0038] 3) Pipeline: It is an implementation technology that overlaps the execution of multiple instructions. Each step in the pipeline completes part of the instruction. Each step is called a pipeline stage or pipeline segment. The pipeline stages are connected to form a pipeline. The instruction enters at one end of the pipeline, passes through these pipeline stages and exits at the other end of the pipeline. Each pipeline corresponds to a task.
[0039] The processing flow of instructions in a pipeline, such as Figure 1 As shown in the figure, the life cycle of an instruction in a pipeline includes: instruction fetch, decoding, execution, memory access and write back. Among them, instruction fetch refers to the process of reading instructions from the memory. Instruction decoding refers to the process of translating the instructions fetched from the memory. After decoding, the operand register index required by the instruction is obtained, and the operand can be read from the general register file using this index. After instruction decoding, the type of calculation required is known, and the required operand has been read from the general register file, then the instruction execution (Instruction Execute) is performed. Instruction execution refers to the process of actually operating the instruction. For example, if the instruction is an addition instruction, the operand is added; if it is a subtraction instruction, the operand is subtracted. The most common component in the "execution" stage is ALU, which is the hardware functional unit for implementing specific operations. Memory access refers to the process of memory access instructions reading data from the memory or writing data into the memory. Write back refers to the process of writing the result of instruction execution back to the general register group. If it is a normal operation instruction, the result value comes from the result calculated in the "execution" stage; if it is a memory read instruction, the result comes from the data read from the memory in the "memory access" stage.
[0040] The resources allocated to the processor core refer to the resources used to execute each pipeline stage of the pipeline. For example, the resources allocated to the processor core may be branch prediction resources, instruction fetch resources, decoding resources, renaming resources, execution resources, etc., wherein the execution resources may include at least one or more of computing resources, register resources, and memory resources. Among them, the memory resources may include a cache and a memory, and the cache may include at least one or more of an L1 cache, an L2 cache, and an L3 cache. The memory may be any type of memory such as a flash memory. The decoding resources may include at least one decoder. The renaming resources may include at least one register.
[0041] In the related art, a computer device includes multiple processor cores, and the resources in the computer device are allocated based on the processor core; specifically, the resources corresponding to each processor core are allocated to each processor core; the resources between the processor cores are independent of each other, and processor core A cannot use the resources allocated to processor core B when executing a task; similarly, processor core B cannot use the resources allocated to processor core A when executing a task. The inventor found that when the resources in the computer device are allocated based on the processor core, there are at least the following problems: when the pipeline executed by a processor core requires stronger resources, the resources allocated to the processor core cannot meet the resource requirements of the pipeline, and the efficiency of executing the task is low; when the pipeline executed by a processor core requires weaker resources, some of the resources allocated to the processor core are idle and the resources cannot be effectively used.
[0042] In response to the problems of low resource utilization and low task execution efficiency in resource allocation in related technologies, the embodiments of the present disclosure provide a resource allocation method, an electronic device and a computer-readable storage medium, which can improve resource utilization and the execution efficiency of tasks to be processed.
[0043] An optional processing flow of the resource allocation method provided in the embodiment of the present disclosure is as follows: Figure 2 As shown, at least the following steps are included:
[0044] Step S101: The resource management unit in the electronic device determines the resources required by the pipeline corresponding to each task to be executed according to each task to be executed.
[0045] For example, a pending task may refer to a task to be executed by a processor core in an electronic device, and one pending task corresponds to one pipeline.
[0046] For example, the resources required for each task to be executed may refer to: the number of resources required for each pipeline stage or pipeline segment of each step when executing a pipeline of the task to be executed and completing the corresponding instructions.
[0047] For example, the resources include one or more of branch prediction resources, instruction fetch resources, decoding resources, renaming resources, or execution unit resources.
[0048] Step S102: The resource management unit determines the resource allocation priority of the pipeline corresponding to the task to be executed based on the resources required by the task to be executed.
[0049] In some embodiments, the resource management unit obtains resources in the resource pool and allocates the resources according to the resource allocation priority. The electronic device includes multiple types of resource pools, and each type of resource pool includes multiple sub-resource pools. The connection method of multiple types of resource pools and the division method of sub-resource pools are described below.
[0050] In some embodiments, for the same type of resources, the resource allocation priority of allocating the type of resources to the tasks to be executed is determined according to the number of resources required by each task to be executed. Among multiple tasks to be executed, each assembly line has different requirements for the same type of resources, so the resource allocation priority can be set according to the demand for resources.
[0051] For example, Figure 3 As shown, step S102 at least includes the following steps:
[0052] Step S102-a1: Determine that the resource allocation priority of allocating this type of resource to the to-be-executed task requiring the largest number of resources is the highest;
[0053] Step S102 - a2 : Determine that the resource allocation priority of allocating this type of resource to the to-be-executed task requiring the least number of resources is the lowest.
[0054] For example, there are two tasks to be executed, namely, a first task to be executed and a second task to be executed. When allocating resources, it is necessary to allocate resource priorities according to the number of resources required by the first task to be executed and the second task to be executed. For example, for the same type of resources, such as branch prediction resources, the number of resources required to execute the first task to be executed pipeline is greater than the number of resources required to execute the second task to be executed pipeline. In this case, the resource allocation priority is set as follows: the priority of the first task to be executed is greater than the priority of the second task to be executed.
[0055] By adopting the above resource allocation method, resources are allocated preferentially to pending tasks that require a large number of resources, which is conducive to full utilization of resources. That is, according to the resource allocation priority, tasks with lower priorities require fewer resources, while when the number of resources in the resource pool is fixed, there is a higher probability of matching fewer resources with pending tasks that require a small number of resources.
[0056] In some embodiments, for the same type of resources, the resource allocation priority of allocating the type of resources to the tasks to be performed is determined based on the number of resources that can be satisfied by the available resources of the electronic device that are required for each task to be performed. Among multiple tasks to be performed, the number of resources in each type of resource pool is fixed, so the resource allocation priority can be set based on the number of resources that can be satisfied by the available resources for each task to be performed.
[0057] For example, Figure 4 As shown, step S102 at least includes the following steps:
[0058] Step S102-b1: Determine among the available resources of the electronic device that the resource allocation priority of the task to be executed that can meet the largest number of required resources is the lowest;
[0059] Step S102-b2: Determine that among the available resources of the electronic device, the resource allocation priority of the task to be executed that can meet the minimum required resource quantity is the highest.
[0060] For example, when a large number of resources are available to meet the needs of the current task to be executed, it means that there are more sub-resource pools that can meet the needs of the current task to be executed, and when a small number of resources are available to meet the needs of the current task to be executed, it means that there are fewer sub-resource pools that can meet the needs of the current task to be executed. The resource allocation priority can be set according to such situations, that is, the smaller the number of resources available to meet the needs, the higher the resource allocation priority, and vice versa.
[0061] For example, there are two tasks to be executed, namely, a first task to be executed and a second task to be executed. For example, the first task to be executed and the second task to be executed require different quantities of a type of resources, such as branch prediction resources. For example, the quantity of a type of resources required to meet the needs of the first task to be executed is less than the quantity of a type of resources required to meet the needs of the second task to be executed, for example, the quantity of a type of resources required to meet the needs of the first task to be executed is 3, and the quantity of a type of resources required to meet the needs of the second task to be executed is 4. In this case, the resource allocation priority is set as follows: the priority of the first task to be executed is greater than the priority of the second task to be executed.
[0062] With the above resource allocation method, if the number of resources that meet the task to be executed is small, it means that the types of resources that are adapted to the task to be executed are even smaller. Therefore, in order to enable this type of task to be executed to obtain adapted resources, resource allocation needs to be prioritized, thereby making resource allocation more reasonable.
[0063] In some embodiments, for the same type of resources, the resource allocation priority of allocating this type of resources to the tasks to be executed is determined based on the number of resources required for each task to be executed and the number of resources available in the electronic device that can meet the requirements of each task to be executed.
[0064] For example, when allocating resources, the priority of the number of resources required for each task to be executed is higher than the priority of the number of resources in the available resources that can meet the needs of each task to be executed, or the priority of the number of resources required for each task to be executed is lower than the priority of the number of resources in the available resources that can meet the needs of each task to be executed.
[0065] Step S103: allocating resources to the pipeline corresponding to each task to be executed according to the resource allocation priority, and the resources are used by the processor core in the electronic device to execute the task to be executed.
[0066] In some embodiments, for each type of resource in the electronic device, the resource management unit divides each type of resource into at least one sub-resource pool, determines a resource in a sub-resource pool of each type of resource as a target resource, and obtains the corresponding target resource according to the resource allocation priority.
[0067] Taking the case where the resources in the electronic device are branch prediction resources, the resource management unit divides the branch prediction resources into one or more branch prediction sub-resource pools, and the size of the resources included in each branch prediction sub-resource pool is the same or different, wherein the size of the resource can be interpreted as: a large resource includes a large number of resource units, while a small resource includes a small number of resource units. According to the resource allocation priority, the resource management unit selects a branch prediction sub-resource pool that meets the requirements of the task to be processed from the multiple branch prediction sub-resource pools, and the resources in the selected branch prediction sub-resource pool are the target resources for performing branch prediction on the task to be processed.
[0068] The above only takes the branch prediction resource as an example to illustrate the process of determining the target resource for branch prediction. In specific implementation, the process of determining the target resource for fetching, decoding, renaming, computing, storing, accessing, etc. is the same as the process of determining the target resource for branch prediction, and the embodiments of the present disclosure will not be described in detail.
[0069] In some embodiments, the resource management unit may be a program installed on the electronic device; or, the resource management unit may be a hardware component within the electronic device; or, the resource management unit includes a program installed on the electronic device and a hardware component within the electronic device.
[0070] In some embodiments, if the resource management unit is a program installed on an electronic device, the resource allocation method provided in the embodiment of the present disclosure is implemented in the form of software; wherein the program installed on the electronic device can be an application installed on the electronic device, or it can be a small program loaded by the application installed on the electronic device.
[0071] In a specific implementation, the program installed on the electronic device determines the resources required for each task to be executed, and determines the resource allocation priority of the task to be executed based on the resources required for the task to be executed; according to the resource allocation priority, the program installed on the electronic device sends the target resources to the corresponding hardware component in the electronic device, and the hardware component executes the task to be processed based on the target resources.
[0072] In other embodiments, if the resource management unit is a hardware component in an electronic device, the resource allocation method provided by the embodiment of the present disclosure is implemented in a hardware manner.
[0073] In a specific implementation, the hardware components in the electronic device determine the resources required for each task to be executed according to each task to be executed, determine the resource allocation priority of the task to be executed based on the resources required for the task to be executed, and execute the task to be processed based on the allocated target resources.
[0074] In some embodiments, if the resource management unit includes a program installed on an electronic device and a hardware component within the electronic device, it indicates that the resource allocation method provided by the embodiment of the present disclosure is implemented in a combination of software and hardware.
[0075] In a specific implementation, the hardware component in the electronic device sends each task to be executed to a program installed on the electronic device; the program installed on the electronic device determines the resources required for each task to be executed according to each task to be executed, and determines the resource allocation priority of the task to be executed based on the resources required for the task to be executed, and sends the allocated target resources to the corresponding hardware component in the electronic device, and the hardware component executes the task to be processed based on the target resources.
[0076] Alternatively, in a specific implementation, the hardware component within the electronic device sends each task to be executed to a program installed on the electronic device; the program installed on the electronic device determines the resources required for each task to be executed according to each task to be executed, determines the resource allocation priority of the task to be executed based on the resources required for the task to be executed, and sends the resource allocation priority to the corresponding hardware component in the electronic device, which allocates target resources to the task to be processed based on the resource allocation priority and executes the task to be processed based on the target resources.
[0077] based on Figure 2 From the resource allocation method shown, it can be understood that the embodiment of the present disclosure divides each type of resource included in an electronic device into a resource pool, and allocates the resources required to execute the task to be processed from the resource pool according to the resource allocation priority of the task to be processed.
[0078] In a specific implementation, a schematic diagram of resource division in an electronic device is shown as follows: Figure 5As shown: the branch prediction resources included in the electronic device are divided into a branch prediction resource pool, the instruction fetch resources included in the electronic device are divided into an instruction fetch resource pool, the decoding resources included in the electronic device are divided into a decoding resource pool, the renaming resources included in the electronic device are divided into a renaming resource pool, and the execution resources included in the electronic device are divided into an execution resource pool; wherein the execution resources may include: one or more of register resources, memory resources, and computing resources. For example, the resource pools are connected through a connection network; wherein the connection network may be a hardware network based on switch control, or may be any other form of network, which is not limited in the embodiments of the present disclosure.
[0079] Figure 5 In the resource partitioning diagram shown, the resource management unit performs resource management on all resource pools; in specific implementation, the resource management unit may also include multiple resource management sub-units, and each resource management sub-unit performs resource management on different resource pools. For example, the resource management unit includes a branch prediction resource sub-management unit, an instruction fetch resource sub-management unit, a decoding resource sub-management unit, a renaming resource sub-management unit, and an execution resource sub-management unit; wherein the branch prediction resource sub-management unit is used to perform resource management on resources in the branch prediction resource pool, the instruction fetch resource sub-management unit is used to perform resource management on resources in the instruction fetch resource pool, the decoding resource sub-management unit is used to perform resource management on resources in the decoding resource pool, the renaming resource sub-management unit is used to perform resource management on resources in the renaming resource pool, and the execution resource sub-management unit is used to manage resources in the execution resource pool.
[0080] against Figure 5 As shown in the resource partitioning diagram, according to different resource allocation strategies, each resource pool can be divided into Figure 6 As shown in the figure, multiple sub-resource pools of the same size, and Figure 7 Multiple sub-resource pools of different sizes are shown; among them, sub-resource pools of the same size refer to resources of the same type, and the sizes of resources included in each sub-resource pool are the same; sub-resource pools of different sizes refer to resources of the same type, and the sizes of resources included in multiple sub-resource pools are partially or completely different.
[0081] The following are Figure 6 A schematic diagram of dividing sub-resource pools based on resource allocation strategy is shown, and Figure 7 Another schematic diagram of dividing sub-resource pools based on resource allocation strategy is shown for explanation.
[0082] against Figure 6, based on the resource allocation strategy, each resource pool is divided into sub-resource pools in the way of organizing the minimum resources. The resources included in each sub-resource pool are the minimum units of resources of this type; in this way, the maximum number of sub-resource pools can be divided for each resource pool to support the maximum number of processor cores to execute the maximum number of tasks in parallel. For example, the branch prediction resource pool, instruction fetch resource pool, decoding resource pool, renaming resource pool and execution resource pool are all divided according to the minimum unit of resources. The branch prediction resource pool is divided into eight branch prediction sub-resource pools, the instruction fetch resource pool is divided into eight instruction fetch resource sub-resource pools, the decoding resource pool is divided into eight decoding sub-resource pools, the renaming resource pool is divided into eight renaming sub-resource pools, and the execution resource pool is divided into eight execution sub-resource pools. Each sub-resource pool can be used by one processor core to execute tasks, Figure 6 The resources shown can support eight processor cores executing eight tasks in parallel.
[0083] When each resource pool is divided into sub-resource pools, the number of sub-resource pools obtained by dividing each resource pool may be different; for example, the branch prediction resource pool is divided into eight branch prediction sub-resource pools, the instruction fetch resource pool is divided into six instruction fetch resource sub-resource pools, the decoding resource pool is divided into seven decoding sub-resource pools, the renaming resource pool is divided into eight renaming sub-resource pools, and the execution resource pool is divided into six execution sub-resource pools. In this scenario, five processor cores can be supported to execute six tasks in parallel.
[0084] In the disclosed embodiment, each resource pool is divided into sub-resource pools in a manner of organizing minimum resources, so that the resources within the electronic device can support the maximum number of processor cores to execute tasks in parallel, thereby improving the task parallel processing capability and thereby improving the performance of the electronic device.
[0085] against Figure 7 , based on the resource allocation strategy, each resource pool is divided into sub-resource pools in an organizational manner of different sizes. For the same type of resources, the sizes of the resources included in multiple sub-resource pools are partially or completely different. In this way, for the sub-resource pools with many resources, the processor core is supported to execute tasks with strong resource requirements, thereby improving the processing efficiency and processing capacity of the tasks. For example, each resource pool in the branch prediction resource pool, instruction fetch resource pool, decoding resource pool, renaming resource pool and execution resource pool is divided into sub-resource pools in an organizational manner of different sizes; taking the branch prediction resource pool as an example, the branch prediction resource pool is divided into five branch prediction sub-resource pools, and the sizes of the five branch prediction sub-resource pools are partially different and the same; Figure 7The size of the first branch prediction sub-resource pool is larger than the size of the second branch prediction sub-resource pool, and the sizes of the third branch prediction sub-resource pool, the fourth branch prediction sub-resource pool, and the fifth branch prediction sub-resource pool are the same. The first branch prediction sub-resource pool is suitable for tasks with high demand for branch prediction resources; the third branch prediction sub-resource pool, the fourth branch prediction sub-resource pool, and the fifth branch prediction sub-resource pool are suitable for tasks with low demand for branch prediction resources; the second branch prediction sub-resource pool is suitable for tasks with moderate demand for branch prediction resources (the demand for branch prediction resources is between the highest and lowest). Among them, the size of the sub-resource pool refers to the number of resources included in the sub-resource pool.
[0086] For a task, you can select any required sub-resource pool from each resource pool based on the demand for each type of resource according to the task to be executed and the resource allocation priority of the task to be executed; for example, under the current priority conditions, a first branch prediction sub-resource pool, a second instruction fetch sub-resource pool, a second decoding sub-resource pool, a third renaming sub-resource pool and a first execution sub-resource pool are allocated to a task to be executed.
[0087] In the disclosed embodiment, if there are idle or surplus resources in a sub-resource pool allocated for a task to be executed, the idle or surplus resources can be set to a sleep mode so that the idle or surplus resources are not used to execute the task, thereby reducing power consumption. The idle or surplus resources can also be cleared from the sub-resource pool and divided into other sub-resource pools so that the idle or surplus resources can be fully utilized and the resource utilization rate can be improved.
[0088] In the disclosed embodiment, each resource pool is divided into sub-resource pools in an organizational manner of different sizes, so that the resource management unit can allocate the required resources to the task according to the task's demand for each type of resource; thereby avoiding the problem of resource waste or insufficient resources to support the processor core in executing tasks due to allocating fixed resources to each processor core in the related technology, thereby improving the efficiency of task execution and resource utilization, and thereby improving the performance of the electronic device.
[0089] In the disclosed embodiment, the resource management unit in the electronic device determines the resources required for each task to be executed according to each task to be executed; the resource management unit determines the resource allocation priority of the task to be executed based on the resources required for the task to be executed; and resources are allocated to each task to be executed according to the resource allocation priority, and the resources are used by the processor core in the electronic device to execute the task to be executed. In this way, when there are multiple tasks to be executed, resources can be allocated according to the priority of the resource requirements of the tasks to be processed, which can not only avoid resource waste and improve resource utilization, but also improve the execution efficiency of the tasks to be executed.
[0090] It should be noted that since the advent of the first general-purpose electronic computer, computer technology has achieved rapid development in the past few decades. The rapid development of computer technology has benefited from the improvement of computer architecture and the development of computer production technology. The contribution of computer production technology to the development of computer technology has been stable; however, as computer architecture has undergone decades of improvement, the room for improvement in computer architecture has become increasingly narrow. Therefore, any small improvement in computer architecture will have a significant impact on processor performance and the development of computer technology.
[0091] The present disclosure also provides an electronic device 800 for implementing the above Figures 2 to 7 The resource allocation method shown in FIG. 8 is a schematic diagram of the composition structure of the electronic device 800, as shown in FIG. Figure 8 As shown, the electronic device 800 at least includes: a resource management unit 801 and a processor core 802; wherein,
[0092] The resource management unit 801 is configured to determine the resources required for each task to be executed according to each task to be executed;
[0093] Determining a resource allocation priority of the tasks to be performed based on the resources required for the tasks to be performed, and allocating resources to each task to be performed according to the resource allocation priority;
[0094] The processor core 802 is configured to execute tasks to be performed according to resources.
[0095] In some embodiments, the resource management unit 801 is configured to determine, for resources of the same type, a resource allocation priority for allocating resources of this type to tasks to be executed according to the number of resources required by each task to be executed.
[0096] In some embodiments, the resource management unit 801 is configured to determine that the resource allocation priority for allocating the type of resources to the to-be-performed task requiring the largest number of resources is the highest; and
[0097] Determine that the resource allocation priority for the task to be executed that requires the least number of resources is the lowest.
[0098] In some embodiments, the resource management unit 801 is configured to determine, for resources of the same type, a resource allocation priority for allocating resources of this type to tasks to be executed based on the number of resources available in the electronic device that can meet the needs of each task to be executed.
[0099] In some embodiments, the resource management unit 801 is configured to determine that among the available resources of the electronic device, the resource allocation priority of the task to be executed that can meet the largest number of required resources is the lowest; and
[0100] It is determined that among the available resources of the electronic device, the task to be executed that can meet the minimum required resource quantity has the highest priority.
[0101] In some embodiments, the resource management unit 801 is a program installed on the electronic device; or, the resource management unit 801 is a hardware component in the electronic device.
[0102] In some embodiments, the resource management unit 801 includes a program installed on the electronic device and a hardware component within the electronic device.
[0103] In some embodiments, the hardware component determines the resources required for each task to be performed according to each task to be performed, and sends the resources required for each task to be performed to the program;
[0104] The program determines a resource allocation priority of the task to be executed based on the resources required by the task to be executed, and sends the resource allocation priority to the hardware component.
[0105] It should be noted that the description of the electronic device in the embodiment of the present disclosure is similar to the description of the resource allocation method embodiment described above, and has similar beneficial effects as the method embodiment, so it will not be repeated. Figures 2 to 7 The present invention should be understood by referring to the description of any one of the accompanying drawings.
[0106] Exemplary applications of the electronic device provided by the embodiments of the present disclosure are described below. The electronic device provided by the embodiments of the present disclosure may be implemented as an electronic device, and the electronic device may be a server or a terminal device.
[0107] The server may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal device and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present disclosure.
[0108] See also Fig. 9 , Fig. 9 is a schematic diagram of the structure of an electronic device 900 provided in an embodiment of the present disclosure, Fig. 9 The electronic device 900 shown includes: at least one processor 910, a memory 950 and a bus 940; the various components in the electronic device 900 are coupled together through the bus 940. It can be understood that the bus 940 is used to realize the connection and communication between these components. In addition to the data bus, the bus 940 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Fig. 9Various buses are labeled as bus 940.
[0109] Processor 910 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0110] The memory 950 stores executable instructions for implementing the resource allocation method provided in the embodiment of the present disclosure. The resource allocation method can be implemented by Figure 8 The resource management unit 801 in the electronic device shown is implemented; the memory 950 can be removable, non-removable or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drive, optical disk drive, etc. The memory 950 optionally includes one or more storage devices that are physically far away from the processor 910.
[0111] In some embodiments, memory 950 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof.
[0112] In some embodiments, the electronic device 900 may further include:
[0113] Operating system 951, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0114] The network communication module 952 is used to reach other computing devices via one or more (wired or wireless) network interfaces 920. Exemplary network interfaces 920 include: Bluetooth, Wireless Authentication (WiFi), and Universal Serial Bus (USB).
[0115] The present disclosure embodiment provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will be caused to execute the resource allocation method provided by the present disclosure embodiment, for example, Figures 2 to 7 The resource allocation method shown.
[0116] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0117] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0118] For example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0119] An embodiment of the present disclosure provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the resource allocation method of the present disclosure is implemented.
[0120] The above are only embodiments of the present disclosure and are not intended to limit the protection scope of the present disclosure. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present disclosure are included in the protection scope of the present disclosure.
Claims
1. A resource allocation method, characterized in that: The method comprises: The resource management unit in the electronic device determines the resources required by the pipeline corresponding to each task to be executed according to each task to be executed; The resource management unit determines the resource allocation priority of the pipeline corresponding to the task to be executed based on the resources required by the pipeline corresponding to the task to be executed; Allocate resources to the pipeline corresponding to each of the tasks to be executed according to the resource allocation priority, and the resources are used by the processor core in the electronic device to execute the tasks to be executed; The electronic device includes multiple types of resource pools, and each type of resource pool includes multiple sub-resource pools. The resource management unit obtains resources in the resource pool and allocates the resources according to the resource allocation priority.
2. The resource allocation method according to claim 1, characterized in that: The resource management unit determines the resource allocation priority of the task to be executed based on the resources required by the task to be executed, including: For resources of the same type, a resource allocation priority for allocating resources of this type to the tasks to be executed is determined according to the quantity of resources required by each of the tasks to be executed.
3. The resource allocation method according to claim 2, characterized in that: The determining, according to the quantity of resources required by each of the tasks to be executed, a resource allocation priority for allocating the type of resources to the tasks to be executed, comprises: Determine that the resource allocation priority for the task to be executed that requires the largest number of resources is the highest for the type of resource; Determine that the resource allocation priority for the task to be executed that requires the least number of resources is the lowest.
4. The resource allocation method according to claim 1, characterized in that: The resource management unit determines the resource allocation priority of the task to be executed based on the resources required by the task to be executed, including: For resources of the same type, the resource allocation priority of allocating resources of this type to the tasks to be executed is determined according to the number of resources required by each of the tasks to be executed that can be satisfied in the available resources of the electronic device.
5. The resource allocation method according to claim 4, characterized in that: The determining, according to the number of resources in the available resources of the electronic device that can satisfy the needs of each of the tasks to be performed, the resource allocation priority of allocating the type of resources to the tasks to be performed, comprises: Determine that among the available resources of the electronic device, the resource allocation priority of the to-be-performed task that can meet the largest number of required resources is the lowest; It is determined that among the available resources of the electronic device, the resource allocation priority of the task to be executed that can meet the minimum required resource quantity is the highest.
6. An electronic device, characterized in that: The electronic device comprises: a resource management unit and a processor core; The resource management unit is configured to determine the resources required by the pipeline corresponding to each task to be executed according to each task to be executed, determine the resource allocation priority of the pipeline corresponding to the task to be executed based on the resources required by the pipeline corresponding to the task to be executed, and allocate resources to the pipeline corresponding to each task to be executed according to the resource allocation priority; The processor core is configured to execute the task to be executed according to the resource; The electronic device includes multiple types of resource pools, and each type of resource pool includes multiple sub-resource pools. The resource management unit obtains resources in the resource pool and allocates the resources according to the resource allocation priority.
7. The electronic device according to claim 6, characterized in that: The resource management unit is further configured to determine, for resources of the same type, a resource allocation priority for allocating resources of this type to the tasks to be executed according to the quantity of resources required by each of the tasks to be executed.
8. The electronic device according to claim 7, characterized in that: The resource management unit is further configured to determine that the resource allocation priority of allocating the type of resources to the to-be-executed task requiring the largest number of resources is the highest; and Determine that the resource allocation priority for the task to be executed that requires the least number of resources is the lowest.
9. The electronic device according to claim 6, characterized in that: The resource management unit is further configured to determine, for resources of the same type, a resource allocation priority for allocating resources of this type to the tasks to be executed according to the number of resources in the available resources of the electronic device that can meet the needs of each task to be executed.
10. The electronic device according to claim 9, characterized in that: The resource management unit is further configured to determine that among the available resources of the electronic device, the resource allocation priority of the to-be-performed task that can meet the largest number of required resources is the lowest; as well as It is determined that among the available resources of the electronic device, the task to be executed that can meet the minimum required resource quantity has the highest priority.
11. An electronic device, characterized in that: The electronic device comprises: processor, memory, and bus; The memory stores executable instructions; The processor communicates with the memory via the bus, and when the processor executes the executable instructions stored in the memory, the resource allocation method according to any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium, characterized in that: Executable instructions are stored, and when executed by a processor, the resource allocation method according to any one of claims 1 to 5 is implemented.
13. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the resource allocation method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Resource allocation method and device, chip and computer readable storage medium
CN111176852A
Apparatus, method, and system for ensuring quality of service for multi-threading processor cores
CN111752615A
Resource allocation method and device, computer device and storage medium
CN112698943A