Command processing method, graphics processing unit, central processing unit and computer equipment
By executing multiple command processing operations on the graphics processor, generating and executing the second scheduling command corresponding to the target configuration information, the problem of long execution time on the CPU side is solved, and the effect of reducing the execution time and resource usage on the CPU side is achieved.
Patent Information
- Application Number
- CN202411998325.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, the CPU side executes a scheduling command that indirectly executes commands to configure N different configuration information, resulting in a longer execution time on the CPU side.
By obtaining the first scheduling command sent by the central processor, and performing the command processing operations multiple times based on the command, the command processing operations are executed by the graphics processor, and the second scheduling command corresponding to the target configuration information is generated and executed, reducing the configuration and execution times on the CPU side.
It reduces the execution time and resource usage on the CPU side, and improves the efficiency of command processing.
Smart Images

Figure CN119847710A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a command processing method, a graphics processor, a central processing unit, and a computer device. Background Art
[0002] An application can send an indirect execution (ExecuteIndirect) command to the central processing unit (CPU) to enable the graphics processing unit (GPU) to cyclically execute multiple dispatch commands with different configuration information.
[0003] In the related art, a driver on the CPU side is required to configure N scheduling commands with different configuration information according to the indirect execution command, and then send the configured N scheduling commands to the GPU, so that the GPU cyclically executes the N scheduling commands.
[0004] However, the current command processing method has the problem of long execution time on the CPU side. Summary of the invention
[0005] Based on this, it is necessary to provide a command processing method, a graphics processor, a central processing unit and a computer device that can reduce the execution time on the CPU side in response to the above technical problems.
[0006] In a first aspect, the present application provides a command processing method, applied to a graphics processor, the method comprising:
[0007] Acquire a first scheduling command sent by the central processing unit; the first scheduling command is generated by the central processing unit based on the indirect execution command;
[0008] Based on the first scheduling command, a command processing operation is executed multiple times; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0009] In one embodiment, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0010] In one embodiment, executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information includes:
[0011] When the value of the counter meets the trigger condition, the target configuration information is obtained, and the second scheduling command corresponding to the target configuration information is executed;
[0012] Update the counter value and return to execute command processing operations until the counter value does not meet the trigger condition.
[0013] In one embodiment, obtaining target configuration information includes:
[0014] Determine the address offset according to the value of the counter;
[0015] The target configuration information is determined from a parameter list according to the address offset and the base address; the parameter list is determined according to the indirect execution command.
[0016] In one of the embodiments, the value of the counter satisfies a trigger condition, including any one of the following:
[0017] The value of the counter is less than or equal to the preset number of cycles;
[0018] The duration corresponding to the counter value is less than or equal to the preset cycle duration.
[0019] In one embodiment, the counter is configured by the central processing unit according to an indirect execution command and is stored in a memory of the graphics processing unit.
[0020] In a second aspect, the present application further provides a command processing method, applied to a central processing unit, the method comprising:
[0021] generating a first scheduling command based on the indirect execution command;
[0022] A first scheduling command is sent to the graphics processor, where the first scheduling command is used for the graphics processor to perform a command processing operation multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0023] In one embodiment, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0024] In one embodiment, the method further comprises:
[0025] The counters are configured according to the indirect execution command; the counters are stored in the memory of the graphics processor.
[0026] In a third aspect, the present application further provides a graphics processor, comprising:
[0027] An acquisition module, used for acquiring a first scheduling command sent by a central processing unit; the first scheduling command is generated by the central processing unit based on an indirect execution command;
[0028] An execution module, configured to execute a command processing operation multiple times based on the first scheduling command;
[0029] In one embodiment, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0030] In a fourth aspect, the present application further provides a central processing unit, including:
[0031] A generating module, configured to generate a first scheduling command based on the indirect execution command;
[0032] The sending module is used to send a first scheduling command to the graphics processor, where the first scheduling command is used for the graphics processor to perform command processing operations multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0033] In a fifth aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.
[0034] In a sixth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0035] In a seventh aspect, the present application also provides a computer program product, comprising a computer program, which implements the steps of any of the above methods when executed by a processor.
[0036] The command processing method, graphics processor, central processing unit and computer device can obtain the first scheduling command sent by the central processing unit, and execute the command processing operation multiple times based on the first scheduling command. Since the first scheduling command is generated by the central processing unit based on the indirect execution command, the command processing operation is used to execute the second scheduling command corresponding to the target configuration information. Therefore, except for the first scheduling command generated by the CPU, other scheduling commands are generated by the GPU, and there is no need for the CPU to configure scheduling commands with different configuration information N times, so that the execution time and resource usage on the CPU side can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1A schematic diagram of a process of executing a scheduling command in the related art;
[0039] Figure 2 It is a schematic diagram of another process of executing a scheduling command in the related art;
[0040] Figure 3 An application environment diagram of a command processing method in an embodiment;
[0041] Figure 4 A flowchart of a command processing method in an embodiment;
[0042] Figure 5 is a schematic diagram of a flow chart of executing a second scheduling command in one embodiment;
[0043] Figure 6 A schematic diagram of a process for obtaining target configuration information in an embodiment;
[0044] Figure 7 is a flowchart of yet another command processing method in an embodiment;
[0045] Figure 8 A process schematic diagram of a command processing method in one embodiment;
[0046] Fig. 9 A process diagram of yet another command processing method in one embodiment;
[0047] Fig.10 is a structural block diagram of a graphics processor in one embodiment;
[0048] Fig.11 is a structural block diagram of a central processing unit in one embodiment;
[0049] Fig.12 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] Figure 1 FIG. 1 is a schematic diagram of a process of executing a scheduling command in a related technology, such as Figure 1As shown, the application can determine the preset number of times N and the parameter list (Argument Buffer). After that, the application will send an indirect execution command including the preset number of times and the parameter list to the driver on the CPU side. The driver obtains the configuration information corresponding to each scheduling command based on the indirect execution command and the parameter list to configure N scheduling commands. N is an integer greater than 1.
[0052] by Figure 1 For example, the driver can determine configuration information 1 based on the parameter list and configure the first dispatch command according to configuration information 1, and determine configuration information 2 based on the parameter list and configure the second dispatch command according to configuration information 2. And so on. After the driver determines configuration information N based on the parameter list and configures the Nth dispatch command according to configuration information N, the driver has configured N dispatch commands with different configuration information.
[0053] Furthermore, the driver sends the configured N scheduling commands to the GPU, for example, to the GPU hardware, so that the GPU can execute the N scheduling commands cyclically. Afterwards, the GPU can return the execution result to the driver, and the driver returns the execution result to the application.
[0054] However, the above process requires the driver on the CPU side to expand the loop to configure N scheduling commands. If N is relatively large, it will lead to a long execution time on the CPU side and a large occupation of resources such as memory space.
[0055] Figure 2 FIG. 1 is another schematic diagram of a process of executing a scheduling command in the related art, such as Figure 2 As shown, after the application sends an indirect execution command including a preset number of times and a parameter list to the driver on the CPU side, the driver on the CPU side directly configures the indirect execution command to the GPU, for example, to the GPU hardware, and the GPU spontaneously obtains the configuration information corresponding to each dispatch based on the parameter list to configure N dispatch commands and execute the N dispatch commands cyclically. Afterwards, the GPU returns the execution result to the driver, and the driver returns the execution result to the application.
[0056] However, the above process completely relies on the GPU hardware's support for indirect execution commands. Currently, many GPU hardware do not support this function and cannot implement loop execution.
[0057] Based on this, it is necessary to provide a command processing method. Under the premise that the CPU hardware does not support indirect execution of commands, the CPU can guide the GPU to complete the N-times loop execution behavior expected by the application, and it can reduce the CPU execution time and resource usage. The command processing method will be introduced below.
[0058] Figure 3 FIG. 1 is an application environment diagram of a command processing method in an embodiment. The command processing method provided in the embodiment of the present application can be applied to the following: Figure 3 In the application environment shown, the CPU 101 communicates with the GPU 102. The CPU 101 sends a first scheduling command to the GPU 102, and the GPU 102 performs command processing operations multiple times based on the first scheduling command to achieve the purpose of cyclically executing multiple scheduling commands.
[0059] Figure 4 FIG. 1 is a flow chart of a command processing method in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 4 As shown, a command processing method is provided, which is applied to Figure 1 The graphics processor in is used as an example for description, including the following S401 to S402.
[0060] S401, obtaining a first scheduling command sent by a central processing unit; the first scheduling command is generated by the central processing unit based on an indirect execution command.
[0061] In this embodiment, the CPU can generate the first scheduling command based on the ExecuteIndirect command. The ExecuteIndirect command can be a command sent by an application to the CPU. The application includes but is not limited to the multimedia programming interface Direct3d12.
[0062] The first dispatch command is a dispatch command configured by the CPU. Optionally, after receiving the ExecuteIndirect command, the CPU can configure the first dispatch command based on the ExecuteIndirect command, and use the first dispatch command as the first dispatch command. Further optionally, the ExecuteIndirect command can include a parameter list, and the CPU can obtain the configuration information corresponding to the first dispatch command from the parameter list, and configure the first dispatch command according to the configuration information corresponding to the first dispatch command to obtain the first dispatch command. Then, the CPU sends the first dispatch command to the GPU, so that the GPU obtains the first dispatch command.
[0063] Further optionally, the CPU may receive an ExecuteIndirect command when pre-rendering processing or post-rendering processing is required, and configure the first dispatch command based on the ExecuteIndirect command.
[0064] S402, based on the first scheduling command, execute a command processing operation multiple times; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0065] In this embodiment, there is a one-to-one correspondence between the command processing operation, the target configuration information and the second scheduling command. That is, each time a command processing operation is executed, a second scheduling command corresponding to the target configuration information is executed.
[0066] The target configuration information is the configuration information corresponding to the second dispatch command to be executed this time. For example, the GPU obtains the target configuration information corresponding to the second dispatch command during the first command processing operation, and obtains the target configuration information corresponding to the third dispatch command during the second command processing operation. Optionally, the GPU can obtain the target configuration information from a preset storage space.
[0067] Furthermore, the first dispatch command can instruct the GPU to perform command processing operations multiple times. In this way, the GPU can perform command processing operations multiple times based on the first dispatch command. In other words, the GPU can perform the second dispatch command corresponding to the target configuration information multiple times based on the first dispatch command. For example, the GPU executes the second dispatch command corresponding to the target configuration information, the third dispatch command corresponding to the target configuration information, and so on based on the first dispatch command.
[0068] Optionally, different second dispatch commands may correspond to different target configuration information. For example, during the first command processing operation, the target configuration information is configuration information A, and the GPU executes the second dispatch command corresponding to configuration information A; during the second command processing operation, the target configuration information is configuration information B, and the GPU executes the third dispatch command corresponding to configuration information B, and so on. In this way, the CPU only needs to configure the first dispatch command, and the GPU will execute the second dispatch command, the third dispatch command, and other dispatch commands with different configuration information based on the first dispatch command.
[0069] In one embodiment, after the GPU executes the command processing operation multiple times, the CPU may perform pre-rendering processing or post-rendering processing based on the results of executing the command processing operation multiple times.
[0070] In an exemplary embodiment, optionally, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0071] In this embodiment, in each command processing operation, the GPU first obtains the value of the counter corresponding to itself, and then executes the second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information. In this way, after receiving the first scheduling command sent by the CPU, the GPU can cyclically execute multiple scheduling commands of different configuration information based on the first scheduling command.
[0072] The counter corresponding to the GPU may be a counter configured in advance by the GPU, or may be a counter generated in the GPU by the CPU after receiving the first scheduling command, and this embodiment is not limited thereto. The value of the counter is used to determine whether the GPU has entered a command processing operation, for example, the value of the counter may be equal to the number of scheduling commands executed by the GPU.
[0073] Exemplarily, after the GPU obtains the value of the counter, if the value of the counter has not reached the preset number of times N, it obtains the target configuration information corresponding to the current command processing operation, and executes the second scheduling command corresponding to the target configuration information, then adds one to the value of the counter, and continues to return to the step of obtaining the value of the counter until the value of the counter reaches the preset number of times N to stop the command processing operation.
[0074] In the above embodiment, since the command processing operation includes: obtaining the value of the counter corresponding to the graphics processor, and executing the second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information, the central processing unit, i.e., the CPU, only needs to configure the scheduling command once to trigger the graphics processor, i.e., the GPU to execute multiple scheduling commands with different configuration information.
[0075] In the above command processing method, the first scheduling command sent by the central processing unit can be obtained, and based on the first scheduling command, the command processing operation is executed multiple times. Since the first scheduling command is generated by the central processing unit based on the indirect execution command, the command processing operation is used to execute the second scheduling command corresponding to the target configuration information. Therefore, except for the first scheduling command generated by the CPU, other scheduling commands are generated by the GPU, and the CPU does not need to configure scheduling commands with different configuration information N times. In this way, the execution time and resource usage on the CPU side can be reduced.
[0076] Figure 5 FIG. 1 is a flow chart of executing a second scheduling command in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 5 As shown, the step of "obtaining the value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information" in S402 includes S501 to S502.
[0077] S501: When the value of the counter meets a trigger condition, obtain target configuration information and execute a second scheduling command corresponding to the target configuration information.
[0078] In this embodiment, when the GPU is executing the command processing operation, it first determines whether the value of the counter meets the trigger condition. The trigger condition is used to determine whether to continue to execute the command processing operation, which can be set according to requirements. For example, the trigger condition can be that the value of the counter does not reach the preset number N.
[0079] Then, when the value of the counter meets the trigger condition, the GPU obtains the target configuration information. It is understandable that when the value of the counter does not meet the trigger condition, the GPU will stop the command processing operation.
[0080] In each command processing operation, the target configuration information obtained by the GPU is the configuration information corresponding to the second dispatch command to be executed this time. Optionally, the parameter list may include the configuration information corresponding to each dispatch command, and the configuration information includes but is not limited to the resources and parameters corresponding to each dispatch command. Furthermore, the GPU can obtain the target configuration information required for this dispatch command from the parameter list.
[0081] Further, after obtaining the target configuration information, the GPU can execute the second dispatch command corresponding to the target configuration information. That is, after obtaining the target configuration information required by this dispatch command, the GPU can execute the dispatch command according to the target configuration information corresponding to this dispatch command.
[0082] S502, updating the value of the counter and returning to execute the command processing operation until the value of the counter does not meet the trigger condition.
[0083] In this embodiment, after each execution of the second scheduling command corresponding to the target configuration information, the GPU updates the value of the counter. Optionally, the GPU may increase the value of the counter by a preset amount to update the value of the counter, and the preset amount is, for example, 1. It is understandable that before executing the command processing operation, the value of the counter is an initial value, and the initial value may be, for example, 0. In some embodiments, the initial value may also be 1.
[0084] After updating the counter value, the GPU will return to execute the command processing operation again. That is, after updating the counter value, the GPU will continue to determine whether the counter value meets the trigger condition, and if the counter value meets the trigger condition, continue to obtain the target configuration information, execute the second scheduling command corresponding to the target configuration information, and update the counter value again, and then return to the command processing operation again, until the counter value does not meet the trigger condition.
[0085] Exemplarily, taking the initial value of the counter as 1 and the preset number of times N=3 as an example, after the CPU sends the first dispatch command to the GPU, that is, the first scheduling command, the GPU enters the first command processing operation based on the first scheduling command. In the first command processing operation, the GPU obtains the value of the counter as 1. At this time, the value of the counter has not reached the preset number of times N, and the trigger condition is met. Therefore, the GPU obtains the target configuration information corresponding to the second dispatch command, and executes the second dispatch command according to the target configuration information, that is, the second scheduling command corresponding to the first command processing operation.
[0086] After that, the GPU updates the counter value to 2 and enters the second command processing operation. In the second command processing operation, the GPU obtains the counter value of 2, and the counter value has not yet reached the preset number of times N, satisfying the trigger condition. Therefore, the GPU obtains the target configuration information corresponding to the third dispatch command and executes the third dispatch command according to the target configuration information, that is, the second dispatch command corresponding to the second command processing operation.
[0087] Further, the GPU updates the counter value to 3 and enters the third command processing operation. In the third command processing operation, since the counter value has reached the preset number of times N and does not meet the trigger condition, the GPU stops the command processing operation. At this point, the GPU can implement multiple command processing operations, thereby implementing the cyclic execution of multiple scheduling commands with different configuration information.
[0088] In the above embodiment, when the value of the counter meets the trigger condition, the target configuration information is obtained, and the second scheduling command corresponding to the target configuration information is executed, and then the value of the counter is updated, and the command processing operation is returned until the value of the counter does not meet the trigger condition. Therefore, the command processing operation can be performed multiple times through the value of the counter to realize the cyclic execution of scheduling commands of different configuration information. In addition, the command processing operation is executed by the GPU, and the CPU does not need to configure the scheduling commands of different configuration information N times, which reduces the execution time and resource occupation on the CPU side. In addition, using the value of the counter as the judgment condition for whether to trigger the command processing operation is easy to implement, which can reduce the computing power resources of the GPU.
[0089] Figure 6 FIG. 1 is a flow chart of obtaining target configuration information in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 6 As shown, "obtaining target configuration information" in S501 includes S601 to S602.
[0090] S601, determining an address offset according to a value of a counter.
[0091] In this embodiment, the GPU can determine the address offset according to the value of the counter. Optionally, the GPU can use the value of the counter as the address offset, or can determine the address offset according to the value of the counter. Continuing with the above example, when entering the first command processing operation, the value of the counter is 1, and the address offset is 1. When entering the second command processing operation, the value of the counter is 2, and the address offset is 2.
[0092] In some embodiments, the GPU may also determine the address offset according to the value of the counter and a preset relationship, where the preset relationship includes a correspondence between different counter values and different address offsets.
[0093] S602, determining target configuration information from a parameter list according to the address offset and the base address; the parameter list is determined according to the indirect execution command.
[0094] In this embodiment, the GPU may determine the base address. Optionally, the CPU receives an ExecuteIndirect command sent by the application, the ExecuteIndirect command includes a parameter list, the parameter list includes the base address, and the CPU may send the base address to the GPU.
[0095] The address offset is used to indicate the address offset of the base address corresponding to the target configuration information. The parameter list may include multiple configuration information and the address corresponding to each configuration information. In this way, after the GPU determines the address offset and the base address, it can determine the target configuration information from the parameter list according to the address offset and the base address. Optionally, the GPU can determine the target address according to the address offset and the base address, for example, taking the sum of the base address and the address offset as the base address, and determining the target configuration information from the parameter list according to the target address.
[0096] Continuing with the above example, in the first command processing operation, the counter value is 1, the address offset is 1, and the GPU obtains the target configuration information corresponding to the second dispatch command from the parameter list based on the base address and address offset "1". In the second command processing operation, the counter value is 2, the address offset is 2, and the GPU obtains the target configuration information corresponding to the third dispatch command from the parameter list based on the base address and address offset "2", and so on.
[0097] In the above embodiment, since the address offset is determined according to the value of the counter, and the target configuration information is determined from the parameter list according to the address offset and the base address, and the parameter list is determined according to the indirect execution command, the GPU can efficiently and accurately obtain the target configuration information during each command processing operation, so as to realize the process of dynamically obtaining the configuration information corresponding to each dispatch.
[0098] In an exemplary embodiment, optionally, the value of the counter satisfies a trigger condition, including any one of the following: (1) the value of the counter is less than or equal to a preset number of cycles; (2) the duration corresponding to the value of the counter is less than or equal to a preset cycle duration.
[0099] In this embodiment, when the GPU determines whether the value of the counter meets the trigger condition, it can determine by a preset number of cycles or by a preset cycle duration.
[0100] In one embodiment, if the value of the counter is less than or equal to the preset number of cycles, the GPU determines that the value of the counter satisfies the trigger condition. Conversely, if the value of the counter is greater than the preset number of cycles, the GPU determines that the value of the counter does not satisfy the trigger condition. The value of the counter may represent the number of command processing operations that the GPU has executed. The preset number of cycles represents the number of command processing operations that the GPU is expected to execute, and the preset number of cycles may be determined according to a preset number N. Exemplarily, the preset number of cycles may be equal to N, and in some embodiments, the preset number of cycles may also be equal to N-1.
[0101] In one embodiment, if the duration corresponding to the value of the counter is less than or equal to the preset cycle duration, the GPU determines that the value of the counter meets the trigger condition. Conversely, if the duration corresponding to the value of the counter is greater than the preset cycle duration, the GPU determines that the value of the counter does not meet the trigger condition. The duration corresponding to the value of the counter represents the duration of the command processing operation executed by the GPU, and the preset cycle duration represents the duration of the command processing operation expected to be executed by the GPU. Exemplarily, when updating the value of the counter, the GPU may update the value of the counter according to the difference between the current time and the time when the value of the counter was last updated. The preset cycle duration may be determined according to the duration corresponding to executing N command processing operations.
[0102] In the above embodiment, since it is possible to determine whether the value of the counter satisfies the trigger condition based on the fact that the value of the counter is less than or equal to the preset number of cycles, and the duration corresponding to the value of the counter is less than or equal to any one of the preset cycle durations, the flexibility of judging the trigger condition is improved.
[0103] In an exemplary embodiment, optionally, the counter is configured by the central processing unit according to an indirect execution command and is stored in the memory of the graphics processing unit.
[0104] In this embodiment, the CPU generates a counter stored in the memory of the GPU according to the ExecuteIndirect command. For example, after receiving the ExecuteIndirect command, the CPU can allocate a piece of GPU memory to store the counter. Further optionally, the memory corresponding to the counter can be smaller than a preset size. For example, the memory corresponding to the counter can be smaller than 32 bits. In this way, the GPU is also less occupied.
[0105] In the above embodiment, since the counter is configured by the central processing unit according to the indirect execution command and is stored in the memory of the graphics processing unit, it does not need to occupy the space resources of the CPU, further reducing the resource occupation on the CPU side.
[0106] The above example uses the command processing method applied to a GPU. The following describes the process of applying the method to a CPU. Figure 7 FIG. 1 is a flow chart of another command processing method in an embodiment. In an exemplary embodiment, as shown in FIG. Figure 7 As shown, a command processing method is provided, which is applied to Figure 1 The central processing unit in is taken as an example for description, including the following S701 to S702.
[0107] S701: Generate a first scheduling command based on an indirect execution command.
[0108] In this embodiment, the CPU may receive an ExecuteIndirect command sent by the application program, and generate a first scheduling command based on the ExecuteIndirect command. The first scheduling command may refer to S401, which will not be described in detail herein.
[0109] In one embodiment, the application may send an ExecuteIndirect command to the CPU when pre-rendering processing or post-rendering processing is required, so that the CPU generates a first scheduling command based on the ExecuteIndirect command.
[0110] S702, sending a first scheduling command to a graphics processor, where the first scheduling command is used for the graphics processor to perform a command processing operation multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0111] The process of S702 may refer to S402 and will not be described in detail here.
[0112] In the above command processing method, a first scheduling command can be generated based on the indirect execution command, and the first scheduling command can be sent to the graphics processor. Since the first scheduling command is used for the graphics processor to perform command processing operations multiple times based on the first scheduling command, and the command processing operation is used to execute the second scheduling command corresponding to the target configuration information, the CPU only needs to configure the scheduling command once to trigger the GPU to execute multiple scheduling commands with different configuration information, and there is no need for the CPU to configure scheduling commands with different configuration information N times, thereby reducing the execution time and resource usage on the CPU side.
[0113] In an exemplary embodiment, optionally, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0114] In this embodiment, after the CPU sends the first scheduling command to the GPU, the GPU can perform command processing operations multiple times based on the first scheduling command. In each command processing operation, the GPU first obtains the value of the counter corresponding to itself, and executes the second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information. In this way, after receiving the first scheduling command sent by the CPU, the GPU can cyclically execute scheduling commands with different configuration information multiple times based on the first scheduling command.
[0115] In the above embodiment, since the command processing operation includes: obtaining the value of the counter corresponding to the graphics processor, and executing the second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information, the GPU can execute scheduling commands with different configuration information multiple times through the value of the counter and the target configuration information.
[0116] In an exemplary embodiment, optionally, the command processing method further includes the following steps:
[0117] The counters are configured according to the indirect execution command; the counters are stored in the memory of the graphics processor.
[0118] In this embodiment, the CPU may further configure the counter according to the ExecuteIndirect command. For example, after receiving the ExecuteIndirect command, the CPU may allocate a GPU memory to store the counter. Optionally, the memory corresponding to the counter may be less than 32 bits.
[0119] In this way, the GPU obtains the value of the counter corresponding to the graphics processor in each command processing operation, and executes the second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0120] In one embodiment, the counter is used for the GPU to obtain target configuration information and execute a second scheduling command corresponding to the target configuration information when the value of the counter meets the trigger condition, and to update the value of the counter and return to execute the command processing operation until the value of the counter does not meet the trigger condition.
[0121] In the above embodiment, since the counter can be configured according to the indirect execution command and the counter is stored in the memory of the graphics processor, it does not need to occupy the space resources of the CPU, further reducing the resource occupation on the CPU side.
[0122] In order to more clearly introduce the command processing method of this application, Figure 8 and Fig. 9 Provide explanation. Figure 8 The following is a process diagram of a command processing method in an embodiment. The CPU and the GPU can execute the command processing method according to the following process.
[0123] S801, the CPU generates a first scheduling command based on the indirect execution command, and then enters S802.
[0124] S802, the CPU configures the counter in the GPU according to the indirect execution command, and then enters S803.
[0125] S803, the CPU sends a first scheduling command to the GPU, and then enters S804.
[0126] S804, the GPU obtains the value of the counter, and then enters S805.
[0127] S805, the GPU determines whether the value of the counter meets the trigger condition. If not, the process ends. If satisfied, the process proceeds to S806.
[0128] S806, the GPU determines the address offset according to the value of the counter, and then enters S807.
[0129] S807, the GPU determines the target configuration information from the parameter list according to the address offset and the base address, and then enters S808.
[0130] S808, the GPU executes the second scheduling command corresponding to the target configuration information, and then enters S809.
[0131] S809, update the value of the counter and return to step S804.
[0132] The processes of S801 to S809 may refer to the above embodiment and will not be described in detail here.
[0133] Fig. 9 FIG. 4 is a process diagram of another command processing method in an embodiment. Fig. 9 As shown, taking the command processing method applied to the CPU driver and GPU hardware as an example, when the application calls the ExecuteIndirect command, that is, when the application sends the ExecuteIndirect command to the driver, the driver configures the counter according to the ExecuteIndirect command to allocate a GPU memory for storing the counter. Afterwards, the driver configures the first dispatch command based on the ExecuteIndirect command, that is, configures the first dispatch command.
[0134] Furthermore, the driver configures a compute shader, which can be a program run by the GPU. The compute shader is used to use the value of the counter as a loop condition to control the GPU hardware to dynamically obtain the resources and parameters corresponding to each dispatch command, execute the dispatch command, and update the value of the counter to implement a loop execution of the configured dispatch command N times. Afterwards, the driver sends a first dispatch command to the GPU hardware. After receiving the first dispatch command, the GPU hardware performs command processing operations based on the first dispatch command multiple times to loop execute the dispatch command N times. Finally, the GPU hardware can return the execution result to the driver, so that the driver returns the execution result to the application. It can be understood that the target configuration information corresponding to the dispatch command executed cyclically by the GPU is different.
[0135] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0136] Based on the same inventive concept, the embodiment of the present application also provides a graphics processor and a central processing unit for implementing the command processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more graphics processor and central processing unit embodiments provided below can refer to the limitations on the command processing method above, and will not be repeated here.
[0137] Fig.10 FIG. 1 is a block diagram of a graphics processor in one embodiment. In an exemplary embodiment, Fig.10 As shown, a graphics processor 1000 is provided, including: an acquisition module 1001 and an execution module 1002, wherein:
[0138] The acquisition module 1001 is used to acquire a first scheduling command sent by the central processing unit; the first scheduling command is generated by the central processing unit based on the indirect execution command.
[0139] The execution module 1002 is used to execute a command processing operation multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0140] In the above-mentioned command processing device, it is possible to obtain the first scheduling command sent by the central processing unit, and based on the first scheduling command, execute the command processing operation multiple times. Since the first scheduling command is generated by the central processing unit based on the indirect execution command, and the command processing operation is used to execute the second scheduling command corresponding to the target configuration information, the central processing unit, that is, the CPU, only needs to configure the scheduling command once to trigger the graphics processing unit, that is, the GPU to execute multiple scheduling commands with different configuration information. That is, except for the first scheduling command generated by the CPU, the other scheduling commands are all generated by the GPU, and there is no need for the CPU to configure the scheduling commands with different configuration information N times. In this way, the execution time and resource usage on the CPU side can be reduced.
[0141] Optionally, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0142] Optionally, the execution module 1002 includes:
[0143] The execution unit is used to obtain the target configuration information and execute the second scheduling command corresponding to the target configuration information when the value of the counter meets the trigger condition.
[0144] The updating unit is used to update the value of the counter and return to execute the command processing operation until the value of the counter does not meet the trigger condition.
[0145] Optionally, the execution unit includes:
[0146] The first determining subunit is used to determine the address offset according to the value of the counter.
[0147] The second determination subunit is used to determine the target configuration information from the parameter list according to the address offset and the base address; the parameter list is determined according to the indirect execution command.
[0148] Optionally, the counter value satisfies a trigger condition, including any of the following:
[0149] The value of the counter is less than or equal to the preset number of cycles;
[0150] The duration corresponding to the counter value is less than or equal to the preset cycle duration.
[0151] Optionally, the counter is configured by the central processing unit according to an indirect execution command and is stored in a memory of the graphics processing unit.
[0152] Fig.11 FIG. 1 is a block diagram of a central processing unit in an embodiment. In an exemplary embodiment, Fig.11 As shown, a central processor 1100 is provided, including: a generating module 1101 and a sending module 1102, wherein:
[0153] The generating module 1101 is configured to generate a first scheduling command based on an indirect execution command.
[0154] The sending module 1102 is used to send a first scheduling command to the graphics processor, where the first scheduling command is used for the graphics processor to perform a command processing operation multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
[0155] In the above command processing device, a first scheduling command can be generated based on the indirect execution command, and the first scheduling command can be sent to the graphics processor. Since the first scheduling command is used for the graphics processor to perform command processing operations multiple times based on the first scheduling command, and the command processing operation is used to execute the second scheduling command corresponding to the target configuration information, the CPU only needs to configure the scheduling command once to trigger the GPU to execute multiple scheduling commands with different configuration information, and the CPU does not need to configure the scheduling commands with different configuration information N times, thereby reducing the execution time and resource usage on the CPU side.
[0156] Optionally, the command processing operation includes: obtaining a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
[0157] Optionally, the central processor 1100 further includes:
[0158] The configuration module is used for configuring the counter according to the indirect execution command; the counter is stored in the memory of the graphics processor.
[0159] Each module in the above-mentioned graphics processor and central processor can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0160] Fig.12 FIG. 1 is an internal structure diagram of a computer device in an embodiment. In an exemplary embodiment, a computer device is provided. The computer device may be a server. The internal structure diagram thereof may be as shown in FIG. Fig.12 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store relevant data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a command processing method is implemented.
[0161] Those skilled in the art will understand that Fig.12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0162] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0163] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0164] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0165] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0166] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0167] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A command processing method, characterized in that: Applied to a graphics processor; the method comprises: Acquire a first scheduling command sent by a central processing unit; the first scheduling command is generated by the central processing unit based on an indirect execution command; Based on the first scheduling command, a command processing operation is performed multiple times; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
2. The method according to claim 1, characterized in that The command processing operation includes: acquiring a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
3. The method according to claim 2, characterized in that The executing, according to the value of the counter and the target configuration information, a second scheduling command corresponding to the target configuration information includes: When the value of the counter meets the trigger condition, obtaining the target configuration information, and executing the second scheduling command corresponding to the target configuration information; The value of the counter is updated, and the command processing operation is returned to be executed until the value of the counter does not meet the trigger condition.
4. The method according to claim 3, characterized in that The obtaining of the target configuration information includes: determining an address offset according to the value of the counter; The target configuration information is determined from a parameter list according to the address offset and the base address; the parameter list is determined according to the indirect execution command.
5. The method according to claim 3, characterized in that: The value of the counter satisfies a trigger condition, including any one of the following: The value of the counter is less than or equal to a preset number of cycles; The duration corresponding to the value of the counter is less than or equal to the preset cycle duration.
6. The method according to any one of claims 2 to 5, characterized in that: The counter is configured by the central processing unit according to the indirect execution command and is stored in the memory of the graphics processing unit.
7. A command processing method, characterized in that: Applied to a central processing unit, the method comprises: generating a first scheduling command based on the indirect execution command; The first scheduling command is sent to the graphics processor, where the first scheduling command is used for the graphics processor to perform a command processing operation multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
8. The method according to claim 7, characterized in that The command processing operation includes: acquiring a value of a counter corresponding to the graphics processor, and executing a second scheduling command corresponding to the target configuration information according to the value of the counter and the target configuration information.
9. The method according to claim 8, characterized in that The method further comprises: The counter is configured according to the indirect execution command; and the counter is stored in a memory of the graphics processor.
10. A graphics processor, characterized in that: The graphics processor comprises: An acquisition module, configured to acquire a first scheduling command sent by a central processing unit; the first scheduling command is generated by the central processing unit based on an indirect execution command; An execution module is used to perform a command processing operation multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
11. A central processing unit, characterized in that: The central processing unit comprises: A generating module, configured to generate a first scheduling command based on the indirect execution command; The sending module is used to send the first scheduling command to the graphics processor, where the first scheduling command is used for the graphics processor to perform command processing operations multiple times based on the first scheduling command; the command processing operation is used to execute a second scheduling command corresponding to the target configuration information.
12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.