command distributor, command distribution method, dispatcher, chip, board, device

By introducing a scheduler and an arbitrator into the command dispatcher and extending the first command queue with a second command queue, the problems of frequent interaction between the host and the device and queue blocking are solved, and efficient distribution and execution of command streams are achieved.

CN116107635BActive Publication Date: 2025-11-25SHANGHAI POWERTENSORS INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310189842.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-28
Publication Date
2025-11-25
Estimated Expiration
2043-02-28

AI Technical Summary

Technical Problem

In the process of command stream distribution, the frequent interaction between the host and the device in the existing technology leads to reduced command issuance efficiency, and the command queue is prone to blockage, which affects command execution efficiency.

Method used

The design employs a scheduler and arbitrator, utilizing a second command queue as an extension of the first command queue. When the first command queue is blocked, the scheduler pulls the command stream down to the second command queue, and combines multiple pull-down strategies to optimize the command stream distribution process.

Benefits of technology

It improves command issuance efficiency, avoids blocking during the host issuance process, ensures unimpeded distribution of command streams, and enhances overall command execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116107635B_ABST
    Figure CN116107635B_ABST
Patent Text Reader

Abstract

The embodiment of the disclosure provides a command distributor, a command distribution method, a scheduler, a chip, a board card and equipment, the command distributor comprises a scheduler, a first command queue, a second command queue and an arbitrator; the scheduler is used for obtaining a command stream, the number of commands in the command stream is greater than the total number of cacheable commands of the first command queue; in the case that the first command queue is in a blocking state, at least part of the commands in the command stream is pulled down to the second command queue, and in the case that the first command queue is in a preparation state, the commands in the second command queue are pulled down to the first command queue; the arbitrator is used for obtaining commands from the first command queue and distributing the obtained commands.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the chip technical field, and in particular to a command distributor, a command distribution method, a scheduler, a chip, a board card and an apparatus. BACKGROUND

[0002] At present, when distributing commands in a command stream, the commands in the command stream are generally pulled down to a command queue at a device end by a host, and then the commands in the command stream are distributed to an execution unit for execution by the command queue at the device end. The process of pulling down the command stream from the host to the device end will affect the execution efficiency of the commands in the command stream, and therefore it is necessary to improve the pulling down process of the command stream. SUMMARY

[0003] In a first aspect, an embodiment of the present disclosure provides a command distributor, comprising: a scheduler, a first command queue, a second command queue and an arbitrator; the scheduler is configured to: acquire a command stream, the number of commands in the command stream being greater than the total number of commands that can be cached by the first command queue; in a case where the first command queue is in a blocked state, pull down at least part of the commands in the command stream to the second command queue, and in a case where the first command queue is in a ready state, pull down the commands in the second command queue to the first command queue; and the arbitrator is configured to acquire commands from the first command queue and distribute the acquired commands.

[0004] In some embodiments, the scheduler is configured to: in a case where the first command queue is in a non-blocked state, send the commands in the command stream to the first command queue until the first command queue is full.

[0005] In some embodiments, the first command queue is in the blocked state in a case where any of the following conditions is met: the first command queue sends the stored commands to the arbitrator and the sending is not yet completed; and the first command queue stores the commands pulled down by the scheduler and the total number of the stored commands reaches an upper limit of the number of commands that can be stored by the first command queue.

[0006] In some embodiments, the first command queue is in the ready state in a case where the following condition is met: the first command queue sends the stored commands to the arbitrator and the number of the sent commands reaches a preset number threshold.

[0007] In some embodiments, the first command queue stores a first flag bit for representing whether the first command queue is in the blocked state; and the scheduler is configured to: read the first flag bit; and determine whether the first command queue is in the blocked state based on the first flag bit.

[0008] In some embodiments, the first command queue stores a second flag bit, used to represent whether the first command queue is in a ready state; the scheduler is configured to read the second flag bit, and determine whether the first command queue is in a ready state based on the second flag bit.

[0009] In some embodiments, the number of command streams, the number of first command queues and the number of second command queues are all greater than 1, and each command stream corresponds to a first command queue and a second command queue; the scheduler is configured to, in a case where the first command queue corresponding to a command stream is in a blocked state, pull at least part of the commands in the command stream to the second command queue corresponding to the command stream, and in a case where the first command queue corresponding to the command stream is in a ready state, pull the commands in the second command queue corresponding to the command stream to the first command queue corresponding to the command stream.

[0010] In some embodiments, the scheduler stores a correspondence between the first command queue and the second command queue; the scheduler is configured to obtain the identification information of the first command queue, and pull at least part of the commands in the command stream to the second command queue based on the identification information of the first command queue and the correspondence.

[0011] In some embodiments, the identification information of the first command queue and the storage address of the command stream are stored in a target element of a ring buffer in association; the scheduler is configured to read the storage address and the identification information from the target element, obtain the command stream based on the storage address, and pull at least part of the commands in the command stream to the second command queue based on the identification information of the first command queue and the correspondence.

[0012] In some embodiments, the scheduler is configured to record the number of commands in the second command queue and the offset of the commands in the second command queue that have been pulled to the first command queue, and pull the commands in the second command queue to the first command queue based on the number and the offset.

[0013] In some embodiments, the scheduler is configured to: update the number and the offset after at least one command in the second command queue is pulled down to the first command queue; and / or in a case where not all commands in the command stream that are pulled down to the second command queue are sent to the first command queue, and the command stream includes at least one command that is not pulled down to the second command queue, pull down the command in the command stream that is not pulled down to the second command queue after the last command stored in the second command queue in the command stream, and update the number and the offset.

[0014] In some embodiments, the command stream includes at least two sub-command streams, each sub-command stream includes at least one command, and storage addresses of different sub-command streams are respectively stored in different target elements in a ring buffer; the scheduler is configured to: sequentially obtain storage addresses of each sub-command stream in the same command stream from each target element according to a positional relationship of each sub-command stream in the command stream, and obtain each sub-command stream in the command stream from the obtained storage addresses; and in a case where the first command queue is in a blocked state, sequentially pull down commands of each sub-command stream in the command stream to a second command queue corresponding to the command stream.

[0015] In a second aspect, the embodiments of the present disclosure provide a command distributor, including: a scheduler, a plurality of first command queues, and an arbitrator; the scheduler is configured to obtain a plurality of command streams, and pull down the plurality of command streams to at least one command queue in the plurality of first command queues based on a target pull-down strategy selected from a plurality of pull-down strategies; wherein different pull-down strategies are used to indicate different pull-down manners of the plurality of command streams pulled down to the plurality of first command queues; and the arbitrator is configured to obtain commands from the first command queues, and distribute the obtained commands.

[0016] In some embodiments, in a case where the plurality of command streams include at least two command streams with a dependency relationship, the target pull-down strategy is a first pull-down strategy, and the first pull-down strategy is used to indicate that the at least two command streams are pulled down to the same first command queue.

[0017] In some embodiments, the at least two command streams are stored in the same command stream buffer, and the command stream buffer corresponds to the first command queue in a one-to-one manner; and the scheduler is configured to: in a case where the target pull-down strategy is the first pull-down strategy, pull down the at least two command streams to the first command queue corresponding to the command stream buffer used to store the at least two command streams.

[0018] In some embodiments, in the case that the command stream with the dependency relationship is not included in the plurality of command streams, the pull-down strategy is a second pull-down strategy, and the second pull-down strategy is used to indicate that any two of the plurality of command streams can be pulled down to different first command queues.

[0019] In some embodiments, different pull-down strategies correspond to different strategy identifiers; the strategy identifiers are stored in a register of the scheduler; or the strategy identifiers are read by the scheduler from elements of a ring buffer.

[0020] In some embodiments, each first command queue corresponds to a second command queue; and the scheduler is configured to: in the case that a first command queue is in a non-blocking state, pull down at least part of the command stream to be pulled down to the first command queue to the first command queue until the first command queue is full or all commands in the command stream to be pulled down to the first command queue are pulled down to the first command queue; in the case that a first command queue is in a blocking state, pull down at least part of the command stream to be pulled down to the first command queue to a second command queue corresponding to the first command queue, and in the case that a first command queue is in a preparation state, pull down the commands in the second command queue corresponding to the first command queue to the first command queue.

[0021] In a third aspect, the embodiments of the present disclosure provide a command distribution method, which comprises: obtaining a command stream, the number of commands in the command stream being greater than the total number of commands that can be cached by a first command queue; in the case that the first command queue is in a blocking state, pulling down at least part of the command stream to a second command queue; in the case that the first command queue is in a preparation state, pulling down the commands in the second command queue to the first command queue, so that an arbiter obtains commands from the first command queue and distributes the obtained commands.

[0022] In a fourth aspect, the embodiments of the present disclosure provide a command distribution method, which comprises: obtaining a plurality of command streams; based on a target pull-down strategy selected from a plurality of pull-down strategies, pulling down the plurality of command streams to at least one command queue of a plurality of first command queues; wherein different pull-down strategies are used to indicate different pull-down manners of the plurality of command streams to the plurality of first command queues; and the commands in the first command queue are used to be sent to an arbiter, so that the arbiter distributes the received commands.

[0023] In a fifth aspect, the embodiments of the present disclosure provide a scheduler configured to perform the method of any of the embodiments of the present disclosure.

[0024] Sixthly, embodiments of this disclosure provide a chip, the chip including the scheduler described in any embodiment of this disclosure, or including the command dispatcher described in any embodiment of this disclosure.

[0025] In a seventh aspect, embodiments of this disclosure provide a board, the board including a package structure encapsulating at least one chip as described in any embodiment of this disclosure.

[0026] Eighthly, embodiments of this disclosure provide an electronic device, which includes a chip as described in any embodiment of this disclosure, or a board as described in any embodiment of this disclosure.

[0027] Ninthly, embodiments of the present disclosure provide a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the methods described in any embodiment of the present disclosure.

[0028] In this embodiment, the second command queue is used as an extension of the first command queue. If the first command queue is full or not idle and cannot be pulled down to the first command queue, the scheduler can still pull down the command stream to the second command queue. In this way, the process of the host sending command stream will not be blocked, thereby improving the command sending efficiency.

[0029] This disclosure embodiment sets up multiple drop-down strategies for command streams, and selects a suitable target drop-down strategy from multiple drop-down strategies according to actual needs to drop down multiple acquired command streams to the first command queue, so that the drop-down strategy of the command stream matches the application scenario, thereby improving the drop-down efficiency of the command stream.

[0030] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0031] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure.

[0032] Figure 1 This is a schematic diagram of a command dispatcher according to an embodiment of the present disclosure.

[0033] Figure 2 This is a schematic diagram of a ring buffer according to an embodiment of the present disclosure.

[0034] Figure 3 This is a schematic diagram of the write pointer according to an embodiment of the present disclosure.

[0035] Figure 4A and Figure 4B These are schematic diagrams illustrating the command flow drop-down process according to embodiments of this disclosure.

[0036] Figure 5 is a schematic diagram of offsets in a second command queue of an embodiment of the present disclosure.

[0037] Figure 6 is a schematic diagram of storage of storage addresses of different sub-command streams in a ring buffer of an embodiment of the present disclosure.

[0038] Figure 7 is a schematic diagram of storage of commands in different sub-command streams in a second command queue of an embodiment of the present disclosure.

[0039] Figure 8A is a schematic diagram of an overall architecture of an embodiment of the present disclosure.

[0040] Figure 8B is a schematic diagram of an overall flowchart of an embodiment of the present disclosure.

[0041] Figure 9 is a flowchart of a command distribution method of an embodiment of the present disclosure.

[0042] Figure 10 is a flowchart of a command distribution method of another embodiment of the present disclosure.

[0043] Figure 11 is a schematic diagram of a board card of an embodiment of the present disclosure. DETAILED DESCRIPTION

[0044] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The description of the exemplary embodiments is intended to apply to various alternative embodiments as well. The following description is not limited to the exemplary embodiments, but rather, is applicable to any embodiment within the scope of the present disclosure. In the description of the exemplary embodiments, terms of a singular form can include one or more quantities in plural form unless otherwise specifically limited. Singular forms “a,” “an,” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be understood that the terms “including,” “comprising,” “consisting of,” and “substantially consisting of” specify the presence of stated features, elements, and / or components, but do not preclude the presence or addition of one or more other features, elements, and / or components. It will be further understood that terms, such as “first” and “second,” “both,” and “either,” are used to arbitrarily distinguish one element from another element without prejudice to either element. It will be understood that when a certain embodiment is

[0045] The terminology used in the present disclosure is solely for the purpose of describing particular embodiments and is not intended to limit the present disclosure. As used in the present disclosure and the accompanying claims, the singular form of “a,” “an,” and “the” is intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises” and / or “comprising,” “includes” and / or “including” used herein, specify the presence of stated features, elements, and / or components, but do not preclude the presence or addition of one or more other features, elements, and / or components. Additionally, the term “at least one of’ is used herein to mean any one of multiple alternatives or some combination of at least two of the multiple alternatives.

[0046] It should be understood that, although the terms first, second, third, etc. can be employed in this disclosure to describe various information, the information should not be limited to these terms. These terms are only used to differentiate one piece of information from another. For example, without departing from the scope of this disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information. Depending on the context, the word "if' as used herein can be interpreted as "when" or "upon" or "in response to determining".

[0047] In order to better understand the technical solutions in the embodiments of the present disclosure by those skilled in the art, and to make the above-mentioned purposes, features and advantages of the embodiments of the present disclosure more apparent and easy to understand, the technical solutions in the embodiments of the present disclosure will be further described in detail below with reference to the drawings.

[0048] At present, when distributing the commands (kernels) in the command stream, the host generally issues the command stream to the command queue of the device end, and then the command queue of the device end distributes the commands in the command stream to the execution unit for execution. One or more command queues (SQs) can be used in the device end for command distribution. In the case of using multiple SQs, each SQ can perform command distribution in parallel to improve the efficiency of command distribution. Correspondingly, the host uses one or more stream buffers (sbufs), the command execution in each sbuf requires order preservation, and in the case of using multiple sbufs, the kernels in different sbufs can be issued in parallel. Therefore, the sbuf of the host needs to be one-to-one corresponding to the SQ of the device end to ensure the correctness of the kernel running order. In the related art, the host directly issues the commands to the SQ of the device end, in this scheme, the host needs to inform the device end which SQ the currently issued command needs to be stored in every time the host issues a command to the device end, which will cause the interaction between the host and the device end to be relatively frequent, thereby reducing the efficiency of command issuing.

[0049] In order to solve the problem of frequent interaction between the host and the device end, a producer-consumer model can be used, that is, the host stores the information of the command to be issued in the elements of a ring buffer, and the device end parses the elements of the ring buffer, so as to complete the pull-down of the command packet in order. Although this scheme can reduce the interaction between the host and the device end, it will cause the process of the host issuing the command stream to be blocked, thereby reducing the command issuing efficiency. For example, in the case where the number of commands in the command stream is greater than the total number of commands that can be replaced in the SQ, the commands in the command stream will be pulled down to the SQ for multiple times. After the SQ is full, the remaining commands in the command stream need to be issued to the SQ again after the SQ is full (i.e., the SQ is in an idle state), thereby causing the process of the host issuing the command stream to be blocked. The above phenomenon is also called ring buffer blocking.

[0050] Based on this, the embodiment of the present disclosure provides a command distributor, which is shown in Figure 1 , and the command distributor comprises:

[0051] a scheduler 101, a first command queue 102, a second command queue 103, and an arbitrator 104;

[0052] The scheduler 101 is configured to obtain a command stream, the number of commands in the command stream being greater than the total number of commands that can be cached by the first command queue 102; in the case where the first command queue 102 is in a blocked state, at least part of the commands in the command stream are pulled down to the second command queue 103, and in the case where the first command queue 102 is in a ready state, the commands in the second command queue 103 are pulled down to the first command queue 102.

[0053] The arbitrator 104 is configured to obtain commands from the first command queue 102 and distribute the obtained commands.

[0054] The command distributor of the embodiment of the present disclosure can be arranged at the device end. The command stream can be stored in a command stream buffer (sbuf) of the host. The number of command streams can be greater than or equal to 1, and different command streams can be stored at different storage addresses in the command stream buffer. The number of commands included in each command stream can be equal or unequal. In order to facilitate description, the scheme of the embodiment of the present disclosure will be described below by taking an example in which each command stream includes v (v is a positive integer) commands.

[0055] In the case where the number of command streams is k, the number of first command queues 102 and the number of second command queues 103 can also be k, each first command queue 102 corresponds to a command stream, and each second command queue 103 corresponds to a command stream, that is, each first command queue 102 corresponds to a second command queue 103.

[0056] The storage addresses of the command streams can be recorded in another buffer area (e.g., a ring buffer) in the host other than the command stream buffer area. The ring buffer can include a plurality of elements, each of which can be used to record a storage address. Each element can be a sub-area of the ring buffer with equal size. Assuming that the size of the ring buffer is 1 MB and the size of each element is 16 B, the ring buffer can include 2 16 elements in total, and one or more of the elements can be used to record the storage addresses. The host can write the storage addresses of the command streams into the elements in the ring buffer in sequence. Referring to Figure 2 , assuming that the elements in the ring buffer are denoted as P1, P2, …, P m (m is a positive integer), and the command streams are denoted as stream1, stream2, … stream k (k is a positive integer), the storage address of stream1 can be recorded in element P1, the storage address of stream2 can be recorded in element P2, and so on. In addition, the elements in the ring buffer can also be used to record the identification information of the first command queues 102 to which the command streams are written. Different command streams can be written to different first command queues 102. In addition to recording the storage addresses of the command streams and the identification information of the first command queues 102, the elements in the ring buffer can also be used to record other information, which is not listed here. For ease of description, the set of information stored in an element is referred to as a group of data.

[0057] The scheduler 101 can pull at least part of the commands in a command stream to the second command queue 103 corresponding to the command stream when the first command queue 102 corresponding to the command stream is in a blocked state, and pull the commands in the second command queue 103 corresponding to the command stream to the first command queue 102 corresponding to the command stream when the first command queue 102 corresponding to the command stream is in a ready state. The above process can be implemented based on the storage addresses of the command streams and the identification information of the first command queues 102 stored in the elements in the ring buffer.

[0058] For example, assuming that the first command queues 102 are denoted as SQ1, SQ2, …, SQ k , and the second command queues 103 are denoted as ESQ1, ESQ2, …, ESQ kIf SQ1 and ESQ1 correspond to each other and both correspond to the command stream stream1, SQ2 and ESQ2 correspond to each other and both correspond to the command stream stream2, and so on, the identification information of SQ1 can be written into the element P1, so that the scheduler 101 obtains the storage address of the command stream stream1 from the element P1, and pulls part of the commands in the command stream stream1 to the first command queue 102 SQ1, pulls another part of the commands in the command stream stream1 to the second command queue 103 ESQ1, or pulls all the commands in the command stream stream1 to the second command queue 103 ESQ1; the identification information of SQ2 can also be written into the element P2, so that the scheduler 101 obtains the storage address of the command stream stream2 from the element P2, and pulls part of the commands in the command stream stream2 to the first command queue 102 SQ2, pulls another part of the commands in the command stream stream2 to the second command queue 103 ESQ2, or pulls all the commands in the command stream stream2 to the second command queue 103 ESQ2; and so on.

[0059] In some embodiments, the first command queue 102 stores a first flag bit, which is used to represent whether the first command queue 102 is in a blocked state. The scheduler 101 can read the first flag bit, and determine whether the first command queue 102 is in a blocked state based on the first flag bit. The first flag bit can be stored in a first register, which can be connected to the scheduler 101 by hardware, so as to improve the efficiency of obtaining the first flag bit. Alternatively, the first flag bit can be a 1-bit binary number, for example, “1” represents a blocked state, and “0” represents a non-blocked state.

[0060] In some embodiments, the scheduler 101 can store a correspondence between the first command queue 102 and the second command queue 103. In this way, after obtaining the identification information of the first command queue 102, the scheduler 101 can pull at least part of the commands in the command stream to the second command queue 103 based on the identification information of the first command queue 102 and the correspondence.

[0061] Further, the scheduler 101 can read the storage address and the identification information from any target element of the ring buffer, obtain the command stream based on the storage address, and pull at least part of the commands in the command stream to the second command queue 103 based on the identification information of the first command queue 102 and the correspondence.

[0062] The second command queue 103 can be implemented by using a random access memory (RAM). In some embodiments, the length of the second command queue 103 can be determined based on an application scenario, for example, the length of the second command queue 103 can be greater than or equal to the maximum length of a command stream in the application scenario, so that all commands in a command stream can be stored by using the first command queue 102 and the second command queue 103. Of course, the actual application is not limited thereto. Even if the second command queue 103 can only store part of the commands in a command stream, because the second command queue 103 is used to expand the capacity of the first command queue 102, compared with the related art, the command issuing efficiency of the embodiments of the present disclosure can still be improved.

[0063] In some embodiments, the second command queue 103 can include a plurality of second sub-queues, and each second sub-queue can have a different storage priority. In the case that the first command queue 102 is in a blocked state, the scheduler 101 can pull the commands in the command stream into each second sub-queue based on the priority of each second sub-queue. Assuming that each second sub-queue is denoted as E1, E2, …, Et, and the storage priorities of E1, E2, …, Et decrease in turn, the scheduler 101 can first pull the commands in the command stream into the second sub-queue with the highest priority (i.e., E1), and then pull the remaining commands in the command stream into the second sub-queue with the second highest priority E2 when the second sub-queue E1 with the highest priority is full, and so on, until all the commands in the command stream are stored in the second command queue 103.

[0064] In the above embodiments, each group of data can be written into the elements of the ring buffer by the host. Because the host only needs to write the identification information of the first command queue 102 into the elements of the ring buffer, the scheduler 101 can automatically select to pull the command stream into the first command queue 102 or the second command queue 103 according to the actual situation, so the above process is transparent to the host. Even if the first command queue 102 is blocked, the host can continue to distribute commands without blocking.

[0065] In some embodiments, the ring buffer can further include a write pointer for pointing to the next element to be written in the ring buffer. The host can write one or more groups of data into the ring buffer each time, and each element is written in a group of data. Assuming that the host writes r (r is a positive integer) groups of data into the ring buffer at a time, the value of the pointer is increased by r. In the case that new elements are written into the data in the ring buffer, the scheduler 101 can determine which element or elements to obtain data from based on the values of the pointers before and after the data is written. Specifically, the host can write the base address of the ring buffer into the scheduler 101 in advance, and the scheduler 101 can determine which element or elements the data is written into according to the base address and the offset corresponding to the value of the pointer before and after the data is written. Referring to Figure 3 , assuming that the initial position of the write pointer is as shown in Pointer1 in the figure, i.e., pointing to element P1, after the host writes 3 groups of data (r = 3) into the ring buffer, the value of the write pointer is increased by 3, and at this time the position of the write pointer is as shown in Pointer2 in the figure, i.e., pointing to element P2.

[0066] After determining the element in which the data is written, the scheduler 101 can read the command stream based on the storage address in the element and pull the command stream down into the first command queue 102 or the second command queue 103. The arbiter 104 can only obtain commands from the first command queue 102 and distribute the commands obtained from the first command queue 102 to the execution unit for execution. The execution unit can be an arithmetic unit, such as an addition unit, a multiplication unit, a convolution processing unit, etc., or it can also be other types of execution units, which are not limited by the present disclosure. In this way, the arbiter 104 is also unaware of the existence of the second command queue 103. The entire process from the issuance of the command from the host end to the command in the command queue to the sending of the command in the command queue to the arbiter 104 to the command distribution by the arbiter 104 can be carried out without blocking, improving the command distribution efficiency. The specific strategy of the scheduler 101 to select the first command queue 102 or the second command queue 103 will be illustrated below. Figure 4A and Figure 4B In Figure 4A and Figure 4B , assuming that different command streams are stored in different command stream buffers, for the sake of brevity, only four command stream buffers are drawn in the figure, which are denoted as sbuf1, sbuf2, sbuf3 and sbuf4, and it is assumed that the storage addresses of the command streams in sbuf1, sbuf2, sbuf3 and sbuf4 correspond to the records in elements P1, P2, P3 and P4, and the number of the first command queues 102 and the number of the second command queues 103 are both assumed to be 32. Each first command queue 102 is denoted as SQ1, SQ2, …, SQ32, and each second command queue 103 is denoted as DQ1, DQ2, …, DQ32. 32The second command queues 103 are respectively denoted as ESQ1, ESQ2, …, ESQn. 32 .

[0067] In some embodiments, the scheduler 101 can determine to pull down the command stream to the first command queue 102 or the second command queue 103 based on the status of the first command queue 102. Wherein, the status of the first command queue 102 includes a blocked state and a non-blocked state. In the case that the first command queue 102 is in the blocked state, the scheduler 101 cannot acquire the command stream from the host; in the case that the first command queue 102 is in the non-blocked state, the scheduler 101 can acquire the command stream from the host. Further, the blocked state includes a busy state and a full state. Wherein, the first command queue 102 is in the busy state means that the first command queue 102 includes at least one command which has not been issued to the arbiter 104 in the process of sending the command to the arbiter 104. The first command queue 102 is in the full state means that the number of stored commands in the first command queue 102 reaches the total number of cacheable commands of the first command queue 102 in the process of storing the command pulled down by the scheduler 101. In contrast, the non-blocked state includes an idle state and a not-full state. Wherein, the first command queue 102 is in the idle state means that all the commands in the first command queue 102 have been issued to the arbiter 104. The first command queue 102 is in the not-full state means that the number of stored commands in the first command queue 102 is less than the total number of cacheable commands of the first command queue 102.

[0068] In the case that the first command queue 102 is in the non-blocked state, the scheduler 101 can first send the commands in the command stream to the first command queue 102 until the first command queue 102 is full, and then send the commands in the command stream to the second command queue 103. In the case that the first command queue 102 is in the blocked state, the scheduler 101 can directly pull down at least part of the commands in the command stream to the second command queue 103.

[0069] Specifically, in the case that the first command queue 102 is in an idle state, the scheduler 101 can pull the command stream from the host into the first command queue 102. In the case that the first command queue 102 is in a non-idle state, the scheduler 101 can pull the commands in the command stream into the second command queue 103. In the case that the command stream is pulled into the first command queue 102, since the number of commands in the command stream is greater than the total number of commands that can be cached by the first command queue 102, in the case that the first command queue 102 is full, there is still at least one command (referred to as an overflow part of the command stream) in the command stream that has not been pulled into the first command queue 102. The scheduler 101 can pull the overflow part into the second command queue 103.

[0070] For example, in the case of Figure 4A , assuming that the initial state of each first command queue is an idle state, the scheduler 101 can first pull the command stream in sbuf1, sbuf2, sbuf3 and sbuf4 into SQ1, SQ2, SQ3 and SQ4 according to the storage addresses recorded in elements P1, P2, P3 and P4 and the identification information of the first command queue 102. Assuming that after pulling part of the command stream in sbuf1 into SQ1, SQ1 is full, the overflow part of the command stream in sbuf1 is pulled into ESQ1.

[0071] For another example, in the case of Figure 4B , assuming that SQ1 and SQ4 are both in a non-idle state, the command stream in sbuf1 will not be pulled into SQ1, or the command in sbuf4 will not be pulled into SQ4, but the command stream in sbuf1 will be directly pulled into ESQ1, and the command stream in sbuf4 will be directly pulled into ESQ4. The process of pulling the command stream in sbuf2 into SQ2 and ESQ2 is similar to the process of pulling the command stream in sbuf1 in Figure 4A , that is, the command stream in sbuf2 is first pulled into SQ2, and after SQ2 is full, the overflow part is pulled into ESQ2. Similarly, the command stream in sbuf3 is first pulled into SQ3, and since SQ3 is not full, the command stream in sbuf3 does not need to be pulled into ESQ3.

[0072] In this case, the scheduler 101 can pull each command in the command stream into the first command queue 102 or the second command queue 103 according to the positional relationship of each command in the command stream, to ensure the order of each command in the same command stream. Assuming that the commands in the command stream are kernel1, kernel2, …, kernel vkernel1, kernel2, …, kernel v In the case that part of the command stream is pulled down to the first command queue 102 and the overflow part of the command stream is pulled down to the second command queue 103, the commands stored in the first command queue 102 are kernel1, kernel2, …, kernel δ , and the commands stored in the second command queue 103 are kernel δ +1, kernel δ +2, …, kernel v , where δ is a positive integer less than v.

[0073] The above embodiment takes the second command queue 103 as an extended command queue of the first command queue 102. In the case that the first command queue 102 is full or in a non-idle state and thus cannot pull down the command stream to the first command queue 102, the scheduler 101 can still pull down the command stream to the second command queue 103. In this way, the process of the host issuing the command stream is not blocked, and thus the command issuing efficiency is improved.

[0074] Further, the state of the first command queue 102 can also include a preparation state. In the process of the first command queue 102 sending the stored commands to the arbiter 104, if the number of the sent commands in the first command queue 102 reaches a preset number threshold, the first command queue 102 is in the preparation state; in the process of the first command queue 102 sending the stored commands to the arbiter 104, if the number of the sent commands in the first command queue 102 does not reach the number threshold, the first command queue 102 is in a non-preparation state. The number threshold can be set to a value greater than or equal to 0 according to actual needs, where the number threshold can be set to an absolute number, for example, 5, or a relative number, for example, 50% of the total number of commands that the first command queue 102 can cache. Since the commands in the command stream are also stored in order in the second command queue 103, the commands in the second command queue 103 can be directly sent to the first command queue 102 according to the storage order of the commands in the second command queue 103. Continuing the previous example, the commands k δ +1, k δ +2, …, k v stored in the second command queue 103 can be sent to the first command queue 102 in turn.

[0075] The commands in the second command queue 103 can be sent to the first command queue 102 at one time or in batches according to actual conditions. In the case of sending the stored commands in the second command queue 103 to the first command queue 102 in batches, the number of commands sent to the first command queue 102 in each batch can be configured. In some embodiments, the scheduler 101 can include a control register for storing control state information, which can include an enabled state and a disabled state. The control state information can be represented by a binary number of 1 bit, for example, the enabled state is represented as "1" and the disabled state is represented as "0". In the case that the number of commands sent from the second command queue 103 to the first command queue 102 reaches a preconfigured number, the scheduler 101 can set the control state information to the enabled state, and the second command queue 103 can start sending commands to the first command queue 102 in response to the control state information being set to the enabled state until the number of commands sent this time reaches a certain number threshold.

[0076] Further, the command distributor further includes a counter for counting the number of commands sent from the second command queue 103 to the first command queue 102, and the counter is enabled to add 1 to the count value each time a command is sent from the second command queue 103 to the first command queue 102. The scheduler 101 can read the count value, and in the case that the count value reaches the number threshold, set the control state information to the disabled state and clear the count value of the counter. The second command queue 103 can stop sending commands to the first command queue 102 in response to the control state information being set to the disabled state.

[0077] In some embodiments, a second flag bit is stored in the first command queue 102 to represent whether the first command queue 102 is in a ready state. The scheduler 101 can read the second flag bit and determine whether the first command queue 102 is in a ready state based on the second flag bit. The second flag bit can be stored in a second register which is connected to the scheduler 101 by hardware, thereby improving the efficiency of obtaining the second flag bit. Alternatively, the second flag bit can be a binary number of 1 bit, for example, "1" represents the ready state and "0" represents the non-ready state.

[0078] To facilitate determining the position of the command needed to be sent to the first command queue 102 in the second command queue 103, the scheduler 101 can record the number of commands in the second command queue 103 and the offset of the command in the second command queue 103 that has been pulled down to the first command queue 102; based on the number and the offset, the command in the second command queue 103 is pulled down to the first command queue 102. The offset can be used to represent the distance between the next command in the command stream that needs to be pulled down to the first command queue 102 and the first command in the command stream that is stored in the second command queue 103. Assuming that the storage address of the first command in the command stream that is stored in the second command queue 103 is A0, the next command that needs to be pulled down to the first command queue 102 is the i-th command in the second command queue 103, then the offset is i, and according to the offset, the storage address of the next command (i.e., the i-th command) in the second command queue 103 that needs to be pulled down to the first command queue 102 can be obtained as A0+i*x, where x is the storage bit width of each command in the second command queue 103. Each time a command in the second command queue 103 is pulled down to the first command queue 102, the offset can be incremented by 1. In the case where the number of commands in the second command queue 103 is 0, it can be considered that all the commands in the second command queue 103 have been pulled down to the first command queue 102.

[0079] Referring to Figure 5 , assuming that there are 5 commands in the same command stream that are issued to the second command queue 103, and the commands are sequentially recorded as kernel1, kernel2, kernel3, kernel4 and kernel5 according to the order of being issued to the second command queue, and assuming that kernel1 and kernel2 have been sent to the first command queue 102, then the current offset is 2, indicating that the distance between the next command in the command stream that will be sent from the second command queue 103 to the first command queue 102 and the first command in the command stream that is issued to the second command queue 103 (i.e., kernel1) is 2. Since kernel1 and kernel2 have been sent to the first command queue 102, the number of commands in the second command queue 103 is 3.

[0080] After the scheduler 101 pulls at least one command in the second command queue 103 to the first command queue 102, the number and the offset can be updated. For example, assuming that the number of commands originally stored in the second command queue 103 is M, after the scheduler 101 pulls △M commands in the second command queue 103 to the first command queue 102, the number of commands stored in the second command queue 103 is updated to M-△M, and the offset is updated to the sum of the original offset and △M.

[0081] The scheduler 101 can also pull the commands in the command stream that are not pulled into the second command queue 103 after the last command stored in the second command queue 103 and update the number of commands in the second command queue 103 in the case that the commands in the command stream are not all sent to the first command queue 102 and the command stream includes at least one command that is not pulled into the second command queue 103. Further, if the commands in the second command queue 103 are also sent to the first command queue 102 in the above process, the offset in the second command queue 103 is also updated. For example, still assuming that the number of commands in the command stream is v, and the commands are sequentially recorded as kernell, kernel2,..., kernelv, and assuming that the commands in the command stream are pulled into the second command queue 103 from the (δ+1)th command in the command stream. If the commands currently pulled into the second command queue 103 include kernel v +1, kernel δ +2,..., kernel δ +δ, and j is a positive integer, the last command stored in the second command queue 103 in the command stream is kernel v-j , and the commands in the command stream can be sequentially stored in the second command queue 103 after kernel v-j , and the number of commands and the offset in the second command queue 103 are updated according to the current number of commands and the position of the next command to be sent to the first command queue 102. v-j+1 v-j+2 v v-j

[0082] In some embodiments, the command stream includes at least two sub-command streams, each of which includes at least one command, and the storage addresses of different sub-command streams are stored in different target elements in the ring buffer. For example, the command stream streaml can be split into sub-command streams stream 11 , stream 12 ,..., stream 1h , the storage addresses of the sub-command streams stream 11 , stream 12 ,..., stream 1h are stored in different storage addresses, and the storage address of the sub-command stream stream 11 is recorded in the target element P 11 in the ring buffer, and the storage address of the sub-command stream stream 12 is recorded in the target element P 12 ​​​​And so on. Figure 6 This illustrates the case where h equals 3, where the subcommand stream... 11 ,stream 12 and stream 13 The storage addresses are respectively stored in the target element P 11 P 12 and P 13 middle.

[0083] Based on this, scheduler 101 can sequentially obtain the storage addresses of each sub-command stream in the same command stream from each target element according to the positional relationship of each sub-command stream in the command stream, and retrieve each sub-command stream in the command stream from the obtained storage addresses; if the first command queue 102 is in a blocked state, the commands of each sub-command stream in the command stream are sequentially pulled down to the second command queue 103 corresponding to the command stream. After splitting, scheduler 101 can retrieve commands from each target element P1, P2, ... P h Obtain the corresponding subcommand stream 11 ,stream 12 , ..., stream 1h The storage address is used to obtain the sub-command stream. 11 ,stream 12 , ..., stream 1h The commands in these sub-command streams are first pulled down to the first command queue 102 corresponding to the command stream, and then the overflow portion is pulled down to the second command queue 103, or all of them are pulled down to the second command queue 103 corresponding to the command stream.

[0084] like Figure 7 As shown, in the subcommand stream 11 ,stream 12 , ..., stream 1h Taking the example where all commands in the command stream are pulled down to the second command queue 103, assuming the value of h is 3, that is, the number of sub-command streams included in command stream 1 is 3, and assuming that each sub-command stream includes 5 commands. As shown in the figure, the three sub-command streams... 11 ,stream 12 and stream 13 All commands in the stream are pulled down to the same second command queue 103 (i.e., ESQ1), and the sub-command stream... 11 ,stream 12 and stream 13 The order of the commands in ESQ1 is the same as the order of these commands in the command stream Stream1.

[0085] In the related art, after splitting the same command stream into multiple sub-command streams, the dependency relationship between the commands in the command stream can not be maintained. For example, assume that the command stream stream1 is split into sub-command streams stream 11 , stream 12 , ……, stream 1h , the command kernel5: c = a + b is included in the sub-command stream stream 11 , and the command kernel 12 : d = c + 1 is included in the sub-command stream stream 20 . In the command stream stream1 before splitting, since the sub-command stream stream 11 is before the sub-command stream stream 12 , it can be guaranteed that kernel5 is executed before kernel 20 , that is, the dependency relationship between kernel5 and kernel 20 can be guaranteed. However, after splitting, kernel5 and kernel 20 will be pulled down to different command queues, and thus the dependency relationship between kernel5 and kernel 20 can no longer be guaranteed. By using the above scheme, the embodiments of the present disclosure can pull down each sub-command stream in the same command stream into the same first command queue 102 or the same second command queue 103, thereby guaranteeing the dependency relationship between the commands in the same command stream. In some embodiments, the identification information of the command stream to which each sub-command stream belongs can also be included in each target element in the ring buffer, and the scheduler 101 can determine whether each sub-command stream belongs to the same command stream according to the identification information.

[0086] The overall architecture of the embodiments of the present disclosure is shown in Figure 8A . The overall architecture is divided into a host end and a device end, the ring buffer is located at the host end and is driven by a driving unit (ring buffer server) of the ring buffer; the scheduler, the SQ, the ESQ, and the dispatcher are all located at the device end. The upper-layer software of the host end inserts the command stream stream into the sbuf, the command stream includes one or more commands, and each command can be encapsulated into a command packet. P1, P2, ……, P mThe ring is a single ring entry (referred to as an entry), and in each entry, there is a pointer pointing to the storage address of the command stream in the sbuf. When a new stream is inserted into the sbuf, an interrupt signal is triggered to make the device end pull down the command stream, and then the device end obtains the newly inserted entry from the ring buffer and parses it to obtain the SQ ID (that is, the identification information of the first command queue) and the sbuf address (that is, the storage address of the command stream) recorded in the entry. When the SQ is idle, the command packet is directly pulled down into the SQ, and the overflow part is pulled down into the ESQ. When the SQ is not idle, the command packet is directly pulled down into the ESQ. When the first command queue is in a preparation state, an ESQ prefetch interrupt is triggered, so that the command packet in the ESQ is moved to the SQ. The arbiter parses the command packet, and distributes each command packet to the destination operation unit. The operation unit receives the command packet and executes it in order, and returns an ACK to the arbiter after the execution is completed. When the command packet is issued, if the SQ is not empty, the command packet is directly pulled down into the ESQ. The scheduler on the device side maintains the pull-down position and structure to ensure that the ring is not blocked, and the upper-layer software of the host can continue to insert a new stream. The ESQ can be located in a high bandwidth memory (HBM). When the ESQ prefetch interrupt is triggered, based on the second flag bit in the direct memory access (DMA) register (that is, the second register), the command packet in the ESQ is moved to the SQ. At this time, the number and offset of the command packet in the ESQ need to be updated. After the command packet in the SQ corresponding ESQ is moved to the SQ, the number maintained by the ESQ is set to 0. When the command packet in the ESQ is not all moved to the SQ, if the ring is updated at this time (that is, the new entry in the ring is inserted with information), the existing data in the ESQ is continuously updated, and the number and offset of the command packet in the ESQ are also updated.

[0087] Since the command packet issued by the upper-layer software can continue to insert a new stream without delay, the action is not sensed by the upper-layer software, and thus the processing speed can be improved.

[0088] In addition, when the upper-layer software inserts a stream into the sbuf, there can be a case of splitting into multiple issuances. For the same stream, the sub-command streams of multiple issuances are issued to the same SQ, so according to the order preserving mechanism of the command distributor, the order of execution of the command packet can be guaranteed.

[0089] For the congestion problem of the upper layer software, the embodiments of the present disclosure adopt software and hardware cooperation to implement command stream scheduling, and support one-to-one correspondence between stream and SQ, the command stream is more efficient in sequence preservation, hardware acceleration is adopted, the command stream congestion is reduced, the command distribution efficiency is improved, and the software synchronization overhead is reduced.

[0090] In some embodiments, the scheduler 101 can pull the obtained command streams to the first command queue 102 or the second command queue 103 based on different pull-down strategies. Wherein, the different pull-down strategies are used to indicate different pull-down manners of the plurality of command streams to the plurality of first command queues 102. In some embodiments, the target pull-down strategy includes a first pull-down strategy, which is used to indicate that the at least two command streams are pulled down to the same first command queue 102. In another embodiment, the target pull-down strategy includes a second pull-down strategy, which is used to indicate that any two command streams obtained can be pulled down to different first command queues 102.

[0091] In the case that a first command queue 102 is in a non-blocking state, the scheduler 101 can first pull down each command stream obtained to the corresponding first command queue 102 based on the pull-down strategy, and after the first command queue 102 is full, if there are remaining commands in a command stream, the remaining commands in the command stream are pulled down to the second command queue 103 corresponding to the first command queue 102.

[0092] In the case that a first command queue 102 is in a blocking state, the scheduler 101 can pull down each command stream obtained to the corresponding second command queue 103 based on the pull-down strategy, and in the case that the first command queue 102 corresponding to a second command queue 103 is in a preparation state, the commands in the second command queue 103 are pulled down to the first command queue 102.

[0093] In some embodiments, the target pull-down strategy is a first pull-down strategy in a case that at least two command streams with dependency exist in the plurality of command streams. In this case, if at least two command streams with dependency exist in the plurality of command streams, the scheduler 101 can employ the first pull-down strategy so as to pull down the at least two command streams to the same first command queue. For example, assuming that the plurality of command streams include command streams streaml, stream2 and stream3, and command streams streaml and stream2 have dependency, the scheduler 101 can employ the first pull-down strategy so as to pull down streaml and stream2 to the same first command queue (denoted as QOO), and pull down stream3 to another first command queue (denoted as QOl) different from QOO since stream3 has no dependency with streaml and stream2. Further, the at least two command streams with dependency can be stored in the same command stream buffer, and the command stream buffer and the first command queue can have one-to-one correspondence. Continuing the previous example, streaml and stream2 can be stored in command stream buffer sbufOO, and stream3 can be stored in command stream buffer sbufOl, and sbufOO and sbufOl correspond to first command queues QOO and QOl respectively, the scheduler 101 can pull down streaml and stream2 to first command queue QOO and pull down stream3 to first command queue QOl according to the correspondence between the first command queue and the command stream buffer.

[0094] In some other embodiments, the pull-down strategy is a second pull-down strategy in a case that no command stream with dependency exists in the plurality of command streams. In this case, if no at least two command streams with dependency exist in the plurality of command streams, the scheduler 101 can employ the second pull-down strategy so as to pull down any two command streams to different first command queues. Further, any two command streams without dependency can be stored in different command stream buffers, and the command stream buffer and the first command queue can not have one-to-one correspondence. In this way, the scheduler can pull down the command streams in each command stream buffer to a first command queue or the second command queue corresponding to the first command queue randomly, or in a round robin manner, or in other manners.

[0095] In some embodiments, different pull-down strategies correspond to different strategy identifiers, and the strategy identifiers are used to uniquely identify the pull-down strategies. For example, "1" represents a first pull-down strategy, and "0" represents a second pull-down strategy. The scheduler can read the strategy identifier to determine the pull-down strategy. The strategy identifier can be stored in a register of the scheduler, and the scheduler 101 can directly read the strategy identifier from the register. Alternatively, the strategy identifier can be stored in an element of a ring buffer and read by the scheduler from the element of the ring buffer.

[0096] The embodiments of the present disclosure provide multiple pull-down strategies for the command stream, and select a target pull-down strategy from the multiple pull-down strategies according to actual needs to pull down the obtained multiple command streams to the first command queue, so that the pull-down strategy of the command stream matches the application scenario, thereby improving the pull-down efficiency of the command stream.

[0097] In some embodiments, the present disclosure also provides a command distributor, which comprises:

[0098] a scheduler, multiple first command queues, and an arbitrator;

[0099] The scheduler is configured to obtain multiple command streams, and pull down the multiple command streams to at least one command queue in the multiple first command queues based on a target pull-down strategy selected from multiple pull-down strategies; and different pull-down strategies are used to indicate different pull-down manners of the multiple command streams to the multiple first command queues.

[0100] The arbitrator is configured to obtain commands from the first command queue and distribute the obtained commands.

[0101] In some embodiments, in the case that the multiple command streams include at least two command streams with a dependency relationship, the target pull-down strategy is a first pull-down strategy, and the first pull-down strategy is used to indicate that the at least two command streams are pulled down to the same first command queue.

[0102] In some embodiments, the at least two command streams are stored in the same command stream buffer, and the command stream buffer corresponds to the first command queue in a one-to-one manner; and the scheduler is configured to, in the case that the target pull-down strategy is the first pull-down strategy, pull down the at least two command streams to the first command queue corresponding to the command stream buffer used to store the at least two command streams.

[0103] In some embodiments, in the case that the multiple command streams do not include command streams with a dependency relationship, the pull-down strategy is a second pull-down strategy, and the second pull-down strategy is used to indicate that any two command streams in the multiple command streams can be pulled down to different first command queues.

[0104] In some embodiments, different pull-down strategies correspond to different strategy identifiers; the strategy identifiers are stored in a register of the scheduler; or the strategy identifiers are read by the scheduler from elements of a ring buffer.

[0105] In some embodiments, each first command queue corresponds to a second command queue; the scheduler is configured to: in a case where a first command queue is in a non-blocking state, pull down at least part of commands in a command stream to be pulled down to the first command queue to the first command queue until the first command queue is full or all commands in the command stream to be pulled down to the first command queue are pulled down to the first command queue; in a case where a first command queue is in a blocking state, pull down at least part of commands in a command stream to be pulled down to the first command queue to a second command queue corresponding to the first command queue, and in a case where a first command queue is in a ready state, pull down commands in the second command queue corresponding to the first command queue to the first command queue.

[0106] The structure of the command distributor and the specific steps performed by the scheduler according to the embodiments of the present disclosure can refer to the foregoing embodiments, and specific details are not repeated here.

[0107] The embodiments of the present disclosure also provide a command distribution method, as shown in Figure 9 The method comprises the following steps:

[0108] Step 901: obtaining a command stream, the number of commands in the command stream being greater than the total number of commands that can be cached by a first command queue;

[0109] Step 902: in a case where the first command queue is in a blocking state, pulling down at least part of commands in the command stream to a second command queue;

[0110] Step 903: in a case where the first command queue is in a ready state, pulling down commands in the second command queue to the first command queue, so that an arbiter obtains commands from the first command queue and distributes the obtained commands.

[0111] The embodiments of the present disclosure also provide a command distribution method, as shown in Figure 10 The method comprises the following steps:

[0112] Step 1001: obtaining a plurality of command streams;

[0113] Step 1002: based on a target pull-down strategy selected from a plurality of pull-down strategies, pulling down the plurality of command streams to at least one command queue in the plurality of first command queues;

[0114] wherein different pull-down strategies are used to indicate different pull-down manners of the plurality of command streams to the plurality of first command queues; and commands in the first command queues are used to send to an arbiter to make the arbiter distribute the received commands.

[0115] The method can be performed by the scheduler 101 in the command distributor in any of the preceding embodiments, and specific details of the method embodiment can refer to the preceding embodiments of the command distributor, which will not be described here.

[0116] The disclosure also provides a scheduler for performing the method in any of the preceding embodiments. The scheduler can be used in the command distributor in any of the preceding embodiments.

[0117] The disclosure also provides a chip comprising the scheduler in any of the embodiments of the disclosure, or comprising the command distributor in any of the embodiments of the disclosure.

[0118] The disclosure also provides a board card comprising a packaging structure in which at least one chip as described in any of the embodiments of the disclosure is packaged.

[0119] Referring to Figure 11 The board card comprises the chip 1101, and can further comprise other components, including but not limited to: a memory 1102, an interface device 1103, and a processor 1104.

[0120] The memory 1102 is connected to the chip 1101 in the chip packaging structure through a bus, and is used to store data. The memory 1102 can comprise a plurality of groups of storage units 1102a, such as DDR SDRAM (Double Data Rate SDRAM, Double Data Rate Synchronous Dynamic Random Access Memory), etc. The memory 1102 can be used to implement the first command queue 102 and the second command queue 103. Each group of storage units 1102a is connected to the chip 1101 through a bus.

[0121] The interface device 1103 is electrically connected to the chip 1101 in the chip packaging structure. The interface device 1103 is used to implement data transmission between the chip 1101 and an external device D (such as a terminal, a server, a camera, etc.). In an embodiment, the interface device 1103 can be a PCIE interface, and can also be a network interface or other interfaces, which are not limited by the disclosure.

[0122] The processor 1104 can generate a command stream. The command stream can be sent to the chip 1101, which can be the chip of any of the preceding embodiments. After obtaining the command stream, the scheduler in the chip 1101 can pull down the command stream to the first command queue 102 or the second command queue 103 in the manner described in the preceding embodiments.

[0123] The embodiments of the present disclosure also provide an electronic device, which includes the chip of any of the embodiments of the present disclosure, or includes the board card of any of the embodiments of the present disclosure.

[0124] The embodiments of the present disclosure also provide a computer readable storage medium, which stores a computer program. The program is executed by a processor to implement the method of any of the preceding embodiments.

[0125] The computer readable medium includes permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. The information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible by a computing device. According to the definition herein, the computer readable medium does not include transitory computer readable media, such as modulated data signals and carriers.

[0126] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments of the present specification can be implemented by means of software plus necessary general hardware platforms. Based on such understanding, the technical solutions of the embodiments of the present specification can be embodied in the form of a software product, which can be stored in a storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in the various embodiments or some parts of the embodiments of the present specification.

[0127] The systems, apparatuses, modules, or units illustrated in the above embodiments can be specifically implemented by computer devices or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0128] The various embodiments in the specification are described in progressive manner, and the same or similar parts between the various embodiments can be mutually referred to. Each embodiment focuses on the difference from other embodiments. In particular, the device embodiments are described more simply because they are basically similar to the method embodiments, and the relevant parts can be referred to the part of the method embodiments. The device embodiments described above are merely illustrative, and the modules described as separate components can or can not be physically separated, and the functions of the modules can be implemented in one or more software and / or hardware in implementing the embodiments of the specification. Part or all of the modules can be selected to achieve the purpose of the embodiments of the specification according to actual needs. Those skilled in the art can understand and implement without creative effort.

[0129] The above is only a specific implementation of the embodiments of the specification, and it should be noted that those skilled in the art can make several improvements and refinements without departing from the principles of the embodiments of the specification, and these improvements and refinements should also be considered as the protection scope of the embodiments of the specification.

Claims

1. A command distributor, characterized by, The command distributor comprises: a scheduler, a first command queue, a second command queue and an arbitrator; The scheduler is configured to: acquire a command stream, the number of commands in the command stream being greater than the total number of commands that can be buffered by the first command queue; in a case where the first command queue is in a blocked state, pull at least part of the commands in the command stream to the second command queue, and in a case where the first command queue is in a ready state, pull the commands in the second command queue to the first command queue; wherein the first command queue is in the ready state in a case where the following condition is met: the first command queue sends the stored commands to the arbitrator, and the number of sent commands reaches a preset number threshold; The arbitrator is configured to acquire commands from the first command queue and distribute the acquired commands.

2. The command distributor of claim 1, wherein, The scheduler is configured to: in a case where the first command queue is in a non-blocked state, send the commands in the command stream to the first command queue until the first command queue is full.

3. The command distributor of claim 1, wherein, The first command queue is in the blocked state in a case where any of the following conditions is met: the first command queue sends the stored commands to the arbitrator, and the sending is not yet complete; the first command queue stores the commands pulled by the scheduler, and the total number of stored commands reaches an upper limit of the number of commands that can be stored by the first command queue.

4. The command distributor of claim 1, wherein, The first command queue stores a first flag bit for representing whether the first command queue is in the blocked state; the scheduler is configured to: read the first flag bit; determine whether the first command queue is in the blocked state based on the first flag bit; and / or The first command queue stores a second flag bit for representing whether the first command queue is in the ready state; the scheduler is configured to: read the second flag bit; determine whether the first command queue is in the ready state based on the second flag bit; and / or The number of command streams, the number of first command queues and the number of second command queues are all greater than 1, each command stream corresponds to a first command queue and a second command queue; the scheduler is configured to: in a case where the first command queue corresponding to a command stream is in the blocked state, pull at least part of the commands in the command stream to the second command queue corresponding to the command stream, and in a case where the first command queue corresponding to the command stream is in the ready state, pull the commands in the second command queue corresponding to the command stream to the first command queue corresponding to the command stream; and / or The scheduler stores a correspondence relationship between the first command queue and the second command queue; the scheduler is configured to: acquire identification information of the first command queue; based on the identification information of the first command queue and the correspondence relationship, pull at least part of the commands in the command stream to the second command queue.

5. The command distributor of claim 4, wherein, In a case that a correspondence between the first command queue and the second command queue is stored in the scheduler, identification information of the first command queue and a storage address of the command stream are stored in a target element of a ring buffer in association with each other; the scheduler is configured to: read the storage address and the identification information from the target element; based on the storage address, acquire the command stream, and based on the identification information of the first command queue and the correspondence, pull at least part of commands in the command stream to the second command queue.

6. The command distributor of claim 1, wherein, The scheduler is configured to: record a number of commands in the second command queue and an offset of commands in the second command queue that have been pulled to the first command queue; based on the number and the offset, pull the commands in the second command queue to the first command queue.

7. The command distributor of claim 6, wherein, The scheduler is configured to: update the number and the offset after at least one command in the second command queue is pulled to the first command queue; and / or, in a case that the commands in the command stream that have been pulled to the second command queue are not all sent to the first command queue, and the command stream includes at least one command that has not been pulled to the second command queue, pull the command in the command stream that has not been pulled to the second command queue after a last command in the command stream that has been stored in the second command queue, and update the number and the offset.

8. The command distributor according to any one of claims 1 to 7, characterized in that, The command stream includes at least two sub-command streams, each sub-command stream includes at least one command, and storage addresses of different sub-command streams are respectively stored in different target elements of a ring buffer; the scheduler is configured to: according to a positional relationship of each sub-command stream in the command stream, acquire the storage addresses of each sub-command stream in the same command stream from each target element in sequence, and acquire each sub-command stream in the command stream from the acquired storage addresses; in a case that the first command queue is in a blocked state, pull the commands of each sub-command stream in the command stream to the second command queue corresponding to the command stream in sequence.

9. The command distributor of claim 1, wherein, The number of the first command queues is greater than 1; The scheduler is further configured to acquire a plurality of command streams, and based on a target pull-down strategy selected from a plurality of pull-down strategies, pull the plurality of command streams to at least one command queue in a plurality of first command queues; wherein the plurality of pull-down strategies includes a first pull-down strategy and a second pull-down strategy, the first pull-down strategy is used to indicate that the at least two command streams are pulled to the same first command queue, and the second pull-down strategy is used to indicate that any two command streams in the plurality of command streams can be pulled to different first command queues; The arbiter is configured to acquire commands from the first command queue and distribute the acquired commands.

10. The command distributor of claim 9, wherein, In a case that the plurality of command streams include at least two command streams that have a dependency relationship, the target pull-down strategy is the first pull-down strategy; and / or In a case that the plurality of command streams include at least two command streams that have a dependency relationship, the target pull-down strategy is the first pull-down strategy; The at least two command streams are stored in the same command stream buffer, and the command stream buffer corresponds to the first command queue one by one; the scheduler is configured to: In a case where the target pull-down strategy is the first pull-down strategy, pull down the at least two command streams to a first command queue corresponding to a command stream buffer used for storing the at least two command streams.

11. The command distributor of claim 9, wherein, In a case where the plurality of command streams do not include command streams with a dependency relationship, the pull-down strategy is a second pull-down strategy; And / or Different pull-down strategies correspond to different strategy identifiers; The strategy identifier is stored in a register of the scheduler, or the strategy identifier is read by the scheduler from an element of a ring buffer; And / or Each first command queue corresponds to a second command queue; the scheduler is configured to: In a case where a first command queue is in a non-blocking state, pull down at least part of commands in a command stream to be pulled down to the first command queue to the first command queue until the first command queue is full, or all commands in the command stream to be pulled down to the first command queue are pulled down to the first command queue; In a case where a first command queue is in a blocking state, pull down at least part of commands in a command stream to be pulled down to the first command queue to a second command queue corresponding to the first command queue, and in a case where the first command queue is in a preparation state, pull down commands in the second command queue corresponding to the first command queue to the first command queue.

12. A command distribution method characterized by comprising: The method comprises: Obtaining a command stream, a number of commands in the command stream being greater than a total number of cacheable commands of a first command queue; In a case where the first command queue is in a blocking state, pulling down at least part of commands in the command stream to a second command queue; In a case where the first command queue is in a preparation state, pulling down commands in the second command queue to the first command queue, so that an arbiter obtains commands from the first command queue and distributes the obtained commands.

13. A scheduler, characterized by A program for executing the method of claim 12.

14. A chip, characterized by The chip comprises the scheduler of claim 13, or comprises the command distributor of any one of claims 1 to 11.

15. A board card, characterized by The board card comprises a packaging structure in which at least one chip as claimed in claim 14 is packaged.

16. An electronic device, comprising: The electronic device comprises the chip of claim 14, or comprises the board card of claim 15.

17. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by a processor to implement the method of claim 12. The chip comprises the scheduler of claim 13, or comprises the command distributor of any one of claims 1 to 11. The board card comprises a packaging structure in which at least one chip as claimed in claim 14 is packaged. The electronic device comprises the chip of claim 14, or comprises the board card of claim 15. The program is executed by a processor to implement the method of claim 12.

Citation Information

Patent Citations

  • Command issuing method and device, processing equipment, computer equipment and storage medium

    CN114626541A

  • Command distributor, command distribution method and system, chip, board card and equipment

    CN115145638A