A task scheduling method, task scheduler and storage medium
By introducing an extended control domain segment into the task scheduler, dynamically decide whether to execute software control instructions, solving the problems of task scheduling delay and resource utilization efficiency in the prior art, and achieving more efficient task processing.
Patent Information
- Application Number
- CN202411296661.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2044-09-14
AI Technical Summary
In the prior art, the task scheduling technology of the graphics processor has the problem that hardware cannot be adjusted, optimized and software control needs to be stored first and then scheduled, resulting in task processing delays and resource utilization efficiency.
The task scheduler is adopted, which includes a resource management unit and an instruction control unit. Through the extended control domain segment, it dynamically determines whether to execute software control instructions, and directly or through the instruction control unit to process the shader task to avoid unnecessary intermediate steps.
Improves the flexibility and efficiency of task processing, reduces latency and overhead, improves overall performance, and adapts to different types of shader tasks.
Smart Images

Figure CN119248444B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of graphics processing technology, and in particular to a task scheduling method, a task scheduler, and a storage medium. Background Art
[0002] In the research of Graphics Processing Units (GPUs), multi-threaded and multi-tasking parallelism is the main goal. However, the main difficulty is to be able to timely assemble input thread data such as vertices, geometry, pixels, or computing units into shader tasks and dispatch them to the shader execution units to fully utilize on-chip storage and computing resources to hide the latency of shader task execution. In related technologies, shader task scheduling is usually achieved by using pure hardware task scheduling technology or software-controlled task scheduling technology. Both technologies have corresponding problems. For example, pure hardware task scheduling technology is overly hardware-based, making it impossible to make relevant adjustments and optimizations. Software-controlled task scheduling technology has the problem of involving too many instructions and requiring storage before scheduling. Summary of the Invention
[0003] The embodiment of the present application provides a task scheduling technical solution.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] An embodiment of the present application provides a task scheduling method, which is applied to a task scheduler, wherein the task scheduler includes a resource management unit and an instruction control unit. The task scheduling method includes: assembling received input thread data into a shader task through the resource management unit; the input thread data includes an extended first control field segment, and the first control field segment is used to determine whether the shader task needs to execute software control instructions; if the shader task does not need to execute software control instructions, directly issuing the shader task to the shader; if the shader task needs to execute software control instructions, issuing the shader task to the shader after the instruction control unit executes the software control instructions.
[0006] An embodiment of the present application also provides a task scheduler, which includes a resource management unit and an instruction control unit, wherein: the resource management unit is configured to assemble received input thread data into a shader task, the input thread data includes an extended first control field segment, and the first control field segment is used to determine whether the shader task needs to execute software control instructions; the resource management unit is also configured to directly send the shader task to the shader if the shader task does not need to execute software control instructions; the resource management unit is also configured to send the shader task to the shader after the instruction control unit executes the software control instructions if the shader task needs to execute software control instructions.
[0007] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, on which computer-executable instructions are stored. After the computer-executable instructions are executed, the task scheduling method described above can be implemented.
[0008] Beneficial effects of this application:
[0009] By introducing an extended first control field in the input thread data, the task scheduler can flexibly handle different types of shader tasks. Specifically, it dynamically determines at runtime whether software control instructions need to be executed. For shader tasks that do not require software control instructions, they are directly dispatched to the shader for execution. This avoids unnecessary intermediate processing steps, reduces task processing latency and overhead, and improves overall performance. Furthermore, shader tasks that do require software control instructions are handled by the instruction control unit, expanding their application range.
[0010] It should be understood that the above general description and the detailed description below are merely exemplary and explanatory, and do not limit the technical solutions provided in the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. Those skilled in the art can also derive other drawings based on these drawings without inventive work, among which:
[0012] Figure 1 A flowchart of a task scheduling method provided in some embodiments of the present application;
[0013] Figure 2 A flowchart of another task scheduling method provided in some embodiments of the present application;
[0014] Figure 3 A flowchart of another task scheduling method provided in some embodiments of the present application;
[0015] Figure 4 A schematic diagram of a framework corresponding to the task scheduling method provided in an embodiment of the present application;
[0016] Figure 5A Schematic diagram of updating the value of the counter in the shader execution unit in the task scheduling method provided in the embodiment of the present application Figure 1 ;
[0017] Figure 5B Schematic diagram of updating the value of the counter in the shader execution unit in the task scheduling method provided in the embodiment of the present application Figure 2 ;
[0018] Figure 5C Schematic diagram of updating the value of the counter in the shader execution unit in the task scheduling method provided in the embodiment of the present application Figure 3 ;
[0019] Figure 5D Schematic diagram of updating the value of the counter in the shader execution unit in the task scheduling method provided in the embodiment of the present application Figure 4 ;
[0020] Figure 6 A schematic diagram of the structural composition of a task scheduler provided in some embodiments of the present application. DETAILED DESCRIPTION
[0021] To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the specific technical solutions of the application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the embodiments of the present application, but are not intended to limit the scope of the embodiments of the present application.
[0022] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0023] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art in the art of the present invention. The terms used herein are for the purpose of describing the present invention only and are not intended to limit the present invention.
[0025] To facilitate understanding of this solution, before describing the embodiments of the present application, the application background of the embodiments of the present application will be described.
[0026] In the related technologies, in the research of full-featured graphics processors, multi-threaded and multi-tasking parallelism is the main goal to be pursued, and more floating-point multiplication and addition times have become a key indicator for measuring modern graphics processors. Among them, the ability to timely assemble input thread data such as vertices, geometries, pixels or computing units used by the application into tasks and dispatch them to the shader program running unit to fully utilize on-chip storage and computing resources to hide the latency of task execution is the main difficulty at present. Existing task assembly and scheduling technical solutions are divided into two directions: one is pure hardware task scheduling and dispatching technology, and the other is programmable task scheduling and dispatching technology triggered by software instructions;
[0027] First, for pure hardware task scheduling and dispatching technology, input thread data such as vertices, pixels, or computational units can be dispatched to the task scheduler through the upstream module. Here, the task scheduler first determines whether the amount of input thread data meets the upper limit of a task, or when no more input thread data can be dispatched within a certain period of time, it assembles the corresponding vertex, geometry, pixel, or computational unit input thread data into a task; then it allocates the hardware resources required for the task and writes the task data corresponding to the assembled task into the allocated hardware resources for storage; finally, after confirming that the task data has been written to the corresponding hardware resources, the task can be dispatched by the task scheduler to the shader for calculation.
[0028] Secondly, for programmable software-controlled task scheduling and distribution technology, the task scheduler is required to first store the input thread data such as vertices, geometry, pixels or computing units passed down from the upstream into the internal storage unit for storage, and then the small instruction control unit inside the task scheduler executes the corresponding instructions to modify and calculate the input thread data. Finally, the instruction control unit writes the calculated input thread data into the storage unit of the shader and schedules the task for distribution.
[0029] The above-mentioned pure hardware task scheduling and dispatching technologies have the following disadvantages: 1. The task scheduling method is hardware-based and cannot be adjusted and optimized through software; 2. The input thread data transmitted from the upstream can only be directly passed to the shader, and scalar data calculation or asynchronous data loading cannot be performed to reduce the load on the downstream shader parallel computing unit.
[0030] At the same time, there are also the following problems with software-programmable task scheduling technology: 1. Task scheduling requires more software participation, including data preparation and instruction generation, which increases the difficulty of locating problems in abnormal scenarios; 2. The input thread data transmitted from the upstream needs to be saved in its own data storage unit before it can be assembled and sent to the downstream module, that is, the shader. If no additional modification is required for the input data, it will still occupy storage space and increase the delay in instruction execution; 3. The difficulty of module design increases.
[0031] To solve the above problems, the present invention provides a task scheduling method 1, which is applied to a task scheduler. The task scheduler includes: a resource management unit, an instruction control unit, such as Figure 1 The figure is a flowchart of a task scheduling method provided by some embodiments of the present application, combined with Figure 1 The steps shown are as follows:
[0032] Step S101: Assembling received input thread data into a shader task through the resource management unit; the input thread data includes an extended first control field segment, and the first control field segment is used to determine whether the shader task needs to execute a software control instruction.
[0033] The resource management unit receives input thread data from upstream modules and allocates resources based on task requirements. Input thread data is the data to be processed in graphics processing tasks, typically including vertices, pixels, or computational data. The extended first control field is a new section within the input thread data that indicates whether specific software control instructions should be executed.
[0034] In some embodiments, the resource management unit continuously monitors and receives input thread data sent by the upstream module, and stores the received input thread data in an internal buffer. After receiving a certain amount of input thread data, the resource management unit begins to analyze the data to identify whether a complete shader task can be formed. If the input thread data is sufficient and meets the task requirements, the resource management unit will begin to assemble the shader task. For example, the relevant input thread data, shader code, etc. can be integrated together to form an executable shader task.
[0035] The control field is an area used to identify specific control requirements or states during shader execution. In some embodiments, the control field can indicate whether the shader task needs to execute specific software control instructions or whether input thread data needs to be cached for subsequent processing.
[0036] In an embodiment of the present application, the first control field segment can be set to a first value or a second value. When the first control field segment of the input thread data is set to the first value, it indicates that the input thread data does not need to execute software control instructions; when the first control field segment of the input thread data is set to the second value, it indicates that the input thread data needs to execute software control instructions.
[0037] In some embodiments, the first value of the first control field segment setting may be a null value / default value, and correspondingly, the second value of the first control field segment setting may be a non-null value; in other embodiments, the first value of the first control field segment setting may be 0, and correspondingly, the second value of the first control field segment setting may be 1; in yet other embodiments, the first value of the first control field segment setting may be F, and correspondingly, the second value of the first control field segment setting may be T.
[0038] In the embodiment of the present application, considering that during the assembly process, the resource management unit will identify which input thread data belongs to the same shader task and assemble the input thread data belonging to the same shader task together. Therefore, the first control field segment (i.e., the field segment that controls whether the shader task requires software control instructions) of multiple input thread data belonging to the same shader task should be the same. Furthermore, the resource management unit will determine whether the shader task needs to execute software control instructions based on the first control field segment.
[0039] Step S102: When the shader task does not need to execute software control instructions, directly send the shader task to the shader.
[0040] Step S103: When the shader task needs to execute a software control instruction, the instruction control unit executes the software control instruction and then sends the shader task to the shader.
[0041] It should be noted that in step S102, after determining that the shader task does not need to execute the software control instruction, the process of directly sending the shader task to the shader here is described relative to the process of sending the shader task in step S103; in the case where the shader task needs to execute the software control instruction, it is necessary to first execute the software control instruction through the instruction control unit before sending the shader task to the shader. In other words, compared to step S103, which requires the instruction control unit to execute the software control instruction before sending the shader task to the shader, step S102 does not require the instruction control unit to execute the software control instruction before sending the shader task to the shader.
[0042] In the embodiments of the present application, by introducing an extended first control field into the input thread data, the task scheduler can flexibly handle different types of shader tasks. Specifically, it dynamically determines at runtime whether software control instructions need to be executed. For shader tasks that do not require software control instructions, they are directly dispatched to the shader for execution. This avoids unnecessary intermediate processing steps, reduces task processing latency and overhead, and improves overall performance. Furthermore, for shader tasks that require software control instructions, they are processed by the instruction control unit, expanding their scope of application.
[0043] In some embodiments, the executing software control instructions includes at least one of the following: scalar data calculation, asynchronous data loading, and modifying input thread data.
[0044] Scalar data calculations refer to arithmetic and logical operations on scalars rather than vectors or matrices. In rendering or computation tasks, scalar data calculations can be used to calculate constant values required by shader programs, such as lighting parameters, camera positions, and time-related changes. These constant values are then passed to the shader program on the GPU to control rendering effects or computational flow. Scalar data calculations can also be used for data preloading and preprocessing.
[0045] Among them, asynchronous data loading refers to the process of loading data from an external data source (such as a hard disk, network, etc.) without blocking the execution of the main program. Before the shader task is executed, it may be necessary to load necessary data from external resources (such as texture files, model files, etc.). By loading this data asynchronously, it can be ensured that the shader task starts executing as soon as the data is ready without waiting for the data loading to be completed. For example, when rendering a complex 3D scene, multiple texture files may need to be loaded from the hard disk. By loading these files asynchronously, the program can continue to perform other tasks (such as processing user input, updating scene status, etc.) during the loading process, and pass the texture file to the shader program for rendering immediately after loading is completed.
[0046] Among them, modifying the input thread data refers to modifying or adjusting the input thread data input to the shader program before or during the execution of the shader task. In some embodiments, the input thread data input to the shader program may need to be adjusted according to actual conditions. For example, the coordinates of the vertices can be adjusted according to the position, rotation or scale of the object; or the properties of the material can be modified according to the user's interactive operation, etc. When rendering an interactive 3D object, the user may change the position or rotation angle of the object by dragging the mouse. At this time, the vertex coordinates of the object are modified according to the user's input. The modified vertex coordinates will be passed to the shader program as new input thread data for rendering.
[0047] In some embodiments, the input thread data further includes an extended second control field segment, and the second control field segment is used to determine whether to cache the task data composed of the input thread data.
[0048] The input thread data includes not only a first control field for determining whether the shader task needs to execute software control instructions, but also a second control field. This second control field is primarily used to determine whether task data consisting of the input thread data needs to be cached. The task data includes thread data for the input threads that make up the shader task.
[0049] In some embodiments, when it is determined based on the first control field segment that the shader task needs to execute a software control instruction, it may be further determined based on the second control field segment whether to cache the task data consisting of the input thread data.
[0050] Generally speaking, considering that software control instructions need to modify task data (input thread data), in order to ensure that the data can be quickly accessed when it needs to be modified and that the modified data can be conveniently re-cached for subsequent use, task data composed of the input thread data can be cached when software control instructions need to modify the input thread data.
[0051] In some embodiments, when the software control instruction is executed for scalar data calculation or asynchronous data loading, task data consisting of input thread data may not be cached; when the software control instruction is executed for modifying input thread data, task data consisting of input thread data may be cached.
[0052] In the above embodiment, by introducing an extended second control domain segment into the input thread data, the system can more flexibly handle the data requirements of the shader task, and then can optimize the data processing flow based on the specific requirements of the task (such as whether software control instructions need to be executed and whether task data needs to be cached), thereby improving the overall processing efficiency. For example, if there is no need to modify the input thread data, not caching this data can reduce the occupancy of the cache space, so that this space can be used by other tasks that need caching more. On the contrary, if the input thread data needs to be modified, caching this data in a timely manner can improve the integrity and availability of the data before and after the modification.
[0053] In some embodiments, the method further includes: determining that the software control instruction needs to be executed when the first control field segment indicates that the shader task needs to execute the software control instruction, or when the second control field segment indicates that the task data composed of the input thread data needs to be cached.
[0054] The first control field segment and / or the second control field segment may be referred to to determine whether the shader task needs to execute a software control instruction.
[0055] In some embodiments, when the first control field segment indicates that the shader task needs to execute a software control instruction, it is determined that the shader task needs to execute a software control instruction. In other embodiments, when the second control field segment indicates that task data consisting of the input thread data needs to be cached, it is determined that the shader task needs to execute a software control instruction. In still other embodiments, when the first control field segment indicates that the shader task needs to execute a software control instruction, and the second control field segment indicates that task data consisting of the input thread data needs to be cached, it is determined that the shader task needs to execute a software control instruction.
[0056] In some embodiments, the first control field segment has a higher priority than the second control field segment.
[0057] In an embodiment of the present application, when the first control domain segment indicates that the shader task does not need to execute software control instructions, regardless of whether the second control domain segment indicates that the task data composed of the input thread data needs to be cached, it is determined that the shader task does not need to execute software control instructions; or, when the first control domain segment indicates that the shader task needs to execute software control instructions, regardless of whether the second control domain segment indicates that the task data composed of the input thread data needs to be cached, it is determined that the shader task needs to execute software control instructions.
[0058] In the above embodiment, by setting the priority of the first control domain segment higher than that of the second control domain segment, when deciding whether the software control instruction needs to be executed, only the status of the first control domain segment needs to be considered without considering the second control domain segment at the same time. This can more quickly determine whether the software control instruction needs to be executed, which helps to reduce unnecessary delays and waiting time and improve the execution efficiency of shader tasks.
[0059] Figure 2 This is a schematic diagram of the implementation process of a task scheduling method provided in an embodiment of the present application. Figure 2 , the method can be executed by a processor of a computer device. Figure 1 The task scheduler further includes an output arbitration unit. Before issuing the shader task to the shader, the method further includes: arbitrating a shader task request via the output arbitration unit; the shader task request is used to issue the shader task to the shader. The shader task request can be sent by a resource management unit to the output arbitration unit, or by an instruction control unit to the output arbitration unit. Figure 1Step S102 in the method can be updated to step S201, and step S103 can be updated to step S202. The method further includes steps S203 and S204. Figure 2 The steps shown are explained.
[0060] In an embodiment of the present application, the output arbitration unit is connected to the resource management unit and the instruction control unit, respectively. When the shader task does not need to execute software control instructions, the shader task can be sequentially issued to the shader through the resource management unit and the output arbitration unit. When the shader task does need to execute software control instructions, the shader task can be sequentially issued to the shader through the resource management unit, the instruction control unit, and the output arbitration unit. The following describes the issuance process using these two scenarios.
[0061] Step S201: When the shader task does not need to execute a software control instruction, the resource management unit sends a shader task request to the output arbitration unit.
[0062] In an embodiment of the present application, compared to the case where the shader task needs to execute software control instructions, when the shader task does not need to execute software control instructions, the resource management unit does not need to send the shader task to the instruction control unit, but directly sends the shader task request to the output arbitration unit.
[0063] The shader task request is used to issue the shader task to the shader. In some embodiments, the shader task may include task information and task data. Accordingly, the shader task request may carry the task data corresponding to the shader task.
[0064] The shader task request may be sent by the resource management unit to the output arbitration unit.
[0065] Step S202: When the shader task needs to execute a software control instruction, the instruction control unit executes the software control instruction and then sends a shader task request to the output arbitration unit.
[0066] In an embodiment of the present application, compared to the case where the shader task does not need to execute software control instructions, in the case where the shader task needs to execute software control instructions, the resource management unit needs to send the shader task to the instruction control unit, and the instruction control unit needs to execute the software control instructions and then send a shader task request to the output arbitration unit.
[0067] In some embodiments, when the above-mentioned software control instruction is to modify the input thread data, the resource management unit needs to first send the input thread data (task data) to the instruction control unit; after the instruction control unit executes the instruction to modify the input thread data, the modified input thread data (task data) is sent to the output arbitration unit through a shader task request.
[0068] In other embodiments, when the above-mentioned software control instruction does not modify the input thread data, that is, when the input thread data (task data) does not need to be sent to the instruction control unit to execute the corresponding instruction to modify the input thread data, the resource management unit can send the input thread data (task data) to the instruction control unit, but does not need to modify the input thread data. The instruction control unit sends the input thread data (task data) to the output arbitration unit through a shader task request; the resource management unit can also send the input thread data (task data) directly to the output arbitration unit through a shader task request.
[0069] For example, taking the above-mentioned software control instruction as an instruction for scalar data calculation as an example, in some embodiments, the resource management unit can send the input thread data (task data) to the instruction control unit, but there is no need to modify the input thread data, the instruction control unit executes the instruction for scalar data calculation and obtains the calculation result; the instruction control unit sends the calculation result and the input thread data (task data) to the output arbitration unit through a shader task request. In other embodiments, the resource management unit can also send the input thread data (task data) directly to the output arbitration unit through a shader task request. On the other hand, the instruction control unit executes the instruction for scalar data calculation and obtains the calculation result, and the instruction control unit sends the calculation result to the output arbitration unit through a shader task request; in the current embodiment, for this shader task, the output arbitration unit can obtain the input thread data (task data) by receiving the shader task request sent by the resource management unit, and can also obtain the calculation result by receiving the shader task request sent by the instruction control unit.
[0070] In some embodiments, the shader task request includes at least one of the following: a task data write request from the resource manager unit, and a task data asynchronous load write request or a task data write request after instruction calculation from an instruction controller.
[0071] Wherein, the above-mentioned task data write request from the resource manager unit carries the original input thread data (task data). In some embodiments, when the shader task does not need to execute the software control instruction, the shader task requests received by the output arbitration unit are all task data write requests from the resource manager unit. In other embodiments, when the shader task needs to execute the software control instruction, if the software control instruction does not need to modify the input thread data (task data), the shader task request received by the output arbitration unit may include the task data write request from the resource manager unit. At this time, the shader task request received by the output arbitration unit also includes the task data write request from the instruction controller (task data asynchronous loading write request, task data write request after scalar data calculation).
[0072] The task data asynchronous load write request from the instruction controller carries the data obtained by asynchronous loading. In some embodiments, the task data asynchronous load write request may also carry the original input thread data (task data). In this case, the output arbitration unit will not receive the task data write request from the resource manager unit.
[0073] The aforementioned request from the instruction controller to write task data after the instruction calculation carries the task data after the instruction calculation. If the software control instruction is an instruction for scalar data calculation, the request to write task data after the instruction calculation carries the calculation result after the scalar data calculation; if the software control instruction is an instruction for modifying input thread data, the request to write task data after the instruction calculation carries the modified task data.
[0074] In some embodiments, when the software control instruction is an instruction for scalar data calculation, the task data write request calculated by the instruction may also carry the original input thread data (task data). In this case, the output arbitration unit will not receive the task data write request from the resource manager unit. When the software control instruction is an instruction for modifying input thread data, the task data write request calculated by the instruction will not carry the original input thread data (task data). At the same time, the output arbitration unit will not receive the task data write request from the resource manager unit.
[0075] Step S203: arbitrate the shader task request through the output arbitration unit.
[0076] The output arbitration unit receives shader task requests from the resource management unit and / or the instruction control unit.
[0077] In some embodiments, the output arbitration unit may send corresponding task data to the shader in response to the received shader task request, that is, write the task data corresponding to the shader task request to the shader.
[0078] In some other embodiments, the output arbitration unit may further set an initial value of a data dependency counter of the shader task based on the arbitrated data dependency relationship of the shader task, thereby determining the timing for the shader to execute the shader task.
[0079] Step S204: Send the shader task to the shader through the output arbitration unit.
[0080] In some embodiments, the output arbitration unit not only needs to send the task data required by the shader task to the shader, but also needs to send the task information corresponding to the shader task to the shader, where the task information may include the task type and instruction address.
[0081] In an embodiment of the present application, compared with the design scheme in which the resource manager and the instruction controller each have independent data paths to send tasks to the shader in the related scheme, the present application introduces an output arbitration unit, which can reuse the same data path to transmit shader task requests from different units (resource management unit and instruction control unit), which not only simplifies the hardware design, but also reduces hardware costs, simplifies the hardware design, and improves the overall efficiency of the system.
[0082] Figure 3 This is a schematic diagram of the implementation process of a task scheduling method provided in an embodiment of the present application. Figure 3 , the method can be executed by a processor of a computer device. Figure 2 , Figure 2 S204 in the above example can be updated to step S301 to step S302, combining Figure 3 The steps shown are explained.
[0083] Step S301 : Setting an initial value of a data dependency counter of the shader task based on the arbitrated data dependency relationship of the shader task.
[0084] In some embodiments, the output arbitration unit can determine the data dependency of the shader task based on the task information of the shader task request received. The data dependency is used to represent the dependency between the data that need to exist at the same time when running the shader task. Accordingly, the initial value of the data dependency counter is used to determine the number of data writes that need to exist at the same time when running the shader task, that is, how many data must be written to run the shader task normally. It should be noted that the data written once (or a piece of data) defined here refers to the output arbitration unit writing task data to the shader once in response to a shader task request.
[0085] Exemplarily, when the shader task does not need to execute software control instructions, what the shader task needs at runtime is the original task data. Therefore, the initial value of the data dependency counter of the shader task can be set to "1", indicating that after the output arbitration unit writes the original task data to the shader in response to a shader task request (task data write request from the resource manager unit), the shader can run the shader task normally. When the shader task needs to execute software control instructions, such as asynchronous load instructions, what the shader task needs at runtime is the original task data and the asynchronous data obtained by asynchronous loading. Therefore, the initial value of the data dependency counter of the shader task can be set to "2", indicating that after the output arbitration unit writes the original task data to the shader in response to a shader task request (task data write request from the resource manager unit), and writes the asynchronous data to the shader in response to another shader task request (task data asynchronous load write request from the instruction controller), the shader can run the shader task normally.
[0086] Step S302: Send the arbitrated task data of the shader task to the shader, and update the value of the data dependency counter of the shader task; the data dependency counter is used to indicate whether the shader runs the shader task.
[0087] In an embodiment of the present application, after the output arbitration unit completes arbitration for a shader task request, it is necessary to respond to the shader task request and write task data corresponding to the shader task request to the shader. After completing the writing process of the task data corresponding to the shader task request, the output arbitration unit needs to update the value of the data dependency counter of the shader task.
[0088] In some embodiments, the initial value of the data dependency counter is used to determine the number of data writes required to be performed simultaneously when executing the shader task. Therefore, after sending the arbitrated task data of the shader task to the shader, the value of the data dependency counter is updated, and the updated value of the data dependency counter is the number of data writes remaining when executing the shader task.
[0089] In some embodiments, the shader includes a shader storage unit and a shader execution unit, and the data dependency counter is included in the shader execution unit.
[0090] In some embodiments, the sending of the task data of the shader task to the shader and the updating of the data dependency counter of the shader task can be achieved through steps S3021 and S3022.
[0091] Step S3021: Storing the task data of the arbitrated shader task into the shader storage unit.
[0092] It is understandable that the task data stored in the shader storage unit can be task data from the resource manager unit or task data from the instruction controller. The task data from the instruction controller can be asynchronous data carried by a task data asynchronous load write request or calculated task data (including calculation results obtained by scalar calculation and modified task data) carried by a task data write request after instruction calculation.
[0093] Step S3022: Update the value of the data dependency counter based on the number of times the task data is written into the shader storage unit.
[0094] The number of times the task data is written to the shader storage unit may be the number of times the output arbitration unit writes the task data to the shader storage unit in response to one shader task request. That is, if the output arbitration unit writes the task data corresponding to one shader task request to the shader storage unit in response to one shader task request, the number of times is one; if the output arbitration unit writes the task data corresponding to each of the N shader task requests to the shader storage unit in response to N shader task requests, the number of times is N.
[0095] For example, taking the above-mentioned software control instruction as an asynchronous data load instruction, in some embodiments, the resource management unit can send the input thread data (task data) to the instruction control unit, but does not need to modify the input thread data. The instruction control unit sends the input thread data (task data) to the output arbitration unit via a shader task request; the instruction control unit executes the asynchronous data load instruction to obtain asynchronous data, and the instruction control unit sends the asynchronous data to the output arbitration unit via a shader task request. In this case, the output arbitration unit writes a total of two data (the original task data and the asynchronous data) to the shader storage unit, a number of times. In other embodiments, the resource management unit can also send the input thread data (task data) directly to the output arbitration unit via a shader task request, and the output arbitration unit writes the original task data to the shader storage unit. On the other hand, the instruction control unit executes the asynchronous data load instruction to obtain asynchronous data, and the instruction control unit sends the asynchronous data to the output arbitration unit via a shader task request, and the output arbitration unit writes the asynchronous data to the shader storage unit; in this case, the output arbitration unit writes a total of two data (the original task data and the asynchronous data) to the shader storage unit, a number of times.
[0096] In some embodiments, in response to the data dependency counter indicating that the data dependency is resolved, the shader is instructed to execute the shader task.
[0097] In the embodiment of the present application, when all data required for the execution of the shader task is sent to the shader, it indicates that the data dependency relationship is resolved. In other words, when the data dependency counter indicates that all data required for the execution of the shader task is sent to the shader, it indicates that the data dependency relationship has been resolved and the shader can run the shader task.
[0098] In some embodiments, the output arbitration unit counts the number of times the task data is written into the shader storage unit during the process of writing the task data into the shader storage unit, and updates the value of the data dependency counter based on the number of times. Exemplarily, the output arbitration unit sends a numerical value update request to the data dependency counter each time the task data is written into the shader storage unit, and the numerical value update request is used to instruct the data dependency counter to update the value of the data dependency counter. Of course, the output arbitration unit may also send a numerical value update request to the data dependency counter every two (or more) times after writing the task data into the shader storage unit, and this application does not limit this.
[0099] In some embodiments, updating the value of the data dependency counter based on the number of times task data is written to the shader storage unit includes: performing a subtraction operation on the value of the data dependency counter based on the number of times; and when the value of the data dependency counter is 0, indicating that the data dependency relationship is released.
[0100] Here, when the data dependency is released, the shader task starts to execute.
[0101] For example, when the output arbitration unit sends a value update request to the data dependency counter each time task data is written to the shader storage unit, a subtraction operation can be performed on the value of the data dependency counter based on the value "1". When the shader task needs to execute an asynchronous load instruction, the initial value of the data dependency counter is set to "2". In this case, two value update requests need to be received respectively, so that when the value of the data dependency counter reaches 0, it indicates that the data dependency relationship is resolved. Then, the shader task begins execution.
[0102] In some embodiments, the shader includes a shader execution unit, and sending the shader task to the shader includes: writing task information of the arbitrated shader task into the shader execution unit, wherein the task information includes a task type and a shader instruction address.
[0103] The task type is a shader task type, which includes but is not limited to vertex shading tasks, pixel shading tasks, or other types of graphics processing tasks. The shading instruction address is the instruction address of the instruction required to run the shader task. The shading instruction address points to the instruction sequence that the shader must follow when executing the task. Generally speaking, these instructions are usually stored in memory or cache, and the shading instruction address is the starting location for accessing these instructions. The shader execution unit will start reading and executing instructions based on the shading instruction address to complete the shader task.
[0104] In some embodiments, the method further includes: the resource management unit sending an instruction address to the instruction control unit; and the instruction control unit acquiring the software control instruction based on the instruction address.
[0105] In the embodiment of the present application, the above-mentioned instruction address can be an instruction address for scalar data calculation, an instruction address for asynchronous data loading, or an instruction address for modifying input thread data.
[0106] Among them, when the instruction control unit receives an instruction address pointing to a scalar data calculation instruction, it reads the instruction sequence at the address, including but not limited to the operation code and operands required to perform scalar data (i.e., a single numerical value, as opposed to a vector or matrix) calculation; thereafter, the instruction control unit performs the corresponding scalar calculation operation based on the operation code and operand to obtain the corresponding calculation result.
[0107] When the instruction control unit receives an instruction address pointing to an asynchronous data loading instruction, the instruction control unit reads and executes instructions related to data loading, and then asynchronously loads asynchronous data from an external memory (such as system memory, hard disk, etc.).
[0108] When the instruction control unit receives an instruction address pointing to an instruction for modifying input thread data, the instruction control unit may use the instruction for modifying input thread data to update or modify the cached task data.
[0109] In some embodiments, the method also includes: when the second control domain segment is used to determine the task data composed of the input thread data to be cached, the resource management unit sends the task data to the storage unit corresponding to the instruction control unit; the instruction control unit runs the execution instruction to calculate the task data stored in the storage unit, and issues the task data after the instruction calculation.
[0110] In the case where the second control field is used to determine the task data comprising the input thread data to be cached, the resource management unit sends the task data to the instruction control unit; at this point, the instruction control unit stores the task data in its corresponding storage unit. Simultaneously, the instruction control unit runs the execution instruction to calculate the task data stored in the storage unit, obtaining the calculated task data; the instruction control unit then sends the calculated task data to the output arbitration unit via a write request for the calculated task data.
[0111] In some embodiments, the method further includes: when the second control domain segment is used to determine not to cache the task data composed of the input thread data, the instruction control unit runs the execution instruction to load asynchronous data, and sends down the asynchronous data and the task data.
[0112] Among them, the instruction control unit can send a task data asynchronous load write request to the output arbitration unit, and the task data asynchronous load write request carries the asynchronous data obtained by asynchronous loading, and at the same time, the task data asynchronous load write request also carries the original task data. It can be understood that in the current embodiment, the output arbitration unit will not receive the task data write request from the resource manager unit.
[0113] In an embodiment of the present application, a resource management unit may receive input thread data, such as vertices, geometries, pixels, or computational units, sent by an upstream module for assembling a shader task, and assemble the input thread data according to certain assembly rules to obtain a shader task. In some embodiments, if the number of input thread data of the same type (i.e., with the same attributes) meets the upper limit of the number of tasks to be assembled, or if the resource management unit does not receive more input thread data within a certain period of time, the received input thread data with the same attributes may be packaged and assembled accordingly to obtain a shader task.
[0114] In some embodiments, the resource management unit assembles the received input thread data into a shader task, including: through the resource management unit, within a first time period, when the number of input thread data with the same attributes received reaches N, assembling N of the input thread data into the shader task.
[0115] Among them, the resource management unit continuously monitors the data flow from the upstream module and receives input thread data; for each input thread data received, the resource management unit will check the attributes of the input thread data and count the number of input thread data under each attribute; when the number of input thread data with the same attribute reaches the preset threshold N, the resource management unit will assemble these input thread data into a shader task.
[0116] For example, suppose that during graphics rendering, the resource management unit receives a series of vertex data describing the vertex positions of a 3D model. For every 100 vertex data received (i.e., N = 100), the resource management unit assembles them into a vertex shader task. This allows the GPU to calculate the positions of all 100 vertices at once, rather than individually, improving processing efficiency.
[0117] In other embodiments, the resource management unit assembles the received input thread data into a shader task, including: the resource management unit receives M input thread data with the same attributes within the first time period, and assembles M input thread data into the shader task when no new input thread data is received in the second time period; wherein the second time period is a time period located after the first time period and adjacent to the first time period in timing.
[0118] Wherein, M and N are both positive integers, and M is less than N.
[0119] In some embodiments, the first time period and the second time period are continuous, and the second time period follows the first time period. The lengths of the first time period and the second time period may be fixed or dynamically adjusted, which is not limited in this application.
[0120] Among them, during the first time period, the resource management unit continuously monitors and receives input thread data from the upstream module. For each input thread data received, the resource management unit will check its attributes and count the number of input thread data with the same attributes. During the statistical process, if the number of input thread data with the same attribute reaches a preset threshold M, and no new input thread data with the attribute is received in the following second time period, the resource management unit will trigger the task assembly process. In other words, the resource management unit will not only consider whether the number of input thread data with the same attribute reaches the threshold, but also consider the time factor, that is, whether no new input thread data with the same attribute arrives within a period of time.
[0121] For example, assume that during the graphics rendering process, the resource management unit is responsible for receiving and processing vertex data. In the first time period, the resource management unit receives 50 vertex data used to describe the vertex positions of the 3D model. Since the attributes of these input thread data are the same (all vertex data) and the number reaches the preset threshold M (50), the resource management unit begins to wait for the second time period. In the second time period that follows, the resource management unit does not receive any new vertex data. At this time, the resource management unit can assemble the 50 vertex data previously received into a vertex shader task.
[0122] In the embodiment of the present application, the resource management unit can more flexibly assemble shader tasks according to the actual reception of input thread data and system requirements, thereby optimizing the utilization efficiency and rendering performance of the GPU.
[0123] The above-mentioned task scheduling method is described below in conjunction with a specific embodiment. However, it is worth noting that this specific embodiment is only for better illustrating the embodiment of the present application and does not constitute an improper limitation on the embodiment of the present application.
[0124] In related technologies, shader task scheduling is usually achieved by using pure hardware task scheduling technology or software-controlled task scheduling technology. Among them, pure hardware task scheduling technology is overly hardware-based and cannot be adjusted and optimized through software. In addition, the input thread data transmitted from upstream can only be directly passed to the shader, and scalar data calculation or asynchronous data loading cannot be performed to reduce the load on the downstream shader parallel computing unit. Software-controlled task scheduling technology requires more instructions to participate, including data preparation and instruction generation, which increases the difficulty of locating problems in abnormal scenarios. In addition, the input thread data transmitted from upstream needs to be saved in the corresponding data storage unit before it can be assembled and sent to the shader. Even if no additional modification is required, the input data will still occupy storage space and increase the delay of instruction execution.
[0125] Based on this, the present application aims to accelerate the scheduling and dispatching of shader tasks. It ensures the efficiency of the pipeline operation by reusing some data paths while retaining the flexibility of software programmability; that is, when the input thread data needs to be modified or the data needs to be loaded asynchronously, the task data of the current task, that is, the input thread data, can be written into the storage unit of the task scheduler through software control (instruction controller) for data calculation and modification; when the input thread data does not need to be modified or instructions are not required for scalar calculations, the input thread data can be directly transmitted to the downstream shader storage unit to accelerate the efficiency of task scheduling, thereby reducing the delay in task transmission.
[0126] like Figure 4As shown, a schematic diagram of the framework corresponding to the task scheduling method provided by an embodiment of the present application is shown. Specifically, in the task assembly and dispatching process, the task scheduler 402 is composed of a resource management unit 4021, an instruction control unit 4022, and an output arbitration unit 4023. The resource management unit 4021 directly receives input thread data 401, such as vertices, geometry, pixels, or computational units, dispatched from upstream. It first assembles the received input thread data 401 into tasks according to certain conditions and allocates the required hardware resources based on the task requirements. After the resources are allocated, if the input thread data a within the task requires additional mathematical or logical calculations, the input thread data a can be dispatched to the instruction control unit 4022. The instruction control unit 4022 receives the input thread data a and the corresponding instruction address sent by the resource management unit 4021, and retrieves the instruction based on the instruction address to execute the corresponding instruction to modify or perform logical calculations on the relevant input thread data a. If the input thread data b within the task does not require additional instructions for modification or logical calculations, it can be directly transmitted to the output arbitration unit 4023.
[0127] Here, for simple input thread data, such as: the input thread data does not need to be modified or calculated, the input thread data can be directly forwarded to the output arbitration unit 4023 through the resource management unit 4021; for complex input thread data, such as: for input thread data that needs to be modified and calculated, the resource management unit 4021 can be used to send the input thread data to the cache corresponding to the instruction control unit 4022, and the input thread data can be calculated or modified through the instruction control unit 4022, so that the modified input thread data can be sent to the output arbitration unit 4023 using the instruction control unit 4022; at the same time, the instruction control unit can also load or save asynchronous data from off-chip storage, so as to increase the flexibility of processing and scheduling of shader tasks in the graphics processor, that is, to achieve the fusion of software control and hardware inherent pipeline.
[0128] To implement the above solution, the input thread data 401 input to the resource management unit 4021 can be expanded, that is, two control fields are added to transmit control information fields. One field (field 1) is used to indicate whether the input thread data needs to be cached in the storage unit of the instruction control unit 4022, and the other field (field 2) is used to indicate whether the input thread data needs to execute additional instructions.
[0129] Correspondingly, if the control domain segment of the input thread data extension indicates that the input thread data does not need to execute instructions (when there is no need to execute instructions, there is no need to store the input thread data in the storage unit of the instruction control unit 4022), then the resource management unit 4021 can directly send the input thread data to the output arbitration unit 4023.
[0130] If the control field segment of the input thread data extension indicates that the input thread data needs to execute instructions but does not need to be stored in the storage unit of the instruction control unit 4022, the resource management unit 4021 will pass the instruction address of the corresponding execution instruction to the instruction control unit 4022, so that the instruction control unit 4022 can retrieve the instruction at the instruction address and run the instruction, such as: loading or storing some status information or performing asynchronous data loading, etc. Finally, the instruction control unit 4022 sends the loaded or stored data to the output arbitration module unit 4023.
[0131] If the control domain segment of the input thread data extension indicates that the input thread data needs to execute instructions and needs to be stored in the storage unit of the instruction control unit 4022, the resource management unit 4021 will pass the instruction address of the corresponding execution instruction to the instruction control unit 4022, so that the instruction control unit 4022 can retrieve the instruction at the instruction address, run the instruction to modify or calculate the cached thread, and send the modified or calculated input thread data to the output arbitration unit 4023.
[0132] Here, you can continue to refer to Figure 4As shown, the output arbitration unit 4023 arbitrates output requests from the resource management unit 4021 and the instruction control unit 4022. The output arbitration unit 4023 exits two types of paths: a data flow path and a control flow path. The data flow path is primarily responsible for writing the shader task's input thread data from the task scheduler 402 to the shader storage unit 4032 for the shader program to read, write, and calculate. This input thread data primarily consists of input thread data from the resource management unit 4021, input thread data modified or calculated by the instruction control unit 4022, and asynchronous data loaded from the instruction control unit 4022. The control flow path is primarily responsible for writing shader task information from the task scheduler 402 to the shader execution unit 4031, including information such as the task type and instruction address. It also updates internal data dependency counters based on the input thread data written by the data stream or the corresponding write request. Here, the internal data dependency counters are data counters corresponding to the shader task, with one data counter corresponding to each shader task. After the shader execution unit 4031 receives the task information of shader task A sent by the output arbitration unit 4023, it can adjust the value of the data counter inside it that matches shader task A to a preset value, which is used to represent the number of input thread data included in the shader task A.
[0133] Here, if all the input thread data included in the shader task A are successfully written from the task scheduler 402 to the shader storage unit 4032, the shader execution unit 4031 will respond to the input thread data stored in the shader storage unit 4032, reduce the value of the internal data counter matching the shader task A to 0, and execute the shader task A based on the value reduced to 0.
[0134] Correspondingly, if 5A to 5DAs shown, multiple transmission paths of input thread data in the task scheduler 402 are provided, wherein 501 shows that the resource management unit 4021 directly sends the input thread data 1 of the shader task A to the output arbitration unit 4023, so that the output arbitration unit 4023 sends the received input thread data 1 to the shader storage unit 4032; 502 shows that the resource management unit 4021 sends the input thread data 2 of the shader task A to the instruction control unit 4022, so that the instruction control unit 4022 modifies or calculates the input thread data 2, so that the instruction control unit 4022 sends the modified or calculated input thread data 2 to the output arbitration unit 4023, and then outputs the arbitration unit 4032. The arbitration unit 4023 sends the received modified or calculated input thread data 2 to the shader storage unit 4032; 503 shows that the resource management unit 4021 sends the corresponding instruction address to the instruction control unit 4022, so that the instruction control unit 4022 obtains relevant instructions based on the instruction address to load asynchronous data, so that there are two data paths: the instruction control unit 4022 sends the loaded asynchronous data to the output arbitration unit 4023, and the resource management unit 4021 sends the input thread data 3 of the shader task A to the output arbitration unit 4023, and then the output arbitration unit 4023 sends the received input thread data 3 and the asynchronous data synchronously to the shader storage unit 4032.
[0135] It should be noted that, in 502 , the resource management unit 4021 also sends the corresponding instruction address to the instruction control unit 4022 , so that the instruction control unit 4022 obtains the relevant instruction based on the instruction address and runs the instruction to modify or calculate the input thread data 2 .
[0136] Here, in 501, the input thread data 1 of the shader task A is transmitted to the shader storage unit 4032 by the resource management unit 4021 and the output arbitration unit 4023, and the value of the data counter matching the shader task A inside the shader execution unit 4031 is reduced by 1 accordingly; in 502, the input thread data 2 of the shader task A is transmitted to the shader storage unit 4032 by the resource management unit 4021, the instruction control unit 4022 and the output arbitration unit 4023, and the value of the data counter matching the shader task A inside the shader execution unit 4031 is reduced by 1 accordingly; in 503, the data of the related asynchronous loading of the shader task A is reduced by 1 accordingly. According to the above, the resource management unit 4021, the instruction control unit 4022 and the output arbitration unit 4023 transmit the input thread data 3 of the shader task A to the shader storage unit 4032, and the resource management unit 4021 and the output arbitration unit 4023 transmit the input thread data 3 of the shader task A to the shader storage unit 4032, and the value of the data counter matching the shader task A inside the shader execution unit 4031 is reduced by 2 accordingly; in 504, since there is no data flow, that is, there is no transmission of the input thread data of the shader task A, then the value of the data counter matching the shader task A inside the shader execution unit 4031 does not change, that is, it is reduced by 0 accordingly.
[0137] The present application also provides a task scheduler. Figure 6 A schematic diagram of the structure of a task scheduler provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the task scheduler 600 includes a resource management unit 601, an instruction control unit 602, and an output arbitration unit 603, wherein:
[0138] The resource management unit 601 is configured to assemble received input thread data into a shader task, wherein the input thread data includes an extended first control field segment, and the first control field segment is used to determine whether the shader task needs to execute a software control instruction;
[0139] The resource management unit 601 is further configured to directly send the shader task to the shader when the shader task does not need to execute the software control instruction;
[0140] The resource management unit 601 is further configured to, when the shader task needs to execute a software control instruction, send the shader task to the shader after the instruction control unit 602 executes the software control instruction.
[0141] In some embodiments, the executing software control instructions includes at least one of the following: scalar data calculation, asynchronous data loading, and modifying input thread data.
[0142] In some embodiments, the input thread data further includes an extended second control field segment, and the second control field segment is used to determine whether to cache the task data composed of the input thread data.
[0143] In some embodiments, the method further includes: determining that the software control instruction needs to be executed when the first control field segment indicates that the shader task needs to execute the software control instruction, or when the second control field segment indicates that the task data composed of the input thread data needs to be cached.
[0144] In some embodiments, the first control field segment has a higher priority than the second control field segment.
[0145] In some embodiments, the task scheduler further includes an output arbitration unit 603, which is configured to arbitrate shader task requests before issuing the shader task to the shader; the shader task request is used to issue the shader task to the shader.
[0146] In some embodiments, the shader task request includes at least one of the following: a task data write request from the resource manager unit, and a task data asynchronous load write request or a task data write request after instruction calculation from an instruction controller.
[0147] In some embodiments, the shader includes a data dependency counter, and the resource management unit 601 is further configured to set an initial value of the data dependency counter of the shader task based on the data dependency relationship of the arbitrated shader task.
[0148] In some embodiments, the shader includes a shader execution unit, and the data dependency counter is included in the shader execution unit.
[0149] In some embodiments, the shader also includes a shader storage unit; the resource management unit 601 is also configured to store the task data of the arbitrated shader task to the shader storage unit, and update the value of the data dependency counter based on the number of times the task data is written to the shader storage unit.
[0150] In some embodiments, the resource management unit 601 is further configured to instruct the shader to execute the shader task in response to the data dependency counter indicating that the data dependency relationship is released.
[0151] In some embodiments, the resource management unit 601 is further configured to perform a subtraction operation on the value of the data dependency counter based on the number of times; when the value of the data dependency counter is 0, it indicates that the data dependency relationship is released.
[0152] In some embodiments, the shader includes a shader execution unit, and the resource management unit 601 is further configured to write task information of the arbitrated shader task into the shader execution unit; the task information includes a task type and a shader instruction address.
[0153] In some embodiments, the resource management unit 601 is further configured to send an instruction address to the instruction control unit 602; and the instruction control unit 602 is further configured to obtain the software control instruction based on the instruction address.
[0154] In some embodiments, when the second control domain segment is used to determine the task data composed of the input thread data to be cached, the resource management unit 601 is also configured to send the task data to the storage unit corresponding to the instruction control unit 602; the instruction control unit 602 is also configured to run the execution instruction to calculate the task data stored in the storage unit, and issue the task data after the instruction calculation.
[0155] In some embodiments, when the second control domain segment is used to determine not to cache the task data composed of the input thread data, the instruction control unit 602 is also configured to run the execution instruction to load asynchronous data, and send down the asynchronous data and the task data.
[0156] In some embodiments, the resource management unit 601 is further configured to, when the number of input thread data with the same attributes received within a first time period reaches N, assemble N of the input thread data into the shader task; or, when the number of input thread data with the same attributes received within the first time period is M and no new input thread data is received in a second time period, assemble M of the input thread data into the shader task; wherein, the second time period is a time period located after the first time period and adjacent to the first time period in time sequence; M and N are both positive integers, and M is less than N.
[0157] It should be noted that the description of the above task scheduler embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiment corresponding to the task scheduler in this application, please refer to the description of the method embodiment of this application for understanding.
[0158] It should be noted that, in the embodiment of the present application, if the above-mentioned task scheduling method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a terminal, a server, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a sports hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0159] Correspondingly, an embodiment of the present application further provides a computer program product, which includes computer-executable instructions. After the computer-executable instructions are executed, the task scheduling method provided in the embodiment of the present application can be implemented.
[0160] Accordingly, an embodiment of the present application further provides a computer-readable storage medium, on which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the task scheduling method provided in the above embodiment is implemented.
[0161] The description of the above task scheduler and storage medium embodiments is similar to the description of the above method embodiments, and has similar technical descriptions and beneficial effects as the corresponding method embodiments. Due to space limitations, reference can be made to the description of the above method embodiments, so they will not be repeated here. For technical details not disclosed in the task scheduler and storage medium embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0162] It should be understood that references to "one embodiment" or "an embodiment" throughout this specification mean that specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present invention. Therefore, the appearance of "in one embodiment" or "in an embodiment" throughout this specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of the present invention, the order of execution of the above-mentioned processes does not necessarily indicate the order in which they are executed. The order in which the processes are executed should be determined by their functions and inherent logic, and should not constitute any limitation on the implementation of the embodiments of the present invention. The above-mentioned serial numbers of the embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. It should be noted that, in this document, the terms "comprise," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises one..." does not preclude the presence of other identical elements in the process, method, article, or apparatus comprising that element.
[0163] In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0164] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0165] In addition, the functional units in each embodiment of the present application can be all integrated into one processing unit, or each unit can be separately used as a unit, or two or more units can be integrated into one unit; the above-mentioned integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units. It can be understood by those skilled in the art that all or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiments.
[0166] The above description is merely a specific implementation of the embodiments of the present application, but the scope of protection of the embodiments of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the embodiments of the present application should be included in the scope of protection of the embodiments of the present application. Therefore, the scope of protection of the embodiments of the present application should be based on the scope of protection of the claims.
Claims
1. A task scheduling method, characterized in that: Applied to a task scheduler, the task scheduler includes a resource management unit and an instruction control unit, and the task scheduling method includes: Assembling received input thread data into a shader task through the resource management unit; the input thread data includes an extended first control field segment and a second control field segment, the first control field segment is used to determine whether the shader task needs to execute a software control instruction; the second control field segment is used to determine whether to cache task data composed of the input thread data; the first control field segment has a higher priority than the second control field segment; When the shader task does not need to execute software control instructions, directly sending the shader task to the shader; In the case where the shader task needs to execute a software control instruction, the shader task is sent to the shader after the instruction control unit executes the software control instruction.
2. The method according to claim 1, characterized in that The executing software control instruction includes at least one of the following: scalar data calculation, asynchronous data loading, and modification of input thread data.
3. The method according to claim 1, characterized in that The method further comprises: When the first control field segment indicates that the shader task needs to execute a software control instruction, or when the second control field segment indicates that task data composed of the input thread data needs to be cached, it is determined that the software control instruction needs to be executed.
4. The method according to claim 1, wherein The task scheduler further includes an output arbitration unit. Before sending the shader task to the shader, the method further includes: The shader task request is arbitrated by the output arbitration unit; the shader task request is used to issue the shader task to the shader.
5. The method according to claim 1, wherein The shader task request includes at least one of the following: a task data write request from the resource management unit, and a task data asynchronous load write request or a task data write request after instruction calculation from an instruction controller.
6. The method according to claim 4, characterized in that The shader includes a data dependency counter, and the sending of the shader task to the shader includes: An initial value of a data dependency counter of the shader task is set based on the arbitrated data dependency relationship of the shader task.
7. The method according to claim 6, characterized in that The shader includes a shader execution unit, and the data dependency counter is included in the shader execution unit.
8. The method according to claim 7, characterized in that The shader further includes a shader storage unit; and the step of sending the shader task to the shader further includes: storing the task data of the arbitrated shader task into the shader storage unit, The value of the data dependency counter is updated based on the number of times task data is written into the shader storage unit.
9. The method according to claim 8, characterized in that The method further comprises: In response to the data dependency counter indicating that the data dependency is resolved, instructing the shader to execute the shader task.
10. The method according to claim 9, characterized in that The updating of the value of the data dependency counter based on the number of times the task data is written into the shader storage unit comprises: A subtraction operation is performed on the value of the data dependency counter based on the number of times; when the value of the data dependency counter is 0, it indicates that the data dependency relationship is released.
11. The method according to claim 4, characterized in that The shader includes a shader execution unit, and sending the shader task to the shader includes: writing task information of the arbitrated shader task into the shader execution unit; the task information includes a task type and a shader instruction address.
12. The task scheduling method according to claim 1, wherein: The method further comprises: Sending the instruction address to the instruction control unit through the resource management unit; The software control instruction is acquired by the instruction control unit based on the instruction address.
13. The task scheduling method according to claim 12, characterized in that: The method further comprises: In a case where the second control field is used to determine task data composed of the input thread data to be cached, the task data is sent to a storage unit corresponding to the instruction control unit through the resource management unit; The software control instruction is executed by the instruction control unit to calculate the task data stored in the storage unit, and the task data calculated by the instruction is issued.
14. The task scheduling method according to claim 12, wherein: The method further comprises: In the case where the second control domain segment is used to determine not to cache the task data composed of the input thread data, the instruction control unit runs the software control instruction to load asynchronous data, and sends the asynchronous data and the task data.
15. The task scheduling method according to claim 1, wherein: The resource management unit assembles the received input thread data into a shader task, including: When the number of input thread data with the same attribute received by the resource management unit reaches N within a first time period, assembling the N input thread data into the shader task; or Through the resource management unit, within the first time period, the number of input thread data with the same attributes received is M, and when no new input thread data is received in the second time period, the M input thread data are assembled into the shader task; wherein, the second time period is a time period located after the first time period and adjacent to the first time period in time sequence; M and N are both positive integers, and M is less than N.
16. A task scheduler, characterized in that: The task scheduler includes a resource management unit and an instruction control unit, wherein: The resource management unit is configured to assemble received input thread data into a shader task, the input thread data including an extended first control field segment and a second control field segment, the first control field segment being used to determine whether the shader task needs to execute a software control instruction; the second control field segment being used to determine whether to cache task data composed of the input thread data; the first control field segment having a higher priority than the second control field segment; The resource management unit is further configured to directly send the shader task to the shader when the shader task does not need to execute the software control instruction; The resource management unit is further configured to, when the shader task needs to execute a software control instruction, send the shader task to the shader after the instruction control unit executes the software control instruction.
17. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, after being executed, can implement the task scheduling method described in any one of claims 1 to 15.
Citation Information
Patent Citations
Tinter treatment system and method
CN101425175A
Switching between dedicated function hardware and use of a software routine to generate result data
US20120007878A1