An algorithm scheduling method, device and storage medium
By subdividing the time period into sub-time periods and planning the execution of algorithm tasks according to the basic and optimization objectives, the problem of low resource utilization in existing technologies is solved, and more efficient resource utilization is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BIG DATA CENT
- Filing Date
- 2025-08-12
- Publication Date
- 2026-06-19
AI Technical Summary
Existing algorithm scheduling methods lack detailed planning for multiple algorithm tasks in electronic devices, resulting in low utilization of device resources.
By dividing the preset time period into multiple sub-time periods, the algorithm task allocation within each sub-time period is determined based on the basic objective and optimization objective, forming an optimal algorithm scheduling scheme to reasonably arrange the execution time of algorithm tasks on the target device.
It improves the utilization rate of the target device's resources, enabling more algorithmic tasks to be executed simultaneously under the constraint of available resources.
Smart Images

Figure CN121166293B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to an algorithm scheduling method, device, and storage medium. Background Technology
[0002] In video parsing scenarios, the algorithm tasks executed are different based on different video parsing requirements. Therefore, in order to meet different video parsing requirements, electronic devices often need to execute multiple different algorithm tasks; for example, multiple target detection tasks for different target objects or different target events in video data.
[0003] Currently, when electronic devices need to execute multiple different algorithm tasks, existing algorithm scheduling methods typically sort these tasks according to their execution time order. Then, based on this sorting, the device's resources (including software and hardware resources) are used to execute these tasks sequentially. However, because these existing methods rely solely on the execution time order of different algorithm tasks, they lack a more detailed plan for the simultaneous execution of different algorithm tasks by the electronic device, given the shared use of device resources. Consequently, electronic devices exhibit low resource utilization when using these existing scheduling methods. Summary of the Invention
[0004] In view of this, this application provides an algorithm scheduling method, device and storage medium to solve the above-mentioned technical problems.
[0005] In a first aspect, embodiments of this application provide an algorithm scheduling method, the algorithm scheduling method comprising:
[0006] From the task execution plan associated with the target device, determine the algorithm tasks that the target device needs to execute within a preset time period and the corresponding task execution conditions for each algorithm task; wherein, the task execution conditions include: the task execution time and task execution duration corresponding to the algorithm task;
[0007] According to the preset unit time length, the preset time period is divided into multiple sub-time periods with a period length equal to the unit time length;
[0008] Based on the pre-set basic objectives and optimization objectives, the algorithm tasks allocated for execution within each sub-time period are determined as the optimal algorithm scheduling scheme corresponding to the task execution plan. The basic objective refers to the sub-time period allocated to each algorithm task matching the task execution conditions corresponding to each algorithm task, and the device resources occupied by the algorithm tasks executed within the same sub-time period not exceeding the target resources. The optimization objective refers to the overall device resources occupied by the algorithm tasks executed within the same sub-time period being close to the target resources. The target resources represent the available device resources pre-configured for the task execution plan from the device resources of the target device.
[0009] On the target device, each algorithm task is scheduled according to the optimal algorithm scheduling scheme.
[0010] Secondly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the algorithm scheduling method described above.
[0011] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when run by a processor, executes the steps of the aforementioned algorithm scheduling method.
[0012] Fourthly, embodiments of this application provide a computer program product that, when executed by a processor, implements the steps of the algorithm scheduling method described above.
[0013] The technical solutions provided by the embodiments of this application may include the following beneficial effects:
[0014] This application provides an algorithm scheduling method that, from the task execution plan associated with the target device, determines the algorithm tasks that the target device needs to execute within a preset time period and the corresponding task execution conditions for each algorithm task; divides the preset time period into multiple sub-time periods according to a preset unit time length, with the length of one sub-time period equal to one unit time length; determines the algorithm tasks allocated for execution within each sub-time period based on pre-set basic and optimization objectives, serving as the optimal algorithm scheduling scheme corresponding to the task execution plan; and schedules each algorithm task on the target device according to the optimal algorithm scheduling scheme. In this way, by subdividing the actual time period during which the target device can execute algorithm tasks, this application more meticulously and rationally plans the specific execution time of each algorithm task on the target device, enabling the target device to execute as many algorithm tasks simultaneously as possible within the constraints of available device resources, thereby effectively improving the utilization rate of the target device's resources. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart illustrating an algorithm scheduling method provided in an embodiment of this application is shown.
[0017] Figure 2 A flowchart illustrating a resource quantification method provided in an embodiment of this application is shown.
[0018] Figure 3 The illustration shows a flowchart of a method for sequentially determining the sub-time periods allocated to different algorithm tasks, according to an embodiment of this application.
[0019] Figure 4 This is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0021] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0022] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0023] One embodiment of the algorithm scheduling method in this application can run in an electronic device, which may be a terminal device or a server. The specific device type of the electronic device is not limited in this application.
[0024] To facilitate understanding of the embodiments of this application, a detailed description of an algorithm scheduling method, device, and storage medium provided in the embodiments of this application is provided below.
[0025] Reference Figure 1 As shown, Figure 1 The diagram illustrates a flowchart of an algorithm scheduling method provided in an embodiment of this application, wherein the algorithm scheduling method includes steps S101-S104; specifically:
[0026] S101, determine the algorithm tasks that the target device needs to execute within a preset time period and the corresponding task execution conditions for each algorithm task from the task execution plan associated with the target device.
[0027] Here, the target device can be the electronic device itself running the algorithm scheduling method provided in the embodiments of this application, or it can be a hardware device in the electronic device that has data processing capabilities; wherein, when the target device is the aforementioned hardware device, the specific device type of the target device can be determined according to the algorithm task included in the aforementioned task execution plan. The embodiments of this application do not impose any mandatory limitations on the specific device type of the target device.
[0028] For example, if the algorithm tasks included in the above task execution plan are all algorithm tasks related to image data such as video parsing or image processing, then the target device can be a hardware device such as a graphics card or GPU (Graphics Processing Unit) in an electronic device that is related to image data processing; if the algorithm tasks included in the above task execution plan are all algorithm tasks with generality and logical complexity, such as complex logical judgments or highly random memory access, then the target device can be a hardware device such as a CPU (Central Processing Unit) in an electronic device.
[0029] Here, the aforementioned task execution plan refers to the algorithm task execution plan pre-configured by the user for the target device; wherein, the aforementioned task execution plan includes at least: the algorithm task (which may be one or more) that the target device needs to execute within a preset time period, and the specific task execution conditions corresponding to each algorithm task, so that the electronic device can subsequently determine the specific algorithm scheduling scheme for each algorithm task according to the specific task execution conditions corresponding to each algorithm task.
[0030] Specifically, for each algorithm task, the execution conditions corresponding to the algorithm task include: the executable time interval corresponding to the algorithm task and the execution duration of the algorithm task within the executable time interval; wherein, the executable time interval is used to represent a time range within the aforementioned preset time period in which the algorithm task can be executed, and the task execution duration is used to represent the specific length of time the target device executes the algorithm task within the aforementioned executable time interval.
[0031] For example, taking a preset time period of one day as an example, if algorithm task a is "to detect whether the trash can in the video data is in an abnormal state of being knocked over", and the task execution condition corresponding to algorithm task a in the task execution plan is "to detect for 1 hour in the time period from 8:00 to 19:00 every day", then it can be determined that the executable time interval corresponding to algorithm task a is "8:00-18:00" (equivalent to the target device being able to execute algorithm task a for 1 hour between 8:00 and 18:00), and the specified task execution duration of algorithm task a within the above executable time interval is "1 hour" (equivalent to the target device needing to reach a total execution time of 1 hour for algorithm task a within the above executable time interval).
[0032] It should be noted that the algorithm scheduling method provided in this application is applicable to various data processing scenarios. Taking video parsing-type image data processing scenarios as an example, all algorithm tasks in the above task execution plan can be: multiple different video parsing tasks performed on video data captured in the same video shooting scene (such as the same construction site). For example, the algorithm task can be a safety helmet detection task to detect whether construction workers are wearing safety helmets in the video data captured in the construction scene, or a dangerous goods detection task to detect whether flammable and explosive materials are present in the video data captured in the construction scene. All algorithm tasks in the above task execution plan can also be: video parsing tasks performed on video data from multiple different shooting scenes. For example, the algorithm task can be a street light detection task to detect whether street lights are damaged in the video data captured in road scene A, or a street light detection task to detect whether street lights are damaged in the video data captured in road scene B. The specific task content and number of algorithm tasks included in the above task execution plan are not subject to any mandatory limitations in this application embodiment, and users can flexibly adjust them according to the actual application scenario.
[0033] S102, the preset time period is divided into multiple sub-time periods according to the preset unit time length, and the time length of one sub-time period is equal to one unit time length.
[0034] Here, within the preset time period, the executable time intervals corresponding to different algorithm tasks may overlap. For example, algorithm task a is "detecting whether the trash can in the video data is in an abnormal state of being knocked over," and algorithm task b is "detecting whether the street light in the video data is in a damaged state." If the task execution condition corresponding to algorithm task a in the task execution plan is "detecting for 1 hour during the time period from 8:00 to 19:00 every day," and the task execution condition corresponding to algorithm task b in the task execution plan is "detecting for 1 hour during any time period between 8:00-10:00 or 22:00-00:00 every day," then it can be determined that the executable time interval corresponding to algorithm task a is "8:00-18:00," and the executable time interval corresponding to algorithm task b is "8:00-9:00 or 22:00-23:00." In this case, the executable time intervals corresponding to algorithm task a and algorithm task b may overlap by 1 hour during the "8:00-9:00" period.
[0035] Based on this, in order to avoid the aforementioned overlap as much as possible and to make the resource utilization of the device resources on the target device more even, before determining the algorithm scheduling scheme, the embodiments of this application can first subdivide the preset time period according to the preset unit time length, and divide the preset time period into multiple sub-time periods with the aforementioned unit time length. At this time, each subdivided sub-time period can be used as the smallest execution unit corresponding to an algorithm task (that is, the aforementioned unit time length can represent the minimum continuous execution time when executing an algorithm task on the target device), which is conducive to the target device executing each algorithm task more flexibly (equivalent to the algorithm task on the target device no longer being limited to executing the aforementioned task execution time in a single continuous execution, but can be executed multiple times in a single continuous execution unit time length, as long as the cumulative execution time can reach the aforementioned task execution time).
[0036] It should be noted that the specific value of the above-mentioned unit time length can be flexibly adjusted according to actual needs. For example, taking a preset time period of 1 day as an example, when the above-mentioned unit time length is 1 hour, the preset time period can be divided into 24 sub-time periods according to the unit time length; when the above-mentioned unit time length is 2 hours, the preset time period can be divided into 12 sub-time periods according to the unit time length. The embodiments of this application do not limit the specific value of the above-mentioned unit time length.
[0037] S103, based on the pre-set basic objectives and optimization objectives, determine the algorithm tasks to be executed in each sub-time period, which serve as the optimal algorithm scheduling scheme corresponding to the task execution plan.
[0038] Here, the basic objective refers to the matching of the sub-time period allocated to each algorithm task with the task execution conditions corresponding to each algorithm task, and the fact that the device resources occupied by the algorithm tasks executed within the same sub-time period do not exceed the target resources; while the optimization objective refers to the fact that the overall device resources occupied by the algorithm tasks executed within the same sub-time period are close to the target resources.
[0039] Here, referring to the relevant description of step S101 above, it can be seen that for each algorithm task, the task execution conditions corresponding to the algorithm task include two parts: the executable time interval and the task execution duration. At this time, the "the sub-time period allocated to each algorithm task matches the task execution conditions corresponding to each algorithm task" in the above basic objective means that: the specific time corresponding to the sub-time period allocated to an algorithm task should be within the executable time interval corresponding to the algorithm task, and the overall time length corresponding to all sub-time periods allocated to an algorithm task should reach the task execution duration corresponding to the algorithm task.
[0040] For example, taking a preset time period of 1 day and a unit time length of 2 hours as an example, the preset time period of 1 day can be divided into the following 12 sub-time periods according to the above unit time length: "0:00-2:00", "2:00-4:00", "4:00-6:00", "6:00-8:00", "8:00-10:00", "10:00-12:00", "12:00-14:00", "14:00-16:00", "16:00-18:00", "18:00-20:00", "20:00-22:00", "22:00-00:00"; where, if the executable time interval corresponding to algorithm task x is "0:00-10:00" and the execution duration of algorithm task x is 2 hours, then the sub-time periods that match the execution conditions of algorithm task x can be determined as "0:00-2:00", "2:00-4:00", "4:00-6:00", "6:00-8:00", "8:00-10:00".
[0041] Here, the aforementioned target resources refer to the available device resources pre-configured for the task execution plan from the device resources of the target device; wherein, the device resources of the target device include, but are not limited to, software resources and hardware resources; for example, taking the target device as a graphics card, the device resources of the graphics card may include, but are not limited to, video memory resources and computing power resources.
[0042] Here, for each algorithm task, the algorithm task is executed within the target algorithm service on the target device; where the target algorithm service represents the algorithm service corresponding to the algorithm task; that is, each algorithm task corresponds to an algorithm service (an algorithm task is also equivalent to a software service, that is, each algorithm task corresponds to a software service that can execute the algorithm task, and running a software service on the target device allows one or more algorithm tasks corresponding to the software service to be executed within the running software service). The target device needs to execute one or more algorithm tasks corresponding to the algorithm service within the currently running algorithm service, based on the running algorithm service; for example, taking the algorithm task as an object detection task as an example, the algorithm service corresponding to the algorithm task can be an object detection model (equivalent to the target device needing to load the object detection model first when executing the object detection task, and then execute the object detection task through the object detection model).
[0043] It should be noted that the operation of algorithm services also requires the use of device resources of the target device (even if no algorithm tasks are executed within an algorithm service, the target device still needs to use relevant device resources to load the algorithm service itself). Therefore, when determining whether the device resources used by the algorithm tasks executed within a sub-time period exceed the target resources, it is necessary to comprehensively consider the device resources used by the algorithm tasks and the corresponding algorithm services.
[0044] Specifically, taking the algorithm tasks executed within a sub-time period as an example, including algorithm task a, algorithm task b, and algorithm task c, if algorithm task a and algorithm task c correspond to the same algorithm service z (e.g., both the safety helmet detection task and the dangerous goods detection task can be executed through the target detection model), while algorithm task b corresponds to another algorithm service y, then, as an optional embodiment, the sum of device resources occupied by the target device in executing algorithm task a, algorithm task b, and algorithm task c can be calculated. When the calculated sum of device resources is less than or equal to the target resource, it is determined that the device resources occupied by the algorithm tasks executed by the target device within the sub-time period do not exceed the target resource.
[0045] In addition, since the device resources occupied by the target device for executing algorithm tasks a and c depend on the device resources occupied by the target device for running algorithm service z, and the device resources occupied by the target device for executing algorithm task b depend on the device resources occupied by the target device for running algorithm service y, as another optional embodiment, it can be first determined whether the sum of the device resources occupied by the target device for executing algorithm tasks a and c exceeds the device resources occupied by the target device for running algorithm service z. If it does not exceed the sum, it can be further determined whether the device resources occupied by the target device for executing algorithm task b exceed the device resources occupied by the target device for running algorithm service y. If it does not exceed the sum, it is only necessary to determine that the sum of the device resources occupied by the target device for running algorithm service z and y does not exceed the target resources, and thus it can be determined that the device resources occupied by the algorithm tasks executed by the target device in this sub-time period do not exceed the target resources.
[0046] Similarly, for the above optimization objectives, the overall device resources occupied by the algorithm task executed within a sub-time period can be determined in the manner shown in the two optional embodiments above, to see if they are close to the target resources. Repeated points will not be repeated here.
[0047] S104, on the target device, each of the algorithm tasks is scheduled according to the optimal algorithm scheduling scheme.
[0048] Here, referring to the specific implementation of steps S101-S103 above, it can be seen that since the specific algorithm tasks to be executed in each sub-time period have been clearly defined in the optimal scheduling scheme, and the algorithm service corresponding to each algorithm task is also known information, after determining the optimal scheduling scheme, the electronic device only needs to perform algorithm scheduling on the target device according to the optimal scheduling scheme for the algorithm tasks in the task execution plan. Under the condition of satisfying the above basic objectives and the above optimization objectives, the task execution plan can be successfully completed. At this time, the completion of the task execution plan satisfies the above optimization objective (i.e., the overall device resources occupied by the algorithm tasks executed in the same sub-time period are close to the target resources). Therefore, the target device can execute as many algorithm tasks as possible at the same time when the available device resources are limited to the target resources, thereby effectively improving the utilization rate of the target device's device resources.
[0049] For example, taking the optimal algorithm scheduling scheme as follows: executing algorithm tasks a and c during the sub-time period "0:00-2:00" and algorithm task b during the sub-time period "12:00-14:00", if algorithm tasks a and c correspond to the same algorithm service z, while algorithm task b corresponds to another algorithm service y, then the algorithm scheduling result on the target device is as follows: the target device runs algorithm service z during the sub-time period "0:00-2:00" and executes algorithm tasks a and c within algorithm service z; the target device runs algorithm service y during the sub-time period "12:00-14:00" and executes algorithm task b within algorithm service y. Since the specific running time of each algorithm service and the specific execution time of each algorithm task can be precisely controlled on the target device, the utilization rate of the target device's resources is effectively improved.
[0050] The following is an exemplary description of each step in the algorithm scheduling method provided in the embodiments of this application:
[0051] Here, referring to the aforementioned description of step S103, it is known that when determining whether the algorithm tasks executed within the same sub-time period meet the above-mentioned basic objectives or optimization objectives, it is necessary to determine the specific device resources occupied by the target device for executing each algorithm task, and also to determine the specific device resources occupied by the target device for executing each algorithm service. In this case, as an optional embodiment, the target resources, the device resources occupied for executing each algorithm task, and the device resources occupied for executing each algorithm service can be quantified separately through resource quantification. The quantification results represented digitally facilitate a simpler and faster determination of the specific device resources occupied by the target device for executing each algorithm service and each algorithm task.
[0052] Based on this Figure 2 The following is a flowchart illustrating a resource quantification method provided in an embodiment of this application, as shown in the figure. Figure 2 As shown, before performing step S103, the method includes steps S201-S203, specifically:
[0053] S201, quantify the target resource to obtain a digital representation of the target resource's resource quantification result.
[0054] Here, when quantifying the target resource, a preset resource occupancy value can be directly used as the resource quantification result of the target resource in digital representation.
[0055] For example, if the preset resource usage value is 100, the resource quantification result of the target resource can be determined as 100. The specific value of the above resource usage value can be flexibly adjusted according to the actual setting requirements. This application embodiment does not impose any mandatory limitation on the specific value of the above resource usage value.
[0056] S202, the resource quantification result is divided equally according to the maximum number of services that the target algorithm service can run simultaneously under the target resource, and this is used as the first resource occupancy result.
[0057] Here, the first resource usage result is used to represent the device resources used by the target device to execute each target algorithm service.
[0058] For example, taking the target algorithm service as the helmet detection algorithm service corresponding to the algorithm task "helmet detection task" (e.g., it can be the target detection model used to perform the helmet detection task), the target device can be the graphics card on the electronic device. If the graphics card can run a maximum of 5 helmet detection algorithm services at the same time under the condition of occupying 100 device resources (i.e., the resource quantification result of the target resources is 100), then it can be determined that the device resources occupied by the graphics card (i.e. the target device) to execute one helmet detection algorithm service is 20 (i.e., the first resource occupation result).
[0059] S203, based on the maximum number of tasks that can be executed simultaneously within the same target algorithm service, the first resource occupancy result is divided equally and used as the second resource occupancy result.
[0060] Here, the second resource usage result is used to represent the device resources used by the target device to execute the algorithm task.
[0061] For example, taking the example in step S202 above, if a helmet detection algorithm service can execute a maximum of 5 algorithm tasks "helmet detection tasks" at the same time, then the device resources occupied by executing a helmet detection algorithm service on the target device are 20. It can be calculated that the device resources occupied by the graphics card (i.e. the target device) to execute an algorithm task "helmet detection task" are 20 ÷ 5 = 4 (i.e., the second resource occupation result is 4).
[0062] Regarding the specific implementation of step S103 above, considering that the task execution plan may include multiple different algorithm tasks, and these multiple different algorithm tasks may correspond to multiple different algorithm services, as an optional embodiment, in the process of determining the optimal algorithm scheduling scheme, the processing order between different algorithm services and the processing order between multiple algorithm tasks corresponding to the same algorithm service can also be determined according to a certain priority order. Compared with the random processing method without sorting, this is beneficial to reduce the phenomenon of frequently modifying the algorithm scheduling scheme due to not meeting the basic goal or the optimization goal, thereby effectively improving the efficiency of formulating the optimal algorithm scheduling scheme.
[0063] Based on this Figure 3 This document illustrates a flowchart of a method for sequentially determining the sub-time periods allocated to different algorithm tasks, as provided in an embodiment of this application. Figure 3 As shown, when performing step S103, the method includes steps S301-S302, specifically:
[0064] S301, sort the multiple algorithm services in descending order of resource usage, and under the condition of satisfying the basic objective and the optimization objective, determine the sub-time period to which the corresponding algorithm task under each algorithm service is allocated according to the sorting result.
[0065] Here, the resource usage result is determined based on the device resources occupied by the target device in executing each algorithm service, and the aforementioned multiple algorithm services are determined based on the algorithm service corresponding to each algorithm task included in the task execution plan; the specific calculation method for the resource usage result can refer to the calculation method for the first resource usage result in the aforementioned step S202, and the repetition will not be repeated here.
[0066] For example, consider a task execution plan that includes 11 algorithm tasks, where algorithm task ad corresponds to algorithm service A, algorithm task eh corresponds to algorithm service B, and algorithm task ik corresponds to algorithm service C. If the resource quantification result of the target resource is 100, and according to the calculation method for the first resource occupancy result in step S202 above, the resource occupancy result of algorithm service A is calculated to be 40, the resource occupancy result of algorithm service B is 20, and the resource occupancy result of algorithm service C is 60, then according to the order of resource occupancy results from high to low, it can be determined that when formulating the optimal algorithm scheduling scheme, the corresponding sub-time period is first allocated to the algorithm task ik under algorithm service C (i.e., the algorithm service with the highest resource occupancy result), then the corresponding sub-time period is allocated to the algorithm task ad under algorithm service A (i.e., the algorithm service with the second highest resource occupancy result), and finally the corresponding sub-time period is allocated to the algorithm task eh under algorithm service B (i.e., the algorithm service with the lowest resource occupancy result).
[0067] S302, for each of the algorithm services, sort the multiple algorithm tasks corresponding to the algorithm service in descending order of coverage results, and under the condition of satisfying the basic objective and the optimization objective, determine the sub-time periods to be allocated to the multiple algorithm tasks in turn according to the sorting results.
[0068] Here, for each of the algorithm tasks, the coverage result corresponding to the algorithm task is determined based on the number of sub-time periods that match the executable time interval corresponding to the algorithm task and the number of target time periods; wherein, the number of target time periods is used to represent the number of unit time lengths covered by the task execution duration corresponding to the algorithm task.
[0069] For example, if the unit time length is 2 hours, and the task execution time corresponding to algorithm task a is 8 hours, then the target time period corresponding to algorithm task a is 4 (equivalent to needing to allocate 4 sub-time periods for algorithm task a).
[0070] Here, taking a preset time period of 1 day as an example, and dividing the preset time period into 12 sub-time periods according to a preset unit time length of 2 hours, assuming that the task execution plan includes a total of 11 algorithm tasks ak, where algorithm task ad corresponds to algorithm service A, algorithm task eh corresponds to algorithm service B, and algorithm task ik corresponds to algorithm service C, and the resource quantification result of the target resource is 100, as shown in Table 1 below, after calculating the first resource occupation result (i.e., occupied device resources) corresponding to each algorithm service and the second resource occupation result (i.e., occupied device resources) corresponding to each algorithm task according to the method shown in steps S202-S203 above, for each algorithm task, the number of target time periods (i.e., the number of sub-time periods to be allocated) corresponding to the algorithm task can be calculated based on the task execution time corresponding to the algorithm task. At this time, based on the executable time interval corresponding to each algorithm task, the sub-time periods that match the executable time interval corresponding to the algorithm task can also be marked from all the sub-time periods using target identifiers (such as √ identifiers). Specifically:
[0071]
[0072] Table 1
[0073] As illustrated in Table 1, referring to step S301 above, when formulating the optimal algorithm scheduling scheme, priority can be given to allocating corresponding sub-time periods to algorithm tasks ik under algorithm service C (i.e., the algorithm service with the highest resource consumption, i.e., the algorithm service that occupies the most device resources in Table 1). When determining the processing order between algorithm tasks ik, taking algorithm task i as an example, the number of sub-time periods matching the executable time interval corresponding to algorithm task i is 8 (i.e., a total of 8 sub-time periods marked with √ in the column where algorithm task i is located in Table 1) and the number of target time periods corresponding to algorithm task i (i.e., the number of sub-time periods that need to be allocated to algorithm task i in Table 1) is 6. Therefore, the coverage result for algorithm task i can be calculated as: 6 ÷ 8 = 75%. Similarly, the coverage result for algorithm task j can be calculated as: 10 ÷ 12 = 83%, and the coverage result for algorithm task k is: 3 ÷ 6 = 50%. Thus, according to the order of coverage results from high to low, when allocating the corresponding sub-time period for algorithm task ik under algorithm service C, priority should be given to allocating the corresponding sub-time period for algorithm task j (i.e., the algorithm task with the highest coverage result), then to algorithm task i (i.e., the algorithm task with the second highest coverage result), and finally to algorithm task k (i.e., the algorithm task with the lowest coverage result).
[0074] Specifically, taking the allocation of corresponding sub-time periods for algorithm task ik under algorithm service C as an example, as shown in Table 1, for each algorithm task, it is only necessary to select the target number of sub-time periods (i.e., the number of sub-time periods that need to be allocated to the algorithm task in Table 1) from the sub-time periods that match the executable time interval corresponding to the algorithm task (i.e., the sub-time periods marked with √ in the column where the algorithm task is located in Table 1), and ensure that the total device resources occupied by the currently selected algorithm task ik do not exceed the target resource of 100 to meet the basic objective.
[0075] Regarding the optimization objective, as an optional embodiment, based on the content shown in Table 1, as shown in Table 2 below, for each sub-time period, the total device resources occupied by the algorithm tasks that can be allocated within that sub-time period can be divided by the device resources occupied by the algorithm service (i.e., algorithm service C) corresponding to those algorithm tasks. The calculated result is used as the resource utilization rate for that sub-time period. A higher resource utilization rate indicates that the overall device resources occupied by the algorithm tasks executed within that sub-time period are closer to the target resources (i.e., a higher resource utilization rate better meets the optimization objective, thus allowing priority allocation of that sub-time period to the corresponding allocable algorithm tasks). Specifically:
[0076]
[0077] Table 2
[0078] For example, as shown in Table 2, taking the sub-time period from 0:00 to 2:00 as an example, the resource utilization rate corresponding to the sub-time period from 0:00 to 2:00 is (12+30)÷60=70%, where (12+30) represents the total device resources occupied by algorithm task i and algorithm task j that can be allocated within the sub-time period from 0:00 to 2:00, and 60 represents the device resources occupied by algorithm service C corresponding to algorithm task i and algorithm task j. For the calculation method of resource utilization rate corresponding to other sub-time periods in Table 2, you can refer to the specific calculation method of resource utilization rate corresponding to the sub-time period from 0:00 to 2:00. The repeated parts will not be repeated here.
[0079] Specifically, taking the allocation of sub-time periods for algorithm task j as an example, as shown in Table 1, it is known that 10 sub-time periods need to be allocated to algorithm task j from the 12 sub-time periods marked with √. As shown in Table 2, based on the currently calculated resource utilization rate, it can be determined that two sub-time periods with a resource utilization rate of 100% should be allocated to algorithm task j: "sub-time periods 6:00-8:00" and "sub-time periods 16:00-18:00". Furthermore, since "sub-time periods 6:00-8:00" and "sub-time periods 16:00-18:00" also match the executable time intervals of algorithm tasks i and k, in order to meet the optimization objective (equivalent to running as many algorithm tasks as possible within the same sub-time period), it can also be determined that "sub-time periods 6:00-8:00" and "sub-time periods 16:00-18:00" can be allocated to algorithm tasks i and k.
[0080] Based on this, since algorithm task k only needs to be allocated one more sub-time period to meet its execution conditions, as an optional embodiment, it is also possible to prioritize allocating one sub-time period to algorithm task k from the sub-time periods with higher resource utilization: "8:00-10:00", "10:00-12:00", "12:00-14:00", and "14:00-16:00" (as shown in Table 2; since the resource utilization rates corresponding to these four sub-time periods are the same, all being 80%, any one sub-time period can be randomly selected as the sub-time period to be allocated to algorithm task k). In this case, assuming the sub-time period allocated to algorithm task k is "8:00-10:00", then since algorithm task k has already been allocated, Table 2 can be updated by removing algorithm task k from the available algorithm tasks within the unselected sub-time periods and recalculating the resource utilization rate corresponding to each sub-time period, resulting in the updated Table 3. Specifically:
[0081]
[0082] Table 3
[0083] As illustrated in Table 3, after removing algorithm task k from the available algorithm tasks within the unselected sub-time periods (i.e., "sub-time periods 10:00-12:00", "sub-time periods 12:00-14:00", and "sub-time periods 14:00-16:00"), the recalculated resource utilization rates for "sub-time periods 10:00-12:00", "sub-time periods 12:00-14:00", and "sub-time periods 14:00-16:00" can be updated from 80% (i.e., (30+18)÷60=80%) in Table 2 to 50% (i.e., ... 30÷60=50%); At this point, based on the updated Table 3, sub-time periods can be allocated to algorithm task j and algorithm task i in descending order of resource utilization from the remaining sub-time periods (i.e., other sub-time periods besides "sub-time period 6 o'clock-8 o'clock" and "sub-time period 16 o'clock-18 o'clock") until algorithm task j is allocated 10 sub-time periods (i.e., the number of sub-time periods to be allocated) and algorithm task i is allocated 6 sub-time periods.
[0084] It should be noted that when allocating sub-time periods for algorithm task i or algorithm task j, for multiple sub-time periods with the same resource utilization (such as "sub-time period 0:00-2:00" and "sub-time period 2:00-4:00" in Table 3), one sub-time period can be arbitrarily allocated to algorithm task i or algorithm task j.
[0085] Specifically, when allocating sub-time periods to multiple algorithm tasks corresponding to algorithm service B and algorithm service A, the specific allocation method can be referred to the specific allocation method for algorithm task ik corresponding to algorithm service C in the previous example. The repetition will not be repeated here.
[0086] It should be noted that when allocating sub-time periods for algorithm task ad under algorithm task A, as shown in Table 1, there may be an abnormal situation where the resource utilization rate of a sub-time period exceeds 100% (e.g., the resource utilization rate of the sub-time period from 2 o'clock to 4 o'clock is (10+30+20+40)÷40=250%). In this case, as an optional embodiment, the algorithm task to be allocated in the sub-time period can be determined first. For example, taking the sub-time period from 2 o'clock to 4 o'clock, the algorithm task combination "algorithm task a and algorithm task b" with the highest resource utilization rate (equivalent to the overall device resources occupied by the algorithm task executed in the same sub-time period being closer to the device resources occupied by algorithm service A, 40%) and not exceeding 100% can be determined from the algorithm tasks ad that can be allocated in the sub-time period from 2 o'clock to 4 o'clock as the algorithm task to be allocated in the sub-time period from 2 o'clock to 4 o'clock.
[0087] In this application embodiment, referring to the above examples of allocating sub-time periods for algorithm tasks, it can be seen that when determining the optimal algorithm scheduling scheme, if the number of algorithm tasks and algorithm services involved in the task execution plan is large, multiple sub-time period allocation processes are often required. Due to the existence of priority order (i.e., the relevant sorting of algorithm services and algorithm tasks in the aforementioned steps S301-S302), it may be possible that when allocating sub-time periods for algorithm tasks with lower priority, the basic objective cannot be met (equivalent to the fact that when allocating sub-time periods for algorithm tasks with lower priority, the overall device resources occupied by the algorithm tasks executed in the sub-time periods that match the task execution conditions of the algorithm task have exceeded the target resources, resulting in the algorithm task not being allocated a sufficient number of sub-time periods).
[0088] At this point, the algorithm task that has the above situation can be marked as a blocked task; that is, when executing step S103, for any of the algorithm tasks, when it is detected that the number of sub-time periods allocated to the algorithm task is less than the number of target time periods under the conditions of satisfying the basic target and the optimization target (equivalent to the algorithm scheduling being unable to be performed in a way that matches the task execution conditions according to the currently determined optimal algorithm scheduling scheme), the electronic device can determine that the algorithm task belongs to a blocked task and mark the algorithm task as a blocked task in the optimal algorithm scheduling scheme, thereby indicating that when the available device resources are limited to the target resources, the marked blocked task cannot be scheduled according to the currently determined optimal scheduling scheme.
[0089] Specifically, for the marked blocked tasks mentioned above, as an optional embodiment, the electronic device can perform algorithmic scheduling of the blocked tasks according to the method shown in steps a1-a2 below:
[0090] Step a1: In response to detecting the marked blocked task, determine the idle device resources other than the target resource from the device resources of the target device.
[0091] Here, referring to the relevant description of the target resources in step S103 above, it can be seen that in this embodiment of the application, the target resources refer to the available device resources pre-configured for the task execution plan from the device resources of the target device. That is, because the target resources are the available device resources pre-configured for the task execution plan before the optimal algorithm scheduling scheme is formulated, rather than all the device resources of the target device, it is inevitable that task blocking may occur when the optimal algorithm scheduling scheme is actually formulated in the future.
[0092] At this time, in response to detecting the marked blocked task, the electronic device can first determine the remaining device resources other than the target resources from the device resources of the target device, and then determine the idle device resources from the remaining device resources as the aforementioned idle device resources.
[0093] Step a2: On the target device, invoke the idle device resources to execute the blocking task.
[0094] Here, electronic devices can call upon the aforementioned idle device resources as additional device resources required by the target device to execute the blocking task according to the task execution plan. Since the aforementioned idle device resources do not belong to the target resources, using the aforementioned idle device resources to execute the blocking task will not affect the smooth execution of the optimal algorithm scheduling scheme based on the target resources.
[0095] Specifically, for the marked blocking tasks mentioned above, as another optional embodiment, the electronic device can also perform algorithmic scheduling on the blocking tasks according to the method shown in steps b1-b2 below:
[0096] Step b1: In response to detecting the marked blocking task, display target prompt information on the graphical user interface corresponding to the target device.
[0097] Here, referring to the relevant description of the target device in step S101 above, it can be seen that since the target device can be the electronic device itself or a hardware device in the electronic device used to execute the task execution plan, the graphical user interface corresponding to the target device is also equivalent to the graphical user interface provided by the electronic device.
[0098] Specifically, the aforementioned target prompt information indicates a prompt regarding modifying the task execution conditions corresponding to the blocked task. After viewing the aforementioned target prompt information displayed on the graphical user interface, the user can choose to instruct the electronic device to re-formulate the optimal algorithm scheduling scheme according to the modified task execution conditions by modifying the task execution conditions corresponding to the blocked task. This overcomes the defect that the marked blocked task cannot be scheduled according to the previously determined optimal scheduling scheme.
[0099] It should be noted that this application embodiment does not impose any limitations on the specific information content or display style of the aforementioned target prompt information.
[0100] Step b2: In response to receiving the modified task execution conditions corresponding to the blocked task, and under the condition that the basic objective and the optimization objective are satisfied, the optimal algorithm scheduling scheme corresponding to the task execution plan is re-determined.
[0101] Here, in response to receiving the modified task execution conditions corresponding to the blocked task, the electronic device can update the basic target and the optimization target according to the modified task execution conditions corresponding to the blocked task. Then, based on the updated basic target and the optimization target, the optimal algorithm scheduling scheme corresponding to the task execution plan is re-determined in the same way as the aforementioned step S103. The repeated parts will not be described again here.
[0102] Based on the algorithm scheduling method provided in this application embodiment, the algorithm tasks that the target device needs to execute within a preset time period and the corresponding task execution conditions are determined from the task execution plan associated with the target device. The preset time period is divided into multiple sub-time periods, and the length of a sub-time period is equal to the length of a unit time. The basic objective is that the sub-time period allocated to each algorithm task matches the task execution conditions corresponding to each algorithm task, and the device resources occupied by the algorithm tasks executed within the same sub-time period do not exceed the target resources. The optimization objective is that the overall device resources occupied by the algorithm tasks executed within the same sub-time period are close to the target resources. Under the condition of satisfying the basic objective and the optimization objective, the algorithm tasks allocated for execution within each sub-time period are determined, and the optimal algorithm scheduling scheme corresponding to the task execution plan is obtained. On the target device, the algorithm scheduling is performed on each algorithm task according to the optimal algorithm scheduling scheme to obtain the algorithm scheduling result corresponding to the task execution plan. In this way, by subdividing the actual time period during which the target device can execute algorithm tasks, this application plans the specific execution time of each algorithm task on the target device in a more detailed and reasonable manner. This allows the target device to execute as many algorithm tasks as possible simultaneously within the limited available device resources, thereby effectively improving the utilization rate of the target device's device resources.
[0103] Based on the same inventive concept, this application also provides a computer program product corresponding to the above-described algorithm scheduling method. When the computer program product is executed by the processor, it can implement the steps of any of the algorithm scheduling methods described on the target device side. Since the principle of solving the problem by the computer program product in the embodiments of this application is similar to the above-described algorithm scheduling method in the embodiments of this application, the implementation of the computer program product can refer to the implementation of the above-described algorithm scheduling method, and the repeated parts will not be described again.
[0104] Based on the same inventive concept, this application also provides an electronic device corresponding to the above-mentioned algorithm scheduling method. Since the principle of solving the problem by the electronic device in the embodiments of this application is similar to that of the above-mentioned algorithm scheduling method in the embodiments of this application, the implementation of the electronic device can refer to the implementation of the above-mentioned algorithm scheduling method, and the repeated parts will not be described again.
[0105] Figure 4 The present application provides a schematic diagram of the structure of an electronic device 400, including a processor 401, a memory 402, and a bus 403. The memory 402 stores machine-readable instructions that can be executed by the processor 401. When the electronic device runs an algorithm scheduling method as described in the embodiment, the processor 401 communicates with the memory 402 through the bus 403, and the processor 401 executes the machine-readable instructions. When the processor 401 executes the machine-readable instructions, it implements the above-mentioned algorithm scheduling method.
[0106] Specifically, the memory 402 and processor 401 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 401 runs the computer program stored in the memory 402, it can execute the above-mentioned algorithm scheduling method.
[0107] Corresponding to the algorithm scheduling method in this application, this application embodiment also provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the steps of the above-described algorithm scheduling method.
[0108] Specifically, the storage medium can be a general-purpose storage medium, such as a removable disk or hard disk. When the computer program on the storage medium is run, it can execute the above-mentioned algorithm scheduling method.
[0109] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. The system embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interface; the indirect coupling or communication connection between systems or units may be electrical, mechanical, or other forms.
[0110] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0111] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0112] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0113] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0114] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.
Claims
1. An algorithm scheduling method, characterized by, The algorithm scheduling method includes: From the task execution plan associated with the target device, determine the algorithm tasks that the target device needs to execute within a preset time period and the task execution conditions corresponding to each algorithm task; wherein, the task execution conditions include: the executable time interval corresponding to the algorithm task and the task execution duration specified by the algorithm task within the executable time interval; According to the preset unit time length, the preset time period is divided into multiple sub-time periods, and the time length of one sub-time period is equal to the unit time length. Based on pre-set basic and optimization objectives, the algorithm tasks allocated for execution within each sub-time period are determined as the optimal algorithm scheduling scheme corresponding to the task execution plan. The basic objective refers to the matching of the sub-time period allocated to each algorithm task with the task execution conditions corresponding to each algorithm task, and the fact that the device resources occupied by the algorithm tasks executed within the same sub-time period do not exceed the target resources. The target resources represent the available device resources pre-configured for the task execution plan from the device resources of the target device. The optimization objective refers to maximizing the resource utilization rate corresponding to each sub-time period. The resource utilization rate is the calculated result obtained by dividing the total device resources occupied by the algorithm tasks executed within the sub-time period by the device resources occupied by the algorithm services corresponding to the algorithm tasks executed within the sub-time period. On the target device, each of the algorithm tasks is scheduled according to the optimal algorithm scheduling scheme; The algorithm scheduling method also includes: For each of the aforementioned algorithm tasks, the algorithm task is executed within a target algorithm service on the target device; wherein, the target algorithm service represents the algorithm service corresponding to the algorithm task. The step of determining the algorithm tasks assigned to be executed in each sub-time period based on pre-set basic and optimization objectives includes: Multiple algorithm services are sorted in descending order of resource usage. Under the condition of satisfying the basic objective and the optimization objective, the sub-time period allocated to the corresponding algorithm task under each algorithm service is determined according to the sorting result. The resource usage result is determined based on the device resources occupied by the target device when executing each algorithm service, and the multiple algorithm services are determined based on the algorithm service corresponding to each algorithm task. For each algorithm service, the multiple algorithm tasks corresponding to the algorithm service are sorted in descending order of coverage results. Under the condition of satisfying the basic objective and the optimization objective, the sub-time periods allocated to the multiple algorithm tasks are determined sequentially according to the sorting results. For each algorithm task, the coverage result corresponding to the algorithm task is determined based on the number of sub-time periods matching the executable time interval corresponding to the algorithm task and the target time period number. The target time period number represents the number of unit time lengths covered by the task execution duration corresponding to the algorithm task.
2. The algorithm scheduling method of claim 1, wherein, For each of the algorithm tasks, the device resources consumed by the target device in executing the algorithm task are determined by the following method: The target resource is quantified to obtain a digital representation of the target resource's resource quantification result; The resource quantification result is divided equally based on the maximum number of target algorithm services that can run simultaneously under the target resources, and this is used as the first resource occupancy result; wherein, the first resource occupancy result is used to represent the device resources occupied by the target device to execute each target algorithm service; The first resource occupancy result is divided equally according to the maximum number of algorithm tasks that can be executed simultaneously within the same target algorithm service, and the result is used as the second resource occupancy result; wherein, the second resource occupancy result is used to represent the device resources occupied by the target device in executing the algorithm task.
3. The method of claim 1, wherein, The algorithm scheduling method also includes: For any of the algorithm tasks, when it is detected that, under the conditions of satisfying the basic objective and the optimization objective, the number of sub-time periods allocated to the algorithm task is less than the target number of time periods, the algorithm task is marked as a blocked task in the optimal algorithm scheduling scheme.
4. The method of claim 3, wherein, After marking the algorithm task as a blocked task in the optimal algorithm scheduling scheme, the algorithm scheduling method further includes: In response to detecting the marked blocked task, free device resources other than the target resource are determined from the device resources of the target device; On the target device, the idle device resources are invoked to execute the blocking task.
5. The method of claim 3, wherein, After marking the algorithm task as a blocked task in the optimal algorithm scheduling scheme, the algorithm scheduling method further includes: In response to detecting the marked blocked task, a target prompt message is displayed on the graphical user interface corresponding to the target device; wherein the target prompt message indicates a prompt regarding modifying the task execution conditions corresponding to the blocked task; In response to receiving the modified task execution conditions corresponding to the blocked task, and under the condition that the basic objective and the optimization objective are satisfied, the optimal algorithm scheduling scheme corresponding to the task execution plan is re-determined.
6. A computer program product, characterised in that, When the computer program product is executed by the processor, it implements the steps of the algorithm scheduling method as described in any one of claims 1 to 5.
7. An electronic device, comprising: include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the algorithm scheduling method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the algorithm scheduling method as described in any one of claims 1 to 5.