Resource allocation method and device, computer equipment and computer readable storage medium

By generating and regulating resource allocation schemes, we ensure that high-priority compilation tasks obtain sufficient resources, solving the problem of low-priority tasks occupying too much resources, and improving the efficiency of software integration.

CN119512753APending Publication Date: 2025-02-25ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411628162.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

During the software integration process, compilation tasks with lower priority may occupy too much computing resources, resulting in compilation tasks with higher priority cannot be completed in time.

Method used

By determining the compilation task of the resources to be allocated, obtain the priority, resource requirement information and available resource information of the task, generate an initial resource allocation plan, and adjust the plan according to the priority, ensure that high-priority tasks are supported by sufficient resource.

Benefits of technology

It realizes the rational allocation of computing resources, ensures that compilation tasks with high priority can be completed in a timely manner, and improves the efficiency and reliability of software integration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512753A_ABST
    Figure CN119512753A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to a resource allocation method and device, computer equipment and a computer readable storage medium. The resource allocation method comprises the following steps: determining a plurality of compiling tasks to be subjected to resource allocation; acquiring priorities and resource demand information of a plurality of compiling tasks and current available resource information of the computer equipment; generating a first resource allocation scheme based on the resource demand information and the available resource information of the plurality of compiling tasks; if the first resource allocation scheme does not meet the preset resource allocation rule, adjusting the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme; and allocating computing resources to the plurality of compiling tasks based on the second resource allocation scheme. Reasonable computing resources can be allocated to the compiling tasks, and computer equipment can complete the compiling tasks with high priorities in time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a resource allocation method, apparatus, computer equipment, and computer-readable storage medium. Background Art

[0002] Compilation is the process of converting software source code into code that computers can understand and execute, and deployment is the process of deploying the compiled software to the target environment.

[0003] When a computer device needs to perform software integration, generally when it needs to execute multiple compilation tasks, the computer device can allocate corresponding computing resources to each compilation task to smoothly execute each compilation task.

[0004] However, during the software integration process, the priorities of different compilation tasks may be different. When allocating computing resources, compilation tasks with lower priorities may occupy too many resources, resulting in the inability to complete compilation tasks with higher priorities in a timely manner. Summary of the invention

[0005] In view of the above, the embodiments of the present application provide a resource allocation method, apparatus, computer device and computer-readable storage medium, which can allocate reasonable computing resources to each compilation task, which is conducive to enabling the computer device to complete high-priority compilation tasks in a timely manner.

[0006] In a first aspect, an embodiment of the present application provides a resource allocation method, which is applied to a computer device. The resource allocation method includes: Determine a plurality of compilation tasks to be resource allocated; Obtaining priorities, resource requirement information, and currently available resource information of the computer device of the plurality of compiling tasks; generating a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; If the first resource allocation scheme does not satisfy a preset resource allocation rule, adjusting the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme; The resource allocation rule is used to represent resource allocation requirements for compilation tasks of each priority level; The computing resources of the computer device are allocated to the plurality of compiling tasks based on the second resource allocation scheme.

[0007] The embodiment of the present application generates a first resource allocation scheme based on the resource requirements of each compilation task and the available resources of the computer device, which is conducive to ensuring that each compilation task obtains resource support from the computer device. When the first resource allocation scheme does not meet the resource allocation requirements for compilation tasks of various priorities, the computer device can further adjust the first resource allocation scheme based on the priority of each compilation task to obtain a second resource allocation scheme, which is conducive to ensuring that high-priority compilation tasks are given priority in obtaining resource support, thereby allowing the computer device to complete high-priority compilation tasks in a timely manner.

[0008] In some embodiments, generating a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information includes: generating a candidate resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; Calculating the fitness of the candidate resource allocation scheme; The fitness is used to characterize the execution efficiency of the multiple compilation tasks when the candidate resource allocation scheme is used for resource allocation; The first resource allocation scheme is determined based on the fitness and the candidate resource allocation schemes.

[0009] In some embodiments, determining the first resource allocation scheme based on the fitness and the candidate resource allocation schemes includes: Check whether the preset solution termination generation conditions are met; If the termination generation condition of the scheme is not met currently, a candidate resource allocation scheme with high fitness is selected from the candidate resource allocation schemes as the parent resource allocation scheme; Generating a new candidate resource allocation scheme based on the parent resource allocation scheme, and again entering the step of detecting whether the preset scheme generation termination condition is currently met; If the solution generation termination condition is currently met, the candidate resource allocation solution with the greatest fitness among the generated candidate resource allocation solutions is used as the first resource allocation solution.

[0010] In some embodiments, the step of confirming that the first resource allocation scheme does not satisfy a preset resource allocation rule includes: Determining a resource allocation amount of a first compile task in the first resource allocation scheme to obtain a first resource allocation amount, wherein the first compile task is a compile task with the highest priority among the multiple compile tasks; Adding resource allocation amounts of each second compile task in the first resource allocation scheme to obtain a second resource allocation amount, wherein the second compile task is a compile task among the multiple compile tasks except the first compile task; If the first resource allocation amount is less than the second resource allocation amount, it is confirmed that the first resource allocation scheme does not satisfy the resource allocation rule.

[0011] In some embodiments, adjusting the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme includes: Calculating a difference between the second resource allocation amount and the first resource allocation amount; increasing the first resource allocation amount based on the difference to obtain a resource allocation amount for the first compilation task in the second resource allocation scheme; The resource allocation amount of each second compiling task is reduced based on the difference to obtain the resource allocation amount of each second compiling task in the second resource allocation scheme.

[0012] In some embodiments, after allocating computing resources of the computer device to the plurality of compiling tasks based on the second resource allocation scheme, the method further includes: If there is a compile task that fails to execute among the multiple compile tasks, the compile task that fails to execute and the compile task that has not been completed are used as the multiple compile tasks to be allocated resources; And re-enter the step of obtaining the priorities, resource requirement information and current available resource information of the computer device of the plurality of compiling tasks.

[0013] In some embodiments, after generating the first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information, the method further includes: If the first resource allocation scheme satisfies the resource allocation rule, computing resources of the computer device are allocated to the multiple compilation tasks based on the first resource allocation scheme.

[0014] In a second aspect, an embodiment of the present application further provides a resource allocation device, which is applied to a computer device, and the resource allocation device includes: A task determination module, used to determine a plurality of compilation tasks to be allocated resources; An information acquisition module, used to acquire the priorities of the plurality of compilation tasks, resource requirement information and currently available resource information of the computer device; A scheme generating module, configured to generate a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; a scheme adjustment module, configured to adjust the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme if the first resource allocation scheme does not satisfy a preset resource allocation rule; The resource allocation rule is used to represent resource allocation requirements for compilation tasks of each priority level; A resource allocation module is used to allocate computing resources of the computer device to the multiple compilation tasks based on the second resource allocation scheme.

[0015] In a third aspect, an embodiment of the present application further provides a computer device, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call the instructions in the memory, so that the computer device executes the resource allocation method described in the first aspect.

[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed on a computer device, the computer device executes the resource allocation method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 The present invention is a schematic diagram of an application scenario of a resource allocation method provided according to an embodiment of the present application.

[0018] Figure 2 The present invention is a flowchart of a method for allocating resources according to an embodiment of the present invention.

[0019] Figure 3 The flowchart is a sub-step flowchart of step 203 provided according to an embodiment of the present application.

[0020] Figure 4 This is a flowchart of sub-steps of step 205 provided according to an embodiment of the present application.

[0021] Figure 5 The present invention is a flowchart of a resource allocation method according to another embodiment of the present application.

[0022] Figure 6 The diagram is a schematic diagram of the structure of a resource allocation device provided according to an embodiment of the present application.

[0023] Figure 7 The figure is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that the implementation methods of the present application and the features in the implementation methods can be combined with each other without conflict.

[0025] In the following description, many specific details are set forth to facilitate a full understanding of the present application. The described implementations are only part of the implementations of the present application, rather than all the implementations.

[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0027] It should be further noted that, in this article, the terms "comprises", "includes" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0028] In this application, "at least one" means one or more, and "more" means two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", "fourth", etc. (if any) in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence.

[0029] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0030] A car's domain controller: an electronic control unit dedicated to communication and control between different functional modules within the car, capable of coordinating the operation of multiple systems.

[0031] Software Integration: The process of integrating multiple independently developed software components into a system to ensure that these components work together in the overall system.

[0032] Compilation: The process of converting source code into an executable program, a key step in software development.

[0033] Deployment: The process of installing and configuring the compiled software into the target system so that it can run normally.

[0034] Computing resources: refers to the hardware resources such as processors, memory, storage, etc. in a computer system, which are used to support the operation of software and process tasks.

[0035] Control Groups (Cgroups) mechanism: The Linux system kernel provides a mechanism called Cgroups (control groups), which allows us to limit, record and isolate the computing resources used by process groups, such as CPU, memory, disk I / O, etc.

[0036] Computer devices can use Cgroups to allocate specific proportions of computing resources to different functional modules, where each module can be regarded as a process group.

[0037] When a computer device needs to perform software integration, generally when it needs to execute multiple compilation tasks, the computer device can allocate corresponding computing resources to each compilation task to smoothly execute each compilation task.

[0038] However, during the software integration process, the priorities of different compilation tasks may be different. When allocating computing resources, compilation tasks with lower priorities may occupy too many resources, resulting in the inability to complete compilation tasks with higher priorities in a timely manner.

[0039] In view of the above, embodiments of the present application provide a resource allocation method, apparatus, computer device, and computer-readable storage medium.

[0040] The resource allocation method of the present application can be applied to one or more computer devices. The computer device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to processors, microprogrammed control units (MCU), application specific integrated circuits (ASIC), programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc. The computer device can be a vehicle-mounted computer, a personal computer, a server, etc.

[0041] When a computer device needs to allocate resources for multiple compilation tasks, the resource allocation method provided in the embodiment of the present application can be used to allocate resources to ensure the rationality of resource allocation.

[0042] For example, a computer device can use the resource allocation method provided in the embodiment of the present application to allocate resources for the compilation task of the automobile domain controller software, thereby improving the compilation efficiency of the automobile domain controller software and further improving the software integration efficiency of the automobile.

[0043] refer to Figure 1 As shown, assuming that the car includes a power domain controller, an infotainment domain controller and a driving assistance domain controller, the power system control software needs to be updated in the power domain controller, the entertainment system needs to be updated in the infotainment domain controller, and the driving assistance system needs to be updated in the driving assistance domain controller. In this case, the computer device (such as the car computer) needs to execute the compilation task of the power system control software (recorded as compilation task 1), the compilation task of the entertainment system (recorded as compilation task 2) and the compilation task of the driving assistance system (recorded as compilation task 3). In order to ensure the power response and driving safety of the vehicle, among the compilation tasks of the domain controller software, compilation task 1 has the highest priority. The computer device can use the resource allocation method provided in the embodiment of the present application to allocate computing resources to compilation task 1, compilation task 2 and compilation task 3, so that these compilation tasks can be executed smoothly, and can also enable compilation task 1 to allocate resources first, so that the computer device can process compilation task 1 in time. Figure 2 This is a flowchart of the steps of an embodiment of the resource allocation method of the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.

[0044] See also Figure 2 As shown, the resource allocation method may include the following steps.

[0045] Step 201: determine a plurality of compiling tasks to be allocated resources.

[0046] For example, assuming that each domain controller in a vehicle needs to update the entertainment system, power system control software, and driver assistance system, the computer device can treat the compilation tasks of these software as multiple compilation tasks to be resource allocated.

[0047] Step 202, obtaining priorities, resource requirement information, and currently available resource information of a plurality of compiling tasks.

[0048] The available resource information is used to characterize the total amount of computing resources that can be allocated to the multiple compiling tasks when the computer device executes the multiple compiling tasks. That is, the available resource information refers to the available computing resources of the computer device for executing the multiple compiling tasks.

[0049] The priority of the compilation task can be configured according to the actual application requirements. The user can configure the priority of the compilation task according to the importance of the compilation task.

[0050] The resource requirement information of the compiling task may include computing resources required to execute the compiling task, where the computing resources are used to support the running of the compiling task.

[0051] The resource requirement information of the compilation task may also include an estimated execution time of the compilation task.

[0052] In some embodiments, a software integration configuration file may be stored in the computer device, and the priority and resource requirement information of each compilation task may be recorded in the software integration configuration file.

[0053] For example, the software integration configuration file may include the identifier of each compilation task (recorded as task_id), the name of the compilation task (recorded as task_name), the computing resources required for the compilation task (recorded as resource_requirements), the priority of the compilation task (recorded as priority), and the estimated execution time of the compilation task (recorded as estimated_time).

[0054] The computing resources required for the compilation task may include central processing unit resources (referred to as CPU), memory resources (referred to as memory), and disk resources (referred to as disk) required for the compilation task.

[0055] When the multiple compilation tasks to be resource allocated include: compilation task 1 (recorded as task1), compilation task 2 (recorded as task2), and compilation task 3 (recorded as task3), the contents of the software integration configuration file are as follows: { "tasks": [ { "task_id": "task1", "task_name": "Powertrain control software compilation", "resource_requirements": { "cpu": 8, "memory": 16, "disk": 50 }, "priority": 1, "estimated_time": 120 }, { "task_id": "task2", "task_name": "Entertainment System Update", "resource_requirements": { "cpu": 4, "memory": 8, "disk": 20 }, "priority": 2, "estimated_time": 60 }, { "task_id": "task3", "task_name": "Driver assistance system upgrade", "resource_requirements": { "cpu": 2, "memory": 4, "disk": 10 }, "priority": 3, "estimated_time": 30 } ] } Step 203: Generate a first resource allocation scheme based on resource requirement information and available resource information of multiple compilation tasks.

[0056] The first resource allocation scheme is used to characterize the computing resources allocated to multiple compilation tasks. In addition, in the first resource allocation scheme, the amount of computing resources allocated to a certain compilation task satisfies the resource requirement information of the compilation task, and the total amount of computing resources allocated to the multiple compilation tasks needs to be less than or equal to the amount of computing resources represented by the available resource information.

[0057] In some embodiments, the available resource information of the computer device may represent the available computing resources of the computer device for executing compilation tasks. When the available computing resources are insufficient to support the computer device to concurrently execute the multiple compilation tasks, the computer device may execute a compilation task with a high priority.

[0058] When the available computing resources are sufficient to support the computer device to concurrently execute the multiple compiling tasks, the computer device may generate a first resource allocation scheme based on the resource requirement information and available resource information of the multiple compiling tasks.

[0059] For example, the computer device may use resource requirement information and available resource information of multiple compilation tasks as constraints and use a preset resource allocation algorithm to generate a first resource allocation scheme. The resource allocation algorithm may be a greedy algorithm, a genetic algorithm, etc., but is not limited thereto.

[0060] refer to Figure 3 As shown, Figure 3 Taking the genetic algorithm as an example, the implementation of step 203 is described. Specifically, step 203 may include: Step 301 : generating candidate resource allocation schemes based on resource requirement information and available resource information of a plurality of compilation tasks.

[0061] For example, the resource requirement information of a compilation task includes a range of computing resources required for the compilation task. The computer device can randomly select a computing resource within the range as the computing resource allocated to the compilation task in the candidate resource allocation scheme, and the total amount of computing resources for each compilation task in the candidate resource allocation scheme is less than or equal to the computing resource represented by the available resource information. In the above manner, multiple candidate resource allocation schemes can be obtained, and the set of multiple candidate resource schemes can be called an initial population.

[0062] Step 302: Calculate the fitness of the candidate resource allocation schemes.

[0063] The fitness is used to characterize the execution efficiency of the multiple compilation tasks when the candidate resource allocation scheme is used for resource allocation.

[0064] Specifically, the evaluation index of the execution efficiency may include: resource utilization rate when the computer device executes the multiple compilation tasks, and / or the total execution time of the multiple compilation tasks.

[0065] In some embodiments, the computer device may use a preset fitness function to calculate the fitness of the candidate resource allocation solution.

[0066] When the evaluation index of execution efficiency includes the resource utilization rate, the fitness function may be a calculation formula of the resource utilization rate.

[0067] When the evaluation index of execution efficiency includes the total execution time, the fitness function may be the inverse of the calculation formula of the total execution time.

[0068] When the evaluation indicators of execution efficiency include resource utilization and total execution time, the fitness function can be as follows: ; Among them, x refers to the candidate resource allocation scheme, F(x) is the fitness of the candidate resource allocation scheme, U(x) is the calculation formula of the resource utilization corresponding to the candidate resource allocation scheme, T(x) is the calculation formula of the total execution time corresponding to the candidate resource allocation scheme, α and β are weight coefficients, which can be set according to actual application requirements.

[0069] When the evaluation indicators of execution efficiency include resource utilization and total execution time, the fitness of the candidate resource allocation scheme can represent the comprehensive evaluation indicators of resource utilization and total execution time. The greater the resource utilization of the candidate resource allocation scheme and the smaller the total execution time, the higher the fitness of the candidate resource allocation scheme.

[0070] Step 303: Determine a first resource allocation scheme based on the fitness and the candidate resource allocation schemes.

[0071] In some embodiments, the computer device uses the candidate resource allocation scheme with the greatest fitness as the first resource allocation scheme, thereby facilitating improving the execution efficiency of multiple compilation tasks.

[0072] In some other embodiments, continue to refer to Figure 3 As shown, step 303 may include: Step 3031, detecting whether the preset solution termination generation condition is currently met.

[0073] If the conditions for terminating the generation of the solution are not met at present, execute steps 3032 to 3033.

[0074] In some embodiments, the solution generation termination condition may include that among the candidate resource allocation solutions currently generated, there is a candidate resource allocation solution whose fitness is greater than or equal to a preset threshold.

[0075] In some embodiments, the condition for terminating generation of the solution may also include the number of executions of steps 3032 to 3033 (ie, the number of iterations for generating candidate resource allocation solutions) exceeding a preset number.

[0076] Step 3032: Select a candidate resource allocation scheme with high fitness from among the candidate resource allocation schemes as a parent resource allocation scheme.

[0077] The electronic device may use the selection operation (selection) in the genetic algorithm to select a candidate resource allocation scheme with high fitness from among the generated candidate resource allocation schemes as the parent resource allocation scheme. The following uses three selection methods as examples to illustrate the selection process of the parent resource allocation scheme.

[0078] Method 1: The electronic device can sort the candidate resource allocation schemes according to the order of fitness, and select the first N candidate resource allocation schemes with high fitness as the parent resource allocation schemes. Wherein, N is an integer greater than or equal to 1, and the specific value of N can be set according to actual application requirements, and this embodiment of the application is not limited to this.

[0079] Method 2: Randomly select a certain number of candidate resource allocation schemes in the current population to obtain a scheme set; in the scheme set, select the top N candidate resource allocation schemes with high fitness as the parent resource allocation schemes.

[0080] The above method of selecting the parent resource allocation scheme has low computational complexity and introduces a certain degree of randomness to avoid falling into a local optimal solution and prevent premature convergence, thereby exploring better candidate resource allocation schemes. Mode 3: The electronic device may assign a selection probability to each candidate resource allocation scheme based on the fitness of each candidate resource allocation scheme, wherein the higher the fitness, the greater the selection probability.

[0081] For example, the selection probability of a candidate resource allocation scheme may be equal to the fitness of the candidate resource allocation scheme divided by the fitness sum value, where the fitness sum value is the sum of the fitness of the candidate resource allocation schemes included in the current population. The current population includes the top M candidate resource allocation schemes with the highest fitness among all candidate resource allocation schemes generated by several iterations. M is an integer greater than 1, and the embodiments of the present application are not limited to this.

[0082] Then, the electronic device can select the parent resource allocation scheme according to the selection probability of each candidate resource allocation scheme, so that the probability of each candidate resource allocation scheme being selected as the parent resource allocation scheme is proportional to the fitness. For example, the electronic device can select the parent resource allocation scheme using a roulette algorithm and the selection probability of each candidate resource allocation scheme.

[0083] The above method can ensure that candidate resource allocation schemes with higher fitness have a greater chance of being selected, and also give candidate resource allocation schemes with lower fitness a certain chance of being selected, thereby maintaining the diversity of generated candidate resource allocation schemes, thereby avoiding falling into local optimal solutions and preventing premature convergence, so as to explore better candidate resource allocation schemes.

[0084] It is understandable that the parent resource allocation scheme provided above is only an example. In actual application, it can be set according to needs, and the embodiments of the present application are not limited to this.

[0085] Step 3033: Generate a new candidate resource allocation scheme based on the parent resource allocation scheme.

[0086] For example, the crossover and mutation operations in the genetic algorithm can be used to generate new candidate resource allocation solutions.

[0087] The crossover operation refers to selecting some features (such as the amount of computing resources allocated to some compilation tasks) from a pair of parent resource allocation schemes and exchanging them to obtain a new candidate resource allocation scheme.

[0088] The mutation operation refers to randomly changing some features from the parent resource allocation plan to obtain a new candidate resource allocation plan.

[0089] The embodiment of the present application can gradually generate candidate resource allocation schemes with high adaptability through the above steps 3032 to 3033.

[0090] After step 3033, step 3031 may be entered again, that is, whether the preset solution termination generation condition is currently met is detected. If the preset solution termination generation condition is currently met, step 3034 may be executed.

[0091] Step 3034: Among the generated candidate resource allocation schemes, the candidate resource allocation scheme with the greatest fitness is used as the first resource allocation scheme.

[0092] That is, the electronic device may use the candidate resource allocation scheme with the greatest fitness as the first resource allocation scheme among the candidate resource allocation schemes generated before the iteration and the candidate resource allocation schemes generated in each iteration process.

[0093] The embodiment of the present application uses a genetic algorithm to ensure that the first resource allocation scheme not only meets the resource requirements of each compilation task, but also ensures the execution efficiency of the first resource allocation scheme as much as possible. For example, it maximizes the resource utilization rate of the computer device when executing the multiple compilation tasks and minimizes the total execution time of the multiple compilation tasks.

[0094] For example, in an automotive domain controller project, suppose there are three compilation tasks that need to be executed simultaneously: 1. Compilation task of power system control software (task1): high priority and large resource requirements.

[0095] 2. Entertainment system software compilation task (task2): medium priority, medium resource requirements.

[0096] 3. Compilation task of the driving assistance system (task3): low priority and small resource requirements.

[0097] The initial population generated by the genetic algorithm based on the above compilation task includes at least the following candidate resource allocation schemes: Candidate resource allocation scheme 1 (denoted as scheme 1): task 1 is allocated 50% of the processor resources, task 2 is allocated 30% of the processor resources, and task 3 is allocated 20% of the processor resources.

[0098] Candidate resource allocation scheme 2 (denoted as scheme 2): task 1 is allocated 60% of the processor resources, task 2 is allocated 25% of the processor resources, and task 3 is allocated 15% of the processor resources.

[0099] Then, the fitness of the candidate resource allocation schemes is calculated. For example, the fitness of candidate resource allocation scheme 1 is F(1)=0.6, and the fitness of candidate resource allocation scheme 2 is F(2)=0.7.

[0100] Next, the electronic device may perform selection, crossover and mutation operations on the candidate resource allocation schemes based on a genetic algorithm.

[0101] For example, the electronic device may select scheme 2 with higher fitness to perform mutation operation and generate a new candidate resource allocation scheme.

[0102] For another example, the electronic device may select scheme 1 and scheme 2 with higher adaptability to perform cross-operation to generate a new candidate resource allocation scheme.

[0103] For another example, the electronic device may select scheme 1 and scheme 2 with higher fitness, and perform mutation operations on the two respectively, and then perform a crossover operation on the two candidate resource allocation schemes generated by the mutation operation to generate a new candidate resource allocation scheme.

[0104] For example, the new candidate resource allocation scheme is as follows: Candidate resource allocation scheme 3: task1 is allocated 65% of the processor resources, task2 is allocated 20% of the processor resources, and task3 is allocated 15% of the processor resources.

[0105] The above steps of generating candidate resource allocation solutions are repeated, and after multiple iterations, a first resource allocation solution is finally obtained.

[0106] By adopting the first resource allocation scheme, the compilation time of task1 can be significantly shortened, and the resource utilization of task2 and task3 can be significantly improved, so that the efficiency of the software integration process can be significantly improved. Step 204: Detect whether the first resource allocation scheme satisfies a preset resource allocation rule.

[0107] The resource allocation rule is used to characterize the resource allocation requirements for compiling tasks of different priorities. For example, the higher the priority of a compiling task, the more computing resources are required to be allocated to the compiling task by the resource allocation rule.

[0108] In some embodiments, the resource allocation rule may include that the amount of computing resources allocated to the highest priority compilation task needs to be greater than or equal to the total amount of computing resources allocated to other compilation tasks except the highest priority compilation task.

[0109] Specifically, step 204 may include the following steps 1 to 4: Step 1: determine a resource allocation amount for a first compilation task in a first resource allocation scheme to obtain a first resource allocation amount.

[0110] The first compiling task is a compiling task with the highest priority among the plurality of compiling tasks. The resource allocation amount refers to the amount of computing resources allocated to the compiling task.

[0111] Step 2: Add the resource allocation amounts of each second compilation task in the first resource allocation scheme to obtain a second resource allocation amount, wherein the second compilation task is a compilation task other than the first compilation task among the multiple compilation tasks.

[0112] Step 3: If the first resource allocation amount is less than the second resource allocation amount, confirm that the first resource allocation scheme does not meet the resource allocation rule.

[0113] Step 4: If the first resource allocation amount is greater than the second resource allocation amount, confirm that the first resource allocation scheme meets the resource allocation rule.

[0114] For example, assuming that in the first resource allocation scheme, the resource allocation amount of the first compilation task is A1, and the resource allocation amounts of each second compilation task are A2 and A3 respectively, then the first resource allocation amount is A1, and the second resource allocation amount = A2 + A3; if A1 is greater than or equal to A2 + A3, it is confirmed that the first resource allocation scheme meets the resource allocation rule; if A1 is less than A2 + A3, it is confirmed that the first resource allocation scheme does not meet the resource allocation rule.

[0115] If the first resource allocation scheme does not satisfy the preset resource allocation rule, step 205 to step 206 are executed; if the first resource allocation scheme satisfies the preset resource allocation rule, step 207 may be executed.

[0116] Step 205: Adjust the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme.

[0117] In some embodiments, reference Figure 4 As shown, step 205 can be implemented in the following manner: Step 2051: Calculate the difference between the second resource allocation amount and the first resource allocation amount.

[0118] For example, the difference X=A2+A3-A1.

[0119] Step 2052: Increase the first resource allocation amount based on the difference to obtain the resource allocation amount of the first compilation task in the second resource allocation scheme.

[0120] For example, the resource allocation amount of the first compilation task in the second resource allocation scheme is recorded as B1, and the calculation formula of B1 can be shown as follows: B1=A1+2X, where 2X refers to twice the difference X.

[0121] Step 2053: Reduce the resource allocation amount of each second compiling task based on the difference to obtain the resource allocation amount of each second compiling task in the second resource allocation scheme.

[0122] For example, the resource allocation amounts of each second compilation task in the second resource allocation scheme are recorded as B2 and B3, and the calculation formulas of B2 and B3 are as follows: B2=A2-(2X / (total number of compilation tasks-1)); B3=A3-(2X / (total number of compilation tasks-1)).

[0123] Through the above-mentioned adjustment, the embodiment of the present application can make the compilation task with the highest priority occupy more computing resources, which is beneficial to ensuring that the computer device can execute the compilation task with the highest priority in a timely manner, and the software corresponding to the compilation task can be compiled and deployed by the computer device in a timely manner.

[0124] In some embodiments, after obtaining the second resource allocation plan in the above manner, the resource allocation plan can be further verified to verify whether the computing resources allocated to each compilation task in the second resource allocation plan meet the minimum requirements of the compilation task for computing resources. If so, the second resource allocation plan can be readjusted so that the computing resources allocated to each compilation task in the second resource allocation plan meet the minimum requirements of the compilation task for computing resources.

[0125] Step 206: Allocate computing resources of the computer device to the plurality of compiling tasks based on the second resource allocation scheme.

[0126] If the first resource allocation scheme satisfies the resource allocation rule, step 207 is executed.

[0127] Step 207: Allocate computing resources of a computer device to multiple compilation tasks based on a first resource allocation scheme.

[0128] The step of allocating computing resources of a computer device to multiple compiling tasks may include: 1. Create a control group (Cgroup). For example, a computer device creates a Cgroup for each compilation task.

[0129] 2. Set computing resources. For example, the computer device sets the computing resources that can be used by each compilation task according to the first resource allocation scheme or the second resource allocation scheme by modifying the Cgroups configuration file.

[0130] 3. Start the compilation task process and bind it to the corresponding control group.

[0131] In some embodiments, reference Figure 5 As shown, after the computer device executes step 206 or step 207 (that is, after the computer device allocates computing resources to multiple compilation tasks), the computer device may execute the following steps: Step 208, executing the plurality of compiling tasks and monitoring the execution status of the plurality of compiling tasks.

[0132] Step 209 : If there are compilation tasks that have failed to execute, the compilation tasks that have failed to execute and the compilation tasks that have not been completed are treated as a plurality of compilation tasks to be allocated resources, and the process goes to step 202 again.

[0133] That is, in the case that there are compilation tasks that have failed to execute among the multiple compilation tasks, the computer device can regard the compilation tasks that have failed to execute and the compilation tasks that have not been completed as the multiple compilation tasks to be allocated resources, and redetermine the resource allocation schemes for the multiple compilation tasks, thereby realizing dynamic resource allocation of compilation task resources, ensuring that the compilation tasks that have failed to run can be executed in a timely manner, especially for high-priority compilation tasks. When the high-priority compilation tasks fail to execute, computing resources can be immediately reallocated to them, avoiding the obstruction of the progress of other compilation tasks and improving compilation efficiency.

[0134] Based on the same idea as the resource allocation method in the above embodiment, the present application also provides a resource allocation device, which can be used to execute the above resource allocation method. For ease of explanation, the structural diagram of the resource allocation device embodiment only shows the parts related to the embodiment of the present application. It can be understood by those skilled in the art that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.

[0135] like Figure 6 The resource allocation device shown may include a task determination module 601, an information acquisition module 602, a solution generation module 603, a solution adjustment module 604, and a resource allocation module 605. In some embodiments, the above modules may be programmable software instructions stored in a memory and can be called and executed by a processor. It is understood that in other embodiments, the above modules may also be program instructions or firmware solidified in the processor.

[0136] A task determination module 601 is used to determine a plurality of compilation tasks to be allocated resources; An information acquisition module 602 is used to acquire the priorities, resource requirement information of the plurality of compilation tasks and the currently available resource information of the computer device; A scheme generating module 603, configured to generate a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; A scheme adjustment module 604 is configured to adjust the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme if the first resource allocation scheme does not satisfy a preset resource allocation rule; The resource allocation rule is used to represent resource allocation requirements for compilation tasks of each priority level; The resource allocation module 605 is configured to allocate computing resources of the computer device to the multiple compilation tasks based on the second resource allocation scheme.

[0137] Figure 7 This is a schematic diagram of an embodiment of a computer device of the present application.

[0138] The computer device 100 includes a memory 20, a processor 30, and a computer program 40 stored in the memory 20 and executable on the processor 30. When the processor 30 executes the computer program 40, the steps in the above resource allocation method embodiment are implemented, for example Figure 2 Steps 201 to 207 are shown.

[0139] Exemplarily, the computer program 40 can also be divided into one or more modules / units, which are stored in the memory 20 and executed by the processor 30. The one or more modules / units can be a series of computer program instruction segments that can perform specific functions, and the instruction segments are used to describe the execution process of the computer program 40 in the computer device 100. For example, it can be divided into Figure 6 The shown module includes a task determination module 601 , an information acquisition module 602 , a solution generation module 603 , a solution adjustment module 604 and a resource allocation module 605 .

[0140] Those skilled in the art will appreciate that the schematic diagram is merely an example of the computer device 100 and does not constitute a limitation on the computer device 100 . The computer device 100 may include more or fewer components than shown in the diagram, or a combination of certain components, or different components. For example, the computer device 100 may also include input and output devices, network access devices, buses, etc.

[0141] The processor 30 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, a single-chip microcomputer, or the processor 30 may also be any conventional processor, etc.

[0142] The memory 20 can be used to store the computer program 40 and / or the module / unit. The processor 30 realizes various functions of the computer device 100 by running or executing the computer program and / or the module / unit stored in the memory 20 and calling the data stored in the memory 20. The memory 20 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data (such as audio data) created according to the use of the computer device 100, etc. In addition, the memory 20 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.

[0143] If the module / unit integrated in the computer device 100 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunication signals.

[0144] In the several embodiments provided in this application, it should be understood that the disclosed computer device and method can be implemented in other ways. For example, the computer device embodiment described above is only illustrative, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation.

[0145] In addition, each functional unit in each embodiment of the present application may be integrated into the same processing unit, each unit may exist physically separately, or two or more units may be integrated into the same unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0146] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or computer devices stated in the computer device claim can also be implemented by the same unit or computer device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the above embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.

Claims

1. A resource allocation method, characterized in that: Applied to computer equipment, the resource allocation method comprises: Determine a plurality of compilation tasks to be resource allocated; Obtaining priorities, resource requirement information, and currently available resource information of the computer device of the plurality of compiling tasks; generating a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; If the first resource allocation scheme does not satisfy a preset resource allocation rule, adjusting the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme; The resource allocation rule is used to represent resource allocation requirements for compilation tasks of each priority level; The computing resources of the computer device are allocated to the plurality of compiling tasks based on the second resource allocation scheme.

2. The resource allocation method according to claim 1, characterized in that: The generating a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information comprises: generating a candidate resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; Calculating the fitness of the candidate resource allocation scheme; The fitness is used to characterize the execution efficiency of the multiple compilation tasks when the candidate resource allocation scheme is used for resource allocation; The first resource allocation scheme is determined based on the fitness and the candidate resource allocation schemes.

3. The resource allocation method according to claim 2, characterized in that: The determining the first resource allocation scheme based on the fitness and the candidate resource allocation schemes includes: Check whether the preset solution termination generation conditions are met; If the termination generation condition of the scheme is not met currently, a candidate resource allocation scheme with high fitness is selected from the candidate resource allocation schemes as the parent resource allocation scheme; Generating a new candidate resource allocation scheme based on the parent resource allocation scheme, and again entering the step of detecting whether the preset scheme generation termination condition is currently met; If the solution generation termination condition is currently met, the candidate resource allocation solution with the greatest fitness among the generated candidate resource allocation solutions is used as the first resource allocation solution.

4. The resource allocation method according to claim 1, characterized in that: The step of confirming that the first resource allocation scheme does not satisfy a preset resource allocation rule includes: Determining a resource allocation amount of a first compile task in the first resource allocation scheme to obtain a first resource allocation amount, wherein the first compile task is a compile task with the highest priority among the multiple compile tasks; Adding resource allocation amounts of each second compile task in the first resource allocation scheme to obtain a second resource allocation amount, wherein the second compile task is a compile task among the multiple compile tasks except the first compile task; If the first resource allocation amount is less than the second resource allocation amount, it is confirmed that the first resource allocation scheme does not satisfy the resource allocation rule.

5. The resource allocation method according to claim 4, characterized in that: The step of adjusting the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme includes: Calculating a difference between the second resource allocation amount and the first resource allocation amount; increasing the first resource allocation amount based on the difference to obtain a resource allocation amount for the first compilation task in the second resource allocation scheme; The resource allocation amount of each second compiling task is reduced based on the difference to obtain the resource allocation amount of each second compiling task in the second resource allocation scheme.

6. The resource allocation method according to any one of claims 1 to 5, characterized in that: After allocating computing resources of the computer device to the plurality of compiling tasks based on the second resource allocation scheme, the method further includes: If there is a compile task that fails to execute among the multiple compile tasks, the compile task that fails to execute and the compile task that has not been completed are used as the multiple compile tasks to be allocated resources; And re-enter the step of obtaining the priorities, resource requirement information and current available resource information of the computer device of the plurality of compiling tasks.

7. The resource allocation method according to any one of claims 1 to 5, characterized in that: After generating the first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information, the method further includes: If the first resource allocation scheme satisfies the resource allocation rule, computing resources of the computer device are allocated to the multiple compilation tasks based on the first resource allocation scheme.

8. A resource allocation device, characterized in that: Applied to computer equipment, the resource allocation device comprises: A task determination module, used to determine a plurality of compilation tasks to be allocated resources; An information acquisition module, used to acquire the priorities of the plurality of compilation tasks, resource requirement information and currently available resource information of the computer device; A scheme generating module, configured to generate a first resource allocation scheme based on the resource requirement information of the plurality of compiling tasks and the available resource information; a scheme adjustment module, configured to adjust the first resource allocation scheme based on the priorities of the plurality of compiling tasks to obtain a second resource allocation scheme if the first resource allocation scheme does not satisfy a preset resource allocation rule; The resource allocation rule is used to represent resource allocation requirements for compilation tasks of each priority level; A resource allocation module is used to allocate computing resources of the computer device to the multiple compilation tasks based on the second resource allocation scheme.

9. A computer device, comprising a processor and a memory, characterized in that: The memory is used to store instructions, and the processor is used to call the instructions in the memory, so that the computer device executes the resource allocation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer device, the computer device executes the resource allocation method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Cloud resource balancing method during end-cloud fusion, computer equipment and medium

    CN120750941A

  • Cloud resource balancing method during end-cloud fusion, computer device and medium

    CN120750941B