GPGPU thread block synchronization method, device and medium based on thread lock

By adopting thread block synchronization method based on thread lock in the GPGPU architecture, the problem of synchronization complexity and low parallelism between thread blocks of GPGPU is solved, efficient memory access and resource utilization are achieved, and computing performance is improved.

CN119557115BActive Publication Date: 2025-04-18YUANQIXIN (SHANDONG) SEMICONDUCTOR TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510121004.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-26
Publication Date
2025-04-18
Estimated Expiration
2045-01-26

AI Technical Summary

Technical Problem

The GPGPU architecture does not support direct synchronization between thread blocks, which causes synchronization between thread blocks to require global memory, blocking thread execution without data dependencies in thread blocks, reducing parallelism and operation efficiency.

Method used

Using the GPGPU thread block synchronization method based on thread lock, thread blocks are allocated to the stream multiprocessor through the thread block scheduling module and the thread start ID is calculated to maintain the thread lock table. Analyze whether the memory access request has a dependency with the thread in the current thread block. If so, it will be added to the lock queue, query the thread lock status and perform memory access after all dependent threads are unlocked to realize the synchronization of thread blocks.

Benefits of technology

It effectively avoids memory access conflicts and errors caused by data dependence, improves the accuracy and efficiency of memory access, and improves the resource utilization and overall computing performance of GPGPU devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557115B_ABST
    Figure CN119557115B_ABST
Patent Text Reader

Abstract

The present application discloses a GPGPU thread block synchronization method, device and medium based on thread lock, and relates to the field of electronic digital data processing technology. The method includes: a thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the thread start ID to maintain the corresponding thread lock table; in the case of memory access demand, analyzes whether the memory access request has a dependency relationship with the thread in the currently occupied thread block, and if so, adds the memory access request with the dependency relationship to the lock queue; queries the thread lock status of the thread in the corresponding thread lock table that has a dependency relationship with the memory access request to add the thread lock status to the entry status corresponding to the lock queue; when the entry status of all threads in the lock queue that have a dependency relationship with the thread bundle are all unlocked, the memory access request is dequeued from the lock queue, and memory access is performed according to the memory access request to achieve synchronization of the GPGPU thread block.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of electronic digital data processing, and in particular to a GPGPU thread block synchronization method, device and medium based on thread locks. Background Art

[0002] At present, General-Purpose computing on Graphics Processing Units (GPGPU) technology is an important innovation in the field of modern computing. It cleverly utilizes the powerful parallel computing capabilities of graphics processing units (GPUs) and expands from traditional graphics rendering to a wide range of general computing tasks such as scientific computing, data analysis, deep learning, etc.

[0003] In GPGPU programming, synchronization between thread blocks is a relatively complex problem, because the GPGPU architecture usually does not support direct synchronization between thread blocks. Therefore, synchronization between thread blocks usually needs to be achieved with the help of global memory to ensure that memory operations before the barrier are completed before memory operations after the barrier can be executed. Although the use of global memory barriers solves the synchronization problem between thread blocks, it blocks the execution of threads that do not have data dependencies within the thread block to a certain extent, reducing the thread parallelism of GPGPU, resulting in a waste of resources and reduced computing efficiency. Summary of the invention

[0004] The embodiments of the present application provide a GPGPU thread block synchronization method, device and medium based on thread lock to solve the above technical problems.

[0005] On the one hand, the embodiment of the present application provides a GPGPU thread block synchronization method based on thread lock, which is applied to a GPGPU thread block synchronization system based on thread lock, wherein the system includes: a host host end and a GPGPU device end, wherein the GPGPU device end includes a thread block scheduling module, a stream multiprocessor and a thread lock control module, including:

[0006] The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block;

[0007] When a thread warp of a stream multiprocessor has a memory access demand, analyze whether the memory access request has a dependency relationship with a thread in a currently occupied thread block, and if so, add the memory access request with the dependency relationship to a lock queue;

[0008] Querying the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table, so as to add the thread lock state to the entry state corresponding to the lock queue;

[0009] When the entry states of all threads in the lock queue that have a dependency relationship with the thread warp are all unlocked, the memory access request is dequeued from the lock queue, and memory access is performed according to the memory access request to achieve synchronization of GPGPU thread blocks.

[0010] In one implementation of the present application, the thread block scheduling module includes a thread block allocation module, an index calculation module and a thread lock control module;

[0011] The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block, specifically including:

[0012] The thread block allocation module of the thread block scheduling module allocates all thread blocks to each stream multiprocessor according to a preset thread block scheduling strategy, and adds a thread lock to each thread in the thread block to be processed;

[0013] Calculate the thread start ID corresponding to the thread block by the index calculation module, and return a calculation completion signal to the thread block scheduling module after the calculation is completed, so that the thread block allocation module allocates the next thread block to be processed to the stream multiprocessor;

[0014] The thread start ID is sent to the thread lock control module to maintain the thread lock table corresponding to the thread block.

[0015] In one implementation of the present application, calculating the thread start ID corresponding to the thread block by the index calculation module specifically includes:

[0016] Determine thread grid information corresponding to the thread block, and calculate the thread start ID of the thread block according to the thread grid information; wherein the thread grid information includes: thread grid coordinates, thread grid dimensions, and thread grid size;

[0017] The thread start ID is calculated using the following formula:

[0018]

[0019] in, Indicates the thread start ID. Represents the horizontal coordinate of the thread grid, Represents the thread grid ordinate, Represents the vertical coordinate of the thread grid, Grid.x represents the horizontal dimension of the thread grid, Grid.y represents the vertical dimension of the thread grid, and Grid.z represents the third dimension of the thread grid. Indicates the length of the thread block size, Indicates the width of the thread block size.

[0020] In one implementation of the present application, maintaining the thread lock table corresponding to the thread block specifically includes:

[0021] The thread lock control module maintains the thread lock table corresponding to the thread block to map the first entry index of the thread lock table corresponding to the thread block to the thread start ID of the thread block;

[0022] The entry indexes in the thread block except the first entry index are accumulated, and the states of all entries are set to be locked.

[0023] In one implementation of the present application, the thread block scheduling module further includes a memory access control module;

[0024] When a thread warp of a stream multiprocessor has a memory access requirement, the memory access request is analyzed to see whether it has a dependency relationship with the thread in the currently occupied thread block. If so, the memory access request with the dependency relationship is added to the lock queue, including:

[0025] In the case where a thread warp of a streaming multiprocessor has a memory access demand, a memory access request is received through a memory access control module, and a dependency analysis is performed on the memory access request to determine whether a thread corresponding to the memory access request has a dependency relationship with a thread in a currently occupied thread block;

[0026] If not, memory access is performed according to the memory access request; if yes, the memory access request is added to the lock queue of the thread lock control module for queuing.

[0027] In one implementation of the present application, the thread lock control module maintains a number of thread lock tables and a lock queue, the number of thread lock tables is the same as the number of currently occupied thread blocks, and each currently occupied thread block corresponds to a thread lock table;

[0028] Querying the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table to add the thread lock state to the entry state corresponding to the lock queue, specifically including:

[0029] Determine the thread lock table corresponding to the thread block through a thread lock control module, and query the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table; wherein the thread lock state includes a locked state and an unlocked state;

[0030] In the lock queue of the thread lock control module, an entry state position corresponding to a thread having a dependency relationship with the thread block is determined, and the thread lock state of the corresponding thread is added to the entry state position.

[0031] In one implementation of the present application, after adding the thread lock state to the entry state corresponding to the lock queue, the method further includes:

[0032] Based on the lock queue, thread lock status monitoring is performed on thread bundles with dependencies, and corresponding monitoring results are obtained by maintaining the monitoring process;

[0033] When there is a thread lock state change in the monitoring result, the state of the changed entry in the lock queue is updated.

[0034] In one implementation of the present application, the GPGPU device side further includes: an L2 cache;

[0035] Performing memory access according to the memory access request to achieve synchronization of GPGPU thread blocks specifically includes:

[0036] The memory access request is forwarded to the L2 cache for memory access, and the access result is returned to the corresponding streaming multiprocessor to achieve synchronization of GPGPU thread blocks.

[0037] On the other hand, the embodiment of the present application further provides a GPGPU thread block synchronization device based on thread lock, which is applied to a GPGPU thread block synchronization system based on thread lock, wherein the system comprises: a host end, a GPGPU device end, the GPGPU device end comprises a thread block scheduling module, a stream multiprocessor and a thread lock control module, and the device comprises:

[0038] at least one processor;

[0039] and, a memory communicatively coupled to the at least one processor;

[0040] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the GPGPU thread block synchronization method based on thread lock as described above.

[0041] On the other hand, an embodiment of the present application also provides a non-volatile computer storage medium storing computer executable instructions, which is applied to a GPGPU thread block synchronization system based on thread locks. The system includes: a Host host end and a GPGPU device end. The GPGPU device end includes a thread block scheduling module, a stream multiprocessor and a thread lock control module. When the computer executable instructions are executed, the GPGPU thread block synchronization method based on thread locks as described above is implemented.

[0042] The embodiments of the present application provide a GPGPU thread block synchronization method, device, and medium based on thread locks, which at least have the following beneficial effects:

[0043] The thread block scheduling module ensures the orderly allocation and management of thread blocks on the GPGPU device side; by adding memory access requests with dependencies to the lock queue, memory access conflicts and errors caused by data dependencies are effectively avoided, ensuring that memory access requests are processed only after the data of related threads are ready, thereby improving the accuracy and efficiency of memory access; by adding the thread lock state to the entry state corresponding to the lock queue, the thread synchronization process is made more flexible and reliable; by real-time updating and monitoring of the thread lock state, the timeliness and accuracy of thread synchronization are ensured, and calculation errors caused by inconsistent thread states are avoided; when it is detected that all threads with dependencies are in the unlocked state, the memory access request is dequeued from the lock queue for memory access, thereby achieving efficient synchronization of GPGPU thread blocks, reducing unnecessary waiting time, optimizing resource utilization of GPGPU devices, and improving overall computing performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0045] Figure 1 A flowchart of a GPGPU thread block synchronization method based on thread locks provided in an embodiment of the present application;

[0046] Figure 2 A schematic diagram of the overall architecture of a GPGPU thread block synchronization method based on thread locks provided in an embodiment of the present application;

[0047] Figure 3 A schematic diagram of thread lock control scheduling provided in an embodiment of the present application;

[0048] Figure 4 A schematic diagram of a thread lock table and lock queue provided in an embodiment of the present application;

[0049] Figure 5 A schematic diagram of the internal structure of a GPGPU thread block synchronization device based on thread locks provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0051] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0052] Figure 1 A flowchart of a GPGPU thread block synchronization method based on thread locks provided in an embodiment of the present application.

[0053] The analysis method involved in the embodiments of the present application may be implemented by a terminal device or a server, and the present application does not impose any special restrictions on this. For the convenience of understanding and description, the following embodiments are described in detail by taking a server as an example.

[0054] It should be noted that the server may be a single device or a system consisting of multiple devices, that is, a distributed server, and this application does not make any specific limitation on this.

[0055] like Figure 1 As shown, the GPGPU thread block synchronization method based on thread lock provided in the embodiment of the present application is applied to the GPGPU thread block synchronization system based on thread lock, the system includes: a Host host end, a GPGPU device end, the GPGPU device end includes a thread block scheduling module, a stream multiprocessor and a thread lock control module, including:

[0056] 101. The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block.

[0057] Figure 2 The overall architecture diagram of the GPGPU thread block synchronization method based on thread lock provided in the embodiment of the present application is shown in FIG. Figure 2 As shown, the overall architecture of this application is divided into two parts: the Host side and the GPGPU device side. The Host side consists of a CPU central processing unit and a memory storage. The CPU is the main processor to complete the establishment, allocation, scheduling and release of tasks. The program written by the developer on the CPU is compiled by the compiler and translated into hardware instructions that can be parsed by the GPGPU.

[0058] GPGPU acts as a coprocessor to handle computationally intensive tasks that the CPU is not very good at. The GPGPU in this application consists of PCIE control, thread block scheduling, global memory, L2 cache, constant parameter memory and streaming multiprocessor (SM). The PCIE control module instantiates the PCIE interface, controls the communication between the host CPU and the GPGPU, and establishes a connection between the GPGPU memory and the Host Memory to achieve data transmission between the Host memory and the GPGPU memory. The GPGPU configuration module initializes the GPGPU and configures the control parameters of the GPGPU. The L2 cache is a high-speed cache that pre-fetches data in the global memory by merging memory accesses to reduce pipeline stagnation caused by data memory accesses and improve computing efficiency.

[0059] Specifically, in one embodiment of the present application, the thread block scheduling module includes a thread block allocation module, an index calculation module and a thread lock control module;

[0060] The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block, including:

[0061] The thread block allocation module of the thread block scheduling module allocates all thread blocks to each stream multiprocessor according to a preset thread block scheduling strategy, and adds a thread lock to each thread in the thread block to be processed;

[0062] The index calculation module calculates the thread start ID corresponding to the thread block, and returns a calculation completion signal to the thread block scheduling module after the calculation is completed, so that the thread block allocation module allocates the next thread block to be processed to the stream multiprocessor;

[0063] The thread start ID is sent to the thread lock control module to maintain the thread lock table corresponding to the thread block.

[0064] In one embodiment, the present application adds thread locks to all threads in all thread blocks. The locking and unlocking of thread locks are controlled by a thread block scheduling module. The thread block scheduling module is composed of an index calculation module, a thread block allocation module, a thread lock control module, and a memory access control module. The thread lock control scheduling diagram is as follows: Figure 3 shown.

[0065] The thread block allocation module is responsible for the allocation and scheduling of thread blocks. It allocates all thread blocks to each SM core according to the preset thread block scheduling strategy, such as polling, greedy and other strategies, and adds a thread lock mechanism in the thread block scheduling module to attach thread locks to the threads within each thread block to prevent memory conflicts in the operations of other thread blocks that have dependencies on them.

[0066] like Figure 2 As shown in the figure, SM is the computing unit of GPGPU, which is composed of two pipelines, SIMT stack, register file, L1Cache, shared memory and pipeline. SITM stack mainly handles the jump of branch instructions, register file is used to cache data and intermediate calculation results during the operation process, shared memory is used for data exchange between warps and threads, and L1Cache cache pre-fetches data and instructions from L2 Cache cache to further reduce the memory access time of pipeline.

[0067] The pipeline is the key to SM's computing function. It completes instruction fetch, decoding, emission, execution and result writeback through a five-stage pipeline. The efficiency of the pipeline directly determines the computing performance of GPGPU. Among them, the execution stage of the pipeline will assign several threads in a thread warp to each SP for execution.

[0068] The streaming processor (SP) is the smallest computing unit of GPGPU, which completes ALU, SFU, FPU and other operations. The number of SPs determines the parallelism of thread execution in a warp. Generally speaking, when the number of SPs is the same as the number of threads in a warp, the parallelism is highest, and all threads in the warp can be completely parallel during the execution phase.

[0069] Then, the index calculation module calculates the thread start ID corresponding to the thread block, and the SM core completes the operation of the thread block data. After the SM core completes the operation of the current thread block, it returns a completion signal to the thread block allocation module, and the thread block allocation module allocates a new thread block to the SM core.

[0070] In one embodiment of the present application, calculating the thread start ID corresponding to the thread block by the index calculation module specifically includes:

[0071] Determine the thread grid information corresponding to the thread block, and calculate the thread start ID of the thread block according to the thread grid information; wherein the thread grid information includes: thread grid coordinates, thread grid dimensions, and thread grid size;

[0072] The thread start ID is calculated using the following formula:

[0073]

[0074] in, Indicates the thread start ID. Represents the horizontal coordinate of the thread grid, Represents the thread grid ordinate, Represents the vertical coordinate of the thread grid, Grid.x represents the horizontal dimension of the thread grid, Grid.y represents the vertical dimension of the thread grid, and Grid.z represents the third dimension of the thread grid. Indicates the length of the thread block size, Indicates the width of the thread block size.

[0075] In one embodiment, when the thread block scheduling module allocates a thread block to an SM core, the threads corresponding to the thread block will be locked, and the IDs of these locked threads can be calculated by the index calculation module. The required parameters include the thread grid coordinates (BlockId.x, BlockId.y, BlockId.z) corresponding to the thread block, the thread grid dimensions (Grid.x, Grid.y, Grid.z), the thread block size (BlockDim.x, BlockDim.y) and other parameters.

[0076] It should be noted that Corresponding to ThreadId_base, it is used to indicate the thread start ID of the thread block, corresponding to, indicating, Corresponding to BlockId.x, it is used to represent the horizontal coordinate of the thread grid. Corresponding to BlockId.y, it is used to represent the vertical coordinate of the thread grid. Corresponding to BlockId.z, it is used to represent the vertical coordinate of the thread grid, Grid.x is used to represent the horizontal dimension of the thread grid, and Grid.y is used to represent the vertical dimension of the thread grid. Corresponding to BlockDim.x, it is used to indicate the length of the thread block size. Corresponding to BlockDim.y, used to indicate the width of the thread block size.

[0077] In one embodiment of the present application, maintaining the thread lock table corresponding to the thread block specifically includes:

[0078] The thread lock control module maintains the thread lock table corresponding to the thread block to map the first entry index of the thread lock table corresponding to the thread block to the thread start ID of the thread block;

[0079] The entry indices except the first entry index in the thread block are accumulated, and the states of all entries are set to locked.

[0080] In one embodiment, the main function of the thread lock control module is to maintain the thread lock table corresponding to the thread block. The thread lock table is a data structure used to record the lock status of each thread in the thread block. Through the thread lock table, the system can easily query and control the lock status of each thread, thereby achieving thread synchronization and mutual exclusion.

[0081] When the thread lock control module initializes the thread lock table, it maps the first entry index of the thread lock table corresponding to the thread block to the thread start ID of the thread block. This means that the first entry of the thread lock table will represent the first thread in the thread block, and its index value is the thread start ID of the thread block. This design makes it easy to query the start thread of the thread block through the thread lock table, so as to perform subsequent thread management and scheduling.

[0082] For the entry indexes other than the first entry index in the thread block, the thread lock control module performs accumulation processing. Specifically, it starts from the second entry, accumulates the entry index values ​​one by one, and assigns a unique index to each entry. In this way, each entry in the thread lock table corresponds to a specific thread in the thread block, and the lock status of the thread can be easily queried and controlled through the entry index.

[0083] At the same time, the thread lock control module sets all entry states to locked. This is because when the thread block is initialized, all threads are in an unexecuted state, so their lock states should be set to locked to prevent other threads or processes from illegally accessing or modifying them.

[0084] 102. When a thread bundle of a streaming multiprocessor has a memory access demand, analyze whether the memory access request has a dependency relationship with threads in a currently occupied thread block. If so, add the memory access request with the dependency relationship to a lock queue.

[0085] Specifically, in one embodiment of the present application, the thread block scheduling module further includes a memory access control module;

[0086] When a thread warp of a stream multiprocessor has a memory access requirement, the memory access request is analyzed to see whether it has a dependency relationship with the thread in the currently occupied thread block. If so, the memory access request with the dependency relationship is added to the lock queue, including:

[0087] When a thread bundle of a stream multiprocessor has a memory access demand, a memory access request is received through a memory access control module, and a dependency analysis is performed on the memory access request to determine whether a thread corresponding to the memory access request has a dependency relationship with a thread in a currently occupied thread block;

[0088] If not, memory access is performed according to the memory access request. If yes, the memory access request is added to the lock queue of the thread lock control module for queuing.

[0089] In one embodiment, the memory access control module is used to control the synchronization between thread blocks. When a thread bundle of a certain SM core initiates a memory access request, the memory access request will first enter the memory access control module, and the memory access control module will perform dependency analysis on the memory access request of the thread bundle. If the memory access of the thread bundle has a dependency relationship with threads in other executing thread blocks, the memory access request will be sent to the lock queue of the thread lock control module for waiting in queue. When all the thread locks with dependency relationships are unlocked, memory access will be performed; if there is no dependency, memory access will be performed directly.

[0090] 103. Query the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table, so as to add the thread lock state to the entry state corresponding to the lock queue.

[0091] Specifically, in one embodiment of the present application, the thread lock control module maintains a plurality of thread lock tables and a lock queue, the number of thread lock tables is the same as the number of currently occupied thread blocks, and each currently occupied thread block corresponds to a thread lock table;

[0092] Query the thread lock status of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table to add the thread lock status to the entry status corresponding to the lock queue, including:

[0093] Determine the thread lock table corresponding to the thread block through the thread lock control module, and query the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table; wherein the thread lock state includes a locked state and an unlocked state;

[0094] In the lock queue of the thread lock control module, an entry state position corresponding to a thread having a dependency relationship with the thread block is determined, and the thread lock state of the corresponding thread is added to the entry state position.

[0095] In one embodiment, after the index calculation module completes the calculation of the starting thread ID, it sends the starting thread ID of the currently occupied thread block to the thread lock control module. The thread lock control module internally maintains several thread lock tables and a lock queue. The number of thread lock tables is the same as the number of currently occupied thread blocks. Each thread lock table corresponds to a thread block and is composed of a lookup table internally.

[0096] The thread lock table reflects the thread lock status of the threads in the current thread block. The size of the thread lock table is equal to the number of threads in the thread block. Each entry has two items: index and thread lock status. The index is used to find entries in the thread lock table. The index of the first entry is mapped to the starting thread ID of the current thread block. The indexes of the remaining entries are accumulated in sequence. When looking up the table, you only need to subtract the thread ID from the starting thread ID to find the index; the thread lock status is used to characterize the thread lock status of the current thread, 1 for locked, and 0 for unlocked. When the thread block is assigned to the SM, the thread lock status of all entries in the thread lock table is set to 1 (locked state). When a thread in the thread block completes all operations, the thread lock status is set to 0 (unlocked state).

[0097] The lock queue maintains thread warps, and the queue depth can be customized by the user. The lock queue is used to queue dependent thread warps and monitor thread lock status. When a thread warp initiates a memory access request and has a dependency relationship with the threads in the occupied thread block, the memory access request will be queued.

[0098] In one embodiment of the present application, after adding the thread lock state to the entry state corresponding to the lock queue, the method further includes:

[0099] Based on the lock queue, the thread lock status of the dependent thread bundles is monitored, and the corresponding monitoring results are obtained through the maintenance monitoring process;

[0100] When there is a thread lock state change in the monitoring result, the state of the changed entry in the lock queue is updated.

[0101] In one embodiment, the lock queue monitors the thread lock states of the threads that are dependent on it, and when the thread lock states of all the threads in the warp that are dependent on it are all unlocked, the memory access request is dequeued.

[0102] Figure 4 A schematic diagram of a thread lock table and lock queue provided in an embodiment of the present application. Figure 4 As shown in the figure, each entry in the lock queue contains two items: index and status. The index is the thread bundle ID of the thread bundle currently in the queue, and the status is the status of the thread lock of the thread that each thread in the current thread bundle depends on. Each bit indicates the thread lock status of one of the threads, which is obtained by querying the thread lock table where the dependent thread is located by the lock queue. The depth of the lock queue determines the monitoring parallelism. The greater the depth of the lock queue, the more dependency detections the lock queue can maintain at the same time, and the higher the queue efficiency of the thread bundles in the queue. All the thread bundles in the figure (5, 8, 1, 0, 12, ...) can monitor the status of each thread lock in parallel. When the status of a thread bundle is all 0, the thread bundle is dequeued.

[0103] 104. When the entry states of all threads having dependencies between entries in the lock queue and the thread warp are all unlocked, the memory access request is dequeued from the lock queue, and memory access is performed according to the memory access request to achieve synchronization of the GPGPU thread block.

[0104] Specifically, in one embodiment of the present application, the GPGPU device side further includes: an L2 cache;

[0105] Perform memory access according to memory access request to achieve synchronization of GPGPU thread blocks, including:

[0106] The memory access request is forwarded to the L2 cache for memory access, and the access result is returned to the corresponding streaming multiprocessor to achieve synchronization of GPGPU thread blocks.

[0107] In one embodiment, after receiving the memory request returned by the thread lock control module, the memory access control module forwards it to the L2 Cache for memory access, and returns the memory access result to the corresponding SM core. Based on the same principle, when the status item of other entries in the lock queue is 0, the corresponding entry is also dequeued, and the corresponding memory access request is forwarded for memory access to achieve synchronization of GPGPU thread blocks.

[0108] The above is an embodiment of the method proposed in this application. Based on the same inventive concept, the embodiment of this application also provides a GPGPU thread block synchronization device based on thread lock, whose structure is as follows: Figure 5 shown.

[0109] Figure 5 The internal structure diagram of the GPGPU thread block synchronization device based on thread lock provided in the embodiment of the present application. Figure 5 As shown, it is applied to the GPGPU thread block synchronization system based on thread lock, the system includes: Host host end, GPGPU device end, the GPGPU device end includes a thread block scheduling module, a stream multiprocessor and a thread lock control module, and the device includes:

[0110] at least one processor;

[0111] and, a memory communicatively coupled to the at least one processor;

[0112] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor to enable the at least one processor to:

[0113] The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block;

[0114] When a thread warp of a stream multiprocessor has a memory access demand, analyze whether the memory access request has a dependency relationship with a thread in a currently occupied thread block, and if so, add the memory access request with the dependency relationship to a lock queue;

[0115] Query the thread lock status of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table, so as to add the thread lock status to the entry status corresponding to the lock queue;

[0116] When the entry states of all threads in the lock queue that have dependencies with the thread warp are unlocked, the memory access request is dequeued from the lock queue, and memory access is performed according to the memory access request to achieve synchronization of the GPGPU thread block.

[0117] The embodiment of the present application further provides a non-volatile computer storage medium storing computer executable instructions, which is applied to a GPGPU thread block synchronization system based on thread locks. The system includes: a host end and a GPGPU device end, wherein the GPGPU device end includes a thread block scheduling module, a stream multiprocessor and a thread lock control module. When the computer executable instructions are executed, they can:

[0118] The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block;

[0119] When a thread warp of a stream multiprocessor has a memory access demand, analyze whether the memory access request has a dependency relationship with a thread in a currently occupied thread block, and if so, add the memory access request with the dependency relationship to a lock queue;

[0120] Query the thread lock status of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table, so as to add the thread lock status to the entry status corresponding to the lock queue;

[0121] When the entry states of all threads in the lock queue that have dependencies with the thread warp are unlocked, the memory access request is dequeued from the lock queue, and memory access is performed according to the memory access request to achieve synchronization of the GPGPU thread block.

Claims

1. A GPGPU thread block synchronization method based on thread lock, characterized in that: The invention is applied to a GPGPU thread block synchronization system based on thread lock, the system comprises: a host end and a GPGPU device end, the GPGPU device end comprises a thread block scheduling module, a stream multiprocessor and a thread lock control module, and the method comprises: The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block; When a thread warp of a stream multiprocessor has a memory access demand, analyze whether the memory access request has a dependency relationship with a thread in a currently occupied thread block, and if so, add the memory access request with the dependency relationship to a lock queue; Querying the thread lock state of the thread having a dependency relationship with the memory access request in the corresponding thread lock table, so as to add the thread lock state to the entry state corresponding to the lock queue; When the entry states of all threads in the lock queue that have a dependency relationship with the thread warp are all unlocked, dequeue the memory access request from the lock queue, and perform memory access according to the memory access request to achieve synchronization of GPGPU thread blocks; The thread block scheduling module includes a thread block allocation module, an index calculation module and a thread lock control module; The thread block scheduling module allocates thread blocks to each stream multiprocessor and calculates the corresponding thread start ID to maintain the thread lock table corresponding to the thread block, specifically including: The thread block allocation module of the thread block scheduling module allocates all thread blocks to each stream multiprocessor according to a preset thread block scheduling strategy, and adds a thread lock to each thread in the thread block to be processed; Calculate the thread start ID corresponding to the thread block by the index calculation module, and return a calculation completion signal to the thread block scheduling module after the calculation is completed, so that the thread block allocation module allocates the next thread block to be processed to the stream multiprocessor; The thread start ID is sent to the thread lock control module to maintain the thread lock table corresponding to the thread block.

2. The GPGPU thread block synchronization method based on thread lock according to claim 1, characterized in that: Calculating the thread start ID corresponding to the thread block by the index calculation module specifically includes: Determine thread grid information corresponding to the thread block, and calculate the thread start ID of the thread block according to the thread grid information; wherein the thread grid information includes: thread grid coordinates, thread grid dimensions, and thread grid size; The thread start ID is calculated using the following formula: in, Indicates the thread start ID. Represents the horizontal coordinate of the thread grid, Represents the thread grid ordinate, Represents the vertical coordinate of the thread grid, Grid.x represents the horizontal dimension of the thread grid, Grid.y represents the vertical dimension of the thread grid, and Grid.z represents the third dimension of the thread grid. Indicates the length of the thread block size, Indicates the width of the thread block size.

3. The GPGPU thread block synchronization method based on thread lock according to claim 1, characterized in that: Maintaining the thread lock table corresponding to the thread block specifically includes: The thread lock control module maintains the thread lock table corresponding to the thread block to map the first entry index of the thread lock table corresponding to the thread block to the thread start ID of the thread block; The entry indexes in the thread block except the first entry index are accumulated, and the states of all entries are set to be locked.

4. The GPGPU thread block synchronization method based on thread lock according to claim 1, characterized in that: The thread block scheduling module also includes a memory access control module; When a thread warp of a stream multiprocessor has a memory access requirement, the memory access request is analyzed to see whether it has a dependency relationship with the thread in the currently occupied thread block. If so, the memory access request with the dependency relationship is added to the lock queue, including: In the case where a thread warp of a streaming multiprocessor has a memory access demand, a memory access request is received through a memory access control module, and a dependency analysis is performed on the memory access request to determine whether a thread corresponding to the memory access request has a dependency relationship with a thread in a currently occupied thread block; If not, memory access is performed according to the memory access request; if yes, the memory access request is added to the lock queue of the thread lock control module for queuing.

5. The GPGPU thread block synchronization method based on thread lock according to claim 1, characterized in that: The thread lock control module maintains several thread lock tables and a lock queue. The number of thread lock tables is the same as the number of currently occupied thread blocks. Each currently occupied thread block corresponds to a thread lock table. Querying the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table to add the thread lock state to the entry state corresponding to the lock queue, specifically including: Determine the thread lock table corresponding to the thread block through a thread lock control module, and query the thread lock state of the thread that has a dependency relationship with the memory access request in the corresponding thread lock table; wherein the thread lock state includes a locked state and an unlocked state; In the lock queue of the thread lock control module, an entry state position corresponding to a thread having a dependency relationship with the thread block is determined, and the thread lock state of the corresponding thread is added to the entry state position.

6. The GPGPU thread block synchronization method based on thread lock according to claim 1, characterized in that: After adding the thread lock state to the entry state corresponding to the lock queue, the method further includes: Based on the lock queue, thread lock status monitoring is performed on thread bundles with dependencies, and corresponding monitoring results are obtained by maintaining the monitoring process; When there is a thread lock state change in the monitoring result, the state of the changed entry in the lock queue is updated.

7. The GPGPU thread block synchronization method based on thread lock according to claim 1, characterized in that: The GPGPU device side also includes: an L2 cache; Performing memory access according to the memory access request to achieve synchronization of GPGPU thread blocks specifically includes: The memory access request is forwarded to the L2 cache for memory access, and the access result is returned to the corresponding streaming multiprocessor to achieve synchronization of GPGPU thread blocks.

8. A GPGPU thread block synchronization device based on thread lock, characterized in that: The invention is applied to a GPGPU thread block synchronization system based on thread lock, the system comprises: a host end, a GPGPU device end, the GPGPU device end comprises a thread block scheduling module, a stream multiprocessor and a thread lock control module, the device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the GPGPU thread block synchronization method based on thread lock as described in any one of claims 1-7.

9. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The invention is applied to a GPGPU thread block synchronization system based on thread locks, the system comprising: a Host host end and a GPGPU device end, the GPGPU device end comprising a thread block scheduling module, a stream multiprocessor and a thread lock control module, and when the computer executable instructions are executed, the GPGPU thread block synchronization method based on thread locks as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Dynamic shared memory multiplexing method and device applicable to GPGPU (General Purpose Graphics Processing Unit)

    CN118535356A

  • Memory controller based on perceptual thread bundle

    CN118732958A