Method for executing task, related device and computer program product
By determining the reference value and execution order of the subtask dependency in the directed acyclic graph, the task execution sequence is generated, and the problem of low scheduling efficiency of complex tasks is solved and more efficient task execution is achieved.
Patent Information
- Application Number
- CN202510128631.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-27
- Publication Date
- 2025-05-13
AI Technical Summary
In the execution of complex tasks, how to more effectively schedule the dependencies between subtasks, reduce computing resource requirements, and improve task processing quality and efficiency.
By determining the reference values of the superior node link that the target node simultaneously depends on in the directed acyclic graph, and determining the execution order based on these reference values, a task execution sequence is generated, and the subtask is finally executed.
It reduces content occupation during task execution and improves the overall task execution efficiency.
Smart Images

Figure CN119987971A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for performing a task, an electronic device, a computer-readable medium, and a computer program product. Background Art
[0002] With the development of computer technology, computers can be used in more scenarios and complete more complex tasks. Accordingly, in order to enable computers to better complete complex tasks with limited computing resources, or in other words, with fewer computing resources, complex tasks are often broken down into multiple simpler and more specific "subtasks". Then, computers complete complex tasks by completing these "subtasks" step by step and continuously.
[0003] For example, in the field of image rendering, the complex task of image rendering can be specifically divided into modeling subtasks, material and texture mapping subtasks, and lighting model subtasks, etc. Then, the computer completes the complex task of image rendering by completing these subtasks in succession.
[0004] In this context, for these complex tasks that need to be completed in the form of "subtasks", how to more effectively perform scheduling between tasks, how to reduce the demand for computing resources, and how to improve the processing quality and efficiency of tasks are worthy of attention and urgent needs. Summary of the invention
[0005] Multiple aspects of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for executing a task. In the process of scheduling and determining the execution order of each subtask based on the dependency relationship between the subtasks of the task, for a target node that depends on at least two upper-level node links at the same time, the subtask in the upper-level node link with a higher reference value and more steps is first executed. Thus, while being able to reduce the content occupancy in the task execution process, the overall execution efficiency of the task is improved.
[0006] In one aspect of the present application, a method for executing a task is provided, comprising: in response to a target node in a directed acyclic graph of a subtask for a target task being dependent on at least two different superior node links at the same time, determining a reference value corresponding to each superior node link with the target node as an end point, wherein the nodes of the directed acyclic graph are subtasks, and the edges of the directed acyclic graph are used to indicate the task dependency relationship between subtasks; based on the size of the reference value, determining the execution order between the superior node links, wherein the order of execution is positively correlated with the size of the reference value; based on the directed acyclic graph and the execution order, generating a task execution sequence for the target task; and executing the subtasks based on the execution order between the subtasks indicated by the task execution sequence.
[0007] On the other hand, the present application provides an apparatus for executing a task, comprising: a link reference value determination unit, configured to determine the reference values corresponding to each upper-level node link with the target node as the end point in response to the target node in the directed acyclic graph of the subtask of the target task relying on at least two different upper-level node links at the same time, wherein the nodes of the directed acyclic graph are subtasks, and the edges of the directed acyclic graph are used to indicate the task dependency relationship between the subtasks; a link order determination unit, configured to determine the execution order between the upper-level node links based on the size of the reference value, wherein the order of execution is positively correlated with the size of the reference value; an execution sequence generation unit, configured to generate a task execution sequence for the target task based on the directed acyclic graph and the execution order; a target task execution unit, configured to execute the subtask based on the execution order between the subtasks indicated by the task execution sequence.
[0008] Another aspect of the present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method for performing tasks provided above.
[0009] In another aspect of the present application, a computer-readable storage medium is provided, on which computer program instructions are stored. The computer program instructions can be executed by a processor to implement the method for performing tasks provided above.
[0010] In another aspect of the present application, a computer program product includes a computer program having computer program instructions stored thereon. When the computer program is executed by a processor, the method for performing tasks as provided above can be implemented.
[0011] In the scheme provided by the embodiment of the present application, first, in response to the target node in the directed acyclic graph of the subtask for the target task relying on at least two different superior node links at the same time, the reference values corresponding to the respective superior node links with the target node as the end point are determined, wherein the nodes of the directed acyclic graph are subtasks, and the edges of the directed acyclic graph are used to indicate the task dependencies between the subtasks. Then, based on the size of the reference value, the execution order between the superior node links is determined, wherein the order of execution is positively correlated with the size of the reference value. Next, based on the directed acyclic graph and the execution order, a task execution sequence for the target task is generated. Finally, based on the execution order between the subtasks indicated by the task execution sequence, the subtasks are executed. Thus, while being able to reduce the content occupancy in the task execution process, the overall execution efficiency of the task is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0013] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0014] Figure 1 A flowchart of a process for executing a task provided in an embodiment of the present application;
[0015] Figure 2 A schematic diagram of the effect of a directed acyclic graph implemented in a specific application scenario provided by an embodiment of the present application;
[0016] Figure 3 A flowchart of a process of calling a thread to execute a first subtask provided in an embodiment of the present application;
[0017] Figure 4 A schematic diagram of the structure of a device for performing a task provided in an embodiment of the present application;
[0018] Figure 5 The present invention is a schematic diagram of the structure of an electronic device suitable for implementing the solution in the embodiment of the present application.
[0019] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0021] In a typical configuration of the present application, the terminal and the equipment of the service network each include one or more processors (CPU), input / output interface, network interface and memory.
[0022] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0023] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer program instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0024] As discussed above, how to more effectively perform scheduling between tasks, how to reduce the demand for computing resources, and how to improve the processing quality and efficiency of tasks are worthy of attention and urgent needs.
[0025] In some schemes, based on the dependency relationship between subtasks, it is chosen to first execute the (superior) subtasks that are dependent on other subtasks, and then execute the (subordinate) subtasks that depend on these (superior) subtasks.
[0026] However, in such a process, a subtask may depend on two or more other subtasks at the same time. For such a situation, some solutions choose to adopt a method such as random scheduling to determine the execution order between the two subtasks (for example, randomly arrange the execution order between two or more upper-level subtasks). However, in such a method, not only may the system memory be in a peak state for a long time (for example, a large number of subtasks "waiting" leads to long-term and excessive memory occupation) because the waiting time of "ready but not yet used" resources is too long (for example, the completed upper-level subtask is waiting for the output results of other upper-level subtasks, so that its output "resources" are occupied for a long time), but it may also have a negative impact on the overall processing efficiency of the task.
[0027] In this regard, an embodiment of the present application provides a method for executing a task, which responds to the target node in the directed acyclic graph of the subtask of the target task relying on at least two different superior node links at the same time, determines the reference values corresponding to each superior node link with the target node as the end point, the nodes of the directed acyclic graph are subtasks, and the edges are used to indicate the task dependencies between subtasks; based on the size of the reference value, the execution order between each superior node link is determined, and the order of execution is positively correlated with the size of the reference value; based on the directed acyclic graph and the execution order, a task execution sequence for the target task is generated; based on the execution order between the subtasks indicated by the task execution sequence, the subtask is executed. Thus, while being able to reduce the content occupancy in the task execution process, the overall execution efficiency of the task is improved.
[0028] In actual scenarios, the execution subject of the method can be a user device, or a device formed by integrating a user device and a network device through a network, or an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, tablet computers, smart watches, and bracelets. The network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing (Cloud Computing), where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.
[0029] When the execution subject is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here.
[0030] Figure 1 A process 100 for executing a task provided by an embodiment of the present application is shown. The process 100 includes at least the following processing steps:
[0031] (Step) S101, in response to a target node in a directed acyclic graph of a subtask of a target task being dependent on at least two different upper-level node links at the same time, determining reference values corresponding to respective upper-level node links with the target node as an end point.
[0032] In an embodiment of the present application, an execution subject (for example, a server or user equipment instructed to process a complex task, etc.) may obtain a directed acyclic graph (DAG) of subtasks for a target task.
[0033] As discussed above, the target task may be a "complex task" that is actually composed of and implemented by multiple subtasks. For example, the target task is the above-mentioned image rendering task, and correspondingly, these subtasks may be, for example, modeling subtasks of various parts of the image, material and texture mapping subtasks, and lighting model subtasks, etc.
[0034] In some embodiments, the subtask may include a first subtask executed by a central processing unit (CPU) and a second subtask executed by a graphics processing unit (GPU). Thus, tasks implemented and executed by different components can be coordinated and scheduled to improve the applicable scenarios of the method for executing tasks provided in the embodiments of the present application.
[0035] For example, in this way, in the scenario of using the Render Graph architecture to implement image rendering, in addition to scheduling GPU tasks, the CPU scheduling tasks are comprehensively introduced, so that it can be expanded into a more general computing framework Work Graph to meet the richness and flexibility of image rendering business needs.
[0036] A directed acyclic graph is a special graph structure consisting of "nodes" (or vertices) and "edges", where each edge has a clear direction and the entire graph is acyclic, that is, there is no path that can start from a node and return to the vertex after passing through a series of edges. Accordingly, a directed acyclic graph can be used to describe the dependency relationship between the various subtasks of the target task.
[0037] In some embodiments, the directed acyclic graph of the target task, or the directed acyclic graph of the subtasks of the target task, may correspond to the subtasks of the target task, and the edges may be used to indicate the task dependencies between the nodes and the subtasks. Thus, based on the directed acyclic graph of the subtasks of the target task, the execution subject may determine the task dependencies between the subtasks.
[0038] Next, if the target node in the directed acyclic graph of the subtask of the target task depends on at least two different upper-level node links at the same time, the execution subject can respond to this and determine the reference values corresponding to each upper-level node link with the target node as the end point.
[0039] The upper node link of the target node may be composed of one or more subtasks, and the processing results of the one or more subtasks (ie, the complete processing results of the upper node link) are dependent on the subtask corresponding to the target node.
[0040] For example, for subtask C1, if it depends on the processing result of subtask A1-subtask B2 (subtask B2 depends on the processing result of subtask A1) (subtask C1 depends on the processing result of subtask B2), then the nodes corresponding to subtask A1 and subtask B2 constitute the "upper node link" of the node corresponding to subtask C1.
[0041] Accordingly, if a subtask depends on at least two such “upper node links” at the same time, the node of the subtask can be called a “target node”.
[0042] Next, for the target node, the execution subject may determine the reference values corresponding to each upper-level node link with the target node as the end point.
[0043] For ease of understanding, for the reference values corresponding to each of the upper-level node links, an upper-level node link can be taken as an example. For the upper-level node link, the execution subject can first take the "first position" node in the upper-level node link as the starting point based on the position order indicated by the directed acyclic graph. For example, in the above-mentioned example of subtask A1 and subtask B2, the node corresponding to subtask A1 can be determined as the "starting point" of the "first position".
[0044] Then, the execution subject reads the number of "edges" from the starting point to the target node in the directed acyclic graph. Accordingly, after reading the number of "edges", the execution subject can use the product of the number of "edges" and the corresponding unit quantity (the unit quantity can usually be set to "1") as the "reference value" corresponding to the link of the upper node.
[0045] In some embodiments, the "reference value" can also be determined by multiplying the "in-degree" of the target node of the starting point value of the superior node link by the unit quantity.
[0046] In some embodiments, in order to distinguish the importance of certain "edges", the coefficients used to calculate the reference value can also be configured differently for the "edges". For example, for some "edges", they can be pre-configured "coefficients" so that when they are used to calculate the reference value, they are counted in, for example, twice the unit amount. For example, for the "upper node link" composed of subtask A1 and subtask B2, if it is not configured with the corresponding coefficient, when calculating the reference value, it may correspond to "2" unit amounts (specifically, subtask A1 and subtask B2 are "1", and subtask B1 and subtask C1 are "1"); and when it is configured with the corresponding coefficient, when calculating the reference value, it may correspond to "3" unit amounts (specifically, subtask A1 and subtask B2 can be counted in "2" unit amounts because they are configured with coefficients, and subtask B1 and subtask C1 are "1").
[0047] Similarly, for some subtasks that may be more important, more expected to be paid attention to, or have priority execution, the subtasks can be assigned corresponding unit quantities so that the execution subject can add the unit quantities of the corresponding subtasks (or nodes) when calculating the reference value, and synchronously refer to the priority of the "subtask" itself to be executed.
[0048] S102, determining the execution order between the links of each upper node based on the size of the reference value.
[0049] In the embodiment of the present application, after the reference values corresponding to the upper node links are determined based on the above S101, the execution subject can determine the execution order corresponding to each upper node link based on the reference value. The execution order is positively correlated with the size of the reference value.
[0050] For example, when the reference value corresponding to the upper node link L1 is 6, the reference value corresponding to the upper node link L2 is 5, and the reference value corresponding to the upper node link L3 is 7, the execution order for the upper node links L1, L2, and L3 is upper node link L3→upper node link L1→upper node link L2.
[0051] S103: Generate a task execution sequence for the target task based on the directed acyclic graph and the execution order.
[0052] In an embodiment of the present application, the execution subject generates a task execution sequence for the target task in this step based on the dependency order between subtasks indicated by the directed acyclic graph and the mutual execution order between the upper-level node links before the target node.
[0053] For easier understanding, you can also refer to Figure 2 . Figure 2 A schematic diagram showing the effect of a directed acyclic graph 200 implemented in a specific application scenario provided by an embodiment of the present application is shown.
[0054] In the directed acyclic graph 200 , only nodes 201 to 207 are shown by way of example.
[0055] Accordingly, based on directed acyclic graph 200, it can be seen that the subtask corresponding to node 203 depends on the subtask corresponding to node 201, the subtask corresponding to node 205 depends on the subtask corresponding to node 204, the subtask corresponding to node 206 depends on the subtask corresponding to node 205, and the subtask corresponding to node 207 depends on the subtasks corresponding to nodes 202, 203 and 206.
[0056] Accordingly, as discussed above, node 207 is a "target node" that depends on at least two upper-level node links (for example, depends on the upper-level node link corresponding to node 202; the upper-level node link corresponding to node 201 and node 203; and the upper-level node links corresponding to node 204, node 205 and node 206).
[0057] In such a case, the execution subject can at least be based on the reference value corresponding to each upper node link with the target node as the end point. For example, the reference value of the upper node link corresponding to node 202 is 1, the reference value of the upper node link corresponding to nodes 201 and 203 is 2, and the reference value of the upper node link corresponding to nodes 204, 205 and 206 is 3.
[0058] Accordingly, the execution subject can determine the execution order of each upper-level node link based on the size of the reference value, that is, first execute the upper-level node links corresponding to node 204, node 205 and node 206; then execute the upper-level node links corresponding to node 201 and node 203; and finally execute the upper-level node link corresponding to node 202.
[0059] Then, after completing the upper node link corresponding to node 202, node 207 is executed.
[0060] It should be understood that, in practice, there may be situations where the reference values are equivalent. In such a case, the execution entity can determine the execution order between the upper-level node links based on pre-configured rules (for example, arbitrarily selecting the execution order of the upper-level node links with the same reference values, or giving priority to the upper-level node links with more subtasks, etc.), which will not be elaborated here.
[0061] S104, executing the subtasks based on the execution order between the subtasks indicated by the task execution sequence.
[0062] In the embodiment of the present application, the execution subject can sequentially and continuously execute each subtask based on the task execution sequence determined in S103, thereby actually and finally completing the target task by executing and completing each subtask.
[0063] In some embodiments, as discussed above, subtasks can actually be performed by different components. For the first subtask performed by the CPU, the execution subject can extract and determine the corresponding thread from a pre-configured thread pool, and then perform the first subtask by calling the corresponding thread.
[0064] In some embodiments, in order to more effectively utilize the threads in the CPU, the thread pool can be pre-configured differently according to the processing priorities of different subtasks, so as to more effectively utilize computing resources while avoiding delays in processing of important subtasks due to unreasonable thread allocation, thereby affecting the overall processing efficiency of the target task.
[0065] For example, for a specific subtask, if its corresponding task priority is the highest, the execution subject can choose to directly schedule the currently available thread for the subtask to execute the subtask. If its corresponding task priority is not the highest, the execution subject can choose to detect whether there are other subtasks with higher task priority than this subtask. If not, the execution subject will choose to schedule the currently available thread for it. In this way, the "priority preemption" method is used to ensure that high-priority subtasks will be executed first.
[0066] In some embodiments, the thread pools may be configured differently to reduce the cost of comparing the task priorities of existing subtasks.
[0067] Specifically, you can choose to configure the corresponding thread pools corresponding to different task priorities. For example, for the high task priority level, it can correspond to thread pool 1, so that when there are threads currently in an available state in thread pool 1, threads are directly provided for subtasks with high task priorities; and for the low task priority level, it can correspond to thread pool 2, so that when there are threads currently in an available state in thread pool 2, threads are directly provided for subtasks with low task priorities.
[0068] In some optional implementations of the present embodiment, for a subtask with a high task priority, when there is a lack of available threads in its corresponding thread pool, the execution subject may also call a thread in the corresponding thread pool with a low task priority to allocate a thread to the high-priority subtask more preferentially than to the low-priority subtask.
[0069] For this, you can also refer to Figure 3 . Figure 3 The embodiment of the present application shows a process 300 of calling a thread to execute a first subtask. The process 300 can be implemented as an alternative or substitute of S104 when the subtask currently being executed is the first subtask.
[0070] The process 300 includes at least the following processing steps:
[0071] S301, based on the task priority of the first subtask, determining a first thread pool corresponding to the task priority.
[0072] Specifically, as discussed above, the task priorities of the subtasks may be divided in advance based on the “importance” and “task priority” corresponding to each subtask, so that the subtasks may be processed differently and thread scheduling strategies may be executed.
[0073] For example, based on the configuration, the execution entity can determine subtasks such as action calculations and lighting calculations executed by the CPU as high task priorities, while subtasks such as post-effect processing and light mapping are determined as low task priorities compared to the above high task priorities.
[0074] S302: Detect whether there is a first thread in the first thread pool that is currently in an available state.
[0075] Specifically, as discussed above, the execution subject can configure an independent thread pool corresponding to different task priorities. Accordingly, after determining the task priority corresponding to the subtask, the execution subject can detect whether there is a first thread in an available state in the thread pool corresponding to the task priority (for convenience of description, it is referred to as the first thread pool).
[0076] If there is currently an available first thread in the first thread pool, the execution body may continue to execute S303 to assign the currently available first thread to the first subtask. After completing S303, the execution body may continue to execute S304 to call the first thread to execute the assigned first subtask.
[0077] S303, assigning the first thread to the first subtask;
[0078] S304: Call the first thread to execute the first subtask.
[0079] In some optional implementations of this embodiment, as discussed above, if in the above S302, it is determined that there is no first thread in the first thread pool that is currently in an available state, the execution subject may choose to further execute S305 to detect whether there is a second thread in the second thread pool with a low task priority that is currently in an available state. Accordingly, the task priority of the corresponding subtask of the second thread pool is lower than that of the first thread pool.
[0080] S305: Detect whether there is a second thread in an available state in the second thread pool.
[0081] If there is currently an available second thread in the second thread pool, the execution subject may respond to this and execute S306 to assign the second thread to the first subtask. And after completing S306, the execution subject may continue to execute S307 to call the assigned second thread to execute the first subtask.
[0082] S306: Allocate the second thread to the first subtask.
[0083] S307: Call the second thread to execute the first subtask.
[0084] It should be understood that multiple thread pools can be configured, and the above embodiments do not expect to limit the number of "thread pools". For example, the first thread pool is for "high task priority", and the second thread pool is for "medium task priority". Later, a third thread pool for "low task priority" can be configured, and so on.
[0085] Accordingly, if there are multiple thread pools, and if there are multiple thread pools with a task priority lower than the thread pool corresponding to the current subtask, the execution subject can start from the thread pool with the lowest task priority and sequentially search for thread pools that can provide threads in the direction of higher task priority. In this way, threads in thread pools with lower task priorities can be more fully utilized to avoid delays in processing of more important subtasks.
[0086] In some embodiments, if there is no lower-level thread pool, the execution subject may temporarily "suspend" the subtask to wait for an idle thread to appear in its corresponding thread pool that can be used by it.
[0087] In some embodiments, if a lower-level thread pool also cannot provide a thread, the execution subject may similarly "suspend" the subtask and wait for threads in the corresponding thread pool and the threads in these lower-level thread pools to appear and be available for use.
[0088] In some embodiments, the first thread pool and / or the second thread pool can be constructed based on a job system. A job system is a framework for processing and scheduling tasks (or jobs), which manages multithreaded code by creating jobs instead of threads. Each job is an independent work unit, and the worker thread obtains these jobs from the job queue and executes them. The thread pool constructed based on the job system can more effectively utilize the threads in the thread pool to improve the parallel processing capability and efficiency between the threads in the thread pool.
[0089] In some embodiments, the subtask corresponding to the target node actually depends on the final execution results and output resources of each upper-level node link. Therefore, in the process of executing the subtasks in "each upper-level node link", the "entire upper-level node link" can actually be used as the execution dimension to concurrently execute at least two upper-level node links to improve the overall execution efficiency.
[0090] For example, in a task execution sequence, the entire "superior node link" can be regarded as a whole. When the execution order of the two is adjacent and there is no dependency relationship between each other, two entire "superior node links" can be selected in parallel (or, multiple "superior node links" in adjacent order can be selected in parallel). For example, for subtask C1, if it depends on subtask A1-subtask B2 and subtask A2-subtask B3 at the same time, then if there is no dependency relationship between subtasks A1 and A2, there is no dependency relationship between subtask B2 and subtasks A2 and B3, and there is no dependency relationship between subtask B3 and subtasks A1 and B2, the execution subject can choose to run "subtask A1-subtask B2" and "subtask A2-subtask B3" in parallel.
[0091] In some embodiments, during the parallel "upper node link" process, the execution entity can choose to temporarily lock the subtask corresponding to the target node through mechanisms such as Mutex (mutual exclusion lock) and Fence (fence), so that the target node can wait until all "upper node links" are completed before being executed.
[0092] Accordingly, for the case where the subtask currently being executed is the subtask corresponding to the target node, when executing the subtask, if at least two of the upper-level node links are executed in a concurrent manner, the executing subject may further choose to execute the subtask in response to determining that the subtasks in the upper-level node links that the target node depends on at the same time have been completed.
[0093] Then, the method for executing tasks provided by the present application, in response to the target node in the directed acyclic graph of the subtask of the target task relying on at least two different superior node links at the same time, determines the reference values corresponding to each superior node link with the target node as the end point, wherein the nodes of the directed acyclic graph are subtasks, and the edges of the directed acyclic graph are used to indicate the task dependencies between subtasks; based on the size of the reference value, determines the execution order between each superior node link, wherein the order of execution is positively correlated with the size of the reference value; based on the directed acyclic graph and the execution order, generates a task execution sequence for the target task; based on the execution order between the subtasks indicated by the task execution sequence, executes the subtask. Thus, while being able to reduce the content occupation during the task execution process, the overall execution efficiency of the task is improved.
[0094] Based on any of the above embodiments, if the management user of the target task (for example, the controlling user of the execution entity) wishes to adjust the target task (for example, add a new subtask), he or she may send updated subtasks (one or more in number) for the target task to the execution entity.
[0095] Accordingly, if the execution subject receives an update subtask for the target task, it can respond to it and update the directed acyclic graph based on the task dependency of the update subtask. For example, based on the task dependency between the update subtask and the existing subtask, it can be inserted into the existing directed acyclic graph to update the existing directed acyclic graph.
[0096] Accordingly, if the update subtask is located after (all) the target nodes, this update will not actually affect the execution order between the previous upper node links, and the execution subject can only update the existing task execution sequence based on the location of the update subtask and whether a new "target node" is generated. Then, the execution subject executes each subtask based on the execution order between the subtasks indicated by the updated task execution sequence.
[0097] If the update subtask is located before the target node, the execution subject can also respond to this and re-determine the reference values corresponding to each upper node link with the target node as the end point based on the updated directed acyclic graph. That is, because the added update subtask is located before the target node, the execution subject needs to re-determine the reference values of the upper node links affected by the addition of the update subtask according to the newly added update subtask.
[0098] Then, the execution subject further re-determines the execution order between each upper node link based on the size of the re-determined reference value, similarly to the above discussion. Then, based on the updated directed acyclic graph and the re-determined execution order, a task execution sequence for the target task is generated, similarly to the above discussion.
[0099] As a result, users can adjust target tasks according to their needs in a personalized and low-cost manner.
[0100] The present application also provides a device for executing a task, the structure of which is as follows: Figure 4The device 400 shown. The device 400 includes: a link reference value determination unit 410, configured to determine the reference values corresponding to each upper-level node link with the target node as the end point in response to the target node in the directed acyclic graph of the subtask of the target task relying on at least two different upper-level node links at the same time, wherein the nodes of the directed acyclic graph are subtasks, and the edges of the directed acyclic graph are used to indicate the task dependency relationship between subtasks; a link order determination unit 420, configured to determine the execution order between each upper-level node link based on the size of the reference value, wherein the order of execution is positively correlated with the size of the reference value; an execution sequence generation unit 430, configured to generate a task execution sequence for the target task based on the directed acyclic graph and the execution order; a target task execution unit 440, configured to execute the subtask based on the execution order between the subtasks indicated by the task execution sequence.
[0101] In some embodiments, the subtasks include: a first subtask executed by a central processing unit and a second subtask executed by a graphics processing unit.
[0102] In some embodiments, in response to the subtask currently being executed being the first subtask, the target task execution unit 440 is further configured to execute the subtask in the following manner: based on the task priority of the first subtask, determine the first thread pool corresponding to the task priority; in response to the first thread currently existing in the first thread pool and being in an available state, assign the first thread to the first subtask; and call the first thread to execute the first subtask.
[0103] In some embodiments, in response to the subtask currently being executed being the first subtask, the target task execution unit 440 can be further configured to execute the subtask in the following manner: in response to the first thread pool not currently having an available first thread, detecting whether the second thread pool currently has an available second thread, wherein the task priority of the corresponding subtask of the second thread pool is lower than that of the first thread pool; in response to the second thread pool currently having an available second thread, assigning the second thread to the first subtask; and calling the second thread to execute the first subtask.
[0104] In some embodiments, the first thread pool and / or the second thread pool are constructed based on a job system.
[0105] In some embodiments, in response to the subtask currently being executed being the subtask corresponding to the target node, the target task execution unit 440 is further configured to execute the subtask in the following manner: in response to determining that the subtasks in each upper-level node link that the target node depends on at the same time have been executed, the subtask is executed, wherein at least two of the upper-level node links are executed separately in a concurrent manner.
[0106] In some embodiments, the device 400 also includes: a directed acyclic graph update unit, configured to update the directed acyclic graph in response to receiving an update subtask for the target task based on the task dependencies of the update subtask; a link reference value update unit, configured to redetermine the reference values corresponding to each upper node link with the target node as the end point based on the updated directed acyclic graph in response to the update subtask being located before the target node; a link order update unit, configured to redetermine the execution order between each upper node link based on the size of the redetermined reference value; and an execution sequence update unit, configured to generate a task execution sequence for the target task based on the updated directed acyclic graph and the redetermined execution order.
[0107] The embodiment of the present device corresponds to the method embodiment as shown in the above figures. First, in response to the target node in the directed acyclic graph of the subtask of the target task relying on at least two different superior node links at the same time, the reference values corresponding to each superior node link with the target node as the end point are determined, wherein the nodes of the directed acyclic graph are subtasks, and the edges of the directed acyclic graph are used to indicate the task dependencies between subtasks. Then, based on the size of the reference value, the execution order between each superior node link is determined, wherein the order of execution is positively correlated with the size of the reference value. Next, based on the directed acyclic graph and the execution order, a task execution sequence for the target task is generated. Finally, based on the execution order between the subtasks indicated by the task execution sequence, the subtasks are executed. Thus, while being able to reduce the content occupancy during the task execution process, the overall execution efficiency of the task is improved.
[0108] Based on the same inventive concept, an electronic device, a readable storage medium and a computer program product are also provided in the embodiments of the present application. The method corresponding to the electronic device may be the method for performing a task in the aforementioned embodiment, and its principle of solving the problem is similar to that of the method. The electronic device provided in the embodiments of the present application includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the methods and / or technical solutions of the aforementioned multiple embodiments of the present application.
[0109] The electronic device may be a user device, or a device formed by integrating a user device and a network device through a network, or an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, tablet computers, smart watches, and bracelets. The network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, which can be used to implement some processing functions when setting an alarm. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.
[0110] Figure 5 The structure of an electronic device suitable for implementing the method and / or technical solution in the embodiment of the present application is shown, and the electronic device 500 includes a central processing unit (CPU, Central Processing Unit) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM, Read Only Memory) 502 or the program loaded from the storage part 508 to the random access memory (RAM, Random Access Memory) 503. In RAM 503, various programs and data required for system operation are also stored. CPU 501, ROM 502 and RAM 503 are connected to each other through bus 505. Input / output (I / O, Input / Output) interface 504 is also connected to bus 505.
[0111] The following components are connected to the I / O interface 504: an input section 506 including a keyboard, a mouse, a touch screen, a microphone, an infrared sensor, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), an LED display, an OLED display, etc., and a speaker, etc.; a storage section 508 including one or more computer-readable media such as a hard disk, an optical disk, a magnetic disk, a semiconductor memory, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet.
[0112] In particular, the methods and / or embodiments in the embodiments of the present application may be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. When the computer program is executed by the central processing unit (CPU) 501, the above functions defined in the method of the present application are executed.
[0113] Another embodiment of the present application further provides a computer-readable storage medium and a computer program product, on which computer program instructions are stored. The computer program instructions can be executed by a processor to implement the methods and / or technical solutions of any one or more embodiments of the present application.
[0114] Specifically, the present embodiment can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, systems, devices or devices including but not limited to electricity, magnetism, light, electromagnetic, infrared, or semiconductors, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0115] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0116] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0117] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0118] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0119] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0120] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules and units is only a logical function division. There may be other division methods in actual implementation. For example, with units as an example, multiple units or page components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0121] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0122] In addition, each functional module or unit in each embodiment of the present application may be integrated into one processing module or unit, or each module or unit may exist physically separately, or two or more units may be integrated into one module or unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules or units.
[0123] The above-mentioned integrated modules and units implemented in the form of software function modules and units can be stored in a computer-readable storage medium. The above-mentioned software function modules and units are stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
[0125] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in a device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A method for performing a task, comprising: In response to a target node in a directed acyclic graph of a subtask of a target task being dependent on at least two different superior node links at the same time, determining reference values corresponding to respective superior node links with the target node as an end point, wherein the nodes of the directed acyclic graph are the subtasks, and the edges of the directed acyclic graph are used to indicate task dependency relationships between the subtasks; Based on the size of the reference value, determining the execution order between the links of each upper node, wherein the order of execution is positively correlated with the size of the reference value; Based on the directed acyclic graph and the execution order, generating a task execution sequence for the target task; The subtasks are executed based on the execution order between the subtasks indicated by the task execution sequence.
2. The method according to claim 1, wherein: The subtasks include: a first subtask executed by a central processing unit and a second subtask executed by a graphics processing unit.
3. The method according to claim 2, wherein: In response to the subtask currently being executed being the first subtask, executing the subtask includes: Based on the task priority of the first subtask, determining a first thread pool corresponding to the task priority; In response to the first thread pool currently having a first thread in an available state, allocating the first thread to the first subtask; The first thread is called to execute the first subtask.
4. The method according to claim 3, further comprising: In response to the first thread pool not currently having a first thread in an available state, detecting whether a second thread in a second thread pool currently has a second thread in an available state, wherein a task priority of a subtask corresponding to the second thread pool is lower than that of the first thread pool; In response to the second thread currently existing in the second thread pool and being in an available state, allocating the second thread to the first subtask; The second thread is called to execute the first subtask.
5. The method according to claim 4, wherein: The first thread pool and / or the second thread pool are constructed based on a job system.
6. The method according to claim 1, wherein: In response to the subtask currently being executed being the subtask corresponding to the target node, executing the subtask includes: In response to determining that the subtasks in each of the upper-level node links that the target node depends on simultaneously have been executed, the subtasks are executed, wherein at least two of the upper-level node links in each of the upper-level node links are executed separately in a concurrent manner.
7. The method according to any one of claims 1 to 6, further comprising: In response to receiving an update subtask for the target task, updating the directed acyclic graph based on task dependencies of the update subtask; In response to the update subtask being located before the target node, re-determining the reference values corresponding to the respective upper-level node links with the target node as the end point based on the updated directed acyclic graph; Based on the re-determined reference value, re-determine the execution order between the links of each upper node; Based on the updated directed acyclic graph and the re-determined execution order, a task execution sequence for the target task is generated.
8. A device for performing a task, comprising: A link reference value determination unit is configured to determine the reference values corresponding to the respective upper-level node links with the target node as the end point in response to the target node in the directed acyclic graph of the subtask of the target task relying on at least two different upper-level node links at the same time, wherein the nodes of the directed acyclic graph are the subtasks, and the edges of the directed acyclic graph are used to indicate the task dependency relationship between the subtasks; A link sequence determination unit is configured to determine the execution sequence between the links of each upper node based on the size of the reference value, wherein the order of the execution sequence is positively correlated with the size of the reference value; an execution sequence generating unit, configured to generate a task execution sequence for the target task based on the directed acyclic graph and the execution order; The target task execution unit is configured to execute the subtasks based on the execution order between the subtasks indicated by the task execution sequence.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A computer-readable medium, characterized in that Computer program instructions are stored thereon, and the computer program instructions can be executed by a processor to implement the method as claimed in any one of claims 1 to 7.
11. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 7.
Citation Information
Cited By
Data link optimization processing method and data link optimization processing device
CN120407124A