Methods, computing devices, media, and program products for a segmentation task
By dividing the task grid based on the size of the thread cluster, the number of thread clusters and their starting coordinates are determined, which solves the problem of frequent communication in traditional methods and improves the efficiency of task splitting.
Patent Information
- Application Number
- CN202511760087.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-11-26
AI Technical Summary
Traditional task splitting methods involve frequent communication and are inefficient.
Based on the size of the thread clusters, the task grid is divided to determine the number of thread clusters allocated to each computing task building module and to calculate their starting coordinates, so as to efficiently allocate thread clusters to computing cores.
This reduces the communication frequency between the instruction processing module and the computing task building module, thus improving the efficiency of task segmentation.
Smart Images

Figure CN121187809B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention generally relate to the field of artificial intelligence technology, and more specifically to a method for task segmentation, a computing device, a computer-readable storage medium, and a computer program product. Background Technology
[0002] Traditional methods for task partitioning divide the job grid into multiple run tasks, which are then assigned to corresponding computational cores, or computational units within those cores. Specifically, the upper-layer software specifies the size of each run task along the X, Y, and Z dimensions of the job grid, with the granularity being thread group clusters (tgclusters). The maximum size of a run task is, for example, eight thread groups. Further, the command processor (CP) partitions each run task sequentially along the X, Y, and Z dimensions of the job grid and distributes the instructions for each run task to the respective compute task constructors (CTCs) in a round-robin fashion, allowing them to further allocate the tasks to computational units. In this traditional method, the upper-layer software needs to be aware of the run tasks and specify their size, and the command processor needs to distribute instructions to the compute task constructors multiple times, resulting in frequent communication and low efficiency.
[0003] In summary, the shortcomings of existing methods for task splitting are: frequent communication and low efficiency. Summary of the Invention
[0004] This invention provides a method, computing device, computer-readable storage medium, and computer program product for task splitting, which can significantly reduce the number of communications and improve the efficiency of task splitting.
[0005] According to a first aspect of the present invention, a method for task partitioning is provided, the method comprising: dividing a task grid based on the size of a thread cluster to obtain a total number of thread clusters, each thread cluster comprising multiple consecutive thread groups; determining the number of thread clusters allocated to each of a plurality of computing task building modules; calculating the starting coordinates of the thread clusters allocated to the current computing task building module; and calculating, based on the starting coordinates, the original coordinates of the multiple thread groups in the thread clusters allocated to the current computing task building module in the task grid, for allocating the thread groups to computing cores based on the original coordinates.
[0006] According to a second aspect of the present invention, a computing device is also provided. The computing device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the computing device to perform the method of the first aspect of the present invention.
[0007] According to a third aspect of the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium stores a computer program that, when executed by a machine, performs the method of the first aspect of the present invention.
[0008] According to a fourth aspect of the present invention, a computer program product is also provided, comprising a computer program that, when executed by a machine, performs the method of the first aspect of the present invention.
[0009] In some embodiments, determining the number of thread clusters allocated to each of the plurality of computing task building modules includes: dividing the total number of thread clusters by the number of computing task building modules to obtain a multiple and a remainder; and determining the number of thread clusters allocated to each computing task building module based on the multiple and the remainder.
[0010] In some embodiments, determining the number of thread clusters allocated to each computing task building module based on the multiple part and the remainder part includes: in response to the total number of thread clusters not being divisible by the number of computing task building modules, confirming whether the sequence number of the current computing task building module is less than the remainder part; in response to confirming that the sequence number of the current computing task building module is less than the remainder part, adding "1" to the multiple part to obtain the number of thread clusters allocated to the current computing task building module.
[0011] In some embodiments, calculating the starting coordinates of the thread cluster allocated by the current computing task building module includes: calculating the linear index of the starting thread cluster in the thread cluster allocated by the current computing task building module; and converting the calculated linear index of the starting thread cluster into three-dimensional coordinates at the thread cluster granularity.
[0012] In some embodiments, calculating the original coordinates of multiple thread groups in the thread cluster allocated by the current computing task building module in the task grid based on the starting coordinates includes: calculating the original coordinates of the starting thread group in the thread cluster allocated by the current computing task building module in the task grid based on the three-dimensional coordinates of the thread cluster granularity and the size of the thread cluster.
[0013] In some embodiments, the linear index of the starting thread cluster indicates the position of the starting thread cluster in the linear arrangement when all thread clusters allocated by the multiple computing task building modules are linearly arranged.
[0014] In some embodiments, the multiple thread clusters allocated to each computing task building module are contiguous.
[0015] This invention divides the task grid based on the size of thread clusters to obtain the total number of thread clusters, with each thread cluster comprising multiple consecutive thread groups. It determines the number of thread clusters allocated to each of the multiple computing task building modules; calculates the starting coordinates of the thread clusters allocated by the current computing task building module; and, based on the starting coordinates, calculates the original coordinates of the multiple thread groups within the thread clusters allocated by the current computing task building module in the task grid, for use in allocating thread groups to computing cores based on these original coordinates. By dividing the task grid, calculating the starting coordinates of the thread clusters allocated by the current computing task building module, and then calculating their original coordinates in the task grid, the position of the thread clusters allocated by multiple computing task building modules in the task grid is efficiently calculated, reducing the communication frequency between the instruction processing module and the computing task building module, and improving efficiency.
[0016] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0017] The above and other features, advantages, and aspects of the various embodiments of the present invention will become more apparent from the accompanying drawings and the following detailed description. In the drawings, the same or similar reference numerals denote the same or similar elements.
[0018] Figure 1 The diagram illustrates a computing device for implementing a method for task segmentation according to an embodiment of the present invention.
[0019] Figure 2 A flowchart of a method for task splitting according to some embodiments of the present invention is shown.
[0020] Figure 3 A flowchart of a method for determining the number of thread clusters according to some embodiments of the present invention is shown.
[0021] Figure 4 A flowchart is shown illustrating a method for determining the number of thread clusters in response to a situation where the total number of thread clusters cannot be divided by the number of task building blocks, according to some embodiments of the present invention.
[0022] Figure 5 A flowchart illustrating a method for calculating starting coordinates according to some embodiments of the present invention is shown.
[0023] Figure 6A , Figure 6B Dot-like and block-like diagrams are shown of the thread clusters allocated to each computing task building module according to some embodiments of the present invention.
[0024] Figure 7 A schematic diagram of the architecture of a task segmentation method according to some embodiments of the present invention is shown.
[0025] In the various figures, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0026] Preferred embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
[0027] The term "comprising" and its variations as used herein signify open inclusion, i.e., "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "one example embodiment" and "one embodiment" mean "at least one example embodiment". The term "another embodiment" means "at least one additional embodiment". The terms "first", "second", etc., may refer to different or the same objects.
[0028] As described above, the shortcomings of traditional methods for instructions used in synchronous matrix multiplication are that the upper-level software needs to be aware of the computation task and specify the size of the computation task, and the CP needs to issue instructions multiple times, resulting in frequent communication and low efficiency.
[0029] To at least partially address one or more of the aforementioned problems and other potential issues, exemplary embodiments of the present invention propose at least one method for task partitioning. In this method, a task grid is divided based on the size of the thread clusters to obtain the total number of thread clusters, each thread cluster comprising multiple consecutive thread groups; the number of thread clusters allocated to each of the multiple computing task building modules is determined; the starting coordinates of the thread clusters allocated to the current computing task building module are calculated; based on the starting coordinates, the original coordinates of the multiple thread groups within the thread clusters allocated to the current computing task building module are calculated in the task grid, for use in allocating the thread groups to computing cores based on the original coordinates. By partitioning the task grid, calculating the starting coordinates of the thread clusters allocated to the current computing task building module, and then calculating their original coordinates in the task grid, the positions of the thread clusters allocated to multiple computing task building modules in the task grid are efficiently calculated, reducing the communication frequency between the instruction processing module and the computing task building modules, and improving efficiency.
[0030] Figure 1 A schematic diagram of a computing device 100 implementing a method for task segmentation according to an embodiment of the present invention is shown. Figure 1 As shown, the computing device 100 may have one or more processing units and a memory communicatively connected to the one or more processing units; wherein the memory stores instructions executable by the at least one processor. The processing units include dedicated processing units such as Graphics Processing Units (GPUs), Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), and General-purpose computing on graphics processing units (GPGPUs), as well as general-purpose processing units such as CPUs. The computing device 100 also includes at least: a task mesh partitioning unit 102, a thread cluster number determination unit 104, a starting coordinate calculation unit 106, and an original coordinate calculation unit 108.
[0031] Regarding the task grid partitioning unit 102, it is used to partition the task grid based on the size of the thread clusters in order to obtain the total number of thread clusters, each thread cluster comprising multiple consecutive thread groups.
[0032] Regarding the thread cluster number determination unit 104, it is used to determine the number of thread clusters allocated to each computing task building module in the multiple computing task building modules.
[0033] The starting coordinate calculation unit 106 is used to calculate the starting coordinates of the thread cluster allocated by the current computing task building module.
[0034] Regarding the original coordinate calculation unit 108, it is used to calculate the original coordinates of multiple thread groups in the thread group cluster allocated by the current computing task construction module in the task grid based on the starting coordinates, so as to allocate the thread groups to the computing core based on the original coordinates.
[0035] The following will combine Figure 2 , Figure 3 , Figure 5 and Figure 7 A method 200 for task segmentation according to an embodiment of the present invention is described. It should be understood that method 200 can, for example, be used in... Figure 1 The described computing device 100 performs the operation. Method 200 may also include additional actions not shown and / or the actions shown may be omitted; the scope of the invention is not limited in this respect.
[0036] At step 202, the computing device 100 divides the task grid based on the size of the thread clusters to obtain the total number of thread clusters, each thread cluster comprising multiple consecutive thread groups.
[0037] A thread group cluster (tg cluster) is, for example, a collection of thread groups, comprising multiple consecutive thread groups. Each thread group includes multiple consecutive threads. In some embodiments, the thread group cluster is allocated by the compute task constructor (CTC) to a compute core, for example, to a compute unit within the compute core, for executing specific computations of the thread group cluster within the compute unit. The size of the thread group cluster indicates, for example, the size of the computational task that a single thread group cluster can execute in the X, Y, and Z dimensions of the task grid.
[0038] Regarding the job grid, it is, for example, a three-dimensional grid indicating tasks, including X, Y, and Z dimensions. In some embodiments, thread groups can be used as the granularity of the job grid; that is, a single grid indicates, for example, the size of the computational tasks that a single thread group can execute in the X, Y, and Z dimensions of the job grid. In some embodiments, thread clusters can be used as the granularity of the job grid; that is, a single grid indicates, for example, the size of the computational tasks that a single thread cluster can execute in the X, Y, and Z dimensions of the job grid. Regarding the partitioning of the job grid, for example, the job grid is divided into multiple corresponding thread clusters so that the thread clusters can be assigned to corresponding computational task building blocks, and then to computational cores.
[0039] A method for obtaining the total number of thread clusters includes, for example, the computing device 100 dividing the dimensions of the task grid in each dimension by the dimensions of the thread clusters in each dimension, and multiplying the division results in each dimension to obtain the total number of thread clusters. For example, the dimensions of the task grid are {gx, gy, gz} (where gx represents the dimension of the task grid in the X dimension, gy represents the dimension of the task grid in the Y dimension, and gz represents the dimension of the task grid in the Z dimension); and the dimensions of the thread clusters are {cx, cy, cz} (where cx represents the dimension of the thread cluster in the X dimension, cy represents the dimension of the thread cluster in the Y dimension, and cz represents the dimension of the thread cluster in the Z dimension). Then, the corresponding divisions of the dimensions in each dimension can be calculated using nx = gx / cx; ny = gy / cy; nz = gz / cz respectively; and the total number of thread clusters can be obtained by multiplying total_clusters = nx. ny nz multiplies the division results nx, ny, and nz of each dimension to obtain the total number of thread clusters total_clusters.
[0040] At step 204, computing device 100 determines the number of thread clusters allocated to each of the plurality of computing task building modules.
[0041] Regarding the computation task building module, it is used, for example, to allocate thread clusters corresponding to computation tasks to computation cores. In some embodiments, thread clusters are allocated to computation units within the computation core. In some embodiments, the computation task building module is, for example, Figure 7 The computation task building module 730 shown includes, for example, a computation unit. Figure 7 The computing unit 740 is shown. For example... Figure 7 In the illustrated task-splitting architecture 700, the command processor (CP) 710 sends instructions to the computing task building module 730 via the low-speed bus 720. Further, the computing task building module 730 allocates the thread clusters corresponding to the computing tasks to the computing units 740. In some embodiments, in the computing device 100, at least one computing task building module has its own serial number, for example: computing task building module 0, computing task building module 1, computing task building module 2, etc.
[0042] Regarding the thread clusters allocated to each computing task building module, in some embodiments, the multiple thread clusters allocated to each computing task building module are contiguous. Unlike the typical round-robin approach described earlier, when each computing task building module is allocated multiple contiguous thread clusters, each module requires less information to characterize its corresponding thread cluster, such as the starting coordinates and the number of thread clusters allocated to it. Furthermore, the thread clusters for each computing task building module can be calculated simultaneously, thus improving the efficiency of task allocation and reducing communication between the instruction processing module and the computing task building modules.
[0043] In some embodiments, the method for determining the number of thread clusters allocated to each computing task building module includes, for example, distributing thread clusters evenly among multiple computing task building modules. In some embodiments, based on the determination that the total number of thread clusters is not divisible by the number of computing task building modules, the computing task building modules with higher sequence numbers are further assigned to evenly distribute the thread clusters that are not divisible by the number of computing task building modules.
[0044] In some embodiments, a method for determining the number of thread clusters allocated to each computing task building module includes, for example, the computing device 100 dividing the total number of thread clusters by the number of computing task building modules to obtain a multiple and a remainder; and determining the number of thread clusters allocated to each computing task building module based on the multiple and the remainder. The following will be combined with... Figure 3 The method for determining the number of thread clusters allocated to each computing task building module is detailed here and will not be repeated.
[0045] In step 206, the computing device 100 calculates the starting coordinates of the thread cluster allocated by the current computing task building module.
[0046] The starting coordinates of a thread cluster indicate the position of the initial thread cluster within the thread clusters allocated by the current computation task building module. Specifically, the starting coordinates are, for example, the three-dimensional coordinates of the thread clusters allocated by the current computation task building module when dividing the task grid at the thread cluster granularity.
[0047] In some embodiments, the method for calculating the starting coordinates of the thread cluster allocated by the current computing task building module includes, for example, the computing device 100 calculating the linear index of the starting thread cluster in the thread cluster allocated by the current computing task building module; and converting the calculated linear index of the starting thread cluster into three-dimensional coordinates at the thread cluster granularity. The method for calculating the starting coordinates of the thread cluster allocated by the current computing task building module will be discussed below in conjunction with... Figure 5 The explanation will not be repeated here.
[0048] One method for converting the linear index of the initial thread cluster into three-dimensional coordinates at the thread cluster granularity is to spatially distribute the linear arrangement of all thread clusters allocated to multiple computational task building blocks according to the size of the task grid and the predetermined priority of the arrangement in each dimension. The method for converting linear indices into three-dimensional coordinates will be discussed below. Figure 6A and Figure 6B The details will not be elaborated here.
[0049] At step 208, the computing device 100 calculates the original coordinates of multiple thread groups in the thread group cluster allocated by the current computing task building module in the task grid based on the starting coordinates, so as to allocate the thread groups to the computing cores based on the original coordinates.
[0050] Regarding the computing core, it is, for example, a streaming processing core (SPC). In some embodiments, the computing core includes, for example, computing units for performing computing tasks.
[0051] Regarding the raw coordinates of multiple thread groups in the task grid, this indicates, for example, the three-dimensional coordinates of each thread group in the task grid. In some embodiments, a thread group cluster includes multiple thread groups, and the three-dimensional coordinates of the thread groups in the task grid are distinct from the three-dimensional coordinates at the thread group cluster granularity.
[0052] Regarding the method for calculating the original coordinates based on the starting coordinates, in some embodiments, it includes: multiplying the dimensions of the starting coordinates with the corresponding dimensions of the thread cluster to obtain the corresponding dimensions of the original coordinates.
[0053] In some embodiments, when the instruction processing module issues instructions for each computation task to the respective computation task building modules, it may use, for example, the commands shown in Table 1. Compared to typical instructions for executing tasks, this command also requires the addition of a task size parameter so that the computation task building modules know how to divide the task into thread clusters.
[0054] Table 1
[0055]
[0056] In the above scheme, the present invention divides the task grid based on the size of the thread clusters to obtain the total number of thread clusters, with each thread cluster including multiple consecutive thread groups; determines the number of thread clusters allocated to each of the multiple computing task building modules; calculates the starting coordinates of the thread clusters allocated by the current computing task building module; and, based on the starting coordinates, calculates the original coordinates of the multiple thread groups in the thread clusters allocated by the current computing task building module in the task grid, so as to allocate the thread groups to the computing cores based on the original coordinates. By dividing the task grid, calculating the starting coordinates of the thread clusters allocated by the current computing task building module, and then calculating their original coordinates in the task grid, the position of the thread clusters allocated by the multiple computing task building modules in the task grid can be calculated efficiently, reducing the communication frequency between the instruction processing module and the computing task building module, and improving efficiency.
[0057] The following combination Figure 3 This describes method 300 for determining the number of thread clusters allocated to each computation task building block. It should be understood that method 300 can, for example, be used in... Figure 1 The described computing device 100 performs the procedure. Method 300 may also include additional actions not shown and / or the actions shown may be omitted; the scope of the invention is not limited in this respect.
[0058] like Figure 3 As shown, in step 302, the computing device 100 divides the total number of thread clusters by the number of computing task building modules to obtain a multiple and a remainder. It can be understood that when the remainder is "0", it indicates that the total number of thread clusters is divisible by the number of computing task building modules, and the multiple computing task building modules are evenly distributed among the thread clusters.
[0059] At step 304, the computing device 100 determines the number of thread clusters allocated to each computing task building module based on the multiple portion and the remainder portion.
[0060] In some embodiments, the number of thread clusters allocated to each computing task building module is greater than or equal to a multiple of the specified value. In some embodiments, the computing task building modules with earlier sequence numbers equally distribute the remaining thread clusters.
[0061] By employing the above methods, this invention can effectively determine the number of thread clusters allocated to each computing task building module. The following is in conjunction with... Figure 4 This describes method 400 for determining the number of thread clusters when the total number of thread clusters cannot be divided evenly by the number of task building blocks. It should be understood that method 400, for example, can... Figure 1The described computing device 100 performs the operation. Method 400 may also include additional actions not shown and / or the actions shown may be omitted; the scope of the invention is not limited in this respect.
[0062] At step 402, in response to the fact that the total number of thread clusters cannot be divided by the number of computing task building modules, the computing device 100 confirms whether the sequence number of the current computing task building module is less than the remainder.
[0063] Methods for determining whether the total number of thread clusters is divisible by the number of task building modules include, for example: judging the remainder obtained by dividing the total number of thread clusters by the number of task building modules; if the remainder is "0", it is determined to be divisible; if the remainder is not "0", it is determined to be divisible.
[0064] At step 404, if the computing device 100 confirms that the sequence number of the current computing task building module is less than the remainder, it adds "1" to the multiple part in order to obtain the number of thread clusters allocated to the current computing task building module.
[0065] In some embodiments, the multiple obtained by dividing the total number of thread clusters by the number of computation task building modules indicates the minimum number of thread clusters allocated to each computation task building module. For the remainder, for example, computation task building modules with higher sequence numbers are further divided equally among thread clusters that are not divisible by the number of computation task building modules; for example, computation task building modules with sequence numbers less than the remainder are allocated an additional "1" thread cluster. That is, the number of thread clusters allocated to computation task building modules with sequence numbers less than the remainder is equal to the multiple plus "1".
[0066] At step 406, if the computing device 100 confirms that the sequence number of the current computing task building module is greater than or equal to the remainder, the value of the multiple is used as the number of thread clusters allocated to the current computing task building module.
[0067] In some embodiments, the sequence number of the current computing task building module being greater than or equal to the remainder indicates that it belongs to a computing task building module with a later sequence number, and there is no need to allocate thread clusters corresponding to the remainder. In other words, the number of thread clusters allocated to computing task building modules with sequence numbers greater than or equal to the remainder is equal to the value of the multiple.
[0068] For example, when the total number of thread clusters is "20" and the number of computation task building modules is "3" (including computation task building module 0, computation task building module 1, and computation task building module 2), the multiple is "6" and the remainder is "2". Therefore, for the multiple, computation task building modules 0, 1, and 2 are each allocated 6 thread clusters. Furthermore, for the remainder, the earlier-numbered computation task building modules, namely computation task building modules 0 and 1, are each allocated 1 more thread cluster. In total, computation task building module 0 is allocated 7 thread clusters, computation task building module 1 is allocated 7 thread clusters, and computation task building module 2 is allocated 6 thread clusters.
[0069] In some embodiments, the method for determining the number of thread clusters allocated to each computing task building module can be implemented by the code "ctc_task[i] = i < remainder ? base + 1 : base;". Here, ctc_task[i] represents the computing task building module with index i, base is the multiple, and remainder is the remainder.
[0070] In the above scheme, the present invention can calculate the thread clusters corresponding to each computing task building module for multiple computing task building modules at one time. Therefore, it can improve the efficiency of task splitting and reduce the communication between the instruction processing module and the computing task building module.
[0071] The following will combine Figure 5 This describes in detail a method 500 for calculating the starting coordinates of the thread cluster allocated to the current computing task building module. It should be understood that method 500, for example, can be used... Figure 1 The described computing device 100 performs the operation. Method 500 may also include additional actions not shown and / or the actions shown may be omitted; the scope of the invention is not limited in this respect.
[0072] At step 502, computing device 100 calculates the linear index of the starting thread cluster in the thread cluster allocated by the current computing task building module.
[0073] The initial thread cluster is, for example, the first thread cluster among at least one thread cluster assigned by the current computation task building block. The initial thread cluster is, for example, located near the origin of the task grid (a position where the X, Y, and Z dimensions are 0).
[0074] The linear index of the starting thread cluster is, for example, the position of the starting thread cluster in the linear arrangement of all thread clusters allocated by multiple computing task building modules. In some embodiments, the linear arrangement is arranged in ascending order of three-dimensional coordinates; in some embodiments, the priority of the three dimensions is decreasing for X, Y, and Z.
[0075] At step 504, the computing device 100 converts the calculated linear index of the initial thread cluster into three-dimensional coordinates at the thread cluster granularity.
[0076] Regarding the three-dimensional coordinates at the thread cluster granularity, for example, it indicates the three-dimensional coordinates of the thread clusters assigned by the current computation task building module when the task grid is divided at the thread cluster granularity.
[0077] By employing the above methods, the present invention can conveniently calculate the starting coordinates of the thread clusters allocated by the current computing task building module.
[0078] The following combination Figure 6A and Figure 6B This further explains the method for allocating thread clusters. Figure 6A , Figure 6B Dot-like and block-like diagrams are shown respectively of the thread clusters allocated to each computing task building module according to some embodiments of the present invention. Figure 6A The points shown are Figure 6B The vertex of the block corresponding to the thread cluster that is close to the origin of the task grid.
[0079] Assuming the task grid size is {gx, gy, gz} and the thread cluster size is {cx, cy, cz}, then the number of thread clusters is: nx = gx / cx, ny = gy / cy, nz = gz / cz.
[0080] The total number of thread clusters can be calculated as: total_clusters = nx ny nz .
[0081] Assuming the number of computation task building modules is N, the task size allocated to each computation task building module and the starting coordinates of the allocated thread cluster can be calculated using the illustrative code shown in Table 2 below.
[0082] Table 2
[0083] For example, when splitting a task grid of size {12, 6, 4} into a thread cluster of size {2, 2, 2}, the result of the splitting, according to the above code, is as follows: Figure 6A and Figure 6B As shown. The values of each variable are as follows.
[0084] Here, 'task_id' indicates the sequence number of the segmented task, which also corresponds to the sequence number of the computing task building module; 'num_clusters' indicates the number of thread clusters allocated by the current computing task building module; 'start_offset' indicates the original coordinates of multiple thread groups in the task grid within the thread clusters allocated by the current computing task building module; and 'start_cluster_idx' indicates the linear index of the starting thread cluster within the thread clusters allocated by the current computing task building module.
[0085] {'task_id': 0, 'num_clusters': 9, 'start_offset': (0, 0, 0), 'start_cluster_idx': 0}
[0086] {'task_id': 1, 'num_clusters': 9, 'start_offset': (6, 2, 0), 'start_cluster_idx': 9}
[0087] {'task_id': 2, 'num_clusters': 9, 'start_offset': (0, 0, 2), 'start_cluster_idx': 18}
[0088] {'task_id': 3, 'num_clusters': 9, 'start_offset': (6, 2, 2), 'start_cluster_idx': 27}
[0089] refer to Figure 6A and Figure 6B ,exist Figure 6A In the diagram, computational task building blocks 0-3 correspond to red, green, blue, and yellow vertices or color blocks, respectively. With a task mesh of size {12, 6, 4} and thread clusters of size {2, 2, 2}, the four computational task building blocks are allocated a total of 36 thread clusters. For example... Figure 6A As shown, each computational task building block is allocated 9 thread clusters, meaning that the number of vertices for each color is "9". Figure 6B As shown, since each thread group cluster includes 2 2 There are 2 = 8 thread groups, and each thread group cluster consists of 8 sub-blocks, with each sub-block corresponding to a thread group. The thread group clusters are linearly ordered in the task grid in descending order of priority (X, Y, Z). For computation task building module 0, the original coordinates of its assigned thread group clusters in the task grid are (0, 0, 0), (2, 0, 0), (4, 0, 0), (6, 0, 0), (8, 0, 0), (10, 0, 0), (0, 2, 0), (2, 2, 0), (4, 2, 0); where the original coordinates (0, 0, 0) represent the starting thread group cluster of computation task building module 0, with a linear index of 0. For computation task building module 1, the original coordinates of its assigned thread clusters in the task grid are (6, 2, 0), (8, 2, 0), (10, 2, 0), (0, 4, 0), (2, 4, 0), (4, 4, 0), (6, 4, 0), (8, 4, 0), and (10, 4, 0). The original coordinate (6, 2, 0) represents the starting thread cluster of computation task building module 1, with a linear index of 9. This pattern continues.
[0090] In the above solution, the present invention eliminates the need for upper-layer software to be aware of task size. For a single task to be segmented, the method described above can be used to segment it all at once, reducing the number of operations performed by the instruction processing module. Simultaneously, the segmentation results can be sent to multiple computation task building modules at once, thus reducing communication between the instruction processing module and the computation task building modules, thereby improving the efficiency of task segmentation. The above solution is particularly effective in scenarios involving the scheduling of a large number of small kernels, offering significant efficiency improvements.
[0091] The various processes and procedures described above, such as methods 200, 300, 400, and 500, can be executed at a computing device. This computing device may include, for example, at least one processor (at least one graphics processor and at least one central processing unit); and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor. In some embodiments, methods 200, 300, 400, and 500 may be implemented as a computer software program or program product tangibly contained in a machine-readable medium. In some embodiments, part or all of the computer program may be loaded and / or installed on the computing device via read-only memory (ROM) and / or a communication unit. When the computer program is loaded into random-access memory (RAM) and executed by the GPU and CPU, one or more actions of methods 200, 300, 400, and 500 described above can be performed.
[0092] This invention can be a method, apparatus, system, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of the invention. The computer-readable storage medium may be a tangible device capable of holding and storing instructions used by an instruction execution device. The computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof.
[0093] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to various computing / processing devices, or downloaded via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network, to an external computer or external storage device. Various aspects of the invention are described herein 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 block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0094] These computer-readable program instructions can be provided to the central processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the central processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of a flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of a flowchart and / or block diagram.
[0095] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0096] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps loaded in this application can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this application can be achieved, and this is not limited herein.
[0097] The specific embodiments described above do not constitute a limitation on the scope of protection of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors.
Claims
1. A method for task segmentation, characterized in that, The method includes: The task grid is divided based on the size of the thread clusters in order to obtain the total number of thread clusters, each of which includes multiple consecutive thread groups. Determine the number of thread clusters allocated to each of the multiple computing task building modules, wherein the multiple thread clusters allocated to each computing task building module are consecutive; Calculate the starting coordinates of the thread cluster allocated by the current computing task building module; and Based on the starting coordinates, the original coordinates of multiple thread groups in the thread group cluster allocated by the current computing task building module in the task grid are calculated, so as to allocate the thread groups to the computing cores based on the original coordinates.
2. The method according to claim 1, characterized in that, Determining the number of thread clusters allocated to each of the multiple compute task building modules includes: Divide the total number of thread clusters by the number of computation task building blocks to obtain the multiple and remainder portions; Based on the multiple and remainder parts, determine the number of thread clusters allocated to each computing task building module.
3. The method according to claim 2, characterized in that, Based on the multiple and remainder portions, the number of thread clusters allocated to each computation task building module is determined as follows: In response to the total number of thread clusters not being divisible by the number of computation task building modules, check whether the sequence number of the current computation task building module is less than the remainder. In response to the confirmation that the sequence number of the current computing task building module is less than the remainder, add "1" to the multiple part in order to obtain the number of thread clusters allocated to the current computing task building module.
4. The method according to claim 1, characterized in that, The starting coordinates for calculating the thread cluster allocated by the current computation task building module include: Calculate the linear index of the initial thread cluster in the thread cluster allocated by the current computation task building module; and The calculated linear index of the initial thread cluster is converted into three-dimensional coordinates at the thread cluster granularity, where, The initial thread cluster is the first thread cluster among at least one thread cluster allocated by the current computation task building module; The linear index of the starting thread cluster is the position of the starting thread cluster in the linear arrangement of all thread clusters allocated by multiple computing task building modules; and The starting coordinates of the thread cluster indicate the position of the starting thread cluster in the thread cluster allocated by the current computing task building module.
5. The method according to claim 4, characterized in that, Based on the starting coordinates, calculating the original coordinates of multiple thread groups in the task grid within the thread cluster allocated by the current computing task building module includes: Based on the 3D coordinates at the thread cluster level and the size of the thread cluster, calculate the original coordinates of the starting thread group in the task grid within the thread cluster allocated by the current computing task building module.
6. The method according to claim 4, characterized in that, The linear index of the starting thread cluster indicates the position of the starting thread cluster in the linear arrangement of all thread clusters allocated by multiple compute task building blocks.
7. A computing device, characterized in that, include: At least one processor; as well as A memory that is communicatively connected to the at least one processor; in The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a machine, performs the method according to any one of claims 1-6.
9. A computer program product, characterized in that, Includes a computer program, which, when executed by a machine, performs the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method for executing calculation, calculation equipment, calculation system and storage medium
CN113284038A
Task scheduling method and device, electronic equipment and storage medium
CN118963967A