Command processing apparatus and method, electronic device, and computer storage medium
By allocating command dispatchers and computing units to users, combined with time-slice scheduling and ring buffers, the problems of low security and efficiency in AI chip virtualization are solved, and security and efficiency are improved.
Patent Information
- Application Number
- CN202110127623.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-29
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2041-01-29
AI Technical Summary
Existing technologies for virtualizing AI chips or GPUs suffer from low security, mainly because computing resources are shared among users, leading to security vulnerabilities and low processing efficiency.
By assigning corresponding command dispatchers and processing units to different users, computing resources are physically isolated. Combined with time-slice scheduling strategies and ring buffers, command processing for different users can be achieved, reducing security risks and improving processing efficiency.
It effectively reduces security risks caused by shared computing resources, improves user security and processing efficiency, and enhances the flexibility of GPU resource utilization.
Smart Images

Figure CN114816652B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer science, and in particular, to a command processing apparatus and method, an electronic device, and a computer readable storage medium. BACKGROUND
[0002] With the rapid development of cloud computing, the cloud can convert physical resources into logically manageable resources through virtualization methods to improve the physical resource utilization rate of the cloud server. Artificial intelligence (AI) computing is an important application scenario of cloud computing; and as an important undertaker of AI computing, the graphics processing unit (GPU) or AI chip also often performs virtualization in actual use.
[0003] The current method of virtualizing AI chips or GPUs has the problem of low security. SUMMARY
[0004] The embodiments of the present disclosure at least provide a command processing apparatus and method, an electronic device, and a computer readable storage medium.
[0005] In a first aspect, the embodiments of the present disclosure provide a command processing apparatus, comprising: a microcontroller, at least one user corresponding command distributor, and an operation unit corresponding to each command distributor; wherein the microcontroller is configured to read commands from the at least one user corresponding buffer and store the commands in the at least one user corresponding command queue; the command distributor is configured to read the commands from the corresponding command queue and distribute the commands to the operation unit corresponding to the command distributor; and the operation unit is configured to execute the commands distributed by the corresponding command distributor.
[0006] In this way, by allocating corresponding command distributors and operation units for different users, the processing of commands corresponding to different users can be realized, thereby physically isolating the computing resources for processing different commands and reducing the security risks caused by the sharing of computing resources among users, and improving the security of users.
[0007] In an optional implementation, for the case that there are multiple users and different users correspond to different buffers, the microcontroller is configured to read the commands from different buffers at different time slices.
[0008] In an alternative implementation, the microcontroller is configured to: sequentially take each of the plurality of time slices as a current time slice, and perform a listening process in the current time slice until the current time slice ends and switches to a next time slice; the listening process comprises: listening in the current time slice whether there is a command in the buffer corresponding to the current time slice; and in response to the case that there is the command in the buffer corresponding to the current time slice, reading the command from the buffer corresponding to the current time slice.
[0009] In this way, by setting different buffers to process commands in different time slices, the commands stored in different buffers can be processed in an orderly manner. Meanwhile, when the commands are processed by using time division multiplexing, the commands issued by the host to different users in the buffer can be divided according to time slices, thereby effectively avoiding errors that may occur when the commands are issued to corresponding users.
[0010] In an alternative implementation, in the case that there are a plurality of users and different users correspond to different buffers, the microcontroller is configured to poll the buffers corresponding to the plurality of users respectively, and in response to the case that the buffer corresponding to a currently polled user is not empty, read a command from the currently polled buffer.
[0011] In this way, by polling the buffers corresponding to a plurality of users, the commands of each user can be quickly and efficiently transmitted to the command queue corresponding to each user, so that the command distributor can obtain the commands from the corresponding command queue in time and distribute the commands to the corresponding operation units, thereby ensuring efficient processing of the commands and improving processing efficiency.
[0012] In an alternative implementation, in the case that different users correspond to different buffers and one user corresponds to a plurality of buffers, the microcontroller is configured to, in each time slice corresponding to each user, poll the plurality of buffers corresponding to each user, and read a command from a currently polled buffer.
[0013] In this way, in the case that one user corresponds to a plurality of different buffers, the user can read commands from different buffers, so that the number of commands that the user can obtain can be increased, thereby enabling the user to process more commands.
[0014] In an alternative implementation, in the case that there are a plurality of users and different users correspond to the same buffer, the microcontroller is configured to read the commands from the same buffer corresponding to the plurality of users.
[0015] In this way, by letting a plurality of users correspond to the same buffer, the storage space of the buffer can be fully utilized, and the efficiency of the microcontroller in obtaining commands of the plurality of users can be improved.
[0016] In an alternative implementation, when there are multiple users and different users correspond to the same buffer, the microcontroller is configured to access the storage locations corresponding to the different users in the same buffer at different time slices respectively and read the commands; or poll the storage locations corresponding to the different users in the same buffer and read the commands.
[0017] In an alternative implementation, the buffer comprises a ring buffer, and the ring buffer comprises storage entries corresponding to each of the at least one command stream in the same user; and the microcontroller is configured to read the commands corresponding to each of the at least one command stream based on the storage entries corresponding to each of the at least one command stream in the ring buffer.
[0018] In this way, the commands corresponding to different command streams are stored in the ring buffer using the target entries corresponding to the command streams, so that the microcontroller can synchronously monitor multiple entries of the ring buffer and pull down the commands in different command streams in one processing cycle, thereby improving the efficiency of command acquisition. Meanwhile, the ring buffer can provide mutual exclusion access to the buffer for the communication program, which is conducive to avoiding the increased system overhead of the storage queue when commands are frequently allocated.
[0019] In an alternative implementation, the microcontroller is configured to store the commands corresponding to the at least one command stream in the same user into the command queue corresponding to the at least one command stream.
[0020] In an alternative implementation, when one user corresponds to multiple buffers, the microcontroller determines the command queue corresponding to each of the different buffers for the user when determining the command queue for the user.
[0021] In an alternative implementation, there are M users, and N target users of the M users share the same command queue and the same command distributor; M is an integer greater than 1; N is an integer less than or equal to M and greater than 1; and the microcontroller is configured to read commands from the buffers corresponding to the N target users at different time slices respectively and store the commands into the command queue shared by the N target users.
[0022] In an alternative implementation, the command distributor is configured to read the commands corresponding to different target users from the command queue shared by the N target users at the different time slices respectively and send the commands corresponding to different target users to the operation units corresponding to the command distributor; and the operation units corresponding to the command distributor are configured to execute the commands corresponding to the N target users at the different time slices respectively.
[0023] In this way, by time division multiplexing on the basis of space division multiplexing, multiple users can realize multiplexing of a certain command distributor and a corresponding operation unit, thereby improving the number of users deployed on the same device and improving the flexibility of GPU resource utilization.
[0024] In a second aspect, the embodiments of the present disclosure further provide a command processing method, applied to a command processing device, the command processing device comprising a microcontroller, at least one user corresponding command distributor, and an operation unit corresponding to each command distributor; the command processing method comprising: the microcontroller reading a command from the at least one user corresponding buffer and storing the command in the at least one user corresponding command queue; the command distributor reading the command from the corresponding command queue and distributing the command to the operation unit corresponding to the command distributor; and the operation unit executing the command distributed by the corresponding command distributor.
[0025] In a third aspect, the embodiments of the present disclosure further provide an electronic device, comprising a host, a buffer, and a command processing device; the host is configured to issue a to-be-executed command and store it in at least one user corresponding buffer;
[0026] The command processing device is configured to execute the command processing method provided in any one of the embodiments of the second aspect.
[0027] In a fourth aspect, the embodiments of the present disclosure further provide a computer readable storage medium having a computer program stored thereon, the program being executed by a microcontroller, a command distributor, and an operation unit to implement the command processing method provided in any one of the embodiments of the second aspect.
[0028] For the effects of the above command processing method, refer to the description of the above command processing device, which will not be repeated here.
[0029] In order to make the above objectives, features and advantages of the present disclosure more apparent, below will be described in detail with reference to preferred embodiments and the accompanying drawings, as follows. BRIEF DESCRIPTION OF DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the drawings needed to be used in the embodiments, the drawings herein are incorporated into the description and form a part of the description, which show the embodiments consistent with the present disclosure, and are used to explain the technical solutions of the present disclosure together with the description. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be considered as a limitation to the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0031] Figure 1A schematic diagram of a command processing device provided by an embodiment of the present disclosure is shown.
[0032] Figure 2 A schematic diagram of a command queue provided by an embodiment of the present disclosure is shown.
[0033] Figure 3 A schematic diagram of a specific command processing device provided by an embodiment of the present disclosure is shown.
[0034] Figure 4 A flowchart of a command processing method provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described below in connection with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only some but not all of the embodiments of the present disclosure. The components of the embodiments of the present disclosure described and shown herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present disclosure.
[0036] It has been found through research that, when virtualizing a GPU or an AI chip, a time slice scheduling strategy can be used for context switching to support multiple user work. For example, in the case of virtualizing an AI chip into multiple users, the AI chip executes the relevant instructions of the current user within a time slice. Once the time slice is used up, the AI chip will immediately switch to the next user and execute the relevant instructions of the next user. This method, which separates different users by software, needs the AI chip to frequently perform context switching (user switching), and the time overhead of scheduling is large, which reduces the processing efficiency of the instructions in the user. At the same time, if a malicious attack on a certain user occurs, since different users share the same computing resources, it is easy to cause security threats to other users, and the security is poor.
[0037] Based on the above research, the present disclosure provides a command processing device, method, computer device, and storage medium, which can physically separate the computing resources for executing computing tasks of different users, reduce the security risks caused by the sharing of computing resources between users, and improve the security of the users.
[0038] The above-mentioned defects are the results of the inventors' practice and careful research, and thus the discovery process of the above-mentioned problems and the solutions proposed by the present disclosure to solve the above-mentioned problems should be the contributions of the inventors to the present disclosure.
[0039] It should be noted that similar reference numbers and letters represent similar items in the following drawings, and thus once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0040] To facilitate the understanding of the present embodiment, first, a command processing method disclosed by the present embodiment is introduced in detail.
[0041] The command processing apparatus provided by the present embodiment can be applied to a GPU, an artificial intelligence chip, or other instruction processing devices including an instruction processor and an execution unit.
[0042] The command processing apparatus provided by the present embodiment is described below by taking the application of the command processing apparatus to a GPU as an example, but it can also be applied to other types of command processing apparatuses.
[0043] Referring to FIG. 1, Figure 1 FIG. 1 is a structural schematic diagram of a command processing apparatus provided by the present embodiment, which includes a microcontroller 10, at least one command distributor 20 corresponding to each user (wherein Figure 1 a plurality of command distributors are shown in FIG. 2, including command distributor 0 to command distributor n), and an operation unit 30 corresponding to each command distributor 20 (wherein Figure 1 a plurality of operation units 0 to operation unit n are shown in FIG. 3);
[0044] The microcontroller 10 is configured to read commands from the buffer corresponding to each user and store the commands in the command queue corresponding to each user.
[0045] The command distributor 20 is configured to read commands from the corresponding command queue and distribute the commands to the operation unit 30 corresponding to the command distributor 20.
[0046] The operation unit 30 is configured to execute the commands distributed by the corresponding command distributor 20.
[0047] In this embodiment, the command processing device includes a microcontroller 10, a command dispatcher 20 corresponding to each of at least one user, and a processing unit 30 corresponding to each command dispatcher 20. After the host sends commands from different users to the corresponding user's buffer, the microcontroller 10 can read the command from the buffer corresponding to the same user and store the command in the command queue corresponding to the same user. After the command dispatcher 20 reads the command from the corresponding command queue, it dispatches the command to the processing unit 30 corresponding to the command dispatcher 20, so that the processing unit 30 corresponding to the command dispatcher 20 can execute the corresponding command. By assigning corresponding command dispatchers 20 and processing units 30 to different users, the processing of instructions corresponding to different users is realized, thereby physically isolating the computing resources for processing different commands, reducing the security risks caused by sharing computing resources among users, and improving user security.
[0048] Users in this disclosure may include, for example, any of the following: virtual machine, computer container, application, or different functions within an application.
[0049] The following describes the microcontroller 10, command dispatcher 20, and arithmetic unit 30 in detail, taking the user as a virtual machine as an example.
[0050] When creating a virtual machine, corresponding computing resources need to be allocated to it. In this embodiment, the computing resources allocated to the virtual machine include the command dispatcher 20 and the arithmetic unit 30 in the GPU. The number of arithmetic units 30 is determined according to the computing resource configuration information determined when the virtual machine is created. Additionally, a buffer corresponding to the virtual machine can also be allocated to it during creation.
[0051] When a virtual machine is running, the application layer of the virtual machine can have one or more command streams at the same time; each stream includes at least one command, and the command in the stream is sent from the host to the buffer corresponding to the virtual machine.
[0052] For example, when running software in virtual machine VM1, one or more software functions of the software can be run; when virtual machine VM1 runs only one of the software functions, the host can generate a command stream for running this software function. When the command stream executes the processing task, it will generate a command stream; the host stores the commands in the stream into a buffer corresponding to the virtual machine VM1.
[0053] In the determination of the buffer, there can be multiple streams (multiple command streams, different command streams corresponding to different streams), and there can be multiple commands in each stream, so there can be parallel processing of commands in different streams, and there can be a processing order of commands in the same stream, for example, after multiple commands in a certain stream are issued, the first issued command is stored and processed according to the time order of the issuance, and after the first issued command is processed, the later issued command is processed. In order to facilitate the parallel processing of commands in multiple streams, and to facilitate the sequential processing of multiple commands in the same stream according to the time order of the command issuance, the embodiment of the present disclosure selects a ring buffer (RBUF) to solve the problem of frequent lock calls (i.e., frequent storage, shifting, and release of commands, etc.). That is, memory is not allocated frequently, so that the buffer can be reused, reducing the waste of storage space in the buffer.
[0054] In the embodiment of the present disclosure, the ring buffer includes a storage entry corresponding to each command stream in at least one command stream; and the at least one command stream runs in the same user.
[0055] For example, the buffer and the user one-to-one correspond;
[0056] And / or, one buffer can correspond to multiple users;
[0057] And / or, one user can also correspond to multiple buffers.
[0058] For example, the determined multiple buffers can include n (n is a positive integer) buffers, respectively represented as RBUF1, RBUF2, …, RBUFn. At the same time, the virtual machine has m (m is a positive integer) virtual machines, for example, which can be represented as VM1, VM2, …, VMm.
[0059] Taking the virtual machine VM1 as an example:
[0060] (1) In the case of one user corresponding to one buffer, VM1 can correspond to one buffer, for example, VM1 corresponds to RBUF1, and all commands in the stream in VM1 are stored in RBUF1.
[0061] Here, for example, the following method can be used to issue commands to the buffer RBUF1: determining at least one command stream corresponding to the same user; determining at least one command corresponding to each command stream based on each command stream in the at least one command stream; and storing at least one command corresponding to each command stream in the at least one command stream in the buffer using the storage entry included in the buffer corresponding to the at least one command stream in the same user.
[0062] In a specific implementation, the command streams corresponding to different applications are different. For example, in an application (Application) for image processing by a user, the command stream for scheduling operations in a process (Process) of an operating system can include, for example, three command streams: image preprocessing, target recognition on the processed image by a convolutional neural network, and determination of the target object in the image. Each command stream can correspond to at least one command. For example, when the command stream includes target recognition on the processed image by a convolutional neural network, the required convolution and pooling operations can be divided into corresponding commands such as various kernels, data migration, and synchronization operations. At this time, for example, H (H is a positive integer) command streams can be determined and sequentially numbered, for example, as 1, 2,..., H. For example, the first command stream (corresponding to the number 1) can include K commands, and the i-th command in the K commands can be represented as P 1-i (i∈[1,K])).
[0063] (2) In the case where one user corresponds to multiple buffers, VM1 can correspond to s buffers, for example, VM1 corresponds to RBUF1, RBUF2,..., RBUFs; RBUF1, RBUF2,..., RBUFs are used to store commands in at least one stream in VM1.
[0064] Here, for example, the commands can be issued to the buffers RBUF1-RBUFs in the following manner: determining the command stream corresponding to the user; dividing the command stream corresponding to the user into multiple command stream groups based on the number of buffers corresponding to the user; each buffer corresponding to the user corresponds to a command stream group; for each command stream group, using the storage entry in the buffer corresponding to the command stream group corresponding to each command stream in the command stream group to store at least one command corresponding to each command stream in the command stream group in the buffer corresponding to the command stream group.
[0065] For example, in the example in (1) above, if s=2, the H command streams can be divided into two command stream groups, and the two command stream groups correspond to RBUF1 and RBUF2, respectively. The instructions in each command stream are issued to RBUF1 or RBUF2 according to the command stream group to which each command stream belongs.
[0066] (3): In the case of a buffer corresponding to multiple users, VM1 and VM2 can, for example, jointly correspond to a buffer RBUF1, which includes the entries of each stream in VM1 and the entries of each stream in VM2.
[0067] At this point, after determining at least one command corresponding to each command stream, at least one command can be stored in buffer RBUF1. When storing commands in buffer RBUF1, for example, the storage entry corresponding to each command stream in buffer RBUF1 can also be determined.
[0068] In one possible implementation, when determining the storage entry in buffer RBUF1, for example, the storage space can be evenly allocated to multiple command streams based on the amount of data corresponding to the commands stored in buffer RBUF1 (hereinafter, for convenience, "data corresponding to the commands" will be uniformly referred to as "commands," but it still includes the corresponding data). The data transmission entry of the first storage space in the storage space corresponding to each command stream is then used as the storage entry of the corresponding command stream. Since the storage location of the command is determined by addressing using read and write pointers when storing commands in buffer RBUF1, for ease of explanation of the storage and read locations corresponding to storing and reading commands in buffer RBUF1, the i-th address in buffer RBUF1 is represented by Loc-i below.
[0069] For example, when there are three command streams and buffer RBUF1 can store six sets of commands, the addresses corresponding to the storage space of buffer RBUF1 storing the six sets of commands can, for example, include Loc-1, Loc-2, ..., Loc-6. When evenly allocating storage space to the three command streams, for example, addresses Loc-1 and Loc-2 can be allocated to the first command stream, addresses Loc-3 and Loc-4 to the second command stream, and addresses Loc-5 and Loc-6 to the third command stream. In this case, the starting address Loc-1 of the first command stream can be used as the storage entry point for the first command stream, the starting address Loc-3 of the second command stream can be used as the storage entry point for the second command stream, and the starting address Loc-5 of the third command stream can be used as the storage entry point for the third command stream.
[0070] It should be noted here that the amount of space for storing commands corresponding to different buffers can be the same or different; this is not limited here. For example, the corresponding commands may include P. 1-1 P 1-2 P 2-1 P 2-2 P 3-1 and P3-2 .
[0071] In another possible implementation, the storage space for the multiple command streams can also be allocated according to experience or actual demand when determining the storage entry in the buffer RBUF1. The specific method is not described here again.
[0072] After the host issues the commands to the buffer, the microcontroller 10 in the command processing device can read the commands from the buffer corresponding to the user and store the commands in the command queue corresponding to each user.
[0073] When the buffer is a ring buffer, the microcontroller 10 can read the commands corresponding to each command stream based on the storage entry corresponding to each command stream in the ring buffer when reading the commands from the buffer corresponding to each user.
[0074] Here, the storage entry of the buffer RBUF1 can also be used as a reading entry. The method of reading the commands is similar to the method of storing the commands described above, and both are achieved by addressing through the read pointer and the write pointer to determine the command to be read. The specific addressing process is not described here again.
[0075] When the microcontroller 10 reads the commands from the buffer:
[0076] For the case where the user has only one, the microcontroller 10 reads the commands from the buffer and distributes the commands to the command distributor 20 corresponding to the user.
[0077] For the case where the user has multiple:
[0078] A: In the case where different users correspond to different buffers and one user corresponds to one buffer:
[0079] The microcontroller 10 can read the commands from the buffers corresponding to the multiple users in any of the following ways, for example:
[0080] (a1): Reading the commands from the different buffers respectively in different time slices.
[0081] Here, the time slice has a preset time length, for example, the time required to read at least one command in the buffer.
[0082] The microcontroller 10 sequentially takes multiple time slices as the current time slice and performs a listening process in each time slice until the current time slice ends and switches to the next time slice. The listening process includes: listening in the current time slice whether there is a command in the buffer corresponding to the current time slice; and in response to the case where there is a command in the buffer corresponding to the current time slice, reading the command from the buffer corresponding to the current time slice.
[0083] At this time, if there is no command to be read in the storage space in the current time slice, the microcontroller 10 will continue to monitor whether a command is stored in the buffer corresponding to the current time slice until the end of the current time slice.
[0084] (a2) : polling a plurality of buffers corresponding to the users respectively, and reading the command from each of the polled buffers corresponding to the users.
[0085] At this time, when polling a plurality of buffers corresponding to the users respectively, if a command is stored in the polled buffer, the microcontroller 10 reads the command stored in the buffer; if the polled buffer is currently empty, the next buffer is continued to be polled.
[0086] At this time, in order to prevent the command stored in a buffer from being too much, the microcontroller 10 spends more time when reading the command in the buffer, which affects the normal processing of other users. A maximum time length can be set for polling; if the command reading time length from a buffer reaches the maximum time length, the next buffer can also be jumped to be polled.
[0087] For example, in the case that there are 6 storage spaces in the buffer SBUF1 and the buffer SBUF2, if only the storage space corresponding to the address Loc-1 in the SBUF1 stores the command P 1-1 , and there is no command to be read in other storage spaces in the SBUF1, and there is a command P 1-2 to be read in the address Loc-1 in the SBUF2, the first entry position of the command in the buffer RBUF1 is read at 0 time; after the end of the first time slice, the first entry position of the command in the buffer RBUF2 is read.
[0088] At this time, for the remaining users VM2, VM3, …, VMm, the process of reading the command by the microcontroller 10 is similar to that of reading the command from the user VM1, which will not be described here.
[0089] B: In the case that different users correspond to different buffers, and one user corresponds to a plurality of buffers:
[0090] The microcontroller 10 polls a plurality of buffers corresponding to each user in the time slice corresponding to each user, and reads the command from the currently polled buffer.
[0091] The microprocessor 10 can read the command from the buffer in the same way as in the above-mentioned A.
[0092] When reading the commands from the buffers in the same way as in the above A, all the buffers corresponding to the users can be numbered, and the different buffers can be polled according to the numbers or the commands can be read in the different buffers in time slices.
[0093] When numbering all the buffers corresponding to the users, for example, the buffers corresponding to the same user can be numbered in a scattered way. For example, there are 3 users, VM1, VM2 and VM3, and the buffers corresponding to VM1, VM2 and VM3 are respectively numbered as 1, 4 and 7, 2, 5 and 8, and 3, 6 and 9. In this way, the instructions of each user can be ensured to be executed in time at least in part. Alternatively, the buffers corresponding to the same user can be numbered in a continuous way. For example, the buffers corresponding to VM1 are numbered as 1, 2 and 3. In this way, the overhead of the context switching of the microcontroller 10 can be reduced.
[0094] The specific way can be determined according to actual needs.
[0095] The process of reading the commands by the microcontroller 10 will be described in detail below by taking the case that the buffers RBUF1 and RBUF2 correspond to VM1 as an example.
[0096] In a specific implementation, when reading the commands from the buffer RBUF1 corresponding to each user, the microcontroller 10 can read the commands corresponding to each command stream based on the storage entries in the buffer RBUF1 corresponding to the command stream.
[0097] When the time slice is set as 2T for the buffers RBUF1 and RBUF2, only two commands in the buffer RBUF1 can be read in the first time slice, and in the next time slice, the microcontroller 10 can no longer read the commands in the buffer RBUF1, but perform the context switching of the buffer and read the commands in the next buffer RBUF2.
[0098] C: When there are multiple users and the same buffers correspond to different users, the microcontroller 10 can access the storage positions in the same buffer corresponding to the multiple users respectively in different time slices and read the commands, or poll the storage positions in the same buffer corresponding to the multiple users respectively and read the commands.
[0099] For example, the same buffer RBUF1 can correspond to users VM1, VM2 and VM3; the same buffer RBUF2 can correspond to users VM4 and VM5. The number of users corresponding to the same buffer can be the same or different, and the specific correspondence can be determined according to actual conditions, which is not limited herein.
[0100] For example, the same buffer RBUF1 can correspond to users VM1, VM2 and VM3; the same buffer RBUF2 can correspond to users VM4 and VM5. The number of users corresponding to the same buffer can be the same or different, and the specific correspondence can be determined according to actual conditions, which is not limited herein.
[0101] In addition, the microcontroller 10 can access the storage positions corresponding to VM1, VM2 and VM3 in the buffer in the same time slice when reading the commands, and read the commands corresponding to VM1, VM2 and VM3 in the same time slice, and then send the command corresponding to VM1 to the command distributor 20 corresponding to VM1; send the command corresponding to VM2 to the command distributor 20 corresponding to VM2; and send the command corresponding to VM3 to the command distributor 20 corresponding to VM3.
[0102] Alternatively, the microcontroller 10 can poll different entries in the buffer, and when polling an entry, if the storage position corresponding to the entry stores a command, the microcontroller 10 reads the command and sends it to the command distributor 20 corresponding to the entry.
[0103] In addition, since the microcontroller 10 can also store new commands in the buffer when reading the commands from the buffer, that is, update the commands in the buffer in real time, the microcontroller 10 can continuously read new commands from the buffer. The method for updating the commands in the buffer in real time is not described herein.
[0104] After the microcontroller 10 reads the commands from the buffer corresponding to each user, the microcontroller 10 can store the commands in the command queue corresponding to each user.
[0105] For example, at least one command queue can be set for each user in advance, the maximum storage amount of commands in different command queues can be the same or different, which is not limited herein; generally, different command queues are used to store commands in different streams of a user. At this time, the microcontroller 10 can read the commands in the corresponding buffer and store the commands in the command queue (Stream Queue) corresponding to each user. At this time, the command queue can include s, denoted as SQ1, SQ2, …, SQs, for example.
[0106] For example, if there are 3 streams in a user, the commands in the 3 streams are stored in SQ1, SQ2, and SQ3, respectively. At this time, in the case of a hardware queue, the command queue can be allocated to the user according to the number of command queues in the GPU and the number of users deployed in the GPU; in the case of a software queue, the command queue can be dynamically created for the user according to the number of streams in the user.
[0107] The process of determining the command queue for the user is described in detail as follows:
[0108] When determining the corresponding command queue for each user, the following (b1) or (b2) can be used, for example:
[0109] (b1): The command queue is determined for the user according to the number of buffers corresponding to the user. In this case, different users correspond to different command distributors 20; different command distributors 20 are used to read commands from the command queue corresponding to the user. In this case, the GPU is multiplexed by using space division multiplexing.
[0110] In this case, when a user corresponds to multiple buffers, the command queue for the user can be determined, for example, the command queue corresponding to different buffers can be determined for different buffers corresponding to the user. For example, the user VM1 corresponds to buffer 1 and buffer 2, and each buffer can store commands of 3 command streams in VM1, the command queue determined for buffer 1 includes SQ1, SQ2, and SQ3; the command queue determined for buffer 2 includes SQ4, SQ5, and SQ6.
[0111] For example, in the case of storing 4 commands in RBUF1 and 2 commands in RBUF2, when the command queue SQ1 corresponding to RBUF1 stores 4 commands, for example, it can include P 1-1 , P 1-2 , P 1-3 , and P 1-4 ; the command queue SQ4 corresponding to RBUF2 stores 2 commands, for example, it can include P 2-1 and P2-2 Referring to FIG. 1, a command queue provided by an embodiment of the present disclosure is shown as a schematic diagram. In FIG. 1, 21 represents a command queue SQ1, 22 represents SQ4, and 23 indicates a space for storing commands in the command queue. Figure 2
[0112] (b2) : allocating a same command queue commonly used by N target users in M users. Wherein, M is an integer greater than 1; N is an integer less than or equal to M and greater than 1. In this case, the N target users use the same command distributor 20 and the same group of command queues in different time slices. In this case, when N is less than M, the GPU is multiplexed by using time division multiplexing and space division multiplexing coexisting; when N is equal to M, the GPU is multiplexed by using only time division multiplexing.
[0113] In this case, when the N users commonly use the same queue, the command processing device processes the commands by using time division multiplexing, that is, processing the commands corresponding to the time slice in different time slices. The microcontroller 10 reads the commands from the buffers corresponding to the N target users in different time slices and stores the commands in the command queue commonly used by the N target users.
[0114] For example, when the N target users include virtual machines VM1, VM2 and VM3, the time slices can be periodically allocated in the order of VM1, VM2 and VM3. In the first time slice, the microcontroller 10 reads the commands corresponding to the virtual machine VM1 from the buffer and stores them in the command queue commonly used by the N target users, in which case the command queue commonly used by the N target users only includes the commands corresponding to the virtual machine VM1. After the first time slice ends and the tasks in the command queue commonly used by the N target users are executed, in the second time slice, the microcontroller 10 reads the commands corresponding to the virtual machine VM2 from the buffer and stores them in the command queue commonly used by the N target users, in which case the command queue commonly used by the N target users only includes the commands corresponding to the virtual machine VM2. After the second time slice ends and the tasks in the command queue commonly used by the N target users are executed, in the third time slice, the microcontroller 10 reads the commands corresponding to the virtual machine VM3 from the buffer and stores them in the command queue commonly used by the N target users, in which case the command queue commonly used by the N target users only includes the commands corresponding to the virtual machine VM3. After the third time slice ends and the tasks in the command queue are executed, in the fourth time slice, the user corresponding to the time slice reverts to the virtual machine VM1, the microcontroller 10 reads the commands corresponding to the virtual machine VM1 from the buffer and stores them in the command queue commonly used by the N target users, in which case the command queue commonly used by the N target users only includes the commands corresponding to the virtual machine VM1.
[0115] After the microcontroller 10 stores the command into the command queue corresponding to each target user, the N-target-user-shared command distributor 20 can read the command from the command queue corresponding to each target user and distribute the command to the operation unit 30 corresponding to the N-target-user-shared command distributor 20.
[0116] In a specific implementation, the command distributor 20 can read the command from the command queue and send the command to the operation unit 30 corresponding to the command distributor 20 in the following two ways (c1) or (c2):
[0117] (c1): Corresponding to b1 above, a corresponding command distributor 20 is allocated to each user, and the command distributors 20 corresponding to different users are different.
[0118] In this case, the command distributor 20 directly distributes the command to be processed by the user to the operation unit 30 corresponding to the user after extracting the command to be processed by the user from the command queue.
[0119] For example, when the N users include virtual machines VM1, VM2, and VM3, the command distributor D1 can be allocated to the virtual machine VM1, the command distributor D2 can be allocated to the virtual machine VM2, and the command distributor D3 can be allocated to the virtual machine VM3. Since the three virtual machines each have a corresponding command queue and a command distributor 20, the separation of the command queue and the command distributor 20 corresponding to different virtual machines is achieved.
[0120] Taking the virtual machine VM1 as an example, the corresponding command queue is SQ1, and the corresponding command distributor 20 is D1. When there is a command to be processed in the command queue, the command distributor D1 can distribute the command to be processed to the operation unit 30 corresponding to the virtual machine VM1 for processing. Similarly, since the virtual machine VM2 and the virtual machine VM3 each correspond to a command queue and a command distributor 20, when there is a command to be processed in the command queue corresponding to the virtual machine VM2 and the virtual machine VM3, the command distributor 20 corresponding to the virtual machine VM2 and the virtual machine VM3 can directly distribute the command to be processed in the corresponding command queue to the operation unit 30 for processing.
[0121] (c2): Corresponding to b2 above, N-target-user-shared command distributors 20 are allocated to the N target users.
[0122] In this case, the N-target-user-shared command distributor 20 is used to read the commands corresponding to different target users from the N-target-user-shared command queue at different time slices and send the commands corresponding to different target users to the operation unit 30 corresponding to the N-target-user-shared command distributor 20.
[0123] For example, when the N target users include virtual machines VM1, VM2, and VM3, the same command distributor 20D4 can be allocated to the virtual machines VM1, VM2, and VM3. According to (b2) above, the target users share the same N target user shared command queue, so the command distributor 20D4 only needs to continuously read commands from the N target user shared command queue and issue them to the operation unit 30.
[0124] After the N target user shared command distributor 20 distributes commands to the operation unit 30 corresponding to the N target user shared command distributor 20, the operation unit 30 can execute the commands distributed by the corresponding N target user shared command distributor 20. The operation unit 30 may, for example, correspond to users and be denoted as ALU1, ALU2, …, ALUm. Each operation unit 30 may, for example, include a plurality of minimum operation units that process commands, such as 32 threads running in the operation unit 30, for executing the commands distributed by the corresponding N target user shared command distributor 20. The threads in the operation unit 30 may, for example, include u (u is a positive integer), and taking the operation unit ALU1 as an example, the threads in the ALU1 may, for example, include a (a is a positive integer) and be denoted as A1-1, A1-2, …, A1-a.
[0125] When the operation unit 30 executes the commands distributed by the command distributor 20 and / or the N target user shared command distributor 20, it may, for example, use the following (d1) and (d2) methods:
[0126] (d1): Determine that each user corresponds to a separate operation unit 30, that is, each user corresponds to a separate operation unit 30. Using this method, the isolation between the data transmission links of multiple users can be further implemented, so that different users do not interfere with each other when processing commands, and the security threat to the work of other users when the data transmission link of one user in multiple users is attacked is effectively prevented.
[0127] (d2): The target users share the operation unit 30.
[0128] In this case, since the commands corresponding to different target users are processed in different time slices, and different target users share the same N target user shared command distributor 20, the different target users can process the commands in turn according to the order of the corresponding time slices, and only one common operation unit 30 needs to be determined. Using this method, the number of operation units 30 determined for different users can be reduced, the waste of computing resources can be effectively reduced, the computing resources can be more concentrated, and the efficiency of command processing can be improved.
[0129] The command processing device can complete the processing of the command to be processed after the operation unit 30 executes the command distributed by the command distributor 20 and / or the command distributor 20 shared by the N target users.
[0130] Referring to Figure 3 As shown in the figure, the embodiment of the disclosure also provides a specific schematic diagram of the command processing device. In this example, user 1, user 2, and user 3 correspond to different ring buffers 31, wherein ring buffer 311 is the ring buffer RBUF1 corresponding to user 1; ring buffer 312 is the ring buffer RBUF2 corresponding to user 2, and RBUF1 and RBUF2 have stored the commands of user 1 and user 2 issued by the host; ……; ring buffer 313 is the ring buffer RBUFM corresponding to user 3; the microcontroller 32 stores the commands into a plurality of command queues 33; wherein 331 includes the command queues SQ1 and SQ2 shared by user 1 and user 2 at different time slices, and the command distributor D1; the command distributor D1 corresponds to the operation unit ALU1; for example, in the time slice belonging to user 1, SQ1 and SQ2 are respectively used to store the commands corresponding to different entries in RBUF1; in the time slice belonging to user 2, SQ1 and SQ2 are respectively used to store the commands corresponding to different entries in RBUF2. 332 is the command queue SQs corresponding to user 3; 34 is the command distributor shared by the N target users corresponding to user 1 and user 2 and the operation unit, wherein 341 is the command distributor D1 shared by the N target users, 342 is the operation unit ALU1 corresponding to user 1, and 343 is the a threads included in the operation unit, which are A1-1~A1-a respectively; 35 is the command distributor and the operation unit corresponding to user 3, wherein 351 represents the command distributor Dm, and 352 represents the operation unit ALUm corresponding to user 3.
[0131] Those skilled in the art can understand that, in the above method of the specific implementation, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process, and the specific execution order of each step should be determined by its function and possible inherent logic.
[0132] Based on the same inventive concept, the embodiment of the disclosure also provides a command processing method corresponding to the command processing device. Since the principle of the device in the embodiment of the disclosure solves the problem, the implementation of the method can be referred to the implementation of the device, and the repeated parts will not be described.
[0133] Referring to Figure 4 As shown in the figure, the embodiment of the disclosure also provides a specific schematic diagram of the command processing device. In this example, user 1, user 2, and user 3 correspond to different ring buffers 31, wherein ring buffer 311 is the ring buffer RBUF1 corresponding to user 1; ring buffer 312 is the ring buffer RBUF2 corresponding to user 2, and RBUF1 and RBUF2 have stored the commands of user 1 and user 2 issued by the host; ……; ring buffer 313 is the ring buffer RBUFM corresponding to user 3; the microcontroller 32 stores the commands into a plurality of command queues 33; wherein 331 includes the command queues SQ1 and SQ2 shared by user 1 and user 2 at different time slices, and the command distributor D1; the command distributor D1 corresponds to the operation unit ALU1; for example, in the time slice belonging to user 1, SQ1 and SQ2 are respectively used to store the commands corresponding to different entries in RBUF1; in the time slice belonging to user 2, SQ1 and SQ2 are respectively used to store the commands corresponding to different entries in RBUF2. 332 is the command queue SQs corresponding to user 3; 34 is the command distributor shared by the N target users corresponding to user 1 and user 2 and the operation unit, wherein 341 is the command distributor D1 shared by the N target users, 342 is the operation unit ALU1 corresponding to user 1, and 343 is the a threads included in the operation unit, which are A1-1~A1-a respectively; 35 is the command distributor and the operation unit corresponding to user 3, wherein 351 represents the command distributor Dm, and 352 represents the operation unit ALUm corresponding to user 3.
[0134] S401: The microcontroller reads the command from the buffer corresponding to at least one user, and stores the command into the command queue corresponding to the at least one user;
[0135] S402: The command distributor reads the command from the corresponding command queue, and distributes the command to the operation unit corresponding to the command distributor;
[0136] S403: The operation unit executes the command distributed by the corresponding command distributor.
[0137] In an alternative embodiment, when there are multiple users, and different users correspond to different buffers, the microcontroller reads the command from the buffer corresponding to at least one user, comprising:
[0138] The microcontroller reads the command from different buffers at different time slices respectively.
[0139] In an alternative embodiment, the microcontroller reads the command from different buffers at different time slices respectively, comprising:
[0140] The microcontroller sequentially takes multiple time slices as a current time slice respectively, and executes the following listening process in each time slice until the current time slice ends and switches to the next time slice.
[0141] The listening process comprises: listening in the current time slice whether there is a command in the buffer corresponding to the current time slice; and reading the command from the buffer corresponding to the current time slice in response to the command existing in the buffer corresponding to the current time slice.
[0142] In an alternative embodiment, when there are multiple users, and different users correspond to different buffers, the microcontroller reads the command from the buffer corresponding to at least one user, comprising:
[0143] The microcontroller polls the buffer corresponding to each of the multiple users respectively, and reads the command from the currently polled buffer in response to the currently polled buffer being non-empty.
[0144] In an alternative embodiment, when different users correspond to different buffers, and one user corresponds to multiple buffers, the microcontroller reads the command from the buffer corresponding to at least one user, comprising:
[0145] The microcontroller polls the multiple buffers corresponding to each of the users in the time slice corresponding to each of the users respectively, and reads the command from the currently polled buffer.
[0146] In an alternative embodiment, in the case that there are multiple users and different users correspond to the same buffer, the microcontroller reads the command from the buffer corresponding to the at least one user, comprising:
[0147] The microcontroller reads the command from the same buffer corresponding to the multiple users.
[0148] In an alternative embodiment, in the case that there are multiple users and different users correspond to the same buffer, the microcontroller reads the command from the same buffer corresponding to the multiple users, comprising:
[0149] The microcontroller accesses the storage locations corresponding to the multiple users respectively in the same buffer at different time slices and reads the commands respectively; or
[0150] The microcontroller polls the storage locations corresponding to the multiple users respectively in the same buffer and reads the commands.
[0151] In an alternative embodiment, the buffer comprises a ring buffer, and the ring buffer comprises storage entries corresponding to at least one command stream in the same user respectively;
[0152] The microcontroller reads the command from the buffer corresponding to the at least one user, comprising:
[0153] The microcontroller reads the command corresponding to each command stream based on the storage entry corresponding to each command stream in the ring buffer.
[0154] In an alternative embodiment, the microcontroller stores the command into the command queue corresponding to the at least one user, comprising:
[0155] The microcontroller stores the command corresponding to at least one command stream in the same user into the command queue corresponding to the at least one command stream.
[0156] In an alternative embodiment, in the case that one user corresponds to multiple buffers, the microcontroller stores the command into the command queue corresponding to the at least one user, comprising:
[0157] The microcontroller determines the command queue corresponding to different buffers for the different buffers corresponding to the user when determining the command queue for the user.
[0158] In an alternative implementation, the users are M in number, N target users of the M users share the same command queue and the same command distributor; where M is an integer greater than 1; N is an integer less than or equal to M and greater than 1; the microcontroller reads the commands from the buffer corresponding to the at least one user and stores the commands into the command queue corresponding to the at least one user, including:
[0159] The microcontroller reads the commands from the buffers corresponding to the N target users respectively at different time slices and stores the commands into the command queue shared by the N target users.
[0160] In an alternative implementation, the command distributor reads the commands from the corresponding command queue and distributes the commands to the operation unit corresponding to the command distributor, including:
[0161] The command distributor reads the commands corresponding to different target users respectively from the command queue shared by the N target users at the different time slices and sends the commands corresponding to different target users respectively to the operation unit corresponding to the command distributor;
[0162] The operation unit executes the commands distributed by the corresponding command distributor, including:
[0163] The operation unit corresponding to the command distributor executes the commands corresponding to the N target users respectively at the different time slices.
[0164] The embodiments of the present disclosure further provide an electronic device, including a host, a buffer, and a command processing apparatus.
[0165] The host is configured to issue a to-be-executed command and store the to-be-executed command in a buffer corresponding to at least one user respectively;
[0166] The command processing apparatus is configured to execute the method provided in any of the command processing method embodiments.
[0167] The command processing apparatus provided in the embodiments of the present disclosure can include a chip, an AI chip, etc. The electronic device provided in the embodiments of the present disclosure can include a smart terminal such as a mobile phone, or can be another device with a camera and capable of image processing, a server, etc., which are not limited herein.
[0168] The embodiments of the present disclosure further provide a computer readable storage medium having a computer program stored thereon, where the program is executed by a microcontroller, a command distributor, and an operation unit to perform the method provided in any of the command processing method embodiments.
[0169] The description of the command processing method can refer to the related description in the method embodiments, which will not be described in detail herein.
[0170] The embodiment of the disclosure further provides a computer program product carrying program codes, the program codes include instructions for executing the steps of the command processing method described in the above method embodiments, and details can be referred to the above method embodiments, which will not be repeated here.
[0171] The computer program product can be specifically implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium, and in another optional embodiment, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.
[0172] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here. In several embodiments provided by the disclosure, it should be understood that the disclosed system, device and method can be implemented by other ways. The above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can be in another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some communication interface, device or unit, and can be electrical, mechanical or other forms.
[0173] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment scheme.
[0174] In addition, each functional unit in each embodiment of the disclosure can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.
[0175] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or the part of the prior art that contributes to the present disclosure or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present disclosure. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0176] Finally, it should be noted that: the above-described embodiments are merely specific embodiments of the present disclosure, used to illustrate the technical solutions of the present disclosure, rather than limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can make modifications or easily think of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present disclosure, or make equivalent replacements to some of the technical features. Such modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.
Claims
1. A command processing device, characterized in that, include: A microcontroller, at least one command dispatcher corresponding to a user, and a processing unit corresponding to each of the command dispatchers; There are multiple users, and different users correspond to different or the same buffers; in the case where different users correspond to the same buffer, the multiple users correspond to different storage locations in the same buffer; The microcontroller is configured to read commands from a buffer corresponding to the at least one user and store the commands in a command queue corresponding to the at least one user. The command dispatcher is used to read the command from the corresponding command queue and dispatch the command to the processing unit corresponding to the command dispatcher; The arithmetic unit is used to execute commands distributed by the corresponding command dispatcher.
2. The command processing device according to claim 1, characterized in that, In the case where there are multiple users, and each user corresponds to a different buffer, The microcontroller is used to read the command from different buffers at different time slices.
3. The command processing device according to claim 2, characterized in that, The microcontroller is used for: The multiple time slices are sequentially used as the current time slice, and the following listening process is performed in the current time slice until the current time slice ends and then the process switches to the next time slice. The monitoring process includes: Check if a command exists in the buffer corresponding to the current time slice; In response to the presence of a command in the buffer corresponding to the current time slice, the command is read from the buffer corresponding to the current time slice.
4. The command processing apparatus according to claim 1, characterized in that, In the case where there are multiple users, and each user corresponds to a different buffer, The microcontroller is used to poll multiple buffers corresponding to the users respectively, and in response to the buffer corresponding to the currently polled user being non-empty, reads commands from the currently polled buffer.
5. The command processing apparatus according to claim 1, characterized in that, For cases where different users correspond to different buffers, and one user corresponds to multiple buffers, The microcontroller is used to poll multiple buffers corresponding to each user within each user's time slice, and read commands from the currently polled buffers.
6. The command processing apparatus according to any one of claims 1-5, characterized in that, In the case where there are multiple users and different users correspond to the same buffer, the microcontroller is used to read the command from the same buffer corresponding to the multiple users.
7. The command processing apparatus according to claim 6, characterized in that, In the case where there are multiple users and different users correspond to the same buffer, the microcontroller is used to access the storage locations corresponding to the same buffer for multiple users at different time slices and read commands. or The system polls the storage locations corresponding to the same buffer for each of the multiple users and reads commands from them.
8. The command processing apparatus according to any one of claims 1-5, characterized in that, The buffer includes: a ring buffer; the ring buffer includes storage entries corresponding to at least one command stream from the same user; The microcontroller is used to read the command corresponding to each command stream based on the storage entry in the ring buffer corresponding to each command stream.
9. The command processing apparatus according to any one of claims 1-5, characterized in that, The microcontroller is used to store commands corresponding to at least one command stream from the same user into a command queue corresponding to the at least one command stream.
10. The command processing apparatus according to claim 9, characterized in that, When a user corresponds to multiple buffers, the microcontroller determines the command queue for the user by determining the command queue for each buffer corresponding to that user.
11. The command processing apparatus according to any one of claims 1-5, characterized in that, There are M users, and N target users among the M users share the same command queue and the same command dispatcher; where M is an integer greater than 1; N is an integer less than or equal to M and greater than 1; The microcontroller is used to read commands from the buffers corresponding to the N target users at different time slices and store the commands in a command queue shared by the N target users.
12. The command processing apparatus according to claim 11, characterized in that, The command dispatcher is used to read commands corresponding to different target users from the command queue shared by the N target users in different time slices, and send the commands corresponding to different target users to the computing unit corresponding to the command dispatcher. The computing unit corresponding to the command dispatcher is used to execute the commands corresponding to the N target users respectively in the different time slices.
13. A command processing method, characterized in that, The method is applied to a command processing device, which includes: a microcontroller, at least one command dispatcher corresponding to a user, and a processing unit corresponding to each command dispatcher; there are multiple users, and different users correspond to different or the same buffers; for the case where different users correspond to the same buffer, the multiple users correspond to different storage locations in the same buffer; the command processing method includes: The microcontroller reads commands from the buffer corresponding to the at least one user and stores the commands in the command queue corresponding to the at least one user; The command dispatcher reads the command from the corresponding command queue and dispatches the command to the processing unit corresponding to the command dispatcher; The arithmetic unit executes the commands distributed by the corresponding command dispatcher.
14. The command processing method according to claim 13, characterized in that, In the case where there are multiple users, and different users correspond to different buffers, the microcontroller reads commands from the buffer corresponding to at least one user, including: The microcontroller reads the commands from different buffers at different time slices.
15. The command processing method according to claim 14, characterized in that, The microcontroller reads the commands from different buffers at different time slices, including: The microcontroller sequentially uses each of the multiple time slices as the current time slice, and performs the following listening process in each time slice until the current time slice ends and switches to the next time slice; The monitoring process includes: monitoring whether a command exists in the buffer corresponding to the current time slice during the current time slice; and reading the command from the buffer corresponding to the current time slice in response to the presence of the command in the buffer corresponding to the current time slice.
16. The command processing method according to claim 13, characterized in that, In the case where there are multiple users, and different users correspond to different buffers, the microcontroller reads commands from the buffer corresponding to at least one user, including: The microcontroller polls multiple buffers corresponding to the users respectively, and reads commands from the currently polled buffer if the buffer corresponding to the currently polled user is not empty.
17. The command processing method according to claim 13, characterized in that, For cases where different users correspond to different buffers, and one user corresponds to multiple buffers, the microcontroller reads commands from the buffer corresponding to at least one user, including: The microcontroller polls multiple buffers corresponding to each user within each user's time slice and reads commands from the currently polled buffers.
18. The command processing method according to any one of claims 13-17, characterized in that, In the case where there are multiple users, and different users correspond to the same buffer, the microcontroller reads commands from the buffer corresponding to at least one user, including: The microcontroller reads the commands from the same buffer corresponding to the multiple users.
19. The command processing method according to claim 18, characterized in that, In the case where there are multiple users, and different users correspond to the same buffer, the microcontroller reads the command from the same buffer corresponding to the multiple users, including: The microcontroller accesses the storage locations corresponding to the same buffer for multiple users at different time slices and reads commands; or The system polls the storage locations corresponding to the same buffer for each of the multiple users and reads commands from them.
20. The command processing method according to any one of claims 13-17, characterized in that, The buffer includes: a ring buffer; the ring buffer includes storage entries corresponding to at least one command stream from the same user; The microcontroller reads commands from the buffer corresponding to the at least one user, including: The microcontroller reads the command corresponding to each command stream based on the storage entry in the ring buffer corresponding to each command stream.
21. The command processing method according to any one of claims 13-17, characterized in that, The microcontroller stores commands in the command queue corresponding to the at least one user, including: The microcontroller stores commands corresponding to at least one command stream from the same user into a command queue corresponding to the at least one command stream.
22. The command processing method according to claim 21, characterized in that, In the case where one user corresponds to multiple buffers, the microcontroller stores commands in the command queue corresponding to at least one user, including: When determining the command queue for the user, the microcontroller determines the command queue corresponding to each buffer for the user.
23. The command processing method according to any one of claims 13-17, characterized in that, There are M users, and N target users among the M users share the same command queue and the same command dispatcher; where M is an integer greater than 1; N is an integer less than or equal to M and greater than 1; the microcontroller reads commands from the buffer corresponding to at least one user and stores the commands in the command queue corresponding to at least one user, including: The microcontroller reads commands from the buffers corresponding to the N target users at different time slices and stores the commands in a command queue shared by the N target users.
24. The command processing method according to claim 23, characterized in that, The command dispatcher reads the command from the corresponding command queue and dispatches the command to the processing unit corresponding to the command dispatcher, including: The command dispatcher reads commands corresponding to different target users from the command queue shared by the N target users at different time slices, and sends the commands corresponding to different target users to the computing unit corresponding to the command dispatcher. The arithmetic unit executes the commands distributed by the corresponding command dispatcher, including: The processing unit corresponding to the command dispatcher executes the commands corresponding to the N target users respectively in different time slices.
25. An electronic device, characterized in that, include: The host computer, buffers, and command processing unit; The host is used to issue commands to be executed and store them in buffers corresponding to at least one user. The command processing device is used to execute the command processing method according to any one of claims 13 to 24.
26. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the microcontroller, command dispatcher, and arithmetic unit, it implements the command processing method as described in any one of claims 13 to 24.
Citation Information
Patent Citations
Accessibility of graphics processing compute resources
CN103262037A
Task scheduling system and method, storage medium and electronic equipment
CN111708639A