Method and equipment for determining thread bundle index

By obtaining the size and index information of thread blocks, and using table lookup or division operations to determine thread bundle index, the problem of low efficiency in thread bundle index determination in general graphics processors is solved, and the processing efficiency of the processor is improved.

CN120407141APending Publication Date: 2025-08-01T-HEAD (SHANGHAI) SEMICON CO LTD +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410149024.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-01
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

In a general-purpose graphics processor, how to quickly and accurately determine thread bundle indexes in thread blocks to improve processing efficiency.

Method used

By obtaining the thread size information of the thread block to be split and the index information of the current thread bundle, the index information of the next thread bundle is determined by using a lookup or division operation, which specifically includes calculations in the X, Y, and Z dimensions based on the thread size value and index value.

Benefits of technology

It realizes fast and accurate determination of thread bundle indexes, improving the processing efficiency of general graphics processors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407141A_ABST
    Figure CN120407141A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a thread bundle index determination method and equipment, and the method comprises the steps: obtaining the thread size information of a to-be-split thread block and the index information of a current thread bundle in the to-be-split thread block, and then determining the index information of a next thread bundle according to the thread size information and the index information of the current thread bundle. In the technical scheme, the index information of the next thread bundle can be accurately determined according to the thread size information of the to-be-split thread block and the index information of the current thread bundle in the to-be-split thread block.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of chip technology, and in particular, to a method and device for determining a warp index. Background Art

[0002] In a general-purpose graphics processing unit, after a kernel function is split into thread blocks, the split thread blocks are dispatched to each computing engine for execution. Each computing engine consists of multiple warp execution units. Therefore, each thread block needs to be split into warps of a fixed size, and then the warp index is dispatched to the warp execution unit to execute the threads in each warp.

[0003] Therefore, in order to ensure the processing efficiency of the general-purpose graphics processing unit, how to quickly and accurately determine the warp index in the thread block has become a technical problem to be solved urgently. Summary of the Invention

[0004] Multiple aspects of this application provide a method and device for determining a warp index to improve the efficiency and effect of warp splitting.

[0005] In a first aspect, an embodiment of this application provides a method for determining a warp index, including:

[0006] In a possible implementation, obtaining the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split;

[0007] Determining the index information of the next warp according to the thread size information and the index information of the current warp.

[0008] In a possible implementation, the thread size information includes: a first size value of the thread block to be split in the X dimension and a second size value of the thread block to be split in the Y dimension; the index information of the current warp includes: a first X index value of the current warp in the X dimension, a first Y index value of the current warp in the Y dimension, and a first Z index value of the current warp in the Z dimension;

[0009] Correspondingly, the determining the index information of the next warp according to the thread size information and the index information of the current warp includes:

[0010] Determining a second X index value of the next warp in the X dimension according to the first size value and the first X index value;

[0011] Determining a second Y index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y index value;

[0012] Determine the second Z-index value of the next warp in the Z dimension according to the first size value, the second size value, and the first Z-index value;

[0013] Among them, the index information of the next warp includes the second X-index value, the second Y-index value, and the second Z-index.

[0014] In a possible implementation manner, the determining the second X-index value of the next warp in the X dimension according to the first size value and the first X-index value includes:

[0015] Determine a preselected value of the second X-index value of the next warp in the X dimension according to the first size value and the first X-index value;

[0016] Determine the second X-index value according to the preselected value of the second X-index value and the first size value.

[0017] In a possible implementation manner, the determining the preselected value of the second X-index value of the next warp in the X dimension according to the first size value and the first X-index value includes:

[0018] Judge whether the first size value is less than 32;

[0019] If the first size value is less than 32, determine the preselected value of the second X-index value as the sum of the first X-index value and the first remainder, where the first remainder is the remainder obtained by dividing 32 by the first size value;

[0020] If the first size value is equal to or greater than 32, determine the preselected value of the second X-index value as the sum of the first X-index value and 32.

[0021] In a possible implementation manner, the determining the second X-index value according to the preselected value of the second X-index value and the first size value includes:

[0022] If the preselected value of the second X-index value is less than the first size value, the second X-index value is the preselected value of the second X-index value;

[0023] If the preselected value of the second X-index value is equal to or greater than the first size value, the second X-index value is the difference between the preselected value of the second X-index value and the first size value.

[0024] In a possible implementation manner, the determining the second Y-index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y-index value includes:

[0025] Determine a preselected value of the second Y index value according to the product of the first Y index value, the first size value, and the second size value;

[0026] Determine the second Y index value according to the preselected value of the second Y index value and the second size value.

[0027] In a possible implementation manner, the determining the preselected value of the second Y index value according to the product of the first Y index value, the first size value, and the second size value includes:

[0028] If the product of the first size value and the second size value is greater than 32, determine the preselected value of the second Y index value as the sum of the first Y index value and a first set value; wherein, the first set value is 0 when the first size value is greater than 32, and is the quotient obtained by dividing 32 by the first size value when the first size value is less than or equal to 32;

[0029] If the product of the first size value and the second size value is less than or equal to 32, determine the preselected value of the second Y index value as the sum of the first Y index value and a third set value; wherein, the third set value is the quotient obtained by dividing the difference between the first set value and a second set value by the product of the first size value and the second size value, the second set value is 0 when the product of the first size value and the second size value is greater than 32, and is the quotient obtained by dividing 32 by the difference when the product of the first size value and the second size value is less than or equal to 32, and the difference is the difference between the product of the first size value and the second size value and 32.

[0030] In a possible implementation manner, the determining the second Y index value according to the preselected value of the second Y index value and the second size value includes:

[0031] If the preselected value of the second Y index value is greater than the second size value, determine the second Y index value as the preselected value of the second Y index value minus the second size value;

[0032] If the preselected value of the second Y index value is less than or equal to the second size value, determine the second Y index value as the preselected value of the second Y index value.

[0033] In a possible implementation manner, the determining the second Z index value of the next warp in the Z dimension according to the first size value, the second size value, and the first Z index value includes:

[0034] If the product of the first size value and the second size value is greater than 32, determine the second Z index value as the first Z index value;

[0035] If the product of the first size value and the second size value is less than or equal to 32, determine the second Z-index value as the sum of the first Z-index value and the second set value.

[0036] In a second aspect, an embodiment of the present application provides an apparatus for determining a warp index, including:

[0037] In a possible implementation manner, an obtaining module is configured to obtain thread size information of a thread block to be split and index information of the current warp in the thread block to be split;

[0038] A determining module is configured to determine index information of the next warp according to the thread size information and the index information of the current warp.

[0039] In a possible implementation manner, the thread size information includes: a first size value of the thread block to be split in the X dimension and a second size value of the thread block to be split in the Y dimension; the index information of the current warp includes: a first X-index value of the current warp in the X dimension, a first Y-index value of the current warp in the Y dimension, and a first Z-index value of the current warp in the Z dimension;

[0040] Correspondingly, the determining module is specifically configured to:

[0041] Determine a second X-index value of the next warp in the X dimension according to the first size value and the first X-index value;

[0042] Determine a second Y-index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y-index value;

[0043] Determine a second Z-index value of the next warp in the Z dimension according to the first size value, the second size value, and the first Z-index value;

[0044] Wherein, the index information of the next warp includes the second X-index value, the second Y-index value, and the second Z-index.

[0045] In a possible implementation manner, when the determining module determines the second X-index value of the next warp in the X dimension according to the first size value and the first X-index value, it is specifically configured to:

[0046] Determine a preselected value of the second X-index value of the next warp in the X dimension according to the first size value and the first X-index value;

[0047] Determine the second X-index value according to the preselected value of the second X-index value and the first size value.

[0048] In a possible implementation manner, the determining module determines a preselected value of a second X index value of the next warp in the X dimension according to the first size value and the first X index value, and specifically is configured to:

[0049] Judge whether the first size value is less than 32;

[0050] If the first size value is less than 32, determine that the preselected value of the second X index value is the sum of the first X index value and a first remainder, where the first remainder is the remainder obtained by dividing 32 by the first size value;

[0051] If the first size value is equal to or greater than 32, determine that the preselected value of the second X index value is the sum of the first X index value and 32.

[0052] In a possible implementation manner, the determining module determines the second X index value according to the preselected value of the second X index value and the first size value, and specifically is configured to:

[0053] If the preselected value of the second X index value is less than the first size value, the second X index value is the preselected value of the second X index value;

[0054] If the preselected value of the second X index value is equal to or greater than the first size value, the second X index value is the difference between the preselected value of the second X index value and the first size value.

[0055] In a possible implementation manner, the determining module determines a second Y index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y index value, and specifically is configured to:

[0056] Determine a preselected value of the second Y index value according to the first Y index value and the product of the first size value and the second size value;

[0057] Determine the second Y index value according to the preselected value of the second Y index value and the second size value.

[0058] In a possible implementation manner, the determining module determines a preselected value of the second Y index value according to the first Y index value and the product of the first size value and the second size value, and specifically is configured to:

[0059] If the product of the first size value and the second size value is greater than 32, determine that the preselected value of the second Y index value is the sum of the first Y index value and a first set value; where the first set value is 0 when the first size value is greater than 32, and is the quotient obtained by dividing 32 by the first size value when the first size value is less than or equal to 32;

[0060] If the product of the first magnitude value and the second magnitude value is less than or equal to 32, determine the preselected value of the second Y index value as the sum of the first Y index value and a third set value; wherein, the third set value is the quotient obtained by dividing the difference between the first set value and the second set value by the product of the first magnitude value and the second magnitude value, the second set value is 0 when the product of the first magnitude value and the second magnitude value is greater than 32, and the second set value is the quotient obtained by dividing 32 by the difference when the product of the first magnitude value and the second magnitude value is less than or equal to 32, and the difference is the difference between the product of the first magnitude value and the second magnitude value and 32.

[0061] In a possible implementation manner, the determining module determines the second Y index value according to the preselected value of the second Y index value and the second magnitude value, and specifically is used for:

[0062] If the preselected value of the second Y index value is greater than the second magnitude value, determine the second Y index value as the preselected value of the second Y index value minus the second magnitude value;

[0063] If the preselected value of the second Y index value is less than or equal to the second magnitude value, determine the second Y index value as the preselected value of the second Y index value.

[0064] In a possible implementation manner, the determining module determines the second Z index value of the next warp in the Z dimension according to the first magnitude value, the second magnitude value, and the first Z index value, and specifically is used for:

[0065] If the product of the first magnitude value and the second magnitude value is greater than 32, determine the second Z index value as the first Z index value;

[0066] If the product of the first magnitude value and the second magnitude value is less than or equal to 32, determine the second Z index value as the sum of the first Z index value and the second set value.

[0067] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor;

[0068] The memory stores computer execution instructions;

[0069] The processor executes the computer execution instructions stored in the memory, so that the processor executes the method according to any one of the first aspects.

[0070] Fourthly, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, the method described in any one of the first aspects is implemented.

[0071] The method and device for determining a warp index provided by the embodiments of the present application obtain the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split, and then determine the index information of the next warp according to the thread size information and the index information of the current warp. In this technical solution, the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split can accurately determine the index information of the next warp. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The schematic embodiments and descriptions thereof of the present application are used to explain the present application, and do not constitute an improper limitation to the present application. In the drawings:

[0073] Figure 1 is a flowchart of the method for determining a warp index provided by an embodiment of the present application Figure 1 ;

[0074] Figure 2 is a flowchart of the method for determining a warp index provided by an embodiment of the present application Figure 2 ;

[0075] Figure 3 is a flowchart of the method for determining a warp index provided by an embodiment of the present application Figure 3 ;

[0076] Figure 4 is a flowchart of the method for determining a warp index provided by an embodiment of the present application Figure 4 ;

[0077] Figure 5 is a flowchart of the method for determining a warp index provided by an embodiment of the present application Figure 5 ;

[0078] Figure 6 is a schematic structural diagram of the device for determining a warp index provided by an exemplary embodiment of the present application;

[0079] Figure 7 is a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0080] To make the objectives, technical solutions and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the described embodiments are only a part rather than all of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application. The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.

[0081] First, the terms involved in the embodiments of this application are explained:

[0082] A General-Purpose Computing on Graphics Processing Units (GPGPU) utilizes the graphics processing unit for processing graphics tasks to compute general computing tasks originally processed by the central processing unit;

[0083] CUDA: Compute Unified Device Architecture, is a general parallel computing architecture that enables the GPU to solve complex computing problems;

[0084] KERNEL: A CUDA kernel function. When the kernel function is called in CUDA, the GPGPU will start multiple threads to execute this kernel function in parallel. One KERNEL corresponds to one GRID;

[0085] Grid (English): A collection of thread blocks. The thread blocks in the grid will be scheduled to multiple CUs of the GPGPU for execution. There is no synchronization mechanism between thread blocks, and the execution order of thread blocks is uncertain;

[0086] Thread block (English): Composed of a group of threads. The threads within each thread block can cooperate and have shared memory that can be accessed jointly. Each thread block will be executed in a certain computing unit (Compute Unit, CU) on the GPGPU;

[0087] Thread (English: thread): The basic execution unit of a CUDA program. The execution within each thread is sequential. All threads execute the same code, but may execute different branches of the same code. All threads execute in parallel with no order of precedence;

[0088] WARP (English: WARP): A collection of 32 threads. A thread block is split into a collection of warps and dispatched to the warp engine (WE) for execution;

[0089] Compute Engine (CE): Fixed and composed of four Compute Units (CU);

[0090] CU: All threads of a thread block execute in the same compute unit. One CU can execute multiple thread blocks simultaneously;

[0091] WE: The smallest unit in a compute unit. One WE can execute multiple warps simultaneously.

[0092] Next, the scenarios involved in the embodiments of this application are introduced:

[0093] During the development process related to the splitting of multiple warps, a warp splitting scheme needs to be developed. Since the warp splitting is repeatedly referenced many times in the entire chip, this warp splitting scheme must have a relatively small area overhead, and at the same time, the timing and performance must also be friendly.

[0094] A thread block (English: thread block) is often composed of many warps (English: warp). One warp represents 32 consecutive threads (English: thread). When a thread block is split into warps and passed to the warp engine (warp engine, WE), the coordinate position of the first thread in this warp, that is, the index information, needs to be passed to the WE.

[0095] Within a thread block, the size of the threads is defined by three dimensions, namely (block.x, block.y, block.z), where:

[0096] block.x: 12-bit, representing the number of threads in the X direction; block.y: 12-bit, representing the number of threads in the Y direction; block.z: 8-bit, representing the number of threads in the Z direction.

[0097] The technical problem to be solved by this solution is as follows: The requirement is to find a simple and effective method to find the coordinate positions of the first threads of all warps in a thread block. It is sufficient to output the coordinate positions of one warp per cycle to meet the performance requirements. That is, in order to ensure the processing efficiency of a general-purpose graphics processing unit, how to quickly and accurately determine the warp index in a thread block has become a technical problem to be solved urgently.

[0098] The following uses specific embodiments to elaborate in detail on the technical solutions shown in this application. It should be noted that the following several embodiments can exist independently or be combined with each other. For the same or similar content, it will not be repeated in different embodiments.

[0099] Figure 1 It is a flow schematic diagram of the method for determining the warp index provided by the embodiment of this application Figure 1 . Please refer to Figure 1 , and this method may include:

[0100] Step 11: Obtain the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split;

[0101] In this step, a thread block usually consists of many warps, and one warp represents 32 consecutive threads. When a thread block is split into individual warps and passed to the WE, the coordinate position of the first thread in this warp needs to be passed to the WE. At this time, the thread size information of the current thread block to be split, that is, the thread size information of the thread block to be split, and the index information of the current warp in the thread block to be split can be obtained first, and then the index information of the next warp can be determined in the following steps.

[0102] Optionally, the thread size information includes: the first size value of the thread block to be split in the X dimension and the second size value of the thread block to be split in the Y dimension; the index information of the current warp includes: the first X index value of the current warp in the X dimension, the first Y index value of the current warp in the Y dimension, and the first Z index value of the current warp in the Z dimension.

[0103] For example, the thread size information of the thread block to be split can be three-dimensional (10, 5, 2) of this thread block to be split, and the index information of the current warp can be three-dimensional index (0, 0, 0) of this current warp.

[0104] That is, the first size value in the X dimension is 10, the second size in the Y dimension is 5; the first X index value in the X dimension is 0, the first Y index value in the Y dimension is 0, and the first Z index value in the Z dimension is 0.

[0105] Step 12. Determine the index information of the next warp according to the thread size information and the index information of the current warp of the thread block to be split.

[0106] In this step, based on the thread size information of the thread block to be split obtained above and the index information of the current warp in the thread block to be split, the index information of the next warp is determined.

[0107] Optionally, a possible implementation of this step can be based on a look-up table: a table generated based on "32 / src[4:0]";

[0108] That is, the input of div_table is src[4:0], and the output is the quotient and remainder of 32 / src[4:0].

[0109] Table 1:

[0110] src[4:0] Quotient Remainder 5'h01 6'h20 4'h0 5'h02 6'h10 4'h0 5'h03 6'h0A 4'h2 5'h04 6'h08 4'h0 5'h05 6'h06 4'h2 5'h06 6'h05 4'h2 5'h07 6'h04 4'h4 5'h08 6'h04 4'h0 5'h09 6'h03 4'h5 5'h0A 6'h03 4'h2 5'h0B 6'h02 4'ha 5'h0C 6'h02 4'h8 5'h0D 6'h02 4'h6 5'h0E 6'h02 4'h4 5'h0F 6'h02 4'h2 5'h10 6'h02 4'h0 others 6'h01 ~src[3:0]+1'b1

[0111] Wherein, rem is the remainder output by div_table; quo is the quotient output by div_table.

[0112] In some implementation solutions in the following embodiments, the look-up table query can be based on this table. Similarly, its implementation can also be directly implemented by using a division operation. In actual implementation, one of them is selected according to the actual situation.

[0113] The method for determining the warp index provided by the embodiments of the present application obtains the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split, and then determines the index information of the next warp according to the thread size information and the index information of the current warp. In this technical solution, the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split can accurately determine the index information of the next warp.

[0114] Based on the above embodiments, then Figure 2 is a schematic flow of the method for determining the warp index provided by the embodiments of the present application Figure 2 . Please refer to Figure 2 , the above step 12 may include:

[0115] Step 21. Determine the second X index value of the next warp in the X dimension according to the first size value and the first X index value;

[0116] For the convenience of explaining the technical details involved in this solution, the features involved in this solution are marked below.

[0117] For example, the first size value may be denoted as blk.x, the first X index value may be denoted as c_x, and the second X index value of the next warp in the X dimension may be denoted as n_x.

[0118] Step 22: Determine a second Y index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y index value.

[0119] Continuing with the above example, the second size value may be recorded as blk.y, the first Y index value may be recorded as c_y, and the second Y index value of the next warp in the Y dimension may be recorded as n_y.

[0120] Step 23: Determine a second Z index value of the next warp in the Z dimension according to the first size value, the second size value, and the first Z index value.

[0121] The index information of the next warp includes a second X index value, a second Y index value, and a second Z index.

[0122] Continuing with the above example, the first Z index value can be recorded as c_z, and the second Z index value of the next warp in the Z dimension can be recorded as n_z.

[0123] The index information of the next warp is (n_x, n_y, n_z).

[0124] The method for determining a warp index provided in an embodiment of the present application determines the second X index value of the next warp in the X dimension based on the first size value and the first X index value; determines the second Y index value of the next warp in the Y dimension based on the first size value, the second size value, and the first Y index value; and determines the second Z index value of the next warp in the Z dimension based on the first size value, the second size value, and the first Z index value. The index information of the next warp includes the second X index value, the second Y index value, and the second Z index. In this technical solution, the index value of the next warp is accurately determined based on the size values of the thread block in the X and Y dimensions and the index values of the current warp in the X, Y, and Z dimensions.

[0125] Based on the above embodiment, Figure 3 Schematic diagram of the process of determining the thread bundle index provided in the embodiment of the present application Figure 3 See Figure 3 , the above step 21 may include:

[0126] Step 31: Determine a preselected value of a second X-index value of the next warp in the X dimension based on the first size value and the first X-index value.

[0127] Take the thread size information (10, 5, 2) of the thread block to be split and the index information (0, 0, 0) of the current warp as an example.

[0128] Optionally, the implementation of this step can be:

[0129] Judge whether the first size value is less than 32; if the first size value is less than 32, determine that the preselected value of the second X index value is the sum of the first X index value and the first remainder, where the first remainder is the remainder obtained by dividing 32 by the first size value; if the first size value is equal to or greater than 32, determine that the preselected value of the second X index value is the sum of the first X index value and 32.

[0130] For example, if the first size value blk.x is 10 (i.e., it can be marked as x_ge_32), and 10 is less than 32, then determine that the preselected value of the second X index value n_x_pre is the first X index value c_x plus the first remainder;

[0131] where c_x (is 0), the first remainder is the remainder of 32 / 10, which is 2, then n_x_pre (is 2). (This implementation can be obtained by looking up a table, that is, 32 / 5'h0A in Table 1, and the remainder is 4'h2, which is 2. The following quotient and remainder can also be obtained by looking up the table).

[0132] For example, if the first size value (e.g., 40) is equal to or greater than 32, then determine that the preselected value of the second X index value is the sum of the first X index value and 32 (0 + 32 = 32).

[0133] Step 32: Determine the second X index value according to the preselected value of the second X index value and the first size value.

[0134] Optionally, the implementation of this step can be:

[0135] First: If the preselected value of the second X index value is less than the first size value, then the second X index value is the preselected value of the second X index value;

[0136] For example, if the preselected value of the second X index value n_x_pre (is 2) is less than the first size value blk.x (is 10), then the second X index value is the preselected value of the second X index value n_x_pre (is 2).

[0137] Second: If the preselected value of the second X index value is equal to or greater than the first size value, then the second X index value is the difference between the preselected value of the second X index value and the first size value.

[0138] For example, if the preselected value of the second X index value is the sum of the first X index value and 32 (0 + 32 = 32), which is greater than the first size value blk.x (e.g., 30), then the second X index value is the difference between the preselected value of the second X index value and the first size value, which is 2.

[0139] In the above embodiment, taking the thread size information (10, 5, 2) of the thread block to be split and the index information (0, 0, 0) of the current warp as an example, the second X index value n_x is obtained as 2.

[0140] The method for determining the warp index provided by the embodiment of the present application determines a preselected value of the second X index value of the next warp in the X dimension according to the first size value and the first X index value; and determines the second X index value according to the preselected value of the second X index value and the first size value. In this technical solution, the index value of the next warp in the X dimension is accurately determined through the size value of the thread block in the X dimension and the index value of the current warp in the X dimension.

[0141] Based on the above embodiment, then Figure 4 is a flow schematic of the method for determining the warp index provided by the embodiment of the present application Figure 4 . Please refer to Figure 4 , the above step 22 may include:

[0142] Step 41, determine a preselected value of the second Y index value according to the first Y index value and the product of the first size value and the second size value;

[0143] Optionally, the implementation of this step can be divided into two possibilities:

[0144] The first: If the product of the first size value and the second size value is greater than 32, determine the preselected value of the second Y index value as the sum of the first Y index value and the first set value; where the first set value is 0 when the first size value is greater than 32, and when the first size value is less than or equal to 32, it is the quotient obtained by dividing 32 by the first size value;

[0145] For example, the first size value blk.x (is 10), the second size value blk.y (is 5), the product of the first size value and the second size value is 50, which is greater than 32, then the preselected value n_y_pre of the second Y index value is the sum of the first Y index value c_y (is 0) and the first set value (that is, 0 + 3 = 3). Specifically, when the first size value 10 is less than or equal to 32, the first set value is the quotient obtained by dividing 32 by 10 (is 3).

[0146] The second: If the product of the first size value and the second size value is less than or equal to 32, determine the preselected value of the second Y index value as the sum of the first Y index value and the third set value; where the third set value is the quotient obtained by dividing the difference between the first set value and the second set value by the product of the first size value and the second size value, the second set value is 0 when the product of the first size value and the second size value is greater than 32, and when the product of the first size value and the second size value is less than or equal to 32, it is the quotient obtained by dividing 32 by the difference value, and the difference value is the difference between the product of the first size value and the second size value and 32.

[0147] For example, if the product of the first size value and the second size value (e.g., 10 * 2 = 20) is less than or equal to 32, then the preselected value n_y_pre of the second Y index value is determined to be the sum of the first Y index value and the third set value (e.g., 0 + 0).

[0148] The third set value is the difference (3 - 2 = 1) between the first set value (when 10 is less than 32, the quotient is 3 as above) and the second set value (when the product of the first size value and the second size value is less than or equal to 32, the quotient obtained by dividing 32 by the difference (32 - 12) is 2), divided by the product of the first size value and the second size value (20), and the resulting quotient is 0.

[0149] In this implementation, if the product of X and Y in the three dimensions of the thread block is 20, then the second Y index value of the next warp is also 0.

[0150] Step 42: Determine the second Y index value according to the preselected value of the second Y index value and the second size value.

[0151] Optionally, the implementation of this step can be divided into two possibilities:

[0152] The first: If the preselected value of the second Y index value is greater than the second size value, then determine the second Y index value as the preselected value of the second Y index value minus the second size value.

[0153] For example, if the preselected value n_y_pre of the second Y index value (e.g., 6) is greater than the second size value blk.y (which is 5), then the second Y index value is the preselected value of the second Y index value minus the second size value (6 - 5 = 1).

[0154] The second: If the preselected value of the second Y index value is less than or equal to the second size value, then determine the second Y index value as the preselected value of the second Y index value.

[0155] For example, if the preselected value n_y_pre of the second Y index value (which is 3) is less than the second size value blk.y (which is 5), then the second Y index value is the preselected value 3 of the second Y index value.

[0156] In the above embodiment, taking the thread size information (10, 5, 2) of the thread block to be split and the index information (0, 0, 0) of the current warp as an example, the second Y index value n_y is obtained as 3.

[0157] The method for determining the warp index provided by the embodiment of the present application determines a preselected value of the second Y index value according to the product of the first Y index value, the first size value, and the second size value; and determines the second Y index value according to the preselected value of the second Y index value and the second size value. In this technical solution, the index value of the next warp in the Y dimension is accurately determined through the size value of the thread block in the Y dimension and the index value of the current warp in the Y dimension.

[0158] Based on the above embodiment, Figure 5 is a schematic flow of the method for determining the warp index provided by the embodiment of the present application Figure 5 . Please refer to Figure 5 , and the above step 23 may include:

[0159] Step 51: When the product of the first size value and the second size value is greater than 32, determine the second Z index value as the first Z index value;

[0160] For example, if the first size value blk.x (is 10), the second size value blk.y (is 5), and the product of the first size value and the second size value is 50, which is greater than 32, then determine the second Z index value n_z as the first Z index value c_z (is 0).

[0161] Step 52: When the product of the first size value and the second size value is less than or equal to 32, determine the second Z index value as the sum of the first Z index value and the second set value.

[0162] For example, if the first size value blk.x (for example, 10), the second size value blk.y (for example, 2), and the product of the first size value and the second size value is 20, which is less than 32, then determine the second Z index value n_z as the sum of the first Z index value c_z (is 0) and the above second set value (for example, 1), which is 1.

[0163] In the above embodiment, taking the thread size information (10, 5, 2) of the thread block to be split and the index information (0, 0, 0) of the current warp as an example, the second Z index value is obtained as 0.

[0164] The method for determining the warp index provided by the embodiment of the present application determines the second Z index value as the first Z index value if the product of the first size value and the second size value is greater than 32, and determines the second Z index value as the sum of the first Z index value and the second set value if the product of the first size value and the second size value is less than or equal to 32. In this technical solution, the index value of the next warp in the Z dimension is accurately determined through the size values of the thread block in the X and Y dimensions obtained above and the first Z index value.

[0165] Figure 6The structural schematic diagram of the thread bundle index determination device provided for the exemplary embodiment of the present application is shown in Figure 6 , the device includes:

[0166] An obtaining module 61, configured to obtain the thread size information of the thread block to be split and the index information of the current thread bundle in the thread block to be split;

[0167] A determining module 62, configured to determine the index information of the next thread bundle according to the thread size information and the index information of the current thread bundle.

[0168] In a possible implementation manner, the thread size information includes: a first size value of the thread block to be split in the X dimension and a second size value of the thread block to be split in the Y dimension; the index information of the current thread bundle includes: a first X index value of the current thread bundle in the X dimension, a first Y index value of the current thread bundle in the Y dimension, and a first Z index value of the current thread bundle in the Z dimension;

[0169] Correspondingly, the determining module 62 is specifically configured to:

[0170] Determine a second X index value of the next thread bundle in the X dimension according to the first size value and the first X index value;

[0171] Determine a second Y index value of the next thread bundle in the Y dimension according to the first size value, the second size value, and the first Y index value;

[0172] Determine a second Z index value of the next thread bundle in the Z dimension according to the first size value, the second size value, and the first Z index value;

[0173] Wherein, the index information of the next thread bundle includes a second X index value, a second Y index value, and a second Z index.

[0174] In a possible implementation manner, the determining module 62 determines a second X index value of the next thread bundle in the X dimension according to the first size value and the first X index value, and is specifically configured to:

[0175] Determine a preselected value of the second X index value of the next thread bundle in the X dimension according to the first size value and the first X index value;

[0176] Determine the second X index value according to the preselected value of the second X index value and the first size value.

[0177] In a possible implementation manner, the determining module 62 determines a preselected value of the second X index value of the next thread bundle in the X dimension according to the first size value and the first X index value, and is specifically configured to:

[0178] Judge whether the first size value is less than 32;

[0179] If the first size value is less than 32, determine that the preselected value of the second X index value is the sum of the first X index value and the first remainder, where the first remainder is the remainder obtained by dividing 32 by the first size value;

[0180] If the first size value is equal to or greater than 32, determine that the preselected value of the second X index value is the sum of the first X index value and 32.

[0181] In a possible implementation, the determining module 62 determines the second X index value according to the preselected value of the second X index value and the first size value, specifically for:

[0182] If the preselected value of the second X index value is less than the first size value, the second X index value is the preselected value of the second X index value;

[0183] If the preselected value of the second X index value is equal to or greater than the first size value, the second X index value is the difference between the preselected value of the second X index value and the first size value.

[0184] In a possible implementation, the determining module 62 determines the second Y index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y index value, specifically for:

[0185] Determine the preselected value of the second Y index value according to the product of the first Y index value, the first size value, and the second size value;

[0186] Determine the second Y index value according to the preselected value of the second Y index value and the second size value.

[0187] In a possible implementation, the determining module 62 determines the preselected value of the second Y index value according to the first Y index value, the product of the first size value and the second size value, specifically for:

[0188] If the product of the first size value and the second size value is greater than 32, determine that the preselected value of the second Y index value is the sum of the first Y index value and the first set value; where the first set value is 0 when the first size value is greater than 32, and the quotient obtained by dividing 32 by the first size value when the first size value is less than or equal to 32;

[0189] If the product of the first size value and the second size value is less than or equal to 32, determine that the preselected value of the second Y index value is the sum of the first Y index value and the third set value; where the third set value is the quotient obtained by dividing the difference between the first set value and the second set value by the product of the first size value and the second size value, the second set value is 0 when the product of the first size value and the second size value is greater than 32, and the quotient obtained by dividing 32 by the difference when the product of the first size value and the second size value is less than or equal to 32, and the difference is the difference between the product of the first size value and the second size value and 32.

[0190] In a possible implementation, the determining module 62 determines the second Y index value according to a preselected value of the second Y index value and a second size value, specifically for:

[0191] If the preselected value of the second Y index value is greater than the second size value, determine the second Y index value as the preselected value of the second Y index value minus the second size value;

[0192] If the preselected value of the second Y index value is less than or equal to the second size value, determine the second Y index value as the preselected value of the second Y index value.

[0193] In a possible implementation, the determining module 62 determines a second Z index value of the next warp in the Z dimension according to the first size value, the second size value, and the first Z index value, specifically for:

[0194] If the product of the first size value and the second size value is greater than 32, determine the second Z index value as the first Z index value;

[0195] If the product of the first size value and the second size value is less than or equal to 32, determine the second Z index value as the sum of the first Z index value and a second set value.

[0196] The apparatus for determining a warp index provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, and will not be elaborated here.

[0197] Figure 7 For a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present application, please refer to Figure 7 , the electronic device may include a processor 71 and a memory 72. Exemplarily, the processor 71 and the memory 72 are connected to each other through a bus 73.

[0198] The memory 72 stores computer-executable instructions;

[0199] The processor 71 executes the computer-executable instructions stored in the memory 72, so that the processor 71 executes the method shown in the above method embodiments.

[0200] Optionally, the above-mentioned various components of the electronic device 70 may be connected through a system bus.

[0201] Optionally, the electronic device 70 may further include a communication interface for interacting with other devices.

[0202] It should be understood that the processor 71 can be a CPU, or other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in conjunction with the present application can be directly embodied as being executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.

[0203] The system bus can be a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The memory may include a random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory.

[0204] The electronic device provided in the embodiments of the present application can be used to execute the method provided in any of the above method embodiments, and its implementation principle and technical effects are similar, which will not be elaborated here.

[0205] Correspondingly, the embodiments of the present application provide a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method of the above method embodiments.

[0206] Correspondingly, the embodiments of the present application can also provide a computer program product, including a computer program, which when executed by a processor, can implement the method shown in the above method embodiments.

[0207] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.

[0208] The present invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each flow and / or block in the flowchart illustrations and / or block diagrams, and combinations of flows and / or blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device create means for implementing the functions specified in the flowchart Figure 1 one flow or more flows and / or blocks Figure 1 one block or more blocks.

[0209] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means that implement the functions specified in the flowchart Figure 1 one flow or more flows and / or blocks Figure 1 one block or more blocks.

[0210] These computer program instructions may also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, thereby providing steps for implementing the functions specified in the flowchart Figure 1 one flow or more flows and / or blocks Figure 1 one block or more blocks.

[0211] In a typical configuration, a computing device includes one or more processors, input / output interfaces, network interfaces, and memory.

[0212] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.

[0213] A computer-readable medium includes both permanent and non-permanent, removable and non-removable media and can implement information storage by any method or technology. 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), SRAM, dynamic random access memory (DRAM), other types of RAM, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory media that can be used to store information that can be accessed by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0214] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0215] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A method for determining a warp index, characterized in that Including: Obtaining the thread size information of the thread block to be split and the index information of the current warp in the thread block to be split; Determining the index information of the next warp according to the thread size information and the index information of the current warp.

2. The method according to claim 1, wherein The thread size information includes: a first size value of the thread block to be split in the X dimension and a second size value of the thread block to be split in the Y dimension; the index information of the current warp includes: a first X index value of the current warp in the X dimension, a first Y index value of the current warp in the Y dimension, and a first Z index value of the current warp in the Z dimension; Correspondingly, the determining the index information of the next warp according to the thread size information and the index information of the current warp includes: Determining a second X index value of the next warp in the X dimension according to the first size value and the first X index value; Determining a second Y index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y index value; Determining a second Z index value of the next warp in the Z dimension according to the first size value, the second size value, and the first Z index value; Wherein, the index information of the next warp includes the second X index value, the second Y index value, and the second Z index.

3. The method according to claim 2, wherein The determining a second X index value of the next warp in the X dimension according to the first size value and the first X index value includes: Determining a preselected value of the second X index value of the next warp in the X dimension according to the first size value and the first X index value; Determining the second X index value according to the preselected value of the second X index value and the first size value.

4. The method according to claim 3, wherein The determining a preselected value of the second X index value of the next warp in the X dimension according to the first size value and the first X index value includes: Judging whether the first size value is less than 32; If the first size value is less than 32, determining the preselected value of the second X index value as the sum of the first X index value and a first remainder, where the first remainder is the remainder obtained by dividing 32 by the first size value; If the first size value is equal to or greater than 32, determining the preselected value of the second X index value as the sum of the first X index value and 32.

5. The method according to claim 3 or 4, characterized in that The determining the second X index value according to the preselected value of the second X index value and the first size value includes: If the preselected value of the second X index value is less than the first size value, the second X index value is the preselected value of the second X index value; If the preselected value of the second X index value is equal to or greater than the first size value, the second X index value is the difference between the preselected value of the second X index value and the first size value.

6. The method according to any one of claims 2 to 4, characterized in that, The determining a second Y index value of the next warp in the Y dimension according to the first size value, the second size value, and the first Y index value includes: Determining a preselected value of the second Y index value according to the first Y index value and the product of the first size value and the second size value; Determine the second Y index value according to a preselected value of the second Y index value and the second size value.

7. The method according to claim 6, wherein The determining the preselected value of the second Y index value according to the first Y index value, the product of the first size value and the second size value includes: If the product of the first size value and the second size value is greater than 32, determine the preselected value of the second Y index value as the sum of the first Y index value and a first set value; wherein, the first set value is 0 when the first size value is greater than 32, and is the quotient obtained by dividing 32 by the first size value when the first size value is less than or equal to 32. If the product of the first size value and the second size value is less than or equal to 32, determine the preselected value of the second Y index value as the sum of the first Y index value and a third set value; wherein, the third set value is the quotient obtained by dividing the difference between the first set value and a second set value by the product of the first size value and the second size value, the second set value is 0 when the product of the first size value and the second size value is greater than 32, and is the quotient obtained by dividing 32 by the difference value when the product of the first size value and the second size value is less than or equal to 32, and the difference value is the difference between the product of the first size value and the second size value and 32.

8. The method according to claim 6, wherein The determining the second Y index value according to the preselected value of the second Y index value and the second size value includes: If the preselected value of the second Y index value is greater than the second size value, determine the second Y index value as the preselected value of the second Y index value minus the second size value. If the preselected value of the second Y index value is less than or equal to the second size value, determine the second Y index value as the preselected value of the second Y index value.

9. The method according to any one of claims 2 to 4, characterized in that The determining the second Z index value of the next warp in the Z dimension according to the first size value, the second size value and the first Z index value includes: If the product of the first size value and the second size value is greater than 32, determine the second Z index value as the first Z index value. If the product of the first size value and the second size value is less than or equal to 32, determine the second Z index value as the sum of the first Z index value and the second set value.

10. A device for determining a warp index, characterized in that Includes: An acquisition module, configured to acquire thread size information of a thread block to be split and index information of the current warp in the thread block to be split. A determination module, configured to determine index information of the next warp according to the thread size information and the index information of the current warp.

11. An electronic device, characterized in that, Includes: A memory and a processor; The memory stores computer execution instructions. The processor executes the computer execution instructions stored in the memory, so that the processor executes the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Data processing device and method, processor and chip

    CN120950128A

  • Obtaining method of target thread index, electronic equipment and medium

    CN120994255A

  • Methods, electronic devices, and media for obtaining the target thread index

    CN120994255B