Task allocation method and device, electronic equipment and computer readable storage medium
By dividing the execution process of the executing program and estimating task information, the task allocation in multi-core processors is optimized, and the peak power consumption problem of high-performance processor chips when performing intensive computing tasks is solved, achieving lower power consumption and higher system reliability and energy efficiency.
Patent Information
- Application Number
- CN202510057879.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-01-14
AI Technical Summary
High-performance processor chips experience peak power consumption problems when performing intensive computing tasks, resulting in difficulty in heat dissipation, voltage fluctuations, electromagnetic interference, and reliability risks.
By segmenting the execution process of the program to be executed, multiple time slices are obtained, each time slice includes at least one task, and the task information (such as start time, end time, and power consumption) of each task is estimated, and the task is allocated to the target processor core in the multi-core processor based on this information to optimize task scheduling.
It effectively reduces the peak power consumption of the chip during execution, reduces heat generation and interference to other circuits, and improves the reliability and energy efficiency of the system.
Smart Images

Figure CN120066706A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of integrated circuit technology, and in particular, to a task allocation method, a task allocation device, an electronic device, and a computer-readable storage medium. Background Art
[0002] A multi-core processor refers to a chip or multiple die integrated with two or more independent processing cores that can independently execute instructions and tasks, thereby improving the performance and efficiency of the system. Figure 1 And Figure 2 respectively show schematic diagrams of the architectures of a multi-core CPU (Central Processing Unit) and a multi-core AI (Artificial Intelligence) processor, Figure 3 showing a schematic diagram of the architecture of a multi-core AI processor implemented using multiple die.
[0003] By simultaneously executing multiple tasks, a multi-core processor can better meet the requirements of multi-threaded applications. This architecture allows different tasks to run simultaneously without interfering with each other, improving the overall performance of the computer, helping to improve the efficiency of multi-task processing, and providing better response times.
[0004] Power consumption optimization is an important aspect of multi-processor chip design. Common power consumption optimization strategies include dynamic voltage and frequency scaling, independent power domain management, parallel task scheduling management, etc. Among them, task scheduling optimization is one of the key optimization strategies. A multi-core processor can improve the energy efficiency ratio by processing tasks in parallel. By optimizing task scheduling, each core of the multi-core processor can work more efficiently, reducing idle time and thus lowering power consumption.
[0005] Power-aware compilation is a technology that realizes hardware power management through software-level improvements. It helps to reduce the energy consumption of the device, extend the service life of the device, and improve the overall energy efficiency without affecting the application performance. By analyzing the code, it identifies different execution methods during the compilation stage, reducing power consumption while maintaining high performance. It can provide effective guidance for multi-core task scheduling and software and hardware energy efficiency optimization by establishing an accurate power consumption estimation model. For example, by analyzing program execution and statistical events (such as the number of instructions, instruction jumps, cache access times, etc.), the power consumption can be estimated, the power consumption performance of different versions of the program can be evaluated, and the optimal version can be selected.
[0006] Peak power consumption is a major challenge in optimizing the power consumption of high-performance processor chips. Peak power consumption refers to the maximum power consumption that occurs in a short period of time. For high-performance computing chips, when the chip executes intensive computing tasks, it may briefly reach a very high power consumption level, which can lead to the following problems:
[0007] Difficult heat dissipation: A large amount of heat generated in a short period of time may cause the temperature to rise rapidly, putting great pressure on the cooling system. Excessive temperature will affect the chip's lifespan.
[0008] Voltage fluctuations: The current required by the chip increases sharply in a short period of time, resulting in an instantaneous large current, which may exceed the power supply's capacity range, causing the voltage to drop or become unstable, thus affecting the stable operation of the chip.
[0009] Electromagnetic interference: Large current changes will generate a strong electromagnetic field, which may interfere with the operation of other circuits.
[0010] Reliability risk: Frequent current spikes will put pressure on the power supply, which may damage the power supply and other related components. Summary of the Invention
[0011] In view of the above problems, embodiments of the present invention are proposed to provide a task allocation method, a task allocation device, an electronic device, and a computer-readable storage medium that overcome the above problems or at least partially solve the above problems.
[0012] Embodiments of the present invention disclose a task allocation method, which includes:
[0013] Segment the execution process of the program to be executed to obtain multiple time slices; each time slice includes at least one task;
[0014] Determine the task information of each task in each time slice;
[0015] Based on the task information, allocate each task in each time slice to the target processor core in the multi-core processor used to execute the program to be executed, to obtain a task allocation scheme corresponding to the program to be executed.
[0016] In one or more embodiments, segmenting the execution process of the program to be executed to obtain multiple time slices includes:
[0017] Segment the execution process of the program to be executed based on the integrity of the instructions in the program to be executed and a preset time period to obtain multiple time slices.
[0018] In one or more embodiments, determining the task information of each task in each time slice includes:
[0019] Estimate each task in each time slice to obtain the estimated task start time, the estimated task end time, and the estimated task power consumption corresponding to each task, and use the estimated task start time, the estimated task end time, and the estimated task power consumption as task information.
[0020] In one or more embodiments, in the multi-core processor for executing the program to be executed, based on the task information, each task in each time slice is assigned to a target processor core in the multi-core processor to obtain a task allocation scheme corresponding to the program to be executed, including:
[0021] S1. Sort the tasks in the current time slice based on the estimated task power consumption in the task information to obtain a task list;
[0022] S2. Assign a target processor core to each task based on the task information and the task list;
[0023] S3. Determine whether all tasks in the current time slice have been assigned. If so, execute S4; if not, execute S2;
[0024] S4. Determine whether there is an unassigned target time slice among multiple time slices. If so, execute S5; if not, obtain the task allocation scheme corresponding to the program to be executed;
[0025] S5. Obtain any one of the target time slices, use the target time slice as the current time slice, and execute S1.
[0026] In one or more embodiments, the assigning a target processor core to each task based on the task information and the task list includes:
[0027] Obtain any unassigned target task from the task list;
[0028] Determine whether there is at least one first candidate processor core to which a task has been assigned currently;
[0029] If there is at least one first candidate processor core, then determine whether there is at least one second candidate processor core among the first candidate processor cores; the time interval of the task assigned to the second candidate processor core does not overlap with the time interval of the target task, and the time interval is composed of the estimated task start time and the estimated task end time in the task information;
[0030] If there is at least one second candidate processor core, then determine whether there is a first target processor core among the second candidate processor cores; the current peak power consumption of the first target processor core is the minimum of the current peak power consumptions corresponding to the second candidate processor cores, and is greater than the estimated task power consumption of the target task;
[0031] If there is a first target processor core, allocate the target task to the first target processor core.
[0032] In one or more embodiments, it further includes:
[0033] If the first candidate processor core does not exist, use the first processor core in the multi-core processor as the second target processor core;
[0034] Allocate the target task to the second target processor core;
[0035] Set the task power consumption estimate of the target task to the current peak power consumption of the second target processor core.
[0036] In one or more embodiments, it further includes:
[0037] If the second candidate processor core does not exist, use any one of the remaining processor cores in the multi-core processor as the third target processor core; the remaining processor cores are the processor cores in the multi-core processor except for each first candidate processor core;
[0038] Allocate the target task to the third target processor core;
[0039] Set the task power consumption estimate of the target task to the current peak power consumption of the third target processor core.
[0040] In one or more embodiments, it further includes:
[0041] If the first target processor core does not exist, determine a fourth target processor core from each second candidate processor core; the current peak power consumption of the fourth target processor core is the maximum value among the current peak power consumptions corresponding to each second candidate processor core;
[0042] Allocate the target task to the fourth target processor core;
[0043] Set the task power consumption estimate of the target task to the current peak power consumption of the fourth target processor core.
[0044] Correspondingly, an embodiment of the present invention discloses a task allocation device, which is characterized in that the device includes:
[0045] A slicing module, configured to slice the execution process of the program to be executed to obtain multiple time slices; each time slice includes at least one task;
[0046] A determination module, configured to determine the task information of each task in each time slice;
[0047] A generation module, configured to allocate each task in each time slice to a target processor core in the multi-core processor for executing the to-be-executed program based on task information, so as to obtain a task allocation scheme corresponding to the to-be-executed program.
[0048] In one or more embodiments, the slicing module is specifically configured to:
[0049] Slice the execution process of the to-be-executed program based on the integrity of instructions in the to-be-executed program and a preset time period, so as to obtain a plurality of time slices.
[0050] In one or more embodiments, the determination module is specifically configured to:
[0051] Estimate each task in each time slice to obtain an estimated task start time, an estimated task end time, and an estimated task power consumption corresponding to each task, and use the estimated task start time, the estimated task end time, and the estimated task power consumption as task information.
[0052] In one or more embodiments, the generation module includes:
[0053] A sorting sub-module, configured to sort each task in the current time slice based on the estimated task power consumption in the task information to obtain a task list;
[0054] An allocation sub-module, configured to allocate a target processor core to each task based on the task information and the task list;
[0055] A first detection sub-module, configured to detect whether all tasks in the current time slice have been allocated. If so, call the second detection sub-module; if not, call the allocation sub-module;
[0056] A second detection sub-module, configured to detect whether there is an unallocated target time slice among the plurality of time slices. If so, call the acquisition sub-module; if not, obtain the task allocation scheme corresponding to the to-be-executed program;
[0057] An acquisition sub-module, configured to acquire any one of the target time slices, use the target time slice as the current time slice, and call the sorting sub-module.
[0058] In one or more embodiments, the allocation sub-module is specifically configured to:
[0059] Acquire any unallocated target task from the task list;
[0060] Determine whether there is at least one first candidate processor core to which a task has been currently allocated;
[0061] If there is at least one first candidate processor core, determine whether there is at least one second candidate processor core among the first candidate processor cores; the time interval of the tasks already assigned on the second candidate processor core does not overlap with the time interval of the target task, and the time interval consists of the task start time estimate and the task end time estimate in the task information;
[0062] If there is at least one second candidate processor core, determine whether there is a first target processor core among the second candidate processor cores; the current peak power consumption of the first target processor core is the minimum of the current peak power consumptions corresponding to the second candidate processor cores, and is greater than the task power consumption estimate of the target task;
[0063] If there is a first target processor core, allocate the target task to the first target processor core.
[0064] In one or more embodiments, the allocation sub-module is specifically further configured to:
[0065] If there is no first candidate processor core, use the first processor core in the multi-core processor as the second target processor core;
[0066] Allocate the target task to the second target processor core;
[0067] Set the task power consumption estimate of the target task to the current peak power consumption of the second target processor core.
[0068] In one or more embodiments, the allocation sub-module is specifically further configured to:
[0069] If there is no second candidate processor core, use any one of the remaining processor cores in the multi-core processor as the third target processor core; the remaining processor cores are the processor cores in the multi-core processor except for each first candidate processor core;
[0070] Allocate the target task to the third target processor core;
[0071] Set the task power consumption estimate of the target task to the current peak power consumption of the third target processor core.
[0072] In one or more embodiments, the allocation sub-module is specifically further configured to:
[0073] If there is no first target processor core, determine a fourth target processor core from among the second candidate processor cores; the current peak power consumption of the fourth target processor core is the maximum of the current peak power consumptions corresponding to the second candidate processor cores;
[0074] Allocate the target task to the fourth target processor core;
[0075] Set the task power consumption estimate of the target task to the current peak power consumption of the fourth target processor core.
[0076] Correspondingly, an embodiment of the present invention discloses an electronic device, including: a processor, a memory, and a computer program stored on the memory and capable of running on the processor. When the computer program is executed by the processor, each step of the embodiment of the above task allocation method is implemented.
[0077] Correspondingly, an embodiment of the present invention discloses a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, each step of the embodiment of the above task allocation method is implemented.
[0078] The embodiments of the present invention have the following advantages:
[0079] For the program to be executed, its execution process can be segmented to obtain multiple time slices; each time slice includes at least one task. Then, determine the task information of each task in each time slice, and then, from the multi-core processor used to execute the program to be executed, based on the task information, allocate each task in each time slice to the target processor core in the multi-core processor to obtain the task allocation scheme corresponding to the program to be executed. In this way, estimate the execution time information and power consumption of each task in the program to be executed, and match each task with each processor core in the multi-core processor based on the estimated values of the execution time information and power consumption, which can effectively reduce the peak power consumption of the chip during the execution process, not only reducing the heat generation and interference to other circuits, but also improving the reliability and energy efficiency of the system. Description of the Drawings
[0080] Figure 1 is a schematic diagram of the architecture of a multi-core CPU;
[0081] Figure 2 is a schematic diagram of the architecture of a multi-core AI processor;
[0082] Figure 3 is a schematic diagram of the architecture of a multi-core AI processor implemented using multi-die;
[0083] Figure 4 is a flowchart of the steps of an embodiment of the task allocation method of the present invention;
[0084] Figure 5 is a schematic diagram of the segmentation of the execution process of the program to be executed according to the present invention;
[0085] Figure 6It is a schematic flowchart of the task allocation scheme generation for any time slice according to the present invention;
[0086] Figure 7 It is a schematic diagram of the task start time estimation, task end time estimation, and task power consumption estimation of a task according to the present invention;
[0087] Figure 8 It is a schematic diagram of the architecture of the multi-core processor according to the present invention;
[0088] Figure 9 In (1) and (2), it shows a schematic diagram of the task allocation scheme that only satisfies the time relationship, and a schematic diagram of the task allocation scheme of the present invention respectively;
[0089] Figure 10 It is the ideal curve and actual curve of the peak power consumption of processor cores 0 and 1 of the present invention, and the ideal curve and actual curve of the peak power consumption of the system;
[0090] Figure 11 It is a structural block diagram of an embodiment of a task allocation device according to the present invention. Detailed Embodiment
[0091] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0092] One of the core concepts of the embodiments of the present invention is to estimate the execution time information and power consumption of each task in the program to be executed, and match each task with each processor core in the multi-core processor based on the estimated values of the execution time information and power consumption, which can effectively reduce the peak power consumption of the chip during the execution process, not only reducing the heat generation and interference to other circuits, but also improving the reliability and energy efficiency of the system.
[0093] Refer to Figure 4 , which shows a step flowchart of an embodiment of a task allocation method according to the present invention, and can be applied to a simulation device. The simulation device can simulate the execution process of the program to be executed, so as to allocate each task in the program to be executed to each processor core in the multi-core processor, thereby obtaining a corresponding allocation scheme. When the multi-core processor executes the program to be executed, it can call each processor core for processing according to the allocation scheme. The method can specifically include the following steps:
[0094] Step 401, divide the execution process of the program to be executed to obtain multiple time slices; each time slice includes at least one task.
[0095] Among them, the program to be executed is a program that requires a multi-core processor for processing. The simulation device can simulate the entire execution process of the program to be executed and divide the execution process to obtain multiple time slices as shown in Figure 5 shown.
[0096] Each time slice includes at least one task. Among them, a task is defined as an independent program segment and is the smallest allocation granularity. That is to say, it cannot be further divided into smaller granularities and allocated to processor cores. The smallest granularity that a processor core can process is a task. The same task is only executed on the same processor core, and different tasks can be allocated to different processor cores for parallel execution. If a processor core is allocated several different tasks, the different tasks are executed in sequence according to their start times.
[0097] In the embodiment of the present invention, the execution process of the program to be executed is divided to obtain multiple time slices, including:
[0098] Dividing the execution process of the program to be executed based on the integrity of instructions in the program to be executed and a preset time period to obtain multiple time slices.
[0099] Specifically, the duration of the time slice needs to be reasonably selected. If the time slice is too large, it is difficult to reflect the instantaneous peak power consumption; if the time slice is too small, the optimization space may be too small. Therefore, it needs to be reasonably selected in combination with the program characteristics and hardware configuration.
[0100] Since a task includes at least one instruction (an instruction is the smallest functional unit for a processor core to run and is related to the program characteristics), different instructions correspond to different estimated execution times (estimated values of instruction execution times). For example, the estimated execution times corresponding to an addition instruction and a matrix multiplication instruction are different. The execution time of a single instruction is in the order of ns to us (related to the hardware configuration). Moreover, the instructions included in a task need to be complete. That is to say, an instruction cannot be divided into two tasks. Therefore, the execution process of the program to be executed can be divided based on the integrity of instructions and a preset time period to obtain multiple time slices. Otherwise, if strictly divided according to equal time lengths, it is very easy to divide an instruction into two tasks.
[0101] Among them, the preset time period can be set according to empirical values, such as 100 us, 1 ms, etc. If divided according to 100 us, then after division, the duration of the time slice can be 100 us, 100.2 us, 99.8 us, etc., rather than being equally divided according to 100 us. Of course, in practical applications, the specific value of the preset time period can be set according to actual needs, and the embodiment of the present invention does not limit this.
[0102] Step 402: Determine the task information of each task in each time slice.
[0103] After splitting into multiple time slices, each task within each time slice can be estimated to determine the task information of each task, and the task information is stored.
[0104] In an embodiment of the present invention, the determining the task information of each task in each time slice includes:
[0105] Estimate each task in each time slice to obtain an estimated task start time, an estimated task end time, and an estimated task power consumption corresponding to each task, and use the estimated task start time, the estimated task end time, and the estimated task power consumption as task information.
[0106] Specifically, the task information may include an estimated task start time, an estimated task end time, and an estimated task power consumption. Of course, in addition to the above information, the task information may also include other information. In practical applications, the specific information included in the task information can be set according to actual needs, and the embodiments of the present invention do not limit this.
[0107] Furthermore, the estimation method may be to perform modeling and analysis based on the hardware configuration and the types of instructions included in the task. For example, if the hardware adder frequency is 1 GHz and an addition instruction needs to perform 1 addition operation once, then a simple instruction time estimate is 1 ns. In practical applications, the modeling is more complex. For example, in addition to considering the operation time of the above instructions, a series of complex factors such as data loading time, whether the loading time can be covered by the execution time of other instructions, and cache hit rate need to be considered, so as to model and calculate the execution time estimate of a set of instruction sequences. The more accurate the modeling, the better the estimation effect.
[0108] Step 403: Based on the task information, allocate each task in each time slice to a target processor core in the multi-core processor for executing the to-be-executed program, to obtain a task allocation scheme corresponding to the to-be-executed program.
[0109] After determining the task information of each task in each time slice, each task can be allocated to a corresponding processor core (denoted as "target processor core") in the multi-core processor according to the task information of each task. That is to say, each task has a one-to-one corresponding target processor core, so as to obtain a task allocation scheme corresponding to the to-be-executed program.
[0110] In an embodiment of the present invention, in the multi-core processor for executing the to-be-executed program, based on the task information, each task in each time slice is allocated to a target processor core in the multi-core processor, and a task allocation scheme corresponding to the to-be-executed program is obtained, including:
[0111] S1. Sort the tasks in the current time slice based on the task power consumption estimation in the task information to obtain a task list;
[0112] S2. Allocate a target processor core to each task based on the task information and the task list;
[0113] S3. Determine whether all tasks in the current time slice have been allocated. If so, execute S4; if not, execute S2;
[0114] S4. Determine whether there is an unallocated target time slice among multiple time slices. If so, execute S5; if not, obtain the task allocation scheme corresponding to the to-be-executed program;
[0115] S5. Obtain any one of the target time slices, use the target time slice as the current time slice, and execute S1.
[0116] Specifically, for any unallocated time slice (denoted as the "current time slice"), the tasks in the current time slice can be sorted according to the task power consumption estimation of the tasks to obtain a task list. Then, a corresponding target processor core is allocated to each task in the task list according to the task start time estimation, task end time estimation, and task power consumption estimation of each task.
[0117] After the allocation is completed, it can be detected whether all tasks in the current time slice have been completely allocated to avoid missing tasks. If all tasks in the current time slice have been allocated, then it can be further detected whether there is an unallocated time slice (denoted as the "target time slice") among all time slices. If there is, then any target time slice can be obtained, and the target time slice is used as the current time slice to repeat the execution of S1.
[0118] If there are still unallocated tasks in the current time slice, then S2 can be repeatedly executed to continue allocating target processor cores to the unallocated tasks.
[0119] If all time slices have been allocated, then the task allocation scheme corresponding to the to-be-executed task can be obtained.
[0120] In an embodiment of the present invention, the allocating a target processor core to each task based on the task information and the task list includes:
[0121] Obtain any unallocated target task from the task list;
[0122] Determine whether there is at least one first candidate processor core to which a task has been currently assigned;
[0123] If there is at least one first candidate processor core, determine whether there is at least one second candidate processor core among the first candidate processor cores; the time interval of the task assigned to the second candidate processor core does not overlap with the time interval of the target task, and the time interval is composed of the estimated task start time and the estimated task end time in the task information;
[0124] If there is at least one second candidate processor core, determine whether there is a first target processor core among the second candidate processor cores; the current peak power consumption of the first target processor core is the minimum of the current peak power consumptions corresponding to the second candidate processor cores, and is greater than the estimated task power consumption of the target task;
[0125] If there is a first target processor core, assign the target task to the first target processor core.
[0126] Specifically, when assigning a target processor core to each task in the current time slice, any unassigned task (denoted as "target task") can be obtained from the task list, and it is determined whether there is at least one processor core (denoted as "first candidate processor core") to which a task has been currently assigned.
[0127] If there is at least one first candidate processor core, it can be further determined whether there is at least one second candidate processor core among the first candidate processor cores. Among them, the time interval of the task assigned to the second candidate processor core does not overlap with the time interval of the target task, and the time interval is composed of the estimated task start time and the estimated task end time of the task. That is to say, when assigning tasks, it is ensured as much as possible that there is no time overlap between multiple tasks in a processor core.
[0128] If there is at least one second candidate processor core, it can be further determined whether there is a processor core (denoted as "first target processor core") that can process the target task among the second candidate processor cores. Among them, the peak power consumption of the first target processor core at the current moment (denoted as "current peak power consumption") is the minimum of the current peak power consumptions corresponding to the second candidate processor cores, and is greater than the estimated task power consumption of the target task.
[0129] If there is a first target processor core, the target task can be assigned to the first target processor core.
[0130] In an embodiment of the present invention, it further includes:
[0131] If the first candidate processor core does not exist, the first processor core in the multi-core processor is used as the second target processor core;
[0132] The target task is assigned to the second target processor core;
[0133] The task power consumption estimate of the target task is set to the current peak power consumption of the second target processor core.
[0134] Specifically, if the first candidate processor core does not exist, it means that each processor core in the multi-core processor has not been assigned a task. That is to say, each processor core is in an idle state. Therefore, the first processor core in the multi-core processor can be used as the processor core for processing the target task (denoted as the "second target processor core"), and the target task is assigned to the second target processor core. In addition, the task power consumption estimate of the target task is set to the current peak power consumption of the second target processor core.
[0135] In an embodiment of the present invention, it further includes:
[0136] If the second candidate processor core does not exist, any one of the remaining processor cores in the multi-core processor is used as the third target processor core; the remaining processor cores are the processor cores in the multi-core processor except for each first candidate processor core;
[0137] The target task is assigned to the third target processor core;
[0138] The task power consumption estimate of the target task is set to the current peak power consumption of the third target processor core.
[0139] Specifically, if the second candidate processor core does not exist, it means that the processor cores that have been assigned tasks cannot process the target task. Therefore, any one of the remaining processor cores in the multi-core processor can be used as the processor core for processing the target task (denoted as the "third target processor core"), and the target task is assigned to the third target processor core. In addition, the task power consumption estimate of the target task is set to the current peak power consumption of the third target processor core. Among them, the remaining processor cores are the processor cores in the multi-core processor except for each first candidate processor core. That is to say, an idle processor core is selected from the multi-core processor as the third target processor core.
[0140] In an embodiment of the present invention, it further includes:
[0141] If the first target processor core does not exist, a fourth target processor core is determined from each second candidate processor core; the current peak power consumption of the fourth target processor core is the maximum value among the current peak power consumptions corresponding to each second candidate processor core;
[0142] Allocate the target task to the fourth target processor core;
[0143] Set the task power consumption estimate of the target task to the current peak power consumption of the fourth target processor core.
[0144] Specifically, if there is no first target processor core, then a processor core that can handle the target task (denoted as the "fourth target processor core") can be determined from each of the second candidate processors, and the target task is allocated to the fourth target processor core, and the task power consumption estimate of the target task is set to the current peak power consumption of the fourth target processor core. Among them, the current peak power consumption of the fourth target processor core is the maximum value among the current peak power consumptions corresponding to each of the second candidate processor cores.
[0145] Refer to Figure 6 , which shows the complete process of generating a task allocation scheme for any time slice. Specifically:
[0146] S1. Sort each task in the current time slice based on the task power consumption estimate in the task information to obtain a task list.
[0147] S2. Obtain any unallocated target task from the task list.
[0148] S3. Determine whether there is at least one first candidate processor core that has been allocated tasks currently. If so, execute S4; if not, execute S7.
[0149] S4. Determine whether there is at least one second candidate processor core among each of the first candidate processor cores. If so, execute S5; if not, execute S10.
[0150] S5. Determine whether there is a first target processor core among each of the second candidate processor cores. If so, execute S6; if not, execute S13.
[0151] S6. Allocate the target task to the first target processor core and execute S16.
[0152] S7. Take the first processor core in the multi-core processor as the second target processor core.
[0153] S8. Allocate the target task to the second target processor core.
[0154] S9. Set the task power consumption estimate of the target task to the current peak power consumption of the second target processor core and execute S16.
[0155] S10. Take any one of the remaining processor cores in the multi-core processor as the third target processor core.
[0156] S11. Allocate the target task to the third target processor core.
[0157] S12. Set the task power consumption estimate of the target task to the current peak power consumption of the third target processor core, and execute S16.
[0158] S13. Determine the fourth target processor core from each of the second candidate processor cores.
[0159] S14. Allocate the target task to the fourth target processor core.
[0160] S15. Set the task power consumption estimate of the target task to the current peak power consumption of the fourth target processor core.
[0161] S16. Whether all tasks in the current time slice have been allocated. If so, obtain the task allocation scheme corresponding to the program to be executed; if not, execute S2.
[0162] Furthermore, in an embodiment of the present invention, a time slice including seven tasks is taken as an example, and the task start time estimate, task end time estimate, and task power consumption estimate are as Figure 7 shown. The multi-core processor includes 8 processor cores, as Figure 8 shown.
[0163] Figure 9 (1) and Figure 9 (2) respectively show the task allocation schemes that only satisfy the time relationship and the result comparison of the task allocation scheme of the embodiment of the present invention. For the former, a total of 4 processor cores are allocated tasks (the other four processor cores can be turned off or put into sleep). The sum of the peak power consumptions of each processor in this time slice is 14.0 watts (the tasks with the highest power consumption in each processor in this time slice are shown in bold). In contrast, the sum of the peak power consumption values of each processor in the task allocation scheme of the embodiment of the present invention is reduced to 12.5 watts in this time slice.
[0164] Furthermore, taking Figure 9 (2) Processor 0 and 1 as an example (for the convenience of understanding, assume that there are only these two processor cores in the processor). If looking at a single time slice (10 time units in the figure), the tasks with the highest power consumption in processor cores 0 and 1 do not occur at the same moment (the task with the highest power consumption in processor core 1 is task 1, and the time interval is 1 - 5; the task with the highest power consumption in processor core 0 is task 4, and the time interval is 5 - 7).
[0165] However, the time information for considering these tasks are all estimated values, and the actual hardware itself will also have time jitter for each execution of the same program segment due to various factors. It is possible that during the actual execution process, the time intervals of Task 4 and Task 1 actually overlap (for example, the actual execution time of Task 1 is 4 - 8). Then, within the overlapping time, in the worst-case scenario, that is, at this time, the dynamic peak power consumption of the processor system is the sum of the power consumptions of the two maximum power-consuming tasks of Processor 0 and 1 within this time slice (Task 1 power consumption + Task 4 power consumption), which will generate a power consumption impact of a spike for the entire system, as Figure 10 shown.
[0166] Since the power consumptions of each task within the same time slice are different, therefore, the figure shows the power consumption changes of Processor Cores 0 and 1 within this time slice. The solid-line curve is an ideal situation, that is, the maximum power-consuming tasks of the two processor cores do not have time overlap. Therefore, from the perspective of the overall power consumption, its peak power consumption presents a double-peak shape. However, due to the influence of the actual execution time jitter of the hardware, it is possible that in fact, the two maximum power-consuming tasks overlap within this time slice, that is, as shown by the dashed line. Then, the overall power consumption will present an instantaneous power consumption pulse spike, causing a greater impact on the system and even triggering system anomalies. The allocation scheme of the embodiments of the present invention essentially minimizes the peak value of the power consumption pulse in the worst-case scenario through a scheduling algorithm.
[0167] In the embodiments of the present invention, for the program to be executed, its execution process can be segmented to obtain multiple time slices; each time slice includes at least one task, then determine the task information of each task in each time slice, and then, from the multi-core processor used to execute the program to be executed, based on the task information, allocate each task in each time slice to the target processor core in the multi-core processor to obtain the task allocation scheme corresponding to the program to be executed. In this way, estimate the execution time information and power consumption of each task in the program to be executed, and match each task with each processor core in the multi-core processor based on the estimated values of the execution time information and power consumption, which can effectively reduce the peak power consumption of the chip during the execution process, not only reduce the heat generation and interference to other circuits, but also improve the reliability and energy efficiency of the system.
[0168] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequence, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.
[0169] Refer toFigure 11 , showing a structural block diagram of an embodiment of a task allocation device according to the present invention, which may specifically include the following modules:
[0170] The slicing module 1101 is configured to slice the execution process of the program to be executed to obtain a plurality of time slices; each time slice includes at least one task;
[0171] The determination module 1102 is configured to determine the task information of each task in each time slice;
[0172] The generation module 1103 is configured to allocate each task in each time slice to a target processor core in the multi-core processor for executing the program to be executed based on the task information, so as to obtain a task allocation scheme corresponding to the program to be executed.
[0173] In the embodiment of the present invention, the slicing module is specifically configured to:
[0174] Slice the execution process of the program to be executed based on the integrity of the instructions in the program to be executed and a preset time period to obtain a plurality of time slices.
[0175] In the embodiment of the present invention, the determination module is specifically configured to:
[0176] Estimate each task in each time slice to obtain an estimated task start time, an estimated task end time, and an estimated task power consumption corresponding to each task, and use the estimated task start time, the estimated task end time, and the estimated task power consumption as task information.
[0177] In the embodiment of the present invention, the generation module includes:
[0178] The sorting sub-module is configured to sort the tasks in the current time slice based on the estimated task power consumption in the task information to obtain a task list;
[0179] The allocation sub-module is configured to allocate target processor cores for each task based on the task information and the task list;
[0180] The first detection sub-module is configured to detect whether all tasks in the current time slice have been allocated. If so, call the second detection sub-module; if not, call the allocation sub-module;
[0181] The second detection sub-module is configured to detect whether there is an unallocated target time slice among the plurality of time slices. If so, call the acquisition sub-module; if not, obtain the task allocation scheme corresponding to the program to be executed;
[0182] The acquisition sub-module is configured to acquire any one of the target time slices, use the target time slice as the current time slice, and call the sorting sub-module.
[0183] In an embodiment of the present invention, the allocation sub-module is specifically configured to:
[0184] Obtain any unallocated target task from the task list;
[0185] Determine whether there is at least one first candidate processor core to which a task has been currently allocated;
[0186] If there is at least one first candidate processor core, determine whether there is at least one second candidate processor core among the first candidate processor cores; the time interval of the task allocated to the second candidate processor core does not overlap with the time interval of the target task, and the time interval is composed of the task start time estimate and the task end time estimate in the task information;
[0187] If there is at least one second candidate processor core, determine whether there is a first target processor core among the second candidate processor cores; the current peak power consumption of the first target processor core is the minimum of the current peak power consumptions corresponding to the second candidate processor cores, and is greater than the task power consumption estimate of the target task;
[0188] If there is a first target processor core, allocate the target task to the first target processor core.
[0189] In an embodiment of the present invention, the allocation sub-module is further specifically configured to:
[0190] If there is no first candidate processor core, use the first processor core in the multi-core processor as the second target processor core;
[0191] Allocate the target task to the second target processor core;
[0192] Set the task power consumption estimate of the target task to the current peak power consumption of the second target processor core.
[0193] In an embodiment of the present invention, the allocation sub-module is further specifically configured to:
[0194] If there is no second candidate processor core, use any one of the remaining processor cores in the multi-core processor as the third target processor core; the remaining processor cores are the processor cores in the multi-core processor except for the first candidate processor cores;
[0195] Allocate the target task to the third target processor core;
[0196] Set the task power consumption estimate of the target task to the current peak power consumption of the third target processor core.
[0197] In an embodiment of the present invention, the distribution sub-module is further specifically configured to:
[0198] If the first target processor core does not exist, determine a fourth target processor core from each of the second candidate processor cores; the current peak power consumption of the fourth target processor core is the maximum value among the current peak power consumptions corresponding to each of the second candidate processor cores;
[0199] Allocate the target task to the fourth target processor core;
[0200] Set the task power consumption estimate of the target task to the current peak power consumption of the fourth target processor core.
[0201] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For related parts, refer to the partial description of the method embodiment.
[0202] An embodiment of the present invention further provides an electronic device, including:
[0203] It includes a processor, a memory, and a computer program stored on the memory and capable of running on the processor. When the computer program is executed by the processor, it implements each process of the above task allocation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described in detail here.
[0204] An embodiment of the present invention further provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by the processor, it implements each process of the above task allocation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described in detail here.
[0205] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, refer to each other.
[0206] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, or a computer program product. Therefore, the embodiments of the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.
[0207] Embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate means for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or means for implementing the functions specified in multiple blocks.
[0208] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implement the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or means for implementing the functions specified in multiple blocks.
[0209] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or means for implementing the functions specified in multiple blocks.
[0210] Although the preferred embodiments of the embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed as including the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present invention.
[0211] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or terminal device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the element.
[0212] The above has introduced in detail a task allocation method and a task allocation device provided by the present invention. Specific examples are used in this text to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A task allocation method, characterized in that: The method comprises: The execution process of the program to be executed is divided into multiple time slices; each time slice includes at least one task; Determine the task information of each task in each time slice; From a multi-core processor for executing the program to be executed, each task in each time slice is allocated to a target processor core in the multi-core processor based on the task information, so as to obtain a task allocation scheme corresponding to the program to be executed.
2. The task allocation method according to claim 1, characterized in that: The execution process of the program to be executed is divided into multiple time slices, including: The execution process of the program to be executed is divided based on the completeness of the instructions in the program to be executed and a preset time period to obtain a plurality of time slices.
3. The task allocation method according to claim 1, characterized in that: The step of determining the task information of each task in each time slice includes: Each task in each time slice is estimated to obtain a task start time estimate, a task end time estimate and a task power consumption estimate corresponding to each task, and the task start time estimate, the task end time estimate and the task power consumption estimate are used as task information.
4. The task allocation method according to claim 1, characterized in that: The step of allocating each task in each time slice to a target processor core in the multi-core processor based on task information from a multi-core processor for executing the program to be executed, and obtaining a task allocation scheme corresponding to the program to be executed, includes: S1. Sort the tasks in the current time slice based on the task power consumption estimate in the task information to obtain a task list; S2, allocating a target processor core to each task based on the task information and the task list; S3: Are all tasks in the current time slice assigned? If yes, execute S4; if not, execute S2; S4: Whether there is an unallocated target time slice in the multiple time slices, if so, execute S5; if not, obtain the task allocation plan corresponding to the program to be executed; S5. Obtain any of the target time slices, take the target time slice as the current time slice, and execute S1.
5. The task allocation method according to claim 4, characterized in that: The allocating a target processor core to each task based on the task information and the task list includes: Obtain any unassigned target task from the task list; determining whether there is at least one first candidate processor core to which a task is currently assigned; If there is at least one first candidate processor core, determine whether there is at least one second candidate processor core among the first candidate processor cores; the time interval of the task assigned to the second candidate processor core does not overlap with the time interval of the target task, and the time interval is composed of the task start time estimate and the task end time estimate in the task information; If there is at least one second candidate processor core, determine whether there is a first target processor core among the second candidate processor cores; the current peak power consumption of the first target processor core is the minimum value of the current peak power consumption corresponding to the second candidate processor cores, and is greater than the task power consumption estimate of the target task; If the first target processor core exists, the target task is allocated to the first target processor core.
6. The task allocation method according to claim 5, characterized in that: Also includes: If the first candidate processor core does not exist, taking the first processor core in the multi-core processor as the second target processor core; Allocating the target task to the second target processor core; The task power consumption estimate of the target task is set to the current peak power consumption of the second target processor core.
7. The task allocation method according to claim 5, characterized in that: Also includes: If the second candidate processor core does not exist, taking any processor core among the remaining processor cores in the multi-core processor as a third target processor core; The remaining processor cores are processor cores in the multi-core processor except the first candidate processor cores; Allocating the target task to the third target processor core; The task power consumption estimate of the target task is set to the current peak power consumption of the third target processor core.
8. The task allocation method according to claim 5, characterized in that: Also includes: If the first target processor core does not exist, determining a fourth target processor core from each second candidate processor core; The current peak power consumption of the fourth target processor core is the maximum value of the current peak power consumptions corresponding to the second candidate processor cores; Allocating the target task to the fourth target processor core; The task power consumption estimate of the target task is set to the current peak power consumption of the fourth target processor core.
9. A task allocation device, characterized in that: The device comprises: A segmentation module is used to segment the execution process of the program to be executed into multiple time slices; each time slice includes at least one task; A determination module, used to determine the task information of each task in each time slice; A generation module is used to allocate each task in each time slice to a target processor core in a multi-core processor for executing the program to be executed based on task information, so as to obtain a task allocation scheme corresponding to the program to be executed.
10. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the task allocation method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the task allocation method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Optimizing boot-time peak power consumption for server / rack systems
CN105492997A
A Bandwidth Scheduling Method for Program Groups with Optimal Concurrency Performance
CN109144944A
Segmented multi-thread task execution method and device
CN109522128A
Multi-core processor and method for controlling the same
JP2010211544A
Computing device for handling tasks in a multi-core processor, and method for operating computing device
US20230418667A1
Cited By
Memory allocation method and device, computer equipment and storage medium
CN122044827A