Work group scheduling method and device, computer equipment, storage medium and computer program product

By introducing a work grid hierarchy into the GPU, adjacent work groups are split and assigned to the same execution unit, which solves the problem of poor data continuity in traditional technology and improves the cache matching effect and memory read and write efficiency.

CN118550705APending Publication Date: 2024-08-27GLENFLY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410759147.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

In traditional technology, the poor data continuity during execution of GPU workgroup tasks affects the cache matching effect and memory read and write efficiency.

Method used

By introducing the Work-Grid hierarchy, adjacent work groups are split and assigned to the same execution unit, optimizing data continuity and resource utilization, and improving cache matching effect and memory read and write efficiency.

Benefits of technology

It effectively improves the cache matching effect and memory reading and writing efficiency, makes full use of the coherence of adjacent data, and reduces the memory reading and writing bandwidth requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550705A
    Figure CN118550705A
Patent Text Reader

Abstract

The invention relates to a working group scheduling method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: receiving a work group task; reading work grid information corresponding to the work group task; determining a current work grid based on the work grid information and the work group task, wherein the current work grid comprises at least two adjacent work groups; performing working group splitting on the current working grid to obtain adjacent working groups; and distributing the working groups in the same current working grid to the same execution unit. By adopting the method, the matching effect of the cache and the read-write efficiency of the memory can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of task processing technology, and in particular to a workgroup scheduling method, apparatus, computer equipment, storage medium and computer program product. Background Art

[0002] GPU (Graphics Processing Unit) is a special chip for graphics and image processing on computers, workstations, game consoles, mobile devices, etc. As the underlying acceleration hardware, GPU is suitable for large-scale parallel computing. With the gradual improvement of computing power, GPU has been widely used in general computing tasks such as artificial intelligence, physical simulation, and scientific computing.

[0003] In order to facilitate the GPU to perform general parallel computing, an open computing language platform OpenCL (Open Computing Language) was introduced. This platform can write kernel functions, which is similar to the C language, and provides an API interface for controlling the platform. OpenCL is a cross-system heterogeneous platform that can support various operating systems such as Windows, Linux, Android, etc. The underlying chip can also be a CPU, GPU or other types of processors, and it has a wide range of applications. In addition, some graphics rendering platforms DirectX, OpenGL, OpenES and the latest Vulkan have added special GPU functions, generally called CS (Compute Shader), which is similar to OpenCL. Through CS or OpenCL, programmers can easily use GPU as a parallel processor, which has made GPU widely used in recent years.

[0004] In traditional technologies, general computing tasks in OpenCL, DirectX, and Vulkan, namely kernel tasks, need to be divided into multiple work groups, and a large number of computing shading threads (CS Waves) are constructed on the GPU for execution. Since the GPU has many computing units, for ease of management, the GPU is divided into PEs (Processing Elements), each of which contains a group of ALU computing units and runs specific CS threads.

[0005] However, sending these multiple work-groups to PE for calculation in sequence results in poor data continuity, which affects the cache matching effect and memory read and write efficiency. Summary of the invention

[0006] Based on this, it is necessary to provide a workgroup scheduling method, device, computer equipment, computer-readable storage medium and computer program product that can improve the matching effect of cache and memory reading and writing efficiency in response to the above technical problems.

[0007] In a first aspect, the present application provides a working group scheduling method, the method comprising:

[0008] Receive work group assignments;

[0009] Reading the work grid information corresponding to the work group task;

[0010] Determine a current work grid based on the work grid information and the work group tasks, wherein the current work grid includes at least two adjacent work groups;

[0011] Splitting the current working grid into working groups to obtain adjacent working groups;

[0012] The working groups located in the same current working grid are allocated to the same execution unit.

[0013] In one embodiment, the work grid information includes a target number of work groups determined based on the dimension to be set and the resources required by each work group; the target number of work groups is evenly distributed on each dimension to be set, and the dimension to be set is obtained based on the form of the work group.

[0014] In one embodiment, the target number of workgroups is obtained based on a target mathematical statistic of an initial number of workgroups determined by various resources and a target range of the number of workgroups; the resources required by each workgroup include at least one of a temporary register size used by each thread corresponding to the workgroup, a shared cache space size of resources for each thread corresponding to the workgroup, and a private cache space size for each thread corresponding to the workgroup; and the target range of the number of workgroups is obtained based on the maximum number of workgroups that an execution unit can accommodate.

[0015] In one embodiment, allocating the workgroups located in the same current workcell to the same execution unit includes:

[0016] Determine a current execution unit, and assign a work group corresponding to the current work cell to the current execution unit;

[0017] The next execution unit is determined as a new current execution unit, and the step of determining the current work grid based on the work grid information and the work group task is continued until the work group task is completed.

[0018] In one embodiment, determining the current work slot based on the work slot information and the work group tasks includes:

[0019] Read the work grid scheduling mode;

[0020] Obtaining the work grid splitting order corresponding to the work grid scheduling mode;

[0021] The current work grid is determined based on the work grid splitting order, the work grid information and the work group tasks.

[0022] In one embodiment, the step of splitting the current working grid into working groups to obtain adjacent working groups includes:

[0023] The current working grid is split into adjacent working groups in a sequential splitting manner.

[0024] In a second aspect, the present application further provides a working group scheduling device, the device comprising:

[0025] A receiving module, used for receiving work group tasks;

[0026] A work grid information reading module, used to read the work grid information corresponding to the work group task;

[0027] A work grid splitting module, used to determine a current work grid based on the work grid information and the work group tasks, wherein the current work grid includes at least two adjacent work groups;

[0028] A work group splitting module is used to split the current work grid into work groups to obtain adjacent work groups;

[0029] The allocation module is used to allocate the work groups located in the same current work grid to the same execution unit.

[0030] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in any one of the above-mentioned embodiments when executing the computer program.

[0031] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method in any one of the above-mentioned embodiments.

[0032] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the method in any one of the above-mentioned embodiments when executed by a processor.

[0033] The above-mentioned workgroup scheduling method, apparatus, computer equipment, storage medium and computer program product, after receiving the workgroup task, determine the current workcell based on the workcell information, and the workcell includes at least two adjacent workgroups. In this way, the adjacent workgroups obtained by splitting the workcell are placed in the same execution unit, thereby ensuring that the adjacent workgroups are executed in the same execution unit, fully considering the continuity of the data, effectively utilizing the coherence of adjacent data, and improving the matching effect of the cache and the memory reading and writing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 An application environment diagram of a work group scheduling method in an embodiment;

[0036] Figure 2a This is a schematic diagram of the work group scheduling of a one-dimensional buffer in traditional technology;

[0037] Figure 2b A schematic diagram of a work group scheduling of a one-dimensional buffer in an embodiment;

[0038] Figure 3a It is a schematic diagram of work group scheduling of a two-dimensional model in traditional technology;

[0039] Figure 3b A schematic diagram of work group scheduling of a two-dimensional model in one embodiment;

[0040] Figure 4 A schematic diagram of a flow chart of a working group scheduling method in one embodiment;

[0041] Figure 5 is a schematic diagram of an execution model of general computing in an embodiment;

[0042] Figure 6 is a flowchart of a working group scheduling method in another embodiment;

[0043] Figure 7 is a schematic diagram of a Morton curve in one embodiment;

[0044] Figure 8 A flowchart of the steps of splitting a work cell in one embodiment;

[0045] Figure 9aA schematic diagram of a split result obtained in a sequential scheduling mode in an embodiment;

[0046] Figure 9b A schematic diagram of the splitting results obtained by the Morton curve scheduling mode in an embodiment

[0047] Fig.10 A schematic diagram of a flow chart of work group splitting steps in an embodiment;

[0048] Fig.11 is a structural block diagram of a work group scheduling device in an embodiment;

[0049] Fig.12 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0051] The working group scheduling method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown in the figure, CPU is taken as the representative of the host, and GPU is the main body of OpenCL device. The OpenCL execution model includes Work-Grid, work-group, work-item, NDRange, work-itemfunctions, etc. GPU thread group constructor (CSTC) is responsible for accepting OpenCL Work-Grid, work-group, work-group, and splitting OpenCL work-group into waves (thread bundles, which pack a certain amount of work items into thread bundles) for task emission.

[0052] For convenience, combined Figure 2a and Figure 2b , Figure 3a and Figure 3b As shown, the conventional technology and the improvements of this application are described, such as Figure 2aIn the example, one-dimensional buffer access is taken as an example. Assume that the current GPU has two execution units PE (PE0 and PE1). Each execution unit PE can schedule three workgroups to execute simultaneously. The traditional method is to schedule in sequence. Workgroup grp0 is scheduled to execution unit PE0, workgroup grp1 is scheduled to execution unit PE1, workgroup grp2 is scheduled to execution unit PE0, and... As a result, workgroup grp0, workgroup grp2 and workgroup grp4 are scheduled to be executed on execution unit PE0, while workgroup grp1, workgroup grp3 and workgroup grp5 are scheduled to be executed on execution unit PE1. This results in three discontinuous buffer data being read and written by execution unit PE0 and execution unit PE1 respectively. If a high-speed cache is used to cache data, discontinuous data segments may be allocated to different cache lines, reducing cache utilization. For this reason, in this application, adjacent workgroups are merged into the same group, called a work-grid. For example Figure 2b In the example, workgroups grp0 to grp2 are merged into grid0, and workgroups grp3 to grp5 are merged into grid1, and they are dispatched to execution units PE0 and PE1 respectively for execution, which effectively ensures the continuity of data.

[0053] Another two-dimensional example, Figure 3a As shown in the figure, assume that the current computing task is divided into 16 working groups, namely working group grp0, working group grp1, ..., working group grp15, among which working group grp0 to working group grp3 will access the A0 part of a two-dimensional image Image, working group grp4 to working group grp7 access the A1 part, working group grp8 to working group grp11 access the A2 part, and working group grp12 to working group grp15 access the A3 part. Assuming that the current GPU has a total of 4 execution units PE, if the strategy of allocating execution units PE in sequence is followed, it will cause working group grp0, working group grp4, working group grp8, and working group grp12 to be allocated to execution unit PE0 for execution. As a result, execution unit PE0 needs to access the 4 parts of the entire image, A0, A1, A2, and A3; the same is true for execution units PE1, PE2, and PE3, resulting in a significant increase in data reading and writing, which puts a lot of pressure on the memory bandwidth and is not conducive to the reuse of cache data. In order to solve this problem, combined with Figure 3bAs shown, in this application, workgroups grp0 to grp3 are classified into a combination, called workgrid grid0, so the entire workgrid grid0 can be scheduled to be executed on execution unit PE0, so that the four workgroups can reuse the accessed data, thereby improving data utilization; similarly, workgroups grp4 to grp7 are classified into workgrid grid1, workgroups grp8 to grp11 are classified into workgrid grid2, and workgroups grp12 to grp15 are merged into workgrid grid3, which are respectively scheduled to be executed on execution unit PE1, execution unit PE2 and execution unit PE3, which can improve the overall data utilization and reduce the demand for memory read and write bandwidth.

[0054] Combination Figure 4 As shown, this embodiment uses the method applied to a terminal as an example. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. This embodiment is implemented through a software program, including the configuration of the work grid information and the work grid scheduling mode at the driver, and the scheduling of the work group at the GPU. The method includes:

[0055] S402: Receive work group tasks.

[0056] Combination Figure 5 As shown, Figure 5This is a schematic diagram of the execution model of general computing in this application, which is the workgroup task in this application. In this application, the general computing platform of GPU, including OpenCL and CS of other platforms, all use similar execution models, generally using a three-dimensional representation method to divide the parallel computing space, requiring three groups of arrays, each of which uses three 32-bit integer arrays to represent the computing space: the three-dimensional size of the global space (globalspace size): (GlobalDx, GlobalDy, GlobalDz); the offset of the global space (global offset): (GlobalFx, GlobalFy, GlobalFz); the three-dimensional size of the work-group, also known as the local size, uses a triplet: (GroupDx, GroupDy, GroupDz). The GPU hardware needs to calculate the number of work-groups GroupN (Number of work-groups) in three directions based on the global size of the computational space and the size of the work-group, so as to create work-groups in a loop. The formula used is: (GroupNx, GroupNy, GroupNz) = (Ceil(GlobalDx / GroupDx), Ceil(GblobalDy / GroupDy), Ceil(GlobalDz / GroupDz))(1)

[0057] Function Ceil represents rounding up the remainder. In versions before OpenCL 2.0, the global size must be able to divide the work-group size. However, after OpenCL 2.0, remainders are allowed, which makes programming more convenient, but the GPU needs to handle this non-divisible situation specially. Then it is necessary to round up the hardware constructor to increase the number of work-groups. The non-divisible remainder can also construct an incomplete work-group, called the Remainder work-group.

[0058] For example, if the three-dimensional size of the work group is (8,8,4) and the total global space size is (20,20,6), then the number of work groups that need to be generated is (3,3,2), and the sizes of the work groups are (8,8,4). The sizes of the remaining work groups may be (4,8,4), (8,4,4), (4,4,4), (8,8,2), (4,8,2), (8,4,2), (4,4,2).

[0059] The GPCP unit of the GPU will be responsible for the process of splitting the global size into working groups, and the split working groups are sent to each execution unit PE of the GPU in turn.

[0060] Each work-group needs to be executed in an execution unit PE on the GPU. When the execution unit PE receives multiple parameters of the work-group, it divides the work-group into multiple GPU threads (waves). Each thread can be in simd32 or simd64 mode, allowing 32 or 64 work-items to perform calculations simultaneously.

[0061] S404: Read the work grid information corresponding to the work group task.

[0062] The work grid information includes the target number of work groups on each dimension to be set.

[0063] In one of the optional embodiments, the target number of workgroups in each dimension to be set is determined based on the dimension to be set and the resources required by each workgroup; the target number of workgroups is evenly distributed in each dimension to be set, and the dimension to be set is obtained based on the form of the workgroup.

[0064] In one of the optional embodiments, the target number of workgroups is obtained based on the target mathematical statistics of the initial number of workgroups determined by each resource and the target number range of workgroups; the resources required by each workgroup include at least one of the temporary register size used by each thread corresponding to the workgroup, the shared cache space size of the resources of each thread corresponding to the workgroup, and the private cache space size of each thread corresponding to the workgroup; the target number range of workgroups is obtained based on the maximum number of workgroups that can be accommodated by an execution unit.

[0065] In order to improve the continuity of adjacent workgroups accessing data, it is best to assign multiple adjacent workgroups to the same execution unit PE for execution. To this end, it is necessary to add a logical layer work grid (work-Grid) between the global space and the workgroup, forming a four-level hierarchical relationship: GlobalSize>Work-Grid>Work-Group>Work-Item. The size of the work grid is also a triple: the number of workgroups contained in the work grid (Work-Grid Group Dimension): GridG (GGx, GGy, GGz): indicates the number of workgroups contained in the Grid in three-dimensional space. After the work grid is introduced, adjacent workgroups can be placed in the same execution unit PE for execution.

[0066] It is worth noting that the work grid is not a standard API setting parameter and is transparent to the user. It is mainly for the optimization of program execution and can be analyzed before execution. It is pre-defined in the registers in the GPU by the driver. The target work group number range, that is, the value range of the work grid has a constraint:

[0067] Tot_GG_Num=GGx*GGy*GGz,1≤Tot_GG_Num≤Tot_Group_in_PE

[0068] That is to say, the product size of the three dimensions of the working grid Tot_GG_Num must be greater than or equal to 1. If GGx=GGy=GGz=1, it means that the Grid contains only one working group and degenerates into the normal mode. At the same time, the product of the three Tot_GG_Num must be less than or equal to the maximum number of groups that an execution unit PE can accommodate (Tot_Group_in_PE). This value is a fixed value and depends on different GPU products. It can be 32 or 64.

[0069] For example, the current GPU product's Tot_Group_in_PE is 32, so (GGx, GGy, GGz) selects (1,8,2), (8,4,1), and (2,4,2) which are all legal, but (10,4,1) and (8,4,2) which are both over 32 are illegal.

[0070] Since the 3-tuple parameter of the work grid needs to be set in the register, the driver needs to help analyze the size of the work grid and set the work grid size to the GPU before the kernel, that is, the model including the work group task, is executed. Since each execution unit PE can accommodate a limited number of work groups at the same time, the size of the work grid needs to be determined based on the various resources required by the current work group. These resources include the temporary register size (CRF size), shared cache space size (Shared Memory Size) and private cache size (Private Memory Size) used by each thread of the work group, which can be configured as follows:

[0071] First, obtain the number of threads in the work group wave_num_per_group and the CRF size wave_Crf_size required by each thread, and calculate the maximum number of work groups currently required: max_group_Crf = Max_Crf_Size_PE / (wave_num_per_group*wave_Crf_size), where Max_Crf_Size_PE is the maximum number of CRFs owned by each execution unit PE.

[0072] If the working group uses a shared cache, the maximum number of working groups determined by the shared cache can also be calculated: max_group_SMem = Max_SMem_Size / group_SMem_Size, where Max_SMem_Size is the shared cache size owned by each execution unit PE, and group_SMem_Size is the size of the shared cache that each working group needs to use.

[0073] If each thread uses a private cache, the maximum number of working groups currently required can be calculated: max_group_PMem = Max_PMem_Size / (wave_num_per_group*wave_PMem_size); here Max_PMem_Size is the size of the private cache owned by each execution unit PE, and wave_PMem_size is the size of the private cache that each thread needs to use;

[0074] Finally, after obtaining these three values, the driver needs to calculate the target data statistics of the three, such as selecting a minimum value. In other real-time, other mathematical statistics can also be selected, and then the number of working groups allowed to be executed simultaneously in an execution unit PE is set based on the target mathematical statistics: max_group_num = min{Tot_Group_in_PE, max_group_Crf, max_group_SMem, max_group_PMem}.

[0075] Next, you need to set the number of working groups GridG (GGx, GGy, GGz) contained in the working grid: for the case where the y and z components of the working group size are both 1, that is, the form is (GroupDx, 1, 1), which is often used to process one-dimensional buffer data, the driver sets the working grid Grid parameters to (max_group_Num, 1, 1), so that multiple one-dimensional continuous working groups can be executed on the same execution unit PE; for working groups that access two-dimensional or three-dimensional images, the driver only evenly distributes the target number of working groups in each dimension to be set. For example, configuring the working grid Grid parameters to be close to a square or cube ratio can improve the continuity of adjacent data access. For example, the calculated max_group_num is 20, and the z component of the work group size is 1, that is, (GroupDx, GroupDy, 1), then we can set the Grid parameters to (5, 4, 1) or (4, 5, 1), but (20, 1, 1) or (2, 10, 1) is not a good strategy, because the adjacent relationship of the work group obtained in this way is too narrow and long, which is not conducive to continuous access to adjacent data.

[0076] After determining the work grid information, the driver stores the work grid information in the register of the GPU, so that when the GPU performs work group scheduling, the corresponding work grid information can be read from the register.

[0077] S406: Determine a current work grid based on the work grid information and the work group tasks, where the current work grid includes at least two adjacent work groups.

[0078] S408: Split the current work grid into work groups to obtain adjacent work groups.

[0079] The GPU determines the current working grid based on the working grid information and the working group task. The working group task here is the model mentioned above. After the general computing task is sent to the GPU through the driver, the working group is split in GPCP and then distributed to each PE in sequence for parallel execution.

[0080] In this example, the splitting of the work cell and the splitting of the work group are performed separately. In one optional embodiment, the work groups located in the same current work cell are assigned to the same execution unit, including: determining the current execution unit, assigning the work group corresponding to the current work cell to the current execution unit; determining the next execution unit as the new current execution unit, and continuing to execute the step of determining the current work cell based on the work cell information and the work group task until the work group task is completed.

[0081] Specifically, combined Figure 6 As shown in FIG. 1 , after the general computing task is sent to the GPU through the driver, it is split into working groups in GPCP and then distributed to each PE in sequence for parallel execution.

[0082] Among them, GPCP, namely General-purpose Control Processing, is used to receive the configuration register REG, split the work grid Grid and the work group Group, and distribute them to each execution unit PE; the configuration register REG is used to record the split configuration information, including the configuration size of the work grid Grid, the work grid scheduling mode Schedule_Mode and other information; the work grid splitting module GRID_SPLIT is used to split the corresponding work grid Grid according to the configuration information, and send the work grid identifier Grid id to the subsequent module; the work group splitting module GRP_SPLIT is used to further split the work grid obtained by the split, obtain each work group Group, and distribute it to each execution unit PE for execution; the execution unit PE (Processing Element, processing calculation unit) mainly includes the following modules: stream processing unit SP: StreamingProcessor, each PE contains a group of stream processing calculation units, usually 16 or 32 units, so that a simd16 or simd32 GPU thread (wave) is executed synchronously; CRF (Common Register File) is used to cache the storage space of the intermediate data of each wave calculation; Cache is the high-speed cache needed in each PE, including instruction, image, buffer and other data caches; SMem (Shared Memory) is used for the data exchange space within each workgroup group, which can be accessed by all thread waves of the group; PMem (Private Memory) is the private cache space of each wave, which generally shares the same SRAM space with Cache. If the current general computing task needs to use PMem, a piece of Cache is divided as PMem; if not, the entire SRAM can be used as cache.

[0083] The basic process of general computing tasks is: determine the setting strategy of the work grid Grid according to the global space and work group space size of the current general computing task, and then the driver transmits the configuration information such as the work grid information Grid and the work grid scheduling mode Schedule_Mode to the register REG in GPCP.

[0084] After receiving the general computing task, the GPU transmits it to GPCP. GPCP first determines the current working grid identifier Grid_Id and the current execution unit identifier PE_Id according to the configuration information in REG through GRID_SPLIT. After receiving the information, GRP_SPLIT performs the work group splitting process, generates the work group identifier Group_Id, the actual work group size and other information, and sends them to the current execution unit PE corresponding to the current execution unit identifier PE_Id for execution. After each current execution unit PE receives the corresponding work group, it continues to split it into multiple thread waves and executes them in the current execution unit PE until completion.

[0085] S410: Allocate the work groups located in the same current work grid to the same execution unit.

[0086] In order to improve the utilization of cache, the present application proposes the concept of a work grid, which includes multiple adjacent work groups. These adjacent work groups are scheduled to be executed in the same execution unit PE as much as possible, which can effectively utilize the consistency of adjacent data and improve the utilization of cache.

[0087] In general computing, a level of hierarchy is added: work grid (Work-Grid), which becomes a four-level structure global model GlobalSize, work grid, work group and work item Work-Item, which can be seamlessly integrated with the existing three-level structure; and the work grid level is transparent to the user, and its size is completely pre-determined and set by the driver according to the resource usage of each work group. In addition, two splitting logic units GRID_SPLIT and GRP_SPLIT are set to handle the splitting process of the work grid and the work group Group.

[0088] The above-mentioned work group scheduling method, after receiving the work group task, determines the current work cell based on the work cell information, and the work cell includes at least two adjacent work cells. In this way, the adjacent work cells obtained by splitting the work cells are placed in the same execution unit, thereby ensuring that the adjacent work cells are executed in the same execution unit, fully considering the continuity of the data, effectively utilizing the coherence of adjacent data, and improving the matching effect of the cache and the memory reading and writing efficiency.

[0089] In one of the optional embodiments, the current work grid is determined based on the work grid information and the work group tasks, including: reading the work grid scheduling mode; obtaining the work grid splitting order corresponding to the work grid scheduling mode; and determining the current work grid based on the work grid splitting order, the work grid information and the work group tasks.

[0090] The work cell scheduling modes in this embodiment include a sequential scheduling mode Sequence and a Morton curve scheduling mode MortonCurve, which are respectively applicable to the scheduling of linear buffers and images.

[0091] The sequential scheduling method can be applied to the work grid, and Grid0, Grid1, Grid2, etc. are distributed to PE0, PE1, PE2, etc. for execution. However, each work grid contains multiple adjacent work groups. This method is called sequential scheduling (Sequence). However, for general calculations of two-dimensional and three-dimensional images, this sequential method is not necessarily good, because the data of these images are often organized according to the Morton Curve, also called the Z-order curve, such as Figure 7 Arrow in the.

[0092] The color and other information of pixels organized according to the position of the Morton curve are closely arranged, and are easy to fall on the same cache line of the cache, which is conducive to continuous reading and writing by GPU threads. Therefore, for general calculations of image access, it is best to schedule the working grid according to the Morton curve, which is called the Morton curve scheduling method (MortonCurve). Reading and writing image data in this way is conducive to improving the hit rate of the working group in the working grid in the cache and reducing the bandwidth demand for memory. Based on this, it is necessary to add corresponding control bits in GPCP, such as 1-bit control bits, to indicate the mode of working grid scheduling: 1-bit Schedule_Mode: 0 indicates the sequential scheduling method Sequence, for each working grid, scheduling is performed in a sequential manner, which is often used for accessing one-dimensional linear buffers; it can also be used for accessing two-dimensional or three-dimensional images, but the continuity of data is not good; 1 indicates the Morton curve scheduling method MotonCurve, for each working grid, scheduling is performed in the order of the Morton curve, which is often used for accessing two-dimensional or three-dimensional images.

[0093] Among them, combined Figure 8 As shown, Figure 8The flowchart of the work-grid splitting step in one embodiment, wherein the work-grid splitting module GRID_SPLIT will receive the following three triplet parameters and then split the work-grid Grid: the three-dimensional size of the global space (global size): (GlobalDx, GlobalDy, GlobalDz); the offset of the global space (globaloffset): (GlobalFx, GlobalFy, GlobalFz); the three-dimensional size of the work-group, also known as the local size (local size), using the triplet: (GroupDx, GroupDy, GroupDz).

[0094] Each work grid obtained by the work grid splitting module GRID_SPLIT has an index number (Grid_Id), which is also a triple (Grid_Idx, Grid_Idy, Grid_Idz). GRID_SPLIT obtains the number of work groups (Work-Grid Group Dimension) contained in the work grid from the register REG, GridG (GGx, GGy, GGz), which indicates the number of work groups contained in the Grid in three-dimensional space. The space size of each Grid is:

[0095] (GridDx,GridDy,GridDz)=(GGx*GroupDx,GGy*GroupDy,GGz*GroupDz)

[0096] The total number of Grids in the global space is: GridN(GridNx, GridNy, GridNz) = (Ceil(GlobalDx / GridDx), Ceil(GlobalDy / GridDy), Ceil(GlobalDz / GridDz))

[0097] Function Ceil represents rounding up the remainder. In this way, according to the above formula, the number of work groups Grid that are split out can be determined in advance, and they can be assigned to each execution unit PE in turn. The splitting process is similar to the work group Group. The work group is split according to the three-dimensional structure, and the global size in the Z direction is divided into multiple layers. The step size in the Z direction is GridDz; first split the XY two-dimensional direction of each layer, and then split the next layer after the layer is completed. For each layer of two-dimensional space, select whether it is a sequential mode (Sequence) or a Morton curve mode (MotonCurve) according to Schedule_Mode. If it is a sequential mode, then split the X direction first, and then split the Y direction. The step sizes of the X and Y directions are GridDx and GridDy respectively, and the current Grid_Id is generated. If it is a Morton curve mode, then obtain the Grid_Id according to the Z-Order.

[0098] Assuming that the total number of execution units PE is PE_NUM, the working grid splitting module GRID_SPLIT will obtain the current PE index (PE_Id) each time it splits a working grid Grid, send the following two sets of data to the subsequent module, and then adjust the PE index to schedule the next Grid: Grid index number (Grid Index): Grid_Id (Grid_Idx, Grid_Idy, Grid_Idz); the PE index number (PE Index) of the working grid to be scheduled: PE_Id.

[0099] For example, assuming that the global size is (64, 64, 2), the work group size is (8, 16, 1), and it is pre-calculated that a PE can accommodate 4 work groups and execute scheduling at the same time (max_group_num=4), then the number of work groups contained in the work grid is set: GridG(GGx, GGy, GGz)=(2,2,1); the size of the work grid: (GridDx, GridDy, GridDz)=(2*8,2*16,1*1)=(16,32,1); the total number of work grids is: (GridNx, GridNy, GridNz)=(64 / 16,64 / 32,2 / 1)=(4,2,2).

[0100] In addition to processing one-dimensional work tasks, the Sequence scheduling mode can also schedule other global-sized work. There are 16 work grids in total. If they are split according to the Sequence scheduling mode, the Grid_Ids obtained are (0,0,0), (1,0,0), (2,0,0), (3,0,0), (0,1 0), (1,1,0), (2,1,0), (3,1,0), (0,0,1), (1,0,1), (2,0,1), (3,0,1), (0,1 1), (1,1,1), (2,1,1), (3,1,1), see Figure 9a .

[0101] If the splitting is performed according to the Morton curve scheduling mode MotonCurve, the grid identifiers (indexes) Grid_Id will be (0,0,0),(1,0,0),(0,1,0),(1,1,0),(2,0,0),(3,0,0),(2,1,0),(3,1,0),(0,0,1),(1,0,1),(0,1,1),(1,1,1),(2,0,1),(3,0,1),(2,1,1),(3,1,1), see Figure 9b .

[0102] In one of the optional embodiments, splitting the current working cell into work groups to obtain adjacent working groups includes: splitting the current working cell into adjacent working groups in a sequential manner.

[0103] After receiving the grid index Grid_Id sent by the grid splitting module GRID_SPLIT, the work group splitting module GRP_SPLIT will start to split the work group Group in the grid. There is only one splitting method, which is the sequential method. The work group is split according to the three-dimensional structure, and the GGz in the Z direction is split into multiple layers; then the XY of each layer is split in the two-dimensional direction, and the next layer is split after the layer is completed. The splitting process is as follows: Fig.10 shown.

[0104] For each split work group Group, a corresponding index number (widx, widy, widz) will be obtained, which can be used to calculate the work group Group index. The calculation method is: Group_Id = (Group_Idx, Group_Idy, Group_Idz) = (Grid_Idx*GGx+widx, Grid_Idy*GGy+widy, Grid_Idz*GGz+widz)

[0105] The work group splitting module GRP_SPLIT splits each work group and generates three sets of triplet data, a total of 9 dwords: the index of the current work group: Group_Id (Group_Idx, Group_Idy, Group_Idz); the actual size of the work group: ActGD (ActGDx, ActGDy, ActGDz); the global offset of the current work group: Group_Off (Group_Offx, Group_Offy, Group_Offz).

[0106] Since the GPU supports residual work groups, the actual size of each work group may be smaller than (GroupDx, GroupDy, GroupDz), so it is necessary to calculate the actual work group size and notify each execution unit PE. This parameter can be calculated by the index of the work group: ActGD = (ActGDx, ActGDy, ActGDz); ActGD x = if (Group_Idx <GroupNx–1)GroupDx;else(GlobalDx–Group_Id x*GroupDx);ActGD y=if(Group_Idy<GroupNy–1)GroupDy;else(GlobalDy–Group_Id y*GroupDy);ActGD z=if(Group_Idz<GroupNz–1)GroupDz;else(GlobalDz–Group_Id z*GroupDz)。

[0107] Among them, (GroupNx, GroupNy, GroupNz) represents the number of workgroups in the computational space, and (Group_Idx, Group_Idy, Group_Idz) is the index of the current workgroup. At the same time, GRP_SPLIT also needs to calculate the global offset of the current workgroup, which can be calculated based on the index of the current workgroup.

[0108] Group_Off=(Group_Offx,Group_Offy,Group_Offz)

[0109] Group_Offx=GlobalFx+Group_Idx*GroupDx

[0110] Group_Offy=GlobalFy+Group_Idy*GroupDy

[0111] Group_Offz=GlobalFz+Group_Idz*GroupDz

[0112] Finally, the workgroup splitting module GRP_SPLIT will package the three groups of triplets according to the execution unit index PE_Id and send them to the corresponding execution unit PE for subsequent calculation.

[0113] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0114] Based on the same inventive concept, the embodiment of the present application also provides a work group scheduling device for implementing the work group scheduling method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more work group scheduling device embodiments provided below can refer to the limitations on the work group scheduling method above, and will not be repeated here.

[0115] In an exemplary embodiment, Fig.11 As shown, a working group scheduling device is provided, comprising:

[0116] Receiving module 1101, used for receiving work group tasks;

[0117] The work grid information reading module 1102 is used to read the work grid information corresponding to the work group task;

[0118] A work grid splitting module 1103 is used to determine a current work grid based on the work grid information and work group tasks, where the current work grid includes at least two adjacent work groups;

[0119] The work group splitting module 1104 is used to split the current work grid into work groups to obtain adjacent work groups;

[0120] The allocation module 1105 is used to allocate the work groups located in the same current work grid to the same execution unit.

[0121] In one optional embodiment, the work grid information includes a target number of work groups determined based on the dimension to be set and the resources required by each work group; the target number of work groups is evenly distributed on each dimension to be set, and the dimension to be set is obtained based on the form of the work group.

[0122] In one of the optional embodiments, the target number of workgroups is obtained based on the target mathematical statistics of the initial number of workgroups determined by each resource and the target number range of workgroups; the resources required by each workgroup include at least one of the temporary register size used by each thread corresponding to the workgroup, the shared cache space size of the resources of each thread corresponding to the workgroup, and the private cache space size of each thread corresponding to the workgroup; the target number range of workgroups is obtained based on the maximum number of workgroups that can be accommodated by an execution unit.

[0123] In one of the optional embodiments, the above-mentioned allocation module 1105 is also used to determine the current execution unit, allocate the work group corresponding to the current work grid to the current execution unit; determine the next execution unit as the new current execution unit, and continue to execute the steps of determining the current work grid based on the work grid information and the work group task until the work group task is completed.

[0124] In one of the optional embodiments, the work grid splitting module 1103 is further used to read the work grid scheduling mode; obtain the work grid splitting sequence corresponding to the work grid scheduling mode; and determine the current work grid based on the work grid splitting sequence, work grid information, and work group tasks.

[0125] In one of the optional embodiments, the work group splitting module 1104 is further used to split the current work grid into adjacent work groups in a sequential splitting manner.

[0126] Each module in the above work group scheduling device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0127] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.12As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a workgroup scheduling method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0128] Those skilled in the art will understand that Fig.12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0130] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0131] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0132] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used 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 must comply with relevant regulations.

[0133] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0134] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0135] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A work group scheduling method, It is characterized in that The method comprises: Receive work group assignments; Reading the work grid information corresponding to the work group task; Determine a current work grid based on the work grid information and the work group tasks, wherein the current work grid includes at least two adjacent work groups; Splitting the current working grid into working groups to obtain adjacent working groups; The working groups located in the same current working grid are allocated to the same execution unit.

2. The method according to claim 1, It is characterized in that The work grid information includes a target number of work groups determined based on the dimension to be set and the resources required by each work group; the target number of work groups is evenly distributed on each dimension to be set, and the dimension to be set is obtained based on the form of the work group.

3. The method according to claim 2, It is characterized in that The target number of working groups is obtained based on the target mathematical statistics of the initial number of working groups determined by each resource and the target number range of working groups; the resources required by each working group include at least one of the temporary register size used by each thread corresponding to the working group, the shared cache space size of the resources of each thread corresponding to the working group, and the private cache space size of each thread corresponding to the working group; the target number range of working groups is obtained based on the maximum number of working groups that an execution unit can accommodate.

4. The method according to any one of claims 1 to 3, It is characterized in that The allocating the work groups located in the same current work grid to the same execution unit includes: Determine a current execution unit, and assign a work group corresponding to the current work cell to the current execution unit; The next execution unit is determined as a new current execution unit, and the step of determining the current work grid based on the work grid information and the work group task is continued until the work group task is completed.

5. The method according to claim 1, It is characterized in that The determining the current work grid based on the work grid information and the work group tasks includes: Read the work grid scheduling mode; Obtaining the work grid splitting order corresponding to the work grid scheduling mode; The current work grid is determined based on the work grid splitting order, the work grid information and the work group tasks.

6. The method according to claim 1, It is characterized in that The step of splitting the current working grid into working groups to obtain adjacent working groups includes: The current working grid is split into adjacent working groups in a sequential splitting manner.

7. A work group scheduling device, It is characterized in that The device comprises: A receiving module, used for receiving work group tasks; A work grid information reading module, used to read the work grid information corresponding to the work group task; A work grid splitting module, used to determine a current work grid based on the work grid information and the work group tasks, wherein the current work grid includes at least two adjacent work groups; A work group splitting module is used to split the current work grid into work groups to obtain adjacent work groups; The allocation module is used to allocate the work groups located in the same current work grid to the same execution unit.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.