Processing method, processing device, electronic equipment, medium and program product

By issuing and executing dependent tasks on the graphics processing unit in advance, the long-tail effect problem in the execution of dependent tasks on the graphics processing unit is solved, and the task execution efficiency and overall computing performance are improved.

CN118626259APending Publication Date: 2024-09-10SHANGHAI BIREN TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410742428.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

On the graphics processing unit, there is a long tail effect in the execution of multiple tasks that are dependent on each other, resulting in serious overall computing delays. Especially in scenarios with a large number of small kernel functions, the second kernel function task needs to wait for the first kernel function task. It is issued and executed only after completion, resulting in increased delay.

Method used

By issuing and starting to execute the second kernel function task before the execution of the first kernel function task ends, the task formation and execution phases of the second task are allowed to proceed in advance, independent of the state of the first kernel function task, thus reducing Wait time and hide some operations during the execution of the first task.

Benefits of technology

It improves the execution efficiency of multiple dependent tasks, reduces the delay waiting for the first task to complete, and improves the overall computing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626259A
    Figure CN118626259A
Patent Text Reader

Abstract

A processing method, a processing apparatus, an electronic device, a non-transitory computer-readable storage medium, and a computer program product are provided for a plurality of tasks having a dependency relationship on a graphics processing unit. The method for processing the multiple tasks with the dependency relationship on the graphics processing unit comprises the steps that a first task is issued to the graphics processing unit so that the graphics processing unit can execute the first task, and execution of a second task depends on execution of the first task; and issuing the second task to the graphics processing unit to execute the second task by the graphics processing unit, the issuing of the second task being earlier than the end of the execution of the first task. According to the processing method, the execution efficiency of the multiple tasks with the dependency relationship is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of processors, and more specifically, to a method for processing multiple tasks with dependencies on a graphics processing unit, a processing device for multiple tasks with dependencies on a graphics processing unit, an electronic device, a non-temporary computer-readable storage medium, and a computer program product. Background Art

[0002] Graphics Processing Unit (GPU) or general purpose graphics processing unit (GPGPU) (hereinafter referred to as GPU) usually works with central processing unit (CPU). Such program processing system host side (host) and device side (device), host side generally refers to CPU, and device side generally refers to GPU. Programs running on GPU are usually called kernel functions, such as data processing tasks for reasoning and training of neural networks. These kernel functions are designed to handle highly parallelizable tasks, and kernel functions can be called tasks. GPU includes multiple computing cores (referred to as "computing cores"), and multiple computing cores can process tasks of one or more kernel functions in parallel. Summary of the invention

[0003] According to one aspect of the present application, at least one embodiment provides a method for processing multiple tasks with dependencies on a graphics processing unit, including: sending a first task to a graphics processing unit so that the graphics processing unit executes the first task, wherein the execution of a second task depends on the execution of the first task; sending a second task to the graphics processing unit so that the graphics processing unit executes the second task, wherein the sending of the second task is earlier than the end of the execution of the first task.

[0004] According to another aspect of the present application, at least one embodiment provides a processing device for multiple tasks with dependencies on a graphics processing unit, including: a first component, configured to send a first task to the graphics processing unit so that the graphics processing unit executes the first task, wherein the execution of a second task depends on the execution of the first task; a second component, configured to send a second task to the graphics processing unit so that the graphics processing unit executes the second task, wherein the sending of the second task is earlier than the end of the execution of the first task.

[0005] According to another aspect of the present application, at least one embodiment provides an electronic device, including: a memory for storing computer instructions; a processor for reading the computer instructions in the memory and executing a method according to an embodiment of the present application.

[0006] According to another aspect of the present application, at least one embodiment provides a non-transitory computer-readable storage medium on which computer instructions are stored, wherein when the computer instructions are executed by a processor, the processor executes a method according to an embodiment of the present application.

[0007] According to another aspect of the present application, at least one embodiment provides a computer program product, including computer instructions, wherein when the computer instructions are executed by a processor, the processor executes the method according to the embodiment of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or related technologies, the drawings required for use in the embodiments or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0009] Figure 1 A schematic diagram showing the operation of a kernel function task 1 and a kernel function task 2 having a mutual dependency relationship is shown.

[0010] Figure 2 A flowchart of a method for processing multiple tasks with dependencies on a graphics processing unit according to an embodiment of the present application is shown.

[0011] Figure 3A An embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0012] Figure 3B Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0013] Figure 3C Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0014] Figure 4A Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0015] Figure 4B Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0016] Figure 4C Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0017] Figure 5 A block diagram of a device for processing multiple tasks with dependencies on a graphics processing unit according to an embodiment of the present application is shown.

[0018] Figure 6 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present application is shown.

[0019] Figure 7 A schematic diagram of a non-transitory computer-readable storage medium according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0020] The specific embodiments of the present application will now be described in detail, examples of which are illustrated in the accompanying drawings. Although the present application will be described in conjunction with the specific embodiments, it will be understood that it is not intended to limit the present application to the described embodiments. On the contrary, it is intended to cover the changes, modifications and equivalents included in the spirit and scope of the present application. It should be noted that the method steps described herein can be implemented by any functional block or functional arrangement, and any functional block or functional arrangement can be implemented as a physical entity or a logical entity, or a combination of the two.

[0021] The GPU supports concurrent execution of kernel functions, but for two kernel function tasks that are dependent on each other, for example, the execution of the second kernel function task needs to rely on the data obtained by the execution of the first kernel function task, the current conventional practice is that the second kernel function task needs to wait until the execution of the first kernel function task is completed before issuing the second kernel function task to start calculation.

[0022] Figure 1 A schematic diagram showing the operation of a kernel function task 1 and a kernel function task 2 having a mutual dependency relationship is shown.

[0023] Generally, the operation of a kernel function on a GPU includes the task dispatching stage, the task construction stage, the task execution stage, and the data flushing and end flag setting stage.

[0024] The task delivery phase is to deliver the kernel function task to the graphics processing unit so that the graphics processing unit can execute the task. After the task is delivered, the graphics processing unit performs the task building phase, task execution phase, data flushing and setting the end mark phase in sequence. The task building phase builds the resources required to execute the task for the task, such as determining the shared memory space in the GPU, determining the number and space of registers, etc., which includes long-delay work such as descriptor extraction and instruction warm-up that requires data to be taken from the memory. The task execution phase refers to the actual execution of the task using the resources constructed in the task building phase, that is, the graphics processing unit uses various resources to calculate the compiled instruction code of the kernel function task, including reading, calculation, writing, etc. The data flushing and setting the end mark phase refers to flushing the data to a memory such as a hard disk and setting the end mark of the task after the task execution phase of the task is completed, so that other tasks know that the task has ended. The graphics processing unit may include multiple computing cores.

[0025] The biggest problem with this method is that the task distribution and task formation of the second kernel function (kernel function task 2) that depends on the first kernel function (kernel function task 1) are always executed serially after the data flushing and setting of the end mark of the first kernel function, which makes the task execution of the second kernel function delayed for a longer time than the task execution of the first kernel function, and there is a serious long tail effect (such as Figure 1 This long tail effect is particularly high in scenarios with a large number of small kernel functions, resulting in serious overall computing delays.

[0026] Figure 2 A flowchart of a method for processing multiple tasks with dependencies on a graphics processing unit according to an embodiment of the present application is shown.

[0027] like Figure 2 As shown, the method for processing multiple tasks with dependencies on a graphics processing unit includes the following steps.

[0028] In step 210, the first task is sent to a graphics processing unit so that the graphics processing unit executes the first task, wherein the execution of the second task depends on the execution of the first task.

[0029] In step 220, the second task is sent to the graphics processing unit so that the graphics processing unit executes the second task, wherein the sending of the second task is earlier than the completion of the execution of the first task.

[0030] In this way, the execution efficiency of multiple tasks with dependencies is improved.

[0031] Specifically, the issuance of the second task is advanced to an earlier time than the completion of the execution of the first task, so that the second task can be issued without waiting for the completion of the execution of the first task, so that the task building phase of the second task and / or various operations in the second task that are not dependent on the first task can be started. In this way, other operations that are not dependent on the execution of the first task (including the task building phase of the second task and subtasks in the second task that are not dependent on the execution of the first task) can be performed in advance, thereby reducing the waiting time for waiting for the completion of the execution of the first task before starting the issuance of the second task and subsequent operations, so that the issuance of the second task and the execution time of part of the subsequent operations can be hidden in the execution process of the first task, thereby improving the execution efficiency of multiple tasks with dependencies.

[0032] Of course, only two tasks are given as examples here. In fact, the tasks that depend on the execution of the first task may include one or more tasks, each of which can be performed according to the above-mentioned method of the second task. For example, the execution of the third task depends on the execution of the first task, and the third task is sent to the graphics processing unit so that the graphics processing unit executes the third task, wherein the sending of the third task is earlier than the end of the execution of the first task. In other words, the embodiments of the third task or more other tasks can be compared with the embodiments of the second task. In this article, the case of multiple tasks is not repeated.

[0033] It is noted here that the first task, the second task, and possibly the third task may be executed on the same graphics processing unit or on different graphics processing units, which is not limited here.

[0034] Figure 3A An embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0035] For example, a dependency relationship is that the execution of the second task depends on the execution of the first task.

[0036] like Figure 3A As shown, the first task is sent to the graphics processing unit so that the graphics processing unit executes the first task.

[0037] The second task is sent to the graphics processing unit so that the graphics processing unit executes the second task. Here, the figure shows that the second task is sent after the first task is sent, but this is only an example. In fact, the second task can be sent at the same time as the first task. As long as the second task is sent earlier than the end of the execution of the first task, the execution efficiency of multiple tasks with dependencies can be improved.

[0038] There may be other operations during the time period between the issuance of the first task and the execution of the first task, such as the task formation phase of the first task or other operations. Figure 3A It is not shown in the figure, and the present disclosure does not limit which operations exist, as long as the second task is issued earlier than the end of the execution of the first task.

[0039] exist Figure 3A In the case where the execution of the second task depends on the execution of the first task, it can mean that the entire execution of the second task depends on the execution of the first task. For example, the second task is a bias summation calculation, and the first task is a multiplication calculation. The second task needs to use the multiplication calculation result of the first task to sum with the bias. At this time, the second task is sent earlier than the end of the execution of the first task, and the start of the execution of the second task is later than the end of the execution of the first task.

[0040] In other cases, the first task may include the first subtask, and the second task may include the second subtask. The execution of the second task depends on the execution of the first task, which may also mean that the execution of the second subtask in the second task depends on the result of the execution of the first task or the first subtask in the first task. For example, the second task is the accumulation calculation of multiple tensors, the second subtask may be the accumulation calculation of a certain tensor A, and the first task is the multiplication calculation of the tensor A, or the first subtask in the first task is the multiplication calculation of the tensor A. Then, in this case, for the sake of simplicity, it is also possible not to consider whether it is the second task or the second subtask that has the dependency, so that the second task is issued earlier than the end of the execution of the first task, and at the same time, the start of the execution of the entire second task is later than the end of the execution of the first task, that is, the tasks with dependencies are processed with the execution of tasks as the granularity, rather than the execution of subtasks as the granularity. Because the multiplication calculation of tensor A obtained after the execution of the first task is completed is a prerequisite for the second task or the second subtask in the second task, in order to facilitate the processing of tasks (i.e., regardless of which subtask in the second task depends on which subtask in the first task), the execution of the second task can be simply made to start later than the end of the execution of the first task with the execution of the task as the granularity, which can be applied to the above two situations. Of course, tasks with dependencies can also be processed with the execution of subtasks as the granularity, and this situation will be described later in conjunction with the accompanying drawings.

[0041] like Figure 3AAs shown, in one embodiment, the start of the execution of the second task is triggered by confirming that the end mark of the first task has been set, so that the start of the execution of the second task is later than the end of the execution of the first task. Here, since the end mark of the first task is usually set after the end of the first task, for example, it is set to 1, it can be stipulated by hardware setting that all dependent tasks are triggered to start the execution of the second task that depends on the first task by confirming that the end mark of the first task has been set, which is relatively easy to operate and implement at the hardware level. Confirming that the end mark of the first task has been set may include sending the end mark of the first task; retrieving the end mark of the first task, etc.

[0042] At the software level, code instructions for waiting for the execution result of the first task can be added before the code instructions for executing the second task during the code compilation stage of the first task and the second task, so that the start of execution of the second task is later than the end of execution of the first task, thereby automatically starting the execution of the second task after the execution result of the first task is obtained during the code execution process.

[0043] In this way, the start of execution of a second task that depends on the first task can be easily and automatically triggered to ensure smooth execution of the second task. At the same time, the execution efficiency of multiple tasks with dependencies is improved by not restricting the execution of operations that do not depend on the first task.

[0044] In another embodiment, it can also be considered that the execution of the second subtask in the second task depends on the result of the execution of the first task ( Figure 3B or the execution of the second subtask in the second task depends on the result of the execution of the first subtask in the first task ( Figure 3C In the case of the embodiment of the present invention, tasks are processed with subtasks as the granularity.

[0045] Specifically, Figure 3B Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0046] In the case where the execution of the second subtask in the second task depends on the result of the execution of the first task, the start of the execution of the second subtask is made later than the end of the execution of the first task.

[0047] Various operations in the second task that are not dependent on the execution of the first task can be performed independently of the end of the execution of the first task, that is, they can be performed before the end of the execution of the first task, or after the end of the execution of the first task, or at the same time as the end of the execution of the first task. In one embodiment, various operations that are not dependent on the execution of the first task can be performed earlier than the end of the execution of the first task. In this way, various operations that are not dependent on the execution of the first task can be performed in advance earlier than the end of the execution of the first task, for example, other subtasks in the second task except the second subtask can be extracted and performed, reducing waiting delays. For example, the second task is the accumulation calculation of tensors A, B, C, and D. The second subtask may be the accumulation calculation of tensor A, and the first task is the multiplication calculation of tensor A. Therefore, only the second subtask will wait for the end of the execution of the first task to execute, and other subtasks in the second task (accumulation calculation) that are not related to tensor A, such as the accumulation of tensor B, the accumulation of tensor C, and the accumulation of tensor D, do not need to wait for the end of the execution of the first task to execute. In this way, the execution time of the second task's issuance, task formation, and other subtasks in the second task (accumulation calculation) that are not related to tensor A, such as the accumulation of tensor B, the accumulation of tensor C, and the accumulation of tensor D, can be hidden in the execution process of the first task. Compared with processing at the task granularity, processing at the subtask granularity further improves the execution efficiency of multiple tasks with dependencies.

[0048] In one embodiment, the start of the execution of the second subtask is triggered by confirming that the end mark of the first task has been set, so that the start of the execution of the second subtask is later than the end of the execution of the first task. Here, it can be stipulated in a hardware setting that all tasks with dependencies are triggered to start the execution of the second subtask by confirming that the end mark of the first task has been set, which is easier to operate and implement at the hardware level.

[0049] At the software level, during the code compilation stage of the first task and the second task, code instructions for waiting for the execution result of the first task can be added before the code instructions for executing the second task, so that the start of execution of the second task is later than the end of execution of the first task. In the code execution process, the code instructions for executing the second task are automatically started after the execution result of the first task is obtained, so as to ensure that the execution of the second subtask that depends on the execution result of the first task must be executed after the execution result of the first task is obtained, so as to ensure the smooth execution of the second subtask. At the same time, since operations that do not depend on the first task can be executed in advance, the execution efficiency of multiple tasks with dependencies is improved.

[0050] Figure 3CAnother embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0051] When the execution of the second subtask in the second task depends on the result of the execution of the first subtask in the first task, the start of the execution of the second subtask is made later than the end of the execution of the first subtask in the first task.

[0052] In the case where the second subtask depends only on the first subtask in the first task and does not depend on other subtasks in the first task, the execution of the second subtask that must depend on the first subtask and other subtasks that do not depend on the first subtask can be distinguished according to the granularity of the subtasks. The operations in the second task that do not depend on the execution of the first subtask are performed independently of the completion of the execution of the first subtask, that is, they can be performed before the completion of the execution of the first subtask, or after the completion of the execution of the first subtask, or at the same time as the completion of the execution of the first subtask. In one embodiment, various operations that do not depend on the execution of the first subtask can be performed earlier than the completion of the execution of the first subtask, which can further improve the overall task execution efficiency. For example, Figure 3C As shown, a subtask in the first task on which the execution of the second subtask in the second task depends is shown, which is called the "first subtask". Among them, all other subtasks that are not dependent on the first subtask (including subtasks in the first task and subtasks in the second task) can be executed before the first subtask, or, a part of the other subtasks that are not dependent on the first subtask can be executed before the first subtask, and another part of the other subtasks that are not dependent on the first subtask can be executed after the first subtask (depending on the execution speed of each subtask and the execution speed of the first subtask, which is not limited here). In short, the overall task execution efficiency can be improved to a certain extent.

[0053] At the hardware level, the start of the execution of the second subtask can be triggered by confirming that the end mark of the first subtask has been set, so that the start of the execution of the second subtask is later than the end of the execution of the first subtask. In this embodiment, it is necessary to set the end mark of the subtask when the first subtask or all subtasks are finished.

[0054] However, the start of the execution of the second subtask that depends on the first subtask may not be triggered by confirming that the end mark of the first subtask has been set, because if it is agreed in advance that the end mark of the subtask is to be set when one or all subtasks end, the end mark may be set too frequently. Therefore, at the software level, in the case where the execution of the second subtask in the second task depends on the result of the execution of the first subtask in the first task, a code instruction for waiting for the result of the execution of the first subtask can be added before the code instruction for the execution of the second subtask during the code compilation stage of the first task and the second task, so that the start of the execution of the second subtask is later than the end of the execution of the first subtask, so as to ensure that the execution of the second subtask that depends on the result of the execution of the first subtask must be executed after the result of the execution of the first subtask is obtained, so as to ensure the smooth execution of the second subtask. At the same time, since the operations that do not depend on the first subtask can be executed in advance, the execution efficiency of multiple tasks with dependencies is improved.

[0055] Figure 4A Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0056] The first task and the second task include their own task formation phase, task execution phase, data flushing and setting end mark phase. In this article, the "beginning of execution" of a task usually refers to the beginning of the task execution phase of a task, the "beginning of execution" of a subtask in a task usually refers to the beginning of the execution of the code instructions of a subtask in the task execution phase of a task, the "end of execution" of a task usually refers to the end of the data flushing and setting end mark phase of a task, and the "end of execution" of a subtask usually refers to the end of the execution of the code instructions of the subtask.

[0057] The second task is issued earlier than the end of the data flushing and setting end mark phase of the first task. The task building phase of the second task begins after the second task is issued and is independent of the end of the data flushing and setting end mark phase of the first task, that is, the task building phase of the second task can begin after the second task is issued.

[0058] If the start of the execution of the second task or the second subtask in the second task that depends on the first task is triggered by confirming that the end mark of the first task has been set, the start of the execution of the second task or the second subtask in the second task is later than the data flushing and setting end mark phase of the first task. Of course, based on the different lengths of the task formation phase of the second task, the present disclosure does not limit the task execution phase of the second task to start immediately at the end of the data flushing and setting end mark phase of the first task, but limits the start of the task execution phase of the second task to be later than the end of the data flushing and setting end mark phase of the first task.

[0059] Usually, after the task formation phase of the second task is completed, the task execution phase and the data flushing and end mark setting phase of the first task may not be completed yet. In this case, the task execution phase of the second task is started after the data flushing and end mark setting phase of the first task is completed (by confirming that the end mark of the first task has been set). Here, it is not limited that the task execution phase of the second task must be started immediately when the data flushing and end mark setting phase of the first task is completed. Of course, if it is started immediately, it will help to speed up the execution efficiency. In short, the start of the task execution phase of the second task depends on and is later than the end of the data flushing and end mark setting phase of the first task.

[0060] Figure 4A What is shown is an example of triggering the start of execution of the second task by confirming that the end mark of the first task has been set, but at the software level (not shown in the figure), during the code compilation stage of the first and second tasks, code instructions for waiting for the result of execution of the first task can be added before the code instructions for executing the second task.

[0061] Figure 4B Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0062] like Figure 4B As shown in the figure, when the execution of a second subtask in the second task depends on the result of the execution of the first task, the start of the execution of the second subtask depends on the completion of the data flushing and setting end mark phase of the first task. Other subtasks in the second task except the second subtask can start execution without depending on the completion of the data flushing and setting end mark phase of the first task. Note that Figure 4BIt is shown that all subtasks except the second subtask in the second task are executed before the execution of the second subtask, but the present disclosure is not limited to this. In view of the execution speed of other subtasks and the first task, other subtasks except the second subtask in the second task can be executed after the execution of the second subtask, or some other subtasks can be executed before the execution of the second subtask, and some other subtasks can be executed after the execution of the second subtask. In short, the overall task execution efficiency can be improved to a certain extent.

[0063] Figure 4B What is shown is an example of triggering the start of execution of the second subtask by confirming that the end mark of the first task has been set, but at the software level (not shown in the figure), during the code compilation stage of the first task and the second task, code instructions for waiting for the result of execution of the first task can be added before the code instructions for executing the second subtask.

[0064] Figure 4C Another embodiment of a processing method of a first task and a second task having a dependency relationship according to an embodiment of the present application is shown.

[0065] like Figure 4C As shown, when the execution of a second subtask in the second task depends on the result of the execution of a first subtask in the first task, the start of the execution of the second subtask depends on the result of the execution of the first subtask. Figure 4C In the case of the first task and the second task code compilation stage, before the second subtask execution code instruction, add a code instruction to wait for the execution result of the first subtask (although Figure 4C The case where the end mark of the first subtask is set at the hardware level is not shown, but the present disclosure is not limited to Figure 4C In the example shown, the execution of a second subtask in the second task can also be triggered by confirming that the end mark of the first subtask has been set). Other subtasks in the second task except the second subtask (because no code instruction for waiting for the result of the execution of the first subtask is added before the code instruction) can be executed without relying on the result of the execution of the first subtask and the completion of the data flushing and setting end mark phase of the first task.

[0066] Note that, similarly, Figure 4CIt is shown that all subtasks except the second subtask in the second task are executed before the execution of the second subtask, but the present disclosure is not limited to this. In view of the execution speed of other subtasks and the first task, other subtasks except the second subtask in the second task can be executed after the execution of the second subtask, or some other subtasks can be executed before the execution of the second subtask, and some other subtasks can be executed after the execution of the second subtask. In short, the overall task execution efficiency can be improved to a certain extent.

[0067] In this way, the start of execution of the second task or second subtask that depends on the first task or the first subtask can be triggered simply and automatically to ensure the smooth execution of the second task or the second subtask. At the same time, since there is no restriction on the execution of other subtasks that are not dependent on the first task or the first subtask, the execution efficiency of multiple tasks with dependencies is improved.

[0068] In one embodiment, after sending the first task to the graphics processing unit, it is determined that the execution of the second task depends on the execution of the first task, and the second task is sent to the graphics processing unit. Here, the sending of the second task will lag behind the sending of the first task. Since it is a common practice to determine that the execution of the second task depends on the execution of the first task after sending the first task to the graphics processing unit, but after determining the dependency, the sending of the second task is made dependent on (i.e., later than) the setting of the end mark of the first task, this embodiment of the present disclosure can send the second task to the graphics processing unit after determining the dependency, without having to depend on (i.e., later than) the setting of the end mark of the first task.

[0069] In another embodiment, before sending the first task to the graphics processing unit, it is determined that the execution of the second task depends on the execution of the first task, and the first task is sent to the graphics processing unit and the second task is sent to the graphics processing unit in parallel. This embodiment can send the first task to the graphics processing unit and the second task to the graphics processing unit in parallel, further improving the efficiency of task execution, and can also be well applied to the triggering method at the software level, that is, before sending the first task to the graphics processing unit, the dependency relationship is determined, and then during the compilation process, the code instructions that need to wait for the dependent data to be obtained can be added before the code instructions of the (sub)task that depends on the data, and after the compilation work is completed, all tasks are sent in parallel, so that all tasks are completed in an orderly and efficient manner according to the dependency relationship based on the compiled code instructions.

[0070] In summary, by advancing the issuance of the second task to an earlier time than the completion of the execution of the first task, the second task can be issued without waiting for the completion of the execution of the first task, so that the task building phase of the second task and / or various operations in the second task that are not dependent on the first task or the first subtask in the first task can be started. In this way, other operations that are not dependent on the execution of the first task or the first subtask in the first task (including the task building phase of the second task and the subtasks in the second task that are not dependent on the execution of the first task or the first subtask) can be performed in advance, thereby reducing the waiting time for waiting for the completion of the execution of the first task before starting the issuance of the second task and subsequent operations, so that the issuance of the second task and the execution time of part of the subsequent operations can be hidden in the execution process of the first task, thereby improving the execution efficiency of multiple tasks with dependencies.

[0071] Figure 5 A block diagram of a processing device 500 for processing multiple tasks with dependencies on a graphics processing unit according to an embodiment of the present application is shown.

[0072] The processing device 500 includes a first component 510 and a second component 520 .

[0073] The first component 510 is configured to send a first task to a graphics processing unit so that the graphics processing unit executes the first task, wherein the execution of the second task depends on the execution of the first task.

[0074] The second component 520 is configured to send the second task to the graphics processing unit so that the graphics processing unit executes the second task, wherein the sending of the second task is earlier than the completion of the execution of the first task.

[0075] In this way, the execution efficiency of multiple tasks with dependencies is improved.

[0076] In one embodiment, the start of execution of the second task is later than the end of execution of the first task. The operation that is independent of execution of the first task is performed independently of the end of execution of the first task. For example, the operation that is independent of execution of the first task is performed before the end of execution of the first task, or is performed after the end of execution of the first task, or is performed simultaneously with the end of execution of the first task.

[0077] In one embodiment, the processing device 500 also includes a third component, which is configured to trigger the start of execution of the second task by confirming that the end mark of the first task has been set, so that the start of execution of the second task is later than the end of execution of the first task; or by adding a code instruction of waiting for the result of execution of the first task before the code instruction of execution of the second task during the code compilation stage of the first task and the second task, so that the start of execution of the second task is later than the end of execution of the first task.

[0078] In one embodiment, the first task includes a first subtask, and the second task includes a second subtask. When the execution of the second subtask in the second task depends on the result of the execution of the first subtask in the first task, the start of the execution of the second subtask is later than the end of the execution of the first subtask. The operation in the second task that is not dependent on the execution of the first subtask is performed independently of the end of the execution of the first subtask. For example, the operation in the second task that is not dependent on the execution of the first subtask is performed before the end of the execution of the first subtask, or is performed after the end of the execution of the first subtask, or is performed simultaneously with the end of the execution of the first subtask.

[0079] In one embodiment, the processing device 500 also includes a fourth component, which is configured to: trigger the start of execution of the second subtask by confirming that the end mark of the first subtask has been set, so that the start of execution of the second subtask is later than the end of execution of the first subtask; or by adding a code instruction of waiting for the result of execution of the first subtask before the code instruction of execution of the second subtask during the code compilation stage of the first task and the second task, so that the start of execution of the second subtask is later than the end of execution of the first subtask.

[0080] In one embodiment, the second task includes a second subtask, and when the execution of the second subtask in the second task depends on the result of the execution of the first task, the execution of the second subtask starts later than the end of the execution of the first task. The operations in the second task that are not dependent on the execution of the first task are performed independently of the end of the execution of the first task. For example, the operations in the second task that are not dependent on the execution of the first task are performed before the end of the execution of the first task, or are performed after the end of the execution of the first task, or are performed simultaneously with the end of the execution of the first task.

[0081] In one embodiment, the processing device 500 also includes a fifth component, which is configured to: trigger the start of execution of the second subtask by confirming that the end mark of the first task has been set, so that the start of execution of the second subtask is later than the end of execution of the first task; or by adding a code instruction for waiting for the result of execution of the first task before the code instruction for execution of the second subtask during the code compilation stage of the first task and the second task, so that the start of execution of the second subtask is later than the end of execution of the first task.

[0082] In this way, the start of execution of the second task or second subtask that depends on the first task or the first subtask can be triggered simply and automatically to ensure the smooth execution of the second task or the second subtask. At the same time, since there is no restriction on the execution of other subtasks that are not dependent on the first task or the first subtask, the execution efficiency of multiple tasks with dependencies is improved.

[0083] In one embodiment, the first task and the second task respectively include their own task building phase, task execution phase, data flushing and setting end mark phase, wherein the start of the task building phase of the second task is after the second task is issued and is not dependent on the completion of the data flushing and setting end mark phases of the first task.

[0084] In one embodiment, after the first task is sent to the graphics processing unit, it is determined that the execution of the second task depends on the execution of the first task, and the second task is sent to the graphics processing unit.

[0085] In one embodiment, before sending the first task to the GPU, it is determined that the execution of the second task depends on the execution of the first task, and the first task and the second task are sent to the GPU in parallel.

[0086] In summary, by advancing the issuance of the second task to an earlier time than the completion of the execution of the first task, the second task can be issued without waiting for the completion of the execution of the first task, so that the task building phase of the second task and / or various operations in the second task that are not dependent on the first task or the first subtask in the first task can be started. In this way, other operations that are not dependent on the execution of the first task or the first subtask in the first task (including the task building phase of the second task and the subtasks in the second task that are not dependent on the execution of the first task or the first subtask) can be performed in advance, thereby reducing the waiting time for waiting for the completion of the execution of the first task before starting the issuance of the second task and subsequent operations, so that the issuance of the second task and the execution time of part of the subsequent operations can be hidden in the execution process of the first task, thereby improving the execution efficiency of multiple tasks with dependencies.

[0087] Figure 6A block diagram of an exemplary electronic device suitable for implementing embodiments of the present application is shown.

[0088] The electronic device may include a processor 610 and a memory 620 , wherein the memory 620 is coupled to the processor 610 and stores computer instructions therein for performing the steps of each method of the embodiments of the present application when executed by the processor.

[0089] The processor 610 may include, but is not limited to, one or more processors or microprocessors.

[0090] The memory 620 may include, but is not limited to, for example, random access memory (RAM), read-only memory (ROM), flash memory, EPROM memory, EEPROM memory, registers, computer storage media (e.g., hard disk, floppy disk, solid-state drive, removable disk, CD-ROM, DVD-ROM, Blu-ray disk, etc.).

[0091] In addition, the electronic device may also include (but not limited to) a data bus 630, an input / output (I / O) bus 640, a display 650, and input / output devices 660 (eg, keyboard, mouse, speaker, etc.).

[0092] The processor 610 may communicate with an external display 650 and an input / output device 660 through an I / O bus 640 .

[0093] The memory 620 may also store at least one computer instruction for executing each function and / or method step in the embodiments described in the present technology when the instruction is executed by the processor 610 .

[0094] In one embodiment, the at least one computer instruction may also be compiled into or constitute a computer program product or software product, wherein one or more computer instructions, when executed by a processor, perform the various functions and / or method steps in the embodiments described in the present technology.

[0095] Figure 7 A schematic diagram of a non-transitory computer-readable storage medium according to an embodiment of the present application is shown.

[0096] like Figure 7As shown, the non-transitory computer-readable storage medium 720 stores instructions, such as computer instructions 710. When the computer instructions 710 are executed by the processor, the various methods described above can be executed. The non-transitory computer-readable storage medium includes, but is not limited to, for example, random access memory (RAM), read-only memory (ROM), flash memory, EPROM memory, EEPROM memory, register, computer storage medium (such as hard disk, floppy disk, solid state drive, removable disk, CD-ROM, DVD-ROM, Blu-ray disc, etc.), etc. For example, the non-transitory computer-readable storage medium 720 can be connected to a computing device such as a computer, and then, when the computing device executes the computer instructions 710 stored on the computer-readable storage medium 720, the various methods described above can be performed.

[0097] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably therewith. The words "such as / for example" used herein refer to the phrase "such as / for example but not limited to", and can be used interchangeably therewith.

[0098] The step flow charts and the above method descriptions in this disclosure are only illustrative examples and are not intended to require or imply that the steps of each embodiment must be performed in the order given. As will be appreciated by those skilled in the art, the order of the steps in the above embodiments can be performed in any order. Words such as "thereafter", "then", "next", etc. are not intended to limit the order of steps; these words are only used to guide the reader through the description of these methods. In addition, any reference to a singular element, such as using the article "one", "one", or "the" is not to be construed as limiting the element to the singular.

[0099] In addition, the steps and devices in the various embodiments of this document are not limited to implementation in a certain embodiment. In fact, according to the concept of this application, relevant partial steps and partial devices in the various embodiments of this document can be combined to conceive new embodiments, and these new embodiments are also included in the scope of this application.

[0100] The above methods may be implemented in hardware, software, firmware or any combination thereof.

[0101] The present disclosure may also include a computer program product, wherein the computer program product can perform the methods, steps, and operations presented herein. For example, such a computer program product can be a computer software package, computer code instructions, a computer-readable tangible medium having computer instructions tangibly stored (and / or encoded) thereon, which instructions can be executed by a processor to perform the operations described herein. The computer program product can include packaging materials.

[0102] In addition, modules and / or other appropriate means for performing the methods and techniques described herein can be downloaded from a server via wireless communication when appropriate. Alternatively, the various methods described herein can be provided via a storage component so that the various methods are available when coupled to the storage component. In addition, any other appropriate technology for providing the methods and techniques described herein to a device can be utilized.

[0103] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A method for processing multiple tasks with dependencies on a graphics processing unit, comprising: Sending a first task to the graphics processing unit so that the graphics processing unit executes the first task, wherein the execution of the second task depends on the execution of the first task; The second task is sent to the graphics processing unit so that the graphics processing unit executes the second task, wherein the sending of the second task is earlier than the completion of the execution of the first task.

2. The method according to claim 1, wherein: The start of execution of the second task is later than the end of execution of the first task, and operations independent of execution of the first task are performed before the end of execution of the first task, or after the end of execution of the first task, or simultaneously with the end of execution of the first task.

3. The method according to claim 2, further comprising: triggering the start of execution of the second task by confirming that the end marker of the first task has been set, so that the start of execution of the second task is later than the end of execution of the first task; or By adding a code instruction for waiting for the result of execution of the first task before the code instruction for executing the second task during the code compilation stage of the first task and the second task, the start of execution of the second task is made later than the end of execution of the first task.

4. The method according to claim 1, wherein: The first task includes a first subtask, and the second task includes a second subtask. In the case where the execution of the second subtask in the second task depends on the result of the execution of the first subtask in the first task, the start of the execution of the second subtask is later than the end of the execution of the first subtask, and the operation in the second task that is not dependent on the execution of the first subtask is performed before the end of the execution of the first subtask, or is performed after the end of the execution of the first subtask, or is performed simultaneously with the end of the execution of the first subtask.

5. The method according to claim 4, further comprising: triggering the start of execution of the second subtask by confirming that the end marker of the first subtask has been set, so that the start of execution of the second subtask is later than the end of execution of the first subtask; or By adding a code instruction for waiting for the result of execution of the first subtask before the code instruction for executing the second subtask during the code compilation stage of the first task and the second task, the start of execution of the second subtask is made later than the end of execution of the first subtask.

6. The method according to claim 1, wherein: The second task includes a second subtask. In the case where the execution of the second subtask in the second task depends on the result of the execution of the first task, the start of the execution of the second subtask is later than the end of the execution of the first task, and the operation in the second task that is not dependent on the execution of the first task is performed before the end of the execution of the first task, or is performed after the end of the execution of the first task, or is performed simultaneously with the end of the execution of the first task.

7. The method according to claim 6, further comprising: triggering the start of execution of the second subtask by confirming that the end marker of the first task has been set, so that the start of execution of the second subtask is later than the end of execution of the first task; or By adding a code instruction for waiting for the result of execution of the first task before the code instruction for executing the second subtask during the code compilation stage of the first task and the second task, the start of execution of the second subtask is later than the end of execution of the first task.

8. The method according to claim 1, wherein: The first task and the second task respectively include a task formation phase, a task execution phase, a data flushing phase and an end mark setting phase. The task building phase of the second task begins after the second task is issued, and is independent of the completion of the data flushing and end mark setting phases of the first task.

9. The method according to claim 1, wherein: After sending the first task to the graphics processing unit, it is determined that the execution of the second task depends on the execution of the first task, and the second task is sent to the graphics processing unit.

10. The method according to claim 1, wherein: Before sending the first task to the graphics processing unit, it is determined that the execution of the second task depends on the execution of the first task, and the first task and the second task are sent to the graphics processing unit in parallel.

11. A processing device for a plurality of tasks having a dependency relationship on a graphics processing unit, comprising: a first component configured to send a first task to the graphics processing unit so that the graphics processing unit performs the first task, wherein the execution of a second task depends on the execution of the first task; The second component is configured to send the second task to the graphics processing unit so that the graphics processing unit executes the second task, wherein the sending of the second task is earlier than the completion of the execution of the first task.

12. An electronic device comprising: Memory, for storing computer instructions; At least one processor, configured to read the computer instructions in the memory and execute the method according to any one of claims 1-10.

13. A non-transitory computer-readable storage medium having computer instructions stored thereon, in, When the computer instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1-10.

14. A computer program product comprising computer instructions, in, When the computer instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1-10.

Citation Information

Cited By

  • Task execution method and device, storage medium and program product

    CN120596297A

  • Task execution methods, devices, storage media, and program products

    CN120596297B

  • Shader task execution method and device, equipment, medium and product

    CN121743007A