A data reduction method and a graphics processor
By using validity markers to assist in data retrieval and result storage during data reduction, the problem of redundant computation is solved, achieving efficient utilization of computing resources and improved energy efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING AIJIE KEXIN TECHNOLOGY CO LTD
- Filing Date
- 2026-03-19
- Publication Date
- 2026-06-19
AI Technical Summary
Existing data reduction methods involve redundant calculations, resulting in wasted computing resources and low energy efficiency.
By using validity markers during the data reduction process to assist in data retrieval and result storage, redundant calculations are reduced and computational efficiency is improved.
While ensuring the accuracy of calculations, it significantly reduces the use of computing resources and improves the energy efficiency of reduction calculations.
Smart Images

Figure CN122240357A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, specifically relating to a data reduction method and a graphics processor. Background Technology
[0002] Reduction computation can combine large amounts of data into a single result through a binary operation, and is commonly used for tasks such as summation, finding the maximum value, and calculating a product. However, current reduction methods involve significant redundant calculations, wasting a large amount of computational resources and resulting in relatively low energy efficiency.
[0003] Therefore, how to provide a data reduction method with higher energy efficiency is an urgent problem to be solved. Summary of the Invention
[0004] To address the problems existing in the prior art, a data reduction method and a graphics processor are proposed. By using this data reduction method and graphics processor, redundant calculations can be reduced, the use of computing resources can be reduced, and the energy efficiency ratio of reduction calculations can be improved.
[0005] This application provides the following solutions.
[0006] Firstly, this application provides a data reduction method, including:
[0007] Each thread in the target thread bundle is added with a validity flag and then stored in the thread buffer queue, with each thread corresponding to a row of data in the thread buffer queue. Retrieve two rows of data whose validity flag is in the first state from the thread buffer queue; Update the two validity flags corresponding to the two rows of data from the first state to the second state; Perform calculations based on the two rows of data to obtain the thread's calculation result; Return to the thread buffer queue and retrieve two rows of data with the validity flag in the first state, until the validity flags in the thread buffer queue are both in the second state; Store the result of the thread operation into the position of the data row whose validity flag is in the second state in the thread buffer queue, and update the validity flag of the data row from the second state to the first state.
[0008] In some possible embodiments, the method further includes: If all validity flags in the thread buffer queue are in the second state, the next received thread bundle is taken as the target thread bundle, and each thread in the target thread bundle is added with a validity flag and stored in the thread buffer queue, until all thread bundles to be reduced are stored.
[0009] In some possible embodiments, after retrieving two rows of data with the validity flag set to the first state from the thread buffer queue, the method further includes: If all validity flags in the thread buffer queue are in the second state, store the thread operation result obtained in this loop into the position of the data row in the thread bundle buffer queue where the validity flag is in the second state, and set the validity flag corresponding to the data row to the first state.
[0010] In some possible embodiments, after performing calculations based on two rows of data to obtain the thread calculation result, the method further includes: If all validity flags in the thread buffer queue are in the second state, retrieve the two rows of data with the validity flag in the first state from the thread bundle buffer queue; Update the two validity flags corresponding to the two rows of data from the first state to the second state; Perform calculations based on the two rows of data to obtain the thread bundle calculation result; Store the thread beam operation result into the position of the data row whose validity flag is in the second state in the thread beam buffer queue, and update the validity flag of the data row from the second state to the first state. Returns to the thread bundle buffer queue and retrieves two rows of data whose validity flag is in the first state.
[0011] In some possible embodiments, the thread buffer queue stores a separate row of validity flag data in addition to the thread data, and each bit in the validity flag data stores an identifier as a validity flag; In addition to thread bundle data, each thread bundle buffer queue stores a separate row of validity flag data. Each bit in a row of validity flag data stores the validity flag corresponding to that row of thread bundle data.
[0012] In some possible embodiments, the method further includes: If the thread operation results in a null value, the reduction process ends and the null result is output.
[0013] In some possible embodiments, adding a validity flag to each thread in the target thread bundle includes: Set the validity flag of each thread in the target thread bundle to the first state; Check if there are any null values in the target thread bundle. If so, output the reduction result of the null value directly. Otherwise, check if there are any positive or negative infinity values in the target thread bundle. The target thread bundle also has a positive infinity flag and a negative infinity flag. If a thread with positive infinity is detected, the positive infinity flag is updated from the third state to the fourth state, and the validity flag of the non-negative infinity data rows detected after this reduction is set to the second state. If a thread with negative infinity is detected, update the negative infinity flag from the fifth state to the sixth state, and set the validity flag of any subsequent non-positive infinity data rows detected in this reduction to the second state. If the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state, then check if there are any threads in the target thread bundle with a zero value, and set the validity flag of the thread with the zero value to the second state.
[0014] In some possible embodiments, after performing calculations based on the two rows of data to obtain the thread bundle calculation result, the method further includes: The counter increments by 1; When the value of the counter is greater than or equal to the preset threshold, the result of the thread bundle operation is output as the reduction result. The difference between the preset threshold and the initial number of the counter is the total number of all thread bundles to be reduced.
[0015] In some possible embodiments, the method is applied to a reduction unit in a graphics processing unit (GPU).
[0016] In some possible embodiments, the graphics processor further includes multiple clients, and the reduction unit is connected to the multiple clients via a data bus. The method also includes: Multiple clients each select a thread bundle to send from the enabled thread bundles; Multiple clients send handshake signals to the reduction unit; The client that receives the permission signal sent by the reduction unit among multiple clients is designated as the target client; The target client sends the thread bundle to be sent as the target thread bundle to the reduction unit via the data bus.
[0017] In some possible embodiments, the method further includes: The target client selects a thread bundle to send from the remaining enabled thread bundles; The process continues until all enabled thread bundles within multiple clients have been sent to the reduction unit. The reduction unit broadcasts the reduction result to multiple clients.
[0018] Secondly, this application provides a graphics processor, including a reduction unit and multiple clients, which are connected via a data bus; Multiple clients are used to send the target thread bundle to the reduction unit via the data bus; The reduction unit adds a validity flag to each thread in the target thread bundle and stores it in the thread buffer queue, with each thread corresponding to one row of data in the thread buffer queue; it retrieves two rows of data with the validity flag in the first state from the thread buffer queue; it updates the two validity flags corresponding to the two rows of data from the first state to the second state; it performs calculations based on the two rows of data to obtain the thread calculation result; it stores the thread calculation result in the thread buffer queue at the position of the data row with the validity flag in the second state, and updates the validity flag corresponding to the data row from the second state to the first state; it returns to execute the process of retrieving two rows of data with the validity flag in the first state from the thread buffer queue.
[0019] In some possible embodiments, the reduction unit is used to take the next received thread bundle as the target thread bundle if all the validity flags in the thread buffer queue are in the second state, and add a validity flag to each thread in the target thread bundle before storing it in the thread buffer queue, until all the thread bundles to be reduced have been stored.
[0020] In some possible embodiments, the reduction unit is used to retrieve two rows of data with the validity flag set to the first state from the thread buffer queue. If the validity flags in the thread buffer queue are both in the second state, the thread operation result obtained in this loop is stored in the position of the data row with the validity flag set to the second state in the thread bundle buffer queue, and the validity flag corresponding to the data row is set to the first state.
[0021] In some possible embodiments, the reduction unit is used to: if all validity flags in the thread buffer queue are in the second state, retrieve two rows of data with validity flags in the first state from the thread bundle buffer queue; update the two validity flags corresponding to the two rows of data from the first state to the second state; perform calculations based on the two rows of data to obtain the thread bundle calculation result; store the thread bundle calculation result in the position of the data row with validity flags in the second state in the thread bundle buffer queue, and update the validity flags corresponding to the data row from the second state to the first state; and return to execute the retrieval of the two rows of data with validity flags in the first state from the thread bundle buffer queue.
[0022] In some possible embodiments, the thread buffer queue stores a separate row of validity flag data in addition to the thread data, and each bit in the validity flag data stores an identifier as a validity flag; In addition to thread bundle data, each thread bundle buffer queue stores a separate row of validity flag data. Each bit in a row of validity flag data stores the validity flag corresponding to that row of thread bundle data.
[0023] In some possible embodiments, the reduction unit is used to end the reduction and output a null value if the thread operation result is null.
[0024] In some possible embodiments, the reduction unit is used to set the validity flag of each thread in the target thread bundle to a first state; detect whether there is a thread with a null value in the target thread bundle, and if so, directly output the reduction result of the null value; otherwise, detect whether there is a thread with positive or negative infinity in the target thread bundle; the target thread bundle also has a positive infinity flag and a negative infinity flag. If a thread with positive infinity is detected, the positive infinity flag is updated from the third state to the fourth state, and the validity flag of the non-negative infinity data rows detected in the subsequent reduction is set to the second state; If the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state, update the negative infinity flag from the fifth state to the sixth state, and set the validity flag of the non-positive infinity data rows detected after this reduction to the second state; if the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state, check if there are any threads with zero values in the target thread bundle, and set the validity flag of the threads with zero values to the second state.
[0025] In some possible embodiments, the reduction unit includes a counter. The counter is used to increment the count by 1 after the result of the thread bundle operation is obtained; The reduction unit is used to output the thread bundle operation result as the reduction result when the value of the counter is greater than or equal to the preset threshold. The difference between the preset threshold and the initial number of the counter is the total number of all thread bundles to be reduced.
[0026] In some possible embodiments, multiple clients are used to select one thread bundle to be sent from the enabled thread bundles; Multiple clients are used to send handshake signals to the reduction unit; The client that receives the permission signal sent by the reduction unit among multiple clients is designated as the target client. The target client is used to send the thread bundle to be sent to the reduction unit via the data bus as the target thread bundle.
[0027] In some possible embodiments, the target client is used to select a thread bundle to be sent from the remaining enabled thread bundles; Multiple clients are used to return to the execution of sending handshake signals to the reduction unit until all enabled thread bundles in multiple clients have been sent; The reduction unit is used to broadcast the reduction result to multiple clients.
[0028] The data reduction method provided in this application, by using validity flags to assist in the capture of valid data and storing the results of thread operations, can significantly reduce redundant calculations, reduce the use of computing resources, and improve the energy efficiency ratio of reduction calculations while ensuring the correctness of calculations.
[0029] Other advantages of this application will be explained in more detail with reference to the following description and figures.
[0030] It should be understood that the above description is merely an overview of the technical solution of this application, so as to enable a clearer understanding of the technical means of this application and thus allow for its implementation in accordance with the contents of the specification. To make the above and other objects, features, and advantages of this application more apparent and understandable, specific embodiments of this application are illustrated below. Attached Figure Description
[0031] By reading the detailed description of the exemplary embodiments below, those skilled in the art will understand the advantages and benefits described herein, as well as other advantages and benefits. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. In the drawings: Figure 1 A schematic diagram of multiple clients and a reduction unit provided in an embodiment of this application; Figure 2 A schematic diagram illustrating a data reduction method provided in an embodiment of this application; Figure 3 A schematic diagram illustrating another data reduction method provided in an embodiment of this application; Figure 4 This is a schematic diagram of a graphics processor provided in an embodiment of this application.
[0032] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0033] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.
[0034] In the description of embodiments of this application, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of the disclosed features, figures, steps, behaviors, components, portions or combinations thereof in this specification, and do not exclude the possibility of the presence of one or more other features, figures, steps, behaviors, components, portions or combinations thereof.
[0035] Unless otherwise stated, " / " means "or". For example, A / B can mean A or B. In this article, "and / or" is merely a way of describing the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A alone, A and B at the same time, and B alone.
[0036] The terms "first," "second," etc., are used only for ease of description to distinguish identical or similar technical features and should not be construed as indicating or implying the relative importance or number of these technical features. Therefore, a feature defined by "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of embodiments of this application, unless otherwise stated, the term "multiple" means two or more.
[0037] It should also be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0038] It should be noted that the data reduction method provided in this application embodiment can be applied to graphics processing units (GPUs), especially GPUs used for large model operations. For example... Figure 1 As shown, a GPU may include multiple clients and reduction units (RUs), and the steps in the above embodiments can be executed by the reduction units in the graphics processor. The reduction unit in this embodiment can be a type of computing unit in the GPU.
[0039] like Figure 2 As shown in the figure, this application provides a data reduction method, including: S201: Add a validity flag to each thread in the target thread bundle and store it in the thread buffer queue. Each thread corresponds to one row of data in the thread buffer queue.
[0040] The N-to-1 handshake polling arbitrator in the reduction unit is used to arbitrate and receive input data, which includes the target thread bundle. It should be noted that in this embodiment, the thread buffer queue, in addition to the thread data, stores a separate 32-bit validity flag data. Each bit in the validity flag data stores an identifier for a validity flag, which has two states: a first state and a second state. In practical applications, the first state can be 1 and the second state can be 0; this embodiment does not impose such limitations.
[0041] In this embodiment, the validity flag of each thread in the target thread bundle can be set to a first state first, and the following steps AC can be executed sequentially: Step A: Check if there are any null values in the target thread bundle. If so, directly output the reduction result of the null value. Otherwise, check if there are any positive or negative infinity values in the target thread bundle.
[0042] Step B: The target thread bundle also has a positive infinity flag and a negative infinity flag. If a thread with positive infinity is detected, the positive infinity flag is updated from the third state to the fourth state, and the validity flag of the non-negative infinity data rows detected after this reduction is set to the second state; if a thread with negative infinity is detected, the negative infinity flag is updated from the fifth state to the sixth state, and the validity flag of the non-positive infinity data rows detected after this reduction is set to the second state.
[0043] Step C: If the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state after step B, then check if there are any threads in the target thread bundle with a zero value, and set the validity flag of the thread with the zero value to the second state.
[0044] It should be noted that both the positive infinity flag and the negative infinity flag can be a single bit of data. If a thread with positive infinity is detected, the positive infinity flag can be changed from 0 to 1. If a thread with negative infinity is detected, the negative infinity flag can be updated from 0 to 1. Step A is used to perform null value detection on the target thread bundle, step B is used to perform positive and negative infinity detection on the target thread bundle, and step C is used to perform zero detection on the target thread bundle. Performing null value detection, positive and negative infinity detection, and zero detection on the threads in the thread bundle before the reduction operation can effectively filter invalid operations, reduce redundant calculations, reduce the use of computing resources, and improve the energy efficiency of the reduction operation.
[0045] S202: Retrieve two rows of data from the thread buffer queue whose validity flag is in the first state.
[0046] In this embodiment, the fetching memory can fetch two rows of data with the validity flag in the first state from the thread buffer queue. In this embodiment, if after step S202, that is, after a certain fetch, all the validity flags in the thread buffer queue change to the second state, it means that the data rows corresponding to the target thread bundle have all been fetched. If there are multiple thread bundles to be reduced at this time, the next received thread bundle is taken as the target thread bundle, and each thread in the target thread bundle is added with a validity flag and stored in the thread buffer queue until all thread bundles to be reduced are stored.
[0047] S203: Update the two validity flags corresponding to the two rows of data from the first state to the second state.
[0048] In this embodiment, the two validity flags corresponding to the two captured rows of data are updated from the first state to the second state, which can mark the two rows of data as read and reduce them, thus avoiding repeated readings in the future.
[0049] S204: Perform calculations based on the two rows of data to obtain the thread calculation result.
[0050] In this embodiment, the Arithmetic Logic Unit (ALU) can perform calculations based on two rows of data to obtain the thread calculation result. After obtaining the thread calculation result, this embodiment can also perform null value detection on the thread calculation result. That is, it detects that the thread calculation result is null; if so, it directly outputs the reduction result with a null value; otherwise, it continues to execute step S205. It should be noted that this embodiment does not limit the execution order of steps S203 and S204; steps S203 and S204 can be executed in any order or simultaneously. As a possible implementation, in this embodiment, if the thread calculation result is null in a certain calculation, the reduction ends and the reduction result with a null value is output.
[0051] In this embodiment, after completing step S202, i.e., after capturing data from the memory, if all validity flags in the thread buffer queue are in the second state, it indicates that all data rows corresponding to the target thread bundle have been captured. Therefore, the thread operation result obtained in this loop is the reduction result of the target thread bundle. As a possible implementation, this application can store the thread operation result obtained in this loop into the location of the data row with the validity flag in the thread bundle buffer queue in the second state, and set the validity flag corresponding to that data row to the first state.
[0052] It should be noted that, apart from the thread bundle data, each thread bundle buffer queue stores a separate 32-bit validity flag data. Each bit in the validity flag data stores an identifier for a validity flag. The validity flag has two states: a first state and a second state. In practical applications, the first state can be 1 and the second state can be 0; this embodiment of the application does not impose such limitations.
[0053] After completing step S204, if the thread buffer queue does not meet the condition that "all validity flags are in the second state", this embodiment can return to step S202, that is, retrieve two rows of data with validity flags in the first state from the thread buffer queue by retrieving the memory, until the last two rows of data with validity flags in the first state are retrieved from the thread buffer queue. The data reduction method provided by this embodiment, by using validity flags to assist in the retrieval of valid data and the storage of thread operation results, can significantly reduce redundant calculations, reduce the use of computing resources, and improve the energy efficiency ratio of reduction calculations while ensuring the correctness of calculations.
[0054] S205: Store the thread operation result into the position of the data row whose validity flag is in the second state in the thread buffer queue, and update the validity flag of the data row from the second state to the first state.
[0055] In this embodiment, after completing step S204, i.e. before retrieving data from the memory, if all validity flags in the thread buffer queue are in the second state, it indicates that all thread bundles to be reduced have been reduced. If there is only one thread bundle, such as... Figure 2 As shown, the thread operation result obtained in this loop can be directly used as the reduction result of the target thread bundle for output. If there is another thread bundle to be reduced after the target thread bundle, such as... Figure 3 As shown, the following steps can be performed in the embodiments of this application.
[0056] It should be noted that when there are multiple thread bundles to be reduced, the step of storing the next thread bundle in the thread buffer queue in this embodiment is usually completed before step S204 is completed, so as to ensure that the data in the thread bundle buffer queue is reduced after all the data in the thread buffer queue is reduced.
[0057] S301: Retrieve two rows of data with the validity flag set to the first state from the thread bundle buffer queue.
[0058] like Figure 1 As shown, the fetch memory can fetch two rows of data in the thread bundle buffer queue with the validity flag in the first state.
[0059] S302: Update the two validity flags corresponding to the two rows of data from the first state to the second state.
[0060] S303: Perform calculations based on the two rows of data to obtain the thread bundle calculation result.
[0061] like Figure 1 As shown, the Arithmetic Logic Unit (ALU) can perform calculations based on two rows of data to obtain the thread bundle calculation result.
[0062] S304: Store the result of the thread beam operation into the position of the data row whose validity flag is in the second state in the thread beam buffer queue, and update the validity flag of the data row from the second state to the first state.
[0063] S305: The counter increments by 1.
[0064] When the counter value is less than the preset threshold, the process returns to step S301, retrieving two rows of data with the validity flag set to the first state from the thread bundle buffer queue. In this embodiment, the difference between the preset threshold and the initial count of the counter is determined based on the number of thread bundles to be reduced. The more thread bundles to be reduced, the larger the difference between the preset threshold and the initial count of the counter. This embodiment does not impose any limitations on this. As an example, the difference between the preset threshold and the initial count of the counter is the total number of all thread bundles to be reduced.
[0065] When the value of the counter is greater than or equal to the preset threshold, it means that all data rows in the thread bundle buffer queue have been reduced, and the following step S306 is executed.
[0066] S306: Output the result of the thread bundle operation as the reduction result.
[0067] The GPU in this embodiment may further include multiple guest machines. For example... Figure 1 As shown, multiple clients may include client 0, client 1, client 2, ..., (N-1) clients. These clients are connected to the reduction unit via a data bus.
[0068] In this embodiment of the application, multiple clients can each select a thread bundle to send from the enabled thread bundles within that client. For example... Figure 1 As shown in Client 0, the client can select one thread bundle from the thread bundles with thread bundle enable signals (Thread Bundle 0, Thread Bundle 1, ..., (M-1)) via the M-to-1 polling arbitrator, and store it as the thread bundle to be sent in the client buffer queue. The client handshake devices among the multiple clients send handshake signals to the N-to-1 handshake polling arbitrator in the reduction unit. Then, the client that receives the permission signal sent by the reduction unit is designated as the target client. Assuming Client 0 receives the permission signal from the reduction unit, then Client 0 is the target client. The target client sends the thread bundle to be sent as the target thread bundle to the reduction unit via the data bus.
[0069] After the target client sends its thread bundle to be sent, the M-to-1 polling arbitrator in the target client selects a new thread bundle to be sent from the remaining enabled thread bundles and stores it in the client's buffer queue. The process continues until all enabled thread bundles in multiple clients have been sent to the reduction unit. Once the reduction unit completes its reduction calculation, it broadcasts the reduction result to the thread bundles that participated in the reduction process in the multiple clients.
[0070] The data reduction method provided in this application, through the use of validity flags to assist in filtering invalid operations, capturing valid data, and storing thread operation results, can significantly reduce redundant calculations, reduce the use of computing resources, and improve the energy efficiency ratio of reduction calculations while ensuring the correctness of calculations.
[0071] In the description of this specification, references to terms such as "some possible implementations," "some implementations," "example," "specific example," or "some examples" indicate that a specific feature, structure, material, or characteristic described in connection with that implementation or example is included in at least one implementation or example of this application, and the aforementioned terms do not necessarily refer to the same implementation or example. Furthermore, the described specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more implementations or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different implementations or examples described in this specification, as well as the features of different implementations or examples.
[0072] The method flowcharts for embodiments of this application describe certain operations as different steps performed in a certain order. Such flowcharts are illustrative and not restrictive. Some steps described herein may be grouped together and performed in a single operation, or some steps may be divided into multiple sub-steps, and some steps may be performed in an order different from that shown herein. The various steps shown in the flowcharts may be implemented in any way by any circuit structure and / or tangible mechanism (e.g., by software running on a computer device, hardware (e.g., logic functions implemented by a processor or chip), and / or any combination thereof).
[0073] Those skilled in the art will understand that in the methods described in the above specific embodiments, the order in which the steps are written does not imply a strict execution order, and the specific execution order of each step should be determined by its function and possible internal logic.
[0074] Based on the data reduction method in the above embodiments, this application also provides a graphics processor.
[0075] like Figure 4 As shown, this application embodiment provides a graphics processor, including a reduction unit 100 and a plurality of clients 200, which are connected via a data bus. Multiple clients 200 are used to send the target thread bundle to the reduction unit via the data bus; The reduction unit 100 is used to add a validity flag to each thread in the target thread bundle and store it in the thread buffer queue, with each thread corresponding to one row of data in the thread buffer queue; it retrieves two rows of data with the validity flag in the first state from the thread buffer queue; it updates the two validity flags corresponding to the two rows of data from the first state to the second state; it performs calculations based on the two rows of data to obtain the thread calculation result; it returns to execute the process of retrieving two rows of data with the validity flag in the first state from the thread buffer queue until all validity flags in the thread buffer queue are in the second state; it stores the thread calculation result in the position of the data row with the validity flag in the second state in the thread buffer queue, and updates the validity flag corresponding to the data row from the second state to the first state.
[0076] As one possible implementation, the reduction unit is used to take the next received thread bundle as the target thread bundle if all the validity flags in the thread buffer queue are in the second state, and add a validity flag to each thread in the target thread bundle before storing it in the thread buffer queue, until all the thread bundles to be reduced have been stored.
[0077] As one possible implementation, the reduction unit is used to, after retrieving two rows of data with the validity flag in the first state from the thread buffer queue, if the validity flags in the thread buffer queue are both in the second state, store the thread operation result obtained in this loop into the position of the data row with the validity flag in the second state in the thread bundle buffer queue, and set the validity flag corresponding to the data row to the first state.
[0078] As one possible implementation, the reduction unit is used to: if all validity flags in the thread buffer queue are in the second state, retrieve two rows of data with validity flags in the first state from the thread bundle buffer queue; update the two validity flags corresponding to the two rows of data from the first state to the second state; perform calculations based on the two rows of data to obtain the thread bundle calculation result; store the thread bundle calculation result in the position of the data row with validity flags in the second state in the thread bundle buffer queue, and update the validity flags corresponding to the data row from the second state to the first state; and return to execute the retrieval of the two rows of data with validity flags in the first state from the thread bundle buffer queue.
[0079] As one possible implementation, the thread buffer queue stores a separate row of validity flag data in addition to the thread data, and each bit in the validity flag data stores an identifier corresponding to the validity flag of the row of thread data; the thread bundle buffer queue stores a separate row of validity flag data in addition to the thread bundle data, and each bit in the validity flag data stores an identifier corresponding to the validity flag of the row of thread bundle data.
[0080] As one possible implementation, the reduction unit is used to end the reduction and output a null value if the thread operation result is null.
[0081] As one possible implementation, the reduction unit is used to set the validity flag of each thread in the target thread bundle to a first state; detect whether there is a thread with a null value in the target thread bundle; if so, directly output the reduction result of the null value; otherwise, detect whether there is a thread with positive or negative infinity in the target thread bundle; the target thread bundle also has a positive infinity flag and a negative infinity flag. If a thread with positive infinity is detected, the positive infinity flag is updated from the third state to the fourth state, and the validity flag of the non-negative infinity data rows detected after this reduction is set to the second state; if a thread with negative infinity is detected, the negative infinity flag is updated from the fifth state to the sixth state, and the validity flag of the non-positive infinity data rows detected after this reduction is set to the second state; if the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state, then detect whether there is a thread with a zero value in the target thread bundle, and set the validity flag of the thread with a zero value to the second state.
[0082] As one possible implementation, the reduction unit includes a counter, which increments by 1 after obtaining the thread bundle operation result; the reduction unit outputs the thread bundle operation result as the reduction result when the value of the counter is greater than or equal to a preset threshold.
[0083] In one possible implementation, multiple clients are used to select a thread bundle to be sent from the enabled thread bundles; multiple clients are used to send a handshake signal to the reduction unit; the client that receives the permission signal sent by the reduction unit among the multiple clients is designated as the target client, and the target client is used to send the thread bundle to be sent as the target thread bundle to the reduction unit via the data bus.
[0084] In one possible implementation, the target client is used to select one thread bundle to be sent from the remaining enabled thread bundles; multiple clients are used to return to the execution of sending handshake signals to the reduction unit until all enabled thread bundles in the multiple clients have been sent; the reduction unit is used to broadcast the reduction result to the multiple clients.
[0085] It should be noted that the apparatus in the embodiments of this application can implement the various processes of the aforementioned method embodiments and achieve the same effects and functions, which will not be repeated here.
[0086] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally, certain steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple sub-steps.
[0087] While the spirit and principles of this application have been described above with reference to several specific embodiments, it should be understood that this application is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined. This application is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A data reduction method, characterized in that, include: Each thread in the target thread bundle is added with a validity flag and then stored in a thread buffer queue, with each thread corresponding to a row of data in the thread buffer queue. Retrieve two rows of data whose validity flag is in the first state from the thread buffer queue; Update the two validity flags corresponding to the two rows of data from the first state to the second state; The thread calculation result is obtained by performing calculations based on the two rows of data. Return to the thread buffer queue and retrieve two rows of data with the validity flag in the first state until the validity flags in the thread buffer queue are both in the second state; The result of the thread operation is stored in the thread buffer queue at the position of the data row whose validity flag is in the second state, and the validity flag corresponding to the data row is updated from the second state to the first state.
2. The method according to claim 1, characterized in that, The method further includes: If all validity flags in the thread buffer queue are in the second state, the next received thread bundle is taken as the target thread bundle, and each thread in the target thread bundle is added with a validity flag and stored in the thread buffer queue until all thread bundles to be reduced are stored.
3. The method according to claim 2, characterized in that, After retrieving two rows of data with the validity flag set to the first state from the thread buffer queue, the method further includes: If all validity flags in the thread buffer queue are in the second state, the thread operation result obtained in this loop is stored in the position of the data row with the validity flag in the second state in the thread bundle buffer queue, and the validity flag corresponding to the data row is set to the first state.
4. The method according to claim 3, characterized in that, After performing calculations based on the two rows of data to obtain the thread calculation result, the method further includes: If all validity flags in the thread buffer queue are in the second state, retrieve the two rows of data with the validity flag in the first state from the thread bundle buffer queue; Update the two validity flags corresponding to the two rows of data from the first state to the second state; The thread bundle operation result is obtained by performing calculations based on the two rows of data. The thread beam operation result is stored in the thread beam buffer queue at the position of the data row whose validity flag is in the second state, and the validity flag corresponding to the data row is updated from the second state to the first state. Returns to the two rows of data in the thread bundle buffer queue whose validity flag is in the first state.
5. The method according to claim 4, characterized in that, In addition to thread data, each thread buffer queue stores a separate row of validity flag data, and each bit in the validity flag data stores an identifier as a validity flag; In addition to the thread bundle data, each thread bundle buffer queue stores a separate row of validity flag data. Each bit in the row of validity flag data stores an identifier corresponding to the validity flag of the row of thread bundle data.
6. The method according to claim 1, characterized in that, The method further includes: If the result of the thread operation is null, then the reduction ends and the reduction result with a null value is output.
7. The method according to claim 1, characterized in that, Adding a validity flag to each thread in the target thread bundle includes: Set the validity flag of each thread in the target thread bundle to the first state; Check if there are any null values in the target thread bundle. If so, output the reduction result of the null value directly. Otherwise, check if there are any positive or negative infinity values in the target thread bundle. The target thread bundle also has a positive infinity flag and a negative infinity flag. If a thread with positive infinity is detected, the positive infinity flag is updated from the third state to the fourth state, and the validity flag of the non-negative infinity data rows detected after this reduction is set to the second state. If a thread with negative infinity is detected, update the negative infinity flag from the fifth state to the sixth state, and set the validity flag of any subsequent non-positive infinity data rows detected in this reduction to the second state. If the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state, then check if there are any threads in the target thread bundle with a zero value, and set the validity flag of the thread with the zero value to the second state.
8. The method according to claim 4, characterized in that, After performing calculations based on the two rows of data to obtain the thread bundle calculation result, the method further includes: The counter increments by 1; When the value of the counter is greater than or equal to a preset threshold, the result of the thread bundle operation is output as the reduction result. The difference between the preset threshold and the initial value of the counter is the total number of all thread bundles to be reduced.
9. The method according to any one of claims 1-8, characterized in that, The method is applied to the reduction unit in a graphics processing unit (GPU).
10. The method according to claim 9, characterized in that, The graphics processor further includes multiple clients, and the reduction unit is connected to the multiple clients via a data bus. The method further includes: Each of the client machines selects a thread bundle to send from the enabled thread bundles; Multiple clients send handshake signals to the reduction unit; The client that receives the permission signal sent by the reduction unit among multiple clients is designated as the target client; The target client sends the thread bundle to be sent as the target thread bundle to the reduction unit through the data bus.
11. The method according to claim 10, characterized in that, The method further includes: The target client selects a thread bundle to send from the remaining enabled thread bundles; The process continues until all enabled thread bundles within the multiple clients have been sent to the reduction unit. The reduction unit broadcasts the reduction result to multiple clients.
12. A graphics processor, characterized in that, It includes a reduction unit and multiple clients, which are connected via a data bus. Multiple clients are used to send the target thread bundle to the reduction unit via the data bus; The reduction unit is used to add a validity flag to each thread in the target thread bundle and store it in a thread buffer queue, with each thread corresponding to a row of data in the thread buffer queue; retrieve two rows of data with the validity flag in the first state from the thread buffer queue; update the two validity flags corresponding to the two rows of data from the first state to the second state; perform calculations based on the two rows of data to obtain the thread calculation result; store the thread calculation result in the position of the data row with the validity flag in the second state in the thread buffer queue, and update the validity flag corresponding to the data row from the second state to the first state; return to execute the retrieval of the two rows of data with the validity flag in the first state from the thread buffer queue.
13. The graphics processor according to claim 12, characterized in that, The reduction unit is used to take the next received thread bundle as the target thread bundle if all the validity flags in the thread buffer queue are in the second state, and add a validity flag to each thread in the target thread bundle before storing it in the thread buffer queue, until all the thread bundles to be reduced have been stored.
14. The graphics processor according to claim 13, characterized in that, The reduction unit is used to retrieve two rows of data with the validity flag in the first state from the thread buffer queue. If the validity flags in the thread buffer queue are both in the second state, the thread operation result obtained in this loop is stored in the position of the data row with the validity flag in the second state in the thread bundle buffer queue, and the validity flag corresponding to the data row is set to the first state.
15. The graphics processor according to claim 14, characterized in that, The reduction unit is used to: if all validity flags in the thread buffer queue are in the second state, retrieve two rows of data with validity flags in the first state from the thread bundle buffer queue; update the two validity flags corresponding to the two rows of data from the first state to the second state; perform calculations based on the two rows of data to obtain the thread bundle calculation result; store the thread bundle calculation result in the position of the data row with validity flags in the second state in the thread bundle buffer queue, and update the validity flags corresponding to the data row from the second state to the first state; and return to execute the retrieval of the two rows of data with validity flags in the first state from the thread bundle buffer queue.
16. The graphics processor according to claim 15, characterized in that, In addition to thread data, each thread buffer queue stores a separate row of validity flag data, and each bit in the validity flag data stores an identifier as a validity flag; In addition to the thread bundle data, each thread bundle buffer queue stores a separate row of validity flag data. Each bit in the row of validity flag data stores an identifier corresponding to the validity flag of the row of thread bundle data.
17. The graphics processor according to claim 12, characterized in that, The reduction unit is used to end the reduction and output a reduction result that is null if the result of the thread operation is null.
18. The graphics processor according to claim 12, characterized in that, The reduction unit is used to set the validity flag of each thread in the target thread bundle to the first state; detect whether there is a thread with a null value in the target thread bundle. If so, the reduction result with a null value is directly output. Otherwise, it detects whether there is a thread with positive or negative infinity in the target thread bundle. The target thread bundle also has a positive infinity flag and a negative infinity flag. If a thread with positive infinity is detected, the positive infinity flag is updated from the third state to the fourth state, and the validity flag of the non-negative infinity data rows detected in the subsequent reduction is set to the second state. If a thread with negative infinity is detected, the negative infinity flag is updated from the fifth state to the sixth state, and the validity flag of subsequent non-positive infinity data rows detected in this reduction is set to the second state; if the positive infinity flag is still in the third state and the negative infinity flag is still in the fifth state, it is checked whether there are any threads with zero values in the target thread bundle, and the validity flag of the threads with zero values is set to the second state.
19. The graphics processor according to claim 15, characterized in that, The reduction unit includes a counter. The counter is used to increment the count by 1 after the result of the thread bundle operation is obtained; The reduction unit is used to output the thread bundle operation result as the reduction result when the value of the counter is greater than or equal to a preset threshold. The difference between the preset threshold and the initial number of the counter is the total number of all thread bundles to be reduced.
20. The graphics processor according to claim 12, characterized in that, The plurality of clients are each used to select one thread bundle to be sent from the enabled thread bundles; Multiple clients are used to send handshake signals to the reduction unit; The client that receives the permission signal sent by the reduction unit among multiple clients is designated as the target client. The target client is used to send the thread bundle to be sent as the target thread bundle to the reduction unit through the data bus.
21. The graphics processor according to claim 20, characterized in that, The target client is used to select one thread bundle to be sent from the remaining enabled thread bundles; The multiple clients are used to return to the execution of sending handshake signals to the reduction unit by the multiple clients until all enabled thread bundles in the multiple clients have been sent; The reduction unit is used to broadcast the reduction result to multiple clients.