Task allocation method, system, device and storage medium for heterogeneous multi-core processor
By generating and optimizing the task allocation scheme for heterogeneous multi-core processors, the problem of low task allocation efficiency of heterogeneous multi-core processors is solved, task immediacy and core load balancing are achieved, and the problem of too long optimization time is avoided.
Patent Information
- Application Number
- CN202311021180.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-14
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-08-14
AI Technical Summary
How to improve the task allocation efficiency of heterogeneous multi-core processors and cope with the gradually increasing number of tasks and computing requirements. It is difficult to effectively improve work efficiency with existing technology.
By obtaining multiple sets of initial solutions, apply optimization algorithms to generate mutation solutions, calculate fitness scores, select target solutions to optimize task allocation, exchange tasks to balance core load, and set termination conditions to prevent optimization from taking too long.
It improves the work efficiency of heterogeneous multi-core processors, ensures task immediacy, reduces the amount of optimization calculations, achieves balanced utilization of core loads, and prevents task immediacy problems caused by too long optimization time.
Smart Images

Figure CN117032969B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of multi-core processors, and in particular to a method, system, device and storage medium for allocating tasks to a heterogeneous multi-core processor. Background Art
[0002] A heterogeneous multi-core processor is a processor that integrates different types of cores on the same chip. These different types of cores can have different architectures, instruction sets, and power consumption characteristics to better meet different computing needs. For a multi-core processor, multiple tasks need to be assigned to multiple cores according to a certain strategy for separate scheduling. This process is called task allocation.
[0003] With the development of computer systems, the tasks that multi-core processors have to handle have increased in magnitude, which is reflected in the change of the cores of heterogeneous multi-core processors from dual cores to quad cores, octa cores, and even more cores. In order to respond to the increasing number of tasks, how to improve the task allocation quality of heterogeneous multi-core processors and thus improve the work efficiency of multi-core processors has always been a key issue that needs to be focused on. Summary of the invention
[0004] The present application provides a method, system, device and storage medium for allocating tasks for a heterogeneous multi-core processor, which has the characteristics of improving the working efficiency of the heterogeneous multi-core processor.
[0005] The first purpose of this application is to provide a task allocation method for a heterogeneous multi-core processor.
[0006] The above-mentioned application objective 1 of the present application is achieved through the following technical solutions:
[0007] A task allocation method for a heterogeneous multi-core processor, comprising:
[0008] Acquire multiple groups of initial solutions generated according to the multiple tasks to be assigned, each group of the initial solutions comprising an assignment result of assigning the multiple tasks to be assigned to multiple cores in a heterogeneous multi-core processor;
[0009] Obtaining a variation solution for at least one of the multiple groups of initial solutions by using an optimization algorithm, wherein the variation solution includes a result of allocating the multiple tasks to be allocated to multiple cores in a heterogeneous multi-core processor;
[0010] Calculating the fitness score of the variation solution;
[0011] A target solution is determined according to the fitness score of the variant solution and the fitness score of the initial solution, wherein the target solution is a group of solutions in the variant solution or the initial solution.
[0012] By adopting the above technical solution, after obtaining multiple tasks to be assigned, multiple pre-allocation schemes are formed according to the multiple tasks to be assigned, each pre-allocation scheme corresponds to a group of initial solutions, and then at least one group of initial solutions is optimized to obtain variant solutions. Then, the fitness score of the variant solution is calculated, and then a group of solutions is determined from the variant solution and the initial solution as the target solution based on the fitness score of the variant solution and the fitness score of the initial solution. It can be seen that the present application selects an allocation scheme from multiple allocation schemes, and then schedules multiple tasks to be assigned to multiple cores in a heterogeneous multi-core processor in sequence according to the selected allocation scheme, so that multiple tasks can be processed by different cores in a timely manner, thereby improving the work efficiency of the heterogeneous multi-core processor.
[0013] In a preferred example, the present application may be further configured as follows: obtaining a variant solution for at least one of the multiple groups of initial solutions through an optimization algorithm includes:
[0014] Calculating the fitness score of the initial solution;
[0015] Arrange multiple initial solutions in descending order of fitness scores, and select a preset number of initial solutions arranged in front as test solutions;
[0016] The optimization algorithm is used to optimize the test solution to obtain the variation solution.
[0017] By adopting the above technical solution, since the present application only optimizes part of the initial solution, it can not only improve the efficiency of optimization but also reduce the amount of calculation of the present application.
[0018] In a preferred example, the present application may be further configured as follows: the optimization algorithm is used to optimize the test solution to obtain the variant solution, including:
[0019] The number of the test solutions is one or more groups, and the method for optimizing any group of test solutions to obtain a group of variant solutions includes: calculating the total execution time of tasks on each core in a group of test solutions, the total execution time of tasks on any core being the sum of the execution time of each task on the core;
[0020] The kernel with the longest total execution time of the task is selected as the first kernel;
[0021] The core with the shortest total execution time of the task is selected as the second core;
[0022] A set of variant solutions is obtained by exchanging at least one task on the first core and the second core.
[0023] By adopting the above technical scheme, for each group of test solutions, only at least one task on the first kernel and the second kernel in the group of test solutions is exchanged, and the first kernel and the second kernel are the two with the longest and shortest total execution time respectively in the group of test solutions. Therefore, exchanging the tasks on the first kernel and the second kernel can effectively change the fitness score of the group of variant solutions, thereby further improving the optimization efficiency.
[0024] In a preferred example, the present application may be further configured as follows: the exchanging of at least one task on the first core and the second core to obtain a set of variant solutions includes:
[0025] Determine a task with the longest execution time on the first core as the first task;
[0026] Determine a task with the shortest execution time on the second core as the second task;
[0027] A set of variant solutions is obtained by exchanging the first task on the first core and the second task on the second core.
[0028] By adopting the above technical scheme, for each group of test solutions, what is exchanged is the task with the longest execution time on the first core and the task with the shortest execution time on the second core. Then, the greater the difference in execution time between the first task and the second task, the greater the change in fitness score of the group of variant solutions after the exchange is completed; similarly, the smaller the difference in execution time between the first task and the second task, the smaller the change in fitness score of the group of variant solutions after the interaction is completed, thereby achieving the purpose of continuously optimizing the variant solutions towards the optimal solution, thereby ensuring that the obtained target solution is the best allocation solution.
[0029] In a preferred example, the present application may be further configured as follows: after calculating the fitness score of the variation solution, the method further includes:
[0030] Arrange the variant solutions and the initial solution in descending order of fitness scores, and determine whether they meet the following conditions: f = F and / or t = T and / or g = G; wherein f is the fitness score, F is the fitness score threshold; t is the real-time timing, and T is the real-time timing threshold; g refers to the number of times the target solution is determined from the variant solution after each iteration during which the test solution is iterated for g consecutive times, and G refers to the maximum number of times the target solution is determined from the variant solution after each iteration during which the test solution is allowed to be iterated for G consecutive times;
[0031] If so, determine the set of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution;
[0032] If not, a preset number of variant solutions and / or initial solutions ranked first are selected as test solutions, and the test solutions are optimized by an optimization algorithm to obtain variant solutions, and f+1 and g+1 are calculated;
[0033] Repeat the above method n times until f+n=S and / or t=T and / or g+n=G are satisfied, and then determine a group of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution.
[0034] By adopting the above technical solution, the present application sets three conditions for terminating the optimization of the variant solution and / or the initial solution. The first is that the fitness score reaches the fitness score threshold, the second is that the real-time timing reaches the real-time timing threshold, and the third is that the target solution obtained after the maximum number of continuous optimizations remains unchanged. After satisfying any one or more termination conditions, the solution with the largest current fitness score is selected as the target solution. On the one hand, the target solution obtained in this way is the current optimal solution. When multiple tasks to be assigned are sequentially scheduled to multiple cores in a heterogeneous multi-core processor according to the allocation scheme of the target solution, multiple cores can process multiple different tasks at the same time, thereby improving the work efficiency of the heterogeneous multi-core processor. On the other hand, it can also prevent the optimization time from being too long, which leads to the problem that the immediacy of the tasks to be assigned cannot be guaranteed.
[0035] In a preferred example, the present application may be further configured as follows: the obtaining of multiple groups of initial solutions generated according to the multiple tasks to be assigned includes:
[0036] Assigning the plurality of tasks to be assigned, which are arranged in ascending order of execution time, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions; and
[0037] Assigning the plurality of tasks to be assigned, which are arranged in descending order of execution time, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions; and
[0038] Assigning the plurality of tasks to be assigned, which are arranged in ascending order of deadline, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions; and
[0039] Assigning the plurality of tasks to be assigned, which are arranged in ascending order of relaxation, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions, wherein relaxation = operation cycle - execution time; and
[0040] Assigning the plurality of tasks to be assigned, which are arranged in descending order of load rate, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions, wherein the load rate = execution time / deadline; and
[0041] sequentially assigning the plurality of tasks to be assigned, which are arranged in ascending order of task numbers, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions, wherein the natural order refers to a time order in which the tasks to be assigned are generated; and
[0042] The plurality of tasks to be assigned, which are arranged in ascending order of task numbers, are randomly assigned to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions.
[0043] By adopting the above technical solution, multiple groups of initial solutions obtained according to the above factors can reduce the time to obtain the optimal solution, that is, it can save the method of traversing each way of forming the initial solution to ensure the immediacy of the requirements of the tasks to be assigned.
[0044] In a preferred example, the present application may be further configured as follows: the calculation of the fitness score of the variation solution includes: the number of the variation solutions is one group or multiple groups, and the method of calculating the fitness score of any group of variation solutions includes:
[0045] f=1 / (Max(|Ca j -Cv|)+1) or f=1 / (∑(Ca j -Cv) 2 +1);
[0046] Among them, Ca j refers to the total execution time of the task on the jth core, J means that there are J kernels in the variation solution, j≤J.
[0047] By adopting the above technical solution, the present application provides two methods for calculating the fitness score of the variant solution. In actual use, any one of the methods can be selected as needed to calculate the fitness score of the variant solution, thereby improving the practicality of the present application.
[0048] The second objective of this application is to provide a task allocation system for heterogeneous multi-core processors.
[0049] The second application objective of the present application is achieved through the following technical solutions:
[0050] A task allocation system for a heterogeneous multi-core processor, comprising:
[0051] A data acquisition module, used for acquiring multiple groups of initial solutions generated according to the multiple tasks to be assigned, each group of initial solutions comprising an allocation result of allocating the multiple tasks to be assigned to multiple cores in a heterogeneous multi-core processor;
[0052] A data processing module, configured to obtain a variant solution for at least one of the multiple sets of initial solutions by using an optimization algorithm, wherein the variant solution includes a result of allocating the multiple tasks to be allocated to multiple cores in a heterogeneous multi-core processor;
[0053] A data calculation module, used to calculate the fitness score of the variation solution;
[0054] A data determination module is used to determine a target solution according to the fitness score of the variant solution and the fitness score of the initial solution, wherein the target solution is a group of solutions in the variant solution or the initial solution.
[0055] The third purpose of this application is to provide a device.
[0056] The third application objective of this application is achieved through the following technical solutions:
[0057] A device includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the program, any of the above-mentioned task allocation methods for heterogeneous multi-core processors is implemented.
[0058] The fourth objective of this application is to provide a computer-readable storage medium capable of storing corresponding programs.
[0059] The fourth application objective of this application is achieved through the following technical solutions:
[0060] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements any of the above-mentioned task allocation methods for heterogeneous multi-core processors.
[0061] In summary, the present application includes at least one of the following beneficial technical effects:
[0062] 1. When establishing multiple sets of initial solutions, the application uses multiple sets of initial solutions formed based on multiple factors to reduce the time to obtain the optimal solution, that is, it can save the process of traversing each way of forming the initial solution to ensure the immediacy of the requirements of the task to be assigned;
[0063] 2. During the optimization process, for each group of test solutions, the task with the longest execution time on the first core and the task with the shortest execution time on the second core are exchanged. The larger the difference in execution time between the first task and the second task, the greater the change in fitness score of the group of variant solutions after the exchange is completed; similarly, the smaller the difference in execution time between the first task and the second task, the smaller the change in fitness score of the group of variant solutions after the interaction is completed, so as to achieve the purpose of continuously optimizing the variant solution in the direction of the optimal solution, thereby ensuring that the target solution obtained is the current optimal allocation scheme; 3. In addition, the present application sets three conditions for terminating the optimization of the variant solution and / or the initial solution. After satisfying any one or more termination conditions, the solution with the largest current fitness score is selected as the target solution. On the one hand, the target solution obtained by setting the termination optimization condition is the current optimal solution. When multiple tasks to be assigned are sequentially scheduled to multiple cores in the heterogeneous multi-core processor according to the allocation scheme of the target solution, multiple cores are made to process different tasks at the same time to improve the working efficiency of the heterogeneous multi-core processor. On the other hand, setting the termination conditions for the optimization can also prevent the optimization time from being too long, which would lead to the problem that the timeliness of the tasks to be assigned cannot be guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 A schematic diagram of an exemplary operating environment in which embodiments of the present application can be implemented is shown.
[0065] Figure 2 A flowchart of a method for allocating tasks for a heterogeneous multi-core processor according to an embodiment of the present application is shown.
[0066] Figure 3 A flow chart of a method for determining a target solution according to an embodiment of the method of the present application is shown.
[0067] Figure 4 An example diagram of a method for determining a target solution according to an embodiment of the method of the present application is shown.
[0068] Figure 5 A block diagram of a task allocation system for a heterogeneous multi-core processor according to an embodiment of the present application is shown.
[0069] Explanation of the accompanying drawings: 1. Data acquisition module; 2. Data processing module; 3. Data calculation module; 4. Data determination module. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0071] In addition, the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. At the same time, the character " / " in this article indicates that the previous and next associated objects are in a "division" calculation relationship. For example, A / B can represent A divided by B.
[0072] All terms (including technical terms or scientific terms) used in this application have the same meaning as those understood by ordinary technicians in the field to which this application belongs, unless otherwise specifically defined. It should also be understood that terms defined in general dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology, and should not be interpreted in an idealized or extremely formal sense, unless explicitly defined herein.
[0073] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0074] Figure 1 A schematic diagram of an exemplary operating environment in which an embodiment of the present application can be implemented is shown. The operating environment is a multi-core processor, and the multi-core processor used in this example is a heterogeneous multi-core processor. Specifically, the heterogeneous multi-core processor includes a task receiving layer and a task running layer, and a waiting queue and a ready queue are set in the task receiving layer. The task running layer is used to store multiple cores in the heterogeneous multi-core processor and can support multiple cores to execute different tasks.
[0075] The waiting queue has bridges for transmitting tasks between the ready queue and multiple cores respectively. The waiting queue receives periodically running tasks released by multiple cores through the bridges built between the multiple cores and the waiting queue. The waiting queue also transmits tasks to the ready queue through the bridge built between the ready queue and the waiting queue. Therefore, the waiting queue has the ability to receive tasks. In addition to tasks released by the core, the tasks received by the waiting queue also include tasks sent by external devices, such as mobile phones, tablets, computers and other electronic devices. In this application, the tasks received by the waiting queue are collectively referred to as tasks to be assigned, and in Figure 1The arrows in the figure indicate the moving direction of the task. After receiving the tasks to be assigned, the waiting queue transfers the tasks to be assigned to the ready queue through the bridge in the order of deadline.
[0076] The ready queue is configured with a task allocation method, and the ready queue distributes the tasks to be allocated to multiple cores evenly through the task allocation method to balance the load on each core, thereby achieving the purpose of effectively utilizing the resources of each core in the heterogeneous multi-core processor.
[0077] In a specific example, the tasks in the ready queue will go through three states, namely the initial state, the test state and the ready state. For example, when the task to be assigned just enters the ready queue, it is in the initial state because it has not been called and assigned. Before the task to be assigned is assigned to the kernel, the task to be assigned in the initial state is pre-assigned using the task assignment method, and the task to be assigned will be converted from the initial state to the test state. The task to be assigned in the test state will obtain multiple groups of pre-assignment schemes according to the set combination method, and select a distribution scheme that can best balance the load on the kernel from the multiple groups of distribution schemes. Then, the task to be assigned will be rearranged in the ready queue according to the selected distribution scheme, and the task to be assigned after the rearrangement will also be converted from the test state to the ready state. The task to be assigned in the ready state can enter the kernel in sequence according to the selected distribution scheme and be run by the corresponding kernel.
[0078] It should be noted that Figure 1 The operating environment shown is only illustrative and is not intended to limit the application or use of the embodiments of the present invention. For example, the operating environment may include multiple waiting queues, multiple ready queues, and multiple cores.
[0079] Figure 2 FIG. 1 is a flowchart of a task allocation method according to an embodiment of the present application. The method may be Figure 1 The ready queue in is executed, and the main process of this method is described as follows.
[0080] Step S100: Acquire multiple tasks to be assigned.
[0081] It can be seen from the operating environment embodiment that the sources of the tasks to be assigned include the input of the external device and the release of the kernel, and after the waiting queue receives the tasks to be assigned, the tasks to be assigned are transmitted to the ready queue through the bridge, that is, the ready queue receives the tasks to be assigned.
[0082] It should be noted that when the ready queue receives the task to be assigned, the ready queue will also generate a start timestamp and start timing, marking the time of the real-time timing as t.
[0083] Step S200: generating a plurality of groups of initial solutions according to a plurality of tasks to be assigned, each group of initial solutions comprising an assignment result of assigning the plurality of tasks to be assigned to a plurality of cores in a heterogeneous multi-core processor.
[0084] The task to be assigned has attributes such as task number, deadline, execution time, operation cycle and priority. Among them, the task number is assigned by the waiting queue, that is, in order to distinguish each task, when the waiting queue receives the task to be assigned, it generates a unique task number corresponding to the time sequence of receiving the task to be assigned, and establishes a binding relationship between the task number and the task to be assigned corresponding to the task number. The deadline, execution time and operation cycle are all configured when establishing the task to be assigned, so this application does not restrict the deadline, execution time and operation cycle. The priority can be set by the waiting queue according to the deadline or operation cycle of the task to be assigned, such as the closer the deadline, the higher the priority, or the shorter the operation cycle, the higher the priority, etc. It can also be a priority manually defined in advance by an external device before inputting the task.
[0085] In order to improve the allocation efficiency and ensure the real-time performance of the tasks to be allocated, the pre-allocation scheme of this application is to form multiple groups of initial solutions based on factors such as the execution time, deadline, slack, load rate, natural order, etc. of the tasks to be allocated. Specifically:
[0086] Arrange multiple tasks to be assigned in ascending order of execution time, take out the tasks to be assigned from the ready queue in sequence, and assign them to each core in sequence to form a set of initial solutions; and
[0087] Arrange multiple tasks to be assigned in descending order of execution time, take out the tasks to be assigned from the ready queue in sequence, and assign them to each core in sequence to form a set of initial solutions; and
[0088] Arrange multiple tasks to be assigned in ascending order of deadline, take out the tasks to be assigned from the ready queue in sequence, and assign them to each core in sequence to form a set of initial solutions; and
[0089] First, calculate the slack of the task to be assigned: slack = running cycle - execution time, then arrange multiple tasks to be assigned in ascending order of slack, and take the tasks to be assigned from the ready queue one by one, and assign them to each core one by one to form a set of initial solutions; and
[0090] First, calculate the load rate of the task to be assigned: load rate = execution time / operation cycle, then arrange multiple tasks to be assigned in ascending order according to the load rate, and take the tasks to be assigned from the ready queue in turn, and assign them to each core in turn to form a set of initial solutions; and
[0091] Arrange multiple tasks to be assigned in ascending order of task numbers, take out the tasks to be assigned from the ready queue in sequence, and assign them to each core in sequence to form a set of initial solutions; and
[0092] Arrange multiple tasks to be assigned in ascending order of task numbers, randomly take tasks to be assigned from the ready queue, and assign them to each core in turn to form a set of initial solutions; and
[0093] Arrange multiple tasks to be assigned in ascending order of task number, randomly take tasks to be assigned from the ready queue, and randomly assign them to each core to form a set of initial solutions.
[0094] By adopting the above factors to form eight groups of initial solutions, the time to obtain the optimal solution can be reduced, that is, it can save the method of traversing each way of forming the initial solution to ensure the immediacy of the requirements of the tasks to be assigned.
[0095] After obtaining eight groups of initial solutions, the present application also needs to evaluate the schedulability of each group of initial solutions, that is, to determine whether each task on each core of the heterogeneous multi-core processor is called and executed within the operating cycle. If any task is not called and executed within the operating cycle, the initial solution group to which the task belongs is not schedulable. To facilitate the explanation of the evaluation process, one of the eight groups of initial solutions is taken as an example below:
[0096] If there are two kernels in the first group of initial solutions, for the first kernel: first, sort the tasks assigned to the first kernel in ascending order according to the deadline, where the deadline refers to the period from start to end. Then, calculate Ki = Tsi / Di, where Tsi is the execution time of task i and Di is the deadline of task i. If the calculation shows that: ∑Ki>1, it means that the task on the first kernel has not been completed once within the operation cycle, which also means that the task on the first kernel is not schedulable, and the first group of initial solutions will also not be schedulable; otherwise, continue to determine whether the task on the second kernel is schedulable. Only when the tasks on both kernels are schedulable, the first group of initial solutions is schedulable.
[0097] It should be noted that, for a group of initial solutions that are not callable, the fitness score of the solution is set to 0 in this application.
[0098] Step S300: obtaining a variant solution for at least one of the multiple sets of initial solutions through an optimization algorithm, wherein the variant solution includes a result of allocating multiple tasks to be allocated to multiple cores in a heterogeneous multi-core processor.
[0099] First, calculate the fitness score of each group of initial solutions, except for the group of initial solutions that are not schedulable. For the sake of convenience, the following takes the calculation of the fitness score of one of the initial solutions in the group of schedulable initial solutions as an example: First, determine the J cores contained in the group of initial solutions and the m tasks assigned to each core. The m values of tasks assigned to different cores can be the same or different. Then, calculate the total execution time of the tasks on each core: Among them, Ca j Refers to the total execution time of the task on the jth core, and Ci is the execution time of the i-th task. Then calculate the average total execution time corresponding to the J cores contained in the initial solution: Among them, Cv refers to the average total execution time corresponding to J cores. Finally, the fitness score is calculated as follows: f = 1 / (Max(|Ca j -Cv|)+1) or f=1 / (∑(Ca j -Cv) 2 +1), the "1" in the fitness score is to prevent j -Cv|) or ∑(Ca j -Cv) 2 When it is 0, the f value is set to be unsolvable. It can be seen that the larger the fitness score, the more concentrated the distribution of the total execution time between multiple cores in the initial solution, so that multiple cores can call and execute multiple tasks with different priorities indiscriminately, so as to ensure that the same high service quality is provided to tasks with lower priorities as to tasks with higher priorities, thereby making full use of the core resources of heterogeneous multi-core processors.
[0100] It should be noted that, among the eight groups of initial solutions generated above, except for the initial solution group that is not schedulable, the remaining initial solution groups need to adopt the calculation process as mentioned above to calculate their corresponding fitness scores respectively. Since the process of calculating the fitness score of each group of initial solutions is the same as the above example, this application will no longer describe the process of calculating the fitness score of each group of initial solutions one by one.
[0101] After obtaining the fitness scores corresponding to the eight groups of initial solutions, multiple initial solutions are arranged in descending order of fitness scores, and at least one group of initial solutions is selected from the front to the back as test solutions according to the arrangement of the initial solutions. In a specific example, a preset number of initial solutions arranged in front are selected as test solutions. In other examples, initial solutions with fitness scores higher than preset scores can also be selected as test solutions. The preset number and the preset score are set in advance. This application uses a preset number to filter out test solutions from the initial solutions, so as to facilitate better management and control of the number of solutions to be optimized subsequently. Of course, which specific method to choose can be selected according to actual needs, and this application is not limited here.
[0102] After the test solution is obtained, for each group of test solutions: first determine the kernel with the longest total execution time of the tasks on the kernel as the first kernel, and also determine the kernel with the shortest total execution time of the tasks on the kernel as the second kernel, and then exchange at least one task on the first kernel and the second kernel to obtain a group of variant solutions. In a specific example, based on the determined first kernel, the task with the longest execution time is determined as the first task; and based on the determined second kernel, the task with the shortest execution time is determined as the second task, and then a group of variant solutions is obtained by exchanging the first task and the second task. In other examples, the total execution time of the tasks on each kernel in each group of test solutions can be calculated first, and then the difference in the total execution time in each group of test solutions is calculated, and the number of tasks exchanged between the first kernel and the second kernel in the group of test solutions is determined according to the calculated difference. For example, multiple levels of preset values can be set, and different levels of preset values correspond to different numbers of tasks exchanged. The larger the difference, the more tasks are exchanged, but it does not exceed the number of tasks in the first kernel or the second kernel with the smaller number of tasks. When the difference reaches a preset value on the corresponding level, the number of tasks set at the level is exchanged accordingly, thereby achieving the purpose of flexibly exchanging tasks on the first core and the second core. In practical applications, a switching method can be selected as needed, and this application does not limit this.
[0103] Step S400: Calculate the fitness score of the variant solution.
[0104] For the obtained variant solutions, the fitness score of each group of variant solutions needs to be calculated separately. Since the process of calculating the fitness score of the variant solution in this application is the same as that of calculating the fitness score of the initial solution, this application will not repeat the process of calculating the fitness score of the variant solution.
[0105] Step S500: determining a target solution according to the fitness score of the variant solution and the fitness score of the initial solution, where the target solution is a set of solutions in the variant solution or the initial solution.
[0106] Specifically, the process of determining the target solution is as follows: Figure 3 As shown:
[0107] Step S501: Obtain the fitness score of the variant solution and the fitness score of the initial solution.
[0108] In order to reduce the computational energy consumption of this application, the initial solutions of all groups are not obtained here, but the eight groups of initial solutions are arranged in descending order of fitness scores, and then at least one group of initial solutions or multiple groups of initial solutions are selected from the front to the back in the arrangement order, but not more than the number of test solution groups. In a specific example, the eight groups of initial solutions are arranged in descending order of fitness scores, and then three groups of initial solutions are selected from the front to the back in the arrangement order, and finally the fitness scores corresponding to the three selected groups of initial solutions are obtained.
[0109] Step S502: Arrange the variant solutions and the initial solution in descending order of fitness scores, and determine whether the following conditions are satisfied: f=F and / or t=T and / or g=G; wherein f is the fitness score, F is the fitness score threshold; t is the real-time timing, and T is the real-time timing threshold; g refers to the number of times the target solution is determined from the variant solution after each iteration during which the test solution is iterated for g consecutive times, and G refers to the maximum number of times the target solution is determined from the variant solution after each iteration during which the test solution is allowed to be iterated for G consecutive times.
[0110] Step S503: If yes, determine the set of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution;
[0111] Step S504: If not, select a preset number of variant solutions and / or initial solutions arranged in front as test solutions, use an optimization algorithm to optimize the test solutions to obtain variant solutions, calculate f+1, g+1, and return to step S501;
[0112] Step S505: loop step S501 to step S504 n times until the following conditions are met: f+n=S and / or t=T and / or g+n=G, then determine a group of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution.
[0113] To facilitate the description of the iterative process from step S501 to step S503, an example is given below:
[0114] If there are eight initial solutions (see Figure 4 The first row in the table): A, B, C, D, E, F, G, H;
[0115] If the preset number is set to 5, five test solutions are obtained (arranged in descending order of fitness scores, see Figure 4 : C, A, B, E, F;
[0116] The five test solutions are optimized to obtain the corresponding variant solutions (see Figure 4 The third line in ): First, select the first three solutions C, A, and B in the eight initial solutions arranged in descending order of fitness scores, and then get the initial solution and variant solution (see Figure 4 The fourth line in ): C, A, B; then arrange the variant solutions and the three selected initial solutions in descending order of fitness scores (see Figure 4 The fifth line in ): C. A, B, Determine whether the following conditions are met: f=F and / or t=T and / or g=G;
[0117] If so, output
[0118] If not, five new test solutions are obtained (arranged in descending order of fitness scores, see Figure 4 The sixth line in ): C. A, and calculate f+1, g+1; repeat the above steps n times until f+n=F and / or t=T and / or g+n=G, then select the solution with the largest fitness score among the solutions obtained after repeating the above steps n times as the target solution.
[0119] It can be seen that the present application selects an initial solution with a higher fitness score, optimizes the selected initial solution to obtain a variant solution, selects the initial solution and variant solution with a higher fitness score, and optimizes again. In the continuous optimization and iteration process, either the fitness score of the obtained solution becomes higher and higher, so that the total execution time distribution of the tasks on multiple cores in the solution becomes more and more concentrated, and finally the solution with the largest fitness score is selected as the target solution; or the obtained solution remains unchanged, but since the solution with the largest fitness score has been selected as the target solution from the initial solution and the variant solution, the selected target solution is also the optimal solution that can be selected at present, so that when the target solution is used as the final allocation scheme, the load of multiple cores in the heterogeneous multi-core processor can reach the best balance state that can be achieved at present, thereby ensuring that each core resource in the heterogeneous multi-core processor can be fully utilized.
[0120] Figure 5 A block diagram of a task allocation system for a heterogeneous multi-core processor according to an embodiment of the present application is shown. The system comprises a data acquisition module 1, a data processing module 2, a data calculation module 3 and a data determination module 4.
[0121] A data acquisition module 1 is used to acquire multiple groups of initial solutions generated according to multiple tasks to be assigned, each group of initial solutions includes an allocation result of allocating multiple tasks to be assigned to multiple cores in a heterogeneous multi-core processor;
[0122] A data processing module 2 is used to obtain a variation solution for at least one of the multiple sets of initial solutions by using an optimization algorithm, wherein the variation solution includes a distribution result of distributing multiple tasks to be distributed to multiple cores in a heterogeneous multi-core processor;
[0123] Data calculation module 3, used to calculate the fitness score of the variation solution;
[0124] The data determination module 4 is used to determine the target solution according to the fitness score of the variant solution and the fitness score of the initial solution. The target solution is a set of solutions in the variant solution or the initial solution.
[0125] Furthermore, the data acquisition module 1 can also be used to obtain the fitness score of the variation solution.
[0126] Furthermore, the data processing module 2 can also be used to arrange the variation solutions and the initial solutions in descending order of fitness scores.
[0127] The modules involved in the embodiments described in the present application may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a data acquisition module 1, a data processing module 2, a data calculation module 3 and a data determination module 4. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the data acquisition module 1 may also be described as "a module for obtaining multiple groups of initial solutions generated based on multiple tasks to be assigned".
[0128] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0129] In order to better execute the program of the above method, the present application also provides a device, which includes a memory and a processor.
[0130] The memory may be used to store instructions, programs, codes, code sets or instruction sets. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing the above-mentioned task allocation method for a heterogeneous multi-core processor, etc.; the data storage area may store data involved in the above-mentioned task allocation method for a heterogeneous multi-core processor, etc.
[0131] The processor may include one or more processing cores. The processor calls the data stored in the memory by running or executing the instructions, programs, code sets or instruction sets stored in the memory, performs various functions of the present application and processes data. The processor may be at least one of a special purpose integrated circuit, a digital signal processor, a digital signal processing device, a programmable logic device, a field programmable gate array, a central processing unit, a controller, a microcontroller and a microprocessor. It is understandable that for different devices, the electronic device used to implement the above-mentioned processor function can also be other, and the embodiments of the present application are not specifically limited.
[0132] The present application also provides a computer-readable storage medium, for example, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc., which can store program codes. The computer-readable storage medium stores a computer program that can be loaded by a processor and execute the task allocation method of the heterogeneous multi-core processor.
[0133] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
Claims
1. A task allocation method for a heterogeneous multi-core processor, characterized in that: include: Acquire multiple groups of initial solutions generated according to the multiple tasks to be assigned, each group of the initial solutions comprising an assignment result of assigning the multiple tasks to be assigned to multiple cores in a heterogeneous multi-core processor; Obtaining a variation solution for at least one of the multiple groups of initial solutions by using an optimization algorithm, wherein the variation solution includes a result of allocating the multiple tasks to be allocated to multiple cores in a heterogeneous multi-core processor; Calculating the fitness score of the variation solution, and after calculating the fitness score of the variation solution, further comprising: Arrange the variant solutions and the initial solution in descending order of fitness scores, and determine whether they satisfy: f=F and / or t=T and / or g=G; where f is the fitness score, F is the fitness score threshold; t is the real-time timing, and T is the real-time timing threshold; g refers to the number of times the target solution is determined from the variant solution after each iteration during the period of g consecutive iterations of the test solution, and G refers to the maximum number of times the target solution is determined from the variant solution after each iteration during the period of G consecutive iterations of the test solution; If so, determine the set of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution; If not, a preset number of variant solutions and / or initial solutions ranked first are selected as test solutions, and the test solutions are optimized by an optimization algorithm to obtain variant solutions, and f+1 and g+1 are calculated; Repeat the above method n times until f+n=S and / or t=T and / or g+n=G are satisfied, and determine the set of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution.
2. The task allocation method for a heterogeneous multi-core processor according to claim 1, characterized in that: The step of obtaining a variation solution of at least one of the multiple groups of initial solutions by using an optimization algorithm comprises: Calculating the fitness score of the initial solution; Arrange multiple initial solutions in descending order of fitness scores, and select a preset number of initial solutions arranged in front as test solutions; The optimization algorithm is used to optimize the test solution to obtain the variation solution.
3. The task allocation method for a heterogeneous multi-core processor according to claim 2, characterized in that: The method of using an optimization algorithm to optimize the test solution to obtain a variant solution includes: The number of the test solutions is one or more groups, and the method for optimizing any group of test solutions to obtain a group of variant solutions includes: calculating the total execution time of tasks on each core in a group of test solutions, the total execution time of tasks on any core being the sum of the execution time of each task on the core; The kernel with the longest total execution time of the task is selected as the first kernel; The core with the shortest total execution time of the task is selected as the second core; A set of variant solutions is obtained by exchanging at least one task on the first core and the second core.
4. The task allocation method for a heterogeneous multi-core processor according to claim 3, characterized in that: The exchanging of at least one task on the first core and the second core to obtain a set of variant solutions comprises: Determine a task with the longest execution time on the first core as the first task; Determine a task with the shortest execution time on the second core as the second task; A set of variant solutions is obtained by exchanging the first task on the first core and the second task on the second core.
5. The task allocation method for heterogeneous multi-core processors according to claim 1, characterized in that: The obtaining of multiple groups of initial solutions generated according to the multiple tasks to be assigned includes: Assigning the plurality of tasks to be assigned, which are arranged in ascending order of execution time, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions; and Assigning the plurality of tasks to be assigned, which are arranged in descending order of execution time, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions; and Assigning the plurality of tasks to be assigned, which are arranged in ascending order of deadline, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions; and Assigning the plurality of tasks to be assigned, which are arranged in ascending order of relaxation, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions, wherein relaxation=operation cycle-execution duration; and Assigning the plurality of tasks to be assigned, which are arranged in descending order of load rate, to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions, wherein the load rate = execution time / deadline; and sequentially assigning the plurality of tasks to be assigned, which are arranged in ascending order of task numbers, to a plurality of cores in the heterogeneous multi-core processor to obtain a set of initial solutions, wherein the task numbers refer to the time sequence in which the tasks to be assigned are received; and The plurality of tasks to be assigned, which are arranged in ascending order of task numbers, are randomly assigned to a plurality of cores in a heterogeneous multi-core processor to obtain a set of initial solutions.
6. The task allocation method for heterogeneous multi-core processors according to claim 1, characterized in that: The step of calculating the fitness score of the variation solution includes: The number of the variation solutions is one or more groups, and the method for calculating the fitness score of any group of variation solutions includes: f=1 / (Max(|Ca j -Cv|)+1) or f=1 / (∑(Ca j -Cv) 2 +1); Among them, Ca j refers to the total execution time of the task on the jth core, , J means there are J kernels in the variation solution, j≤J.
7. A task allocation system for heterogeneous multi-core processors, characterized in that: include: A data acquisition module (1) is used to acquire multiple groups of initial solutions generated according to multiple tasks to be assigned, each group of the initial solutions comprising the results of assigning the multiple tasks to be assigned to multiple cores in a heterogeneous multi-core processor; A data processing module (2) is used to obtain a variant solution for at least one of the multiple sets of initial solutions by using an optimization algorithm, wherein the variant solution includes a distribution result of distributing the multiple tasks to be distributed to multiple cores in a heterogeneous multi-core processor; A data calculation module (3) is used to calculate the fitness score of the variant solution, and after calculating the fitness score of the variant solution, further comprising: arranging the variant solution and the initial solution in descending order of the fitness score, and judging whether the following conditions are satisfied: f=F and / or t=T and / or g=G; wherein f is the fitness score, F is the fitness score threshold; t is the real-time timing, and T is the real-time timing threshold; g refers to the number of times during which the test solution is iterated g times continuously, when the target solution is determined from the variant solution after each iteration, the target solution is the same; G refers to the maximum number of times during which the test solution is iterated G times continuously, when the target solution is determined from the variant solution after each iteration, the target solution is the same; if yes, determining a group of solutions with the largest fitness score among the variant solution and the initial solution as the target solution; if no, selecting a preset number of variant solutions and / or the initial solution ranked first as the test solution, optimizing the test solution using an optimization algorithm to obtain the variant solution, and calculating f+1, g+1; Repeat the above method n times until f+n=S and / or t=T and / or g+n=G are satisfied; The data determination module (4) is used to determine a group of solutions with the largest fitness score among the variant solutions and the initial solutions as the target solution.
8. A device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
