Synchronization method and system of GPU (Graphics Processing Unit) thread bundle supporting priority
By assigning priorities to GPU thread warps and performing priority arbitration in the arbitration module, the problem of thread warp synchronization failure and waiting in the existing technology is solved, and the operating efficiency of real-time tasks is improved.
Patent Information
- Application Number
- CN202411280958.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2024-10-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing mutex lock scheme does not consider the priorities of different thread warps. As a result, the thread warps after synchronization failure have to wait for a long time before they can continue to run downward, which cannot meet the real-time requirements.
By setting the priority for assigning tasks to each warp, and conducting arbitration between warps according to the priority in the arbitration module, it is decided whether to release the mutex lock to allow a warp with a higher priority to acquire the lock.
It improves the running efficiency of tasks with higher real-time requirements, ensures the satisfaction of different real-time tasks, and solves the problem of thread warps waiting after synchronization failure.
Smart Images

Figure CN118796400A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of heterogeneous computing technology, and in particular to a priority-supporting GPU thread bundle synchronization method and system. Background Art
[0002] In modern computer systems, graphics processing units (GPUs) are key components for accelerated computing and are widely used in graphics rendering, scientific computing, artificial intelligence, and big data processing. As the complexity and scale of GPU computing tasks continue to increase, how to efficiently manage and schedule GPU threads has become an important issue. In GPUs, in order to improve computing efficiency and resource utilization, threads are divided into four levels: the lowest level is GPU threads; the higher level is warps (warps / wavefronts), which consist of a certain number of GPU threads (usually 32). Multiple warps are further composed of thread blocks; and multiple thread blocks are further composed of grids. Among them, a warp consists of a group of threads that execute simultaneously, and these threads execute the same instructions in the same clock cycle.
[0003] In the same thread block, different thread bundles may compete for certain common storage resources and encounter data contention, that is, different thread bundles have mutually exclusive access to shared data. To achieve this goal, the mainstream solution is to use some atomic operations to set mutual exclusion locks for shared data. When the shared data is not locked, the thread bundle accessing it can lock the data through atomic operations to prevent other thread bundles from accessing the data during the access. If a thread bundle cannot obtain a certain mutual exclusion lock, it will release all the locks it has obtained and try to obtain the lock again after a period of time. This phenomenon is called synchronization failure. It is not difficult to see that when a thread bundle fails to synchronize, it will cause additional execution overhead and reduce parallelism.
[0004] In the current mutex lock schemes, most of them do not consider the priority of different thread bundles, which results in all thread bundles that fail to synchronize having to wait for other thread bundles to actively release the mutex or passively release the mutex due to occupying the mutex for too long before they can continue to run. For tasks with lower real-time requirements, this processing method has little impact, but when processing certain tasks with higher real-time requirements, this method usually does not meet the real-time requirements. Summary of the invention
[0005] An embodiment of the present invention provides a priority-supported GPU thread bundle synchronization method and system, which is used to solve the following technical problem: the current mutex lock scheme does not consider the priority issues of different thread bundles, resulting in the thread bundle after synchronization failure having to wait for a long time before continuing to run downward, which cannot meet the real-time requirements of data access tasks.
[0006] The embodiment of the present invention adopts the following technical solutions: In one aspect, an embodiment of the present invention provides a priority-supporting GPU thread warp synchronization method, the method comprising: assigning tasks to a plurality of thread warps in the same thread block, and setting the priority of each thread warp based on the assigned tasks; Detecting the locking state of the mutex lock applied for by the current thread warp; wherein the locking state is unlocked or locked; If the mutex lock is locked, arbitrating the current thread warp and the thread warp that is occupying the mutex lock based on the priority of the thread warp; According to the arbitration result, it is determined whether the current thread warp can acquire the mutex lock.
[0007] In a feasible implementation, tasks are assigned to several warps in the same thread block, and the priority of each warp is set based on the assigned tasks, specifically including: Get the real-time requirement level of the tasks assigned to each thread warp; According to the order of the real-time requirement level from high to low, corresponding priorities are set for a plurality of thread warps to which tasks are assigned through a competitive priority register; Among them, the thread warp that receives the task with high real-time requirement level is set to high priority; Two or more thread warps that receive tasks with the same real-time requirement level also have the same priority.
[0008] In a feasible implementation manner, detecting the locking state of the mutex lock applied for by the current warp specifically includes: Get the value of the highest storage bit of the mutex lock applied by the current thread warp; If the value of the highest storage bit is 0, it is determined that the mutex lock is not locked, that is, no thread warp currently occupies the mutex lock; If the value of the highest storage bit is 1, it is determined that the mutex lock has been locked, that is, a thread warp currently occupies the mutex lock.
[0009] In a feasible implementation manner, after detecting the locking state of the mutex lock applied for by the current warp, the method further includes: If the mutex lock is not locked, the mutex lock is directly acquired to execute the mutex task, and the ID of the current thread warp is stored in the remaining storage bits of the mutex lock.
[0010] In a feasible implementation manner, after directly acquiring the mutex lock to execute the mutex task, the method further includes: After the current thread warp acquires the mutex lock, each time a task instruction is executed forward, the count value of the counting thread in the current thread warp is increased by one; the initial value of the count value is 0; When the count value reaches a preset upper limit, the current thread warp is controlled to release the mutex lock and the count value is cleared.
[0011] In a feasible implementation manner, if the mutex lock has been locked, arbitration is performed between the current thread warp and the thread warp that is occupying the mutex lock based on the priority of the thread warp, specifically including: An arbitration device is provided in the thread block, and a FIFO queue is provided in the arbitration device; If the mutex lock is currently occupied, obtaining the ID of the thread warp currently occupying the mutex lock in the mutex lock; storing the ID of the thread warp currently occupying the mutex lock and the ID of the current thread warp in the arbitration device; The arbitration device compares the priorities of the thread warp occupying the mutex lock and the current thread warp to perform arbitration.
[0012] In a feasible implementation manner, storing the ID of the thread warp that is occupying the mutex lock and the ID of the current thread warp in the arbitration device specifically includes: The ID of the thread warp currently occupying the mutex lock and the ID of the current thread warp form a thread warp ID pair, and store the pair as an element in the FIFO queue of the arbitration device; The elements in the FIFO queue are taken out in sequence by the arbitration device and arbitrated.
[0013] In a feasible implementation manner, judging whether the current thread warp can acquire the mutex lock according to the arbitration result specifically includes: If the priority of the current thread warp is higher than the priority of the thread warp currently occupying the mutex lock, a signal to release the mutex lock is sent to the thread warp currently occupying the mutex lock, so that the thread warp releases all acquired mutex locks and enables the current thread warp to acquire the mutex lock to perform a mutex task.
[0014] In a feasible implementation manner, judging whether the current thread warp can acquire the mutex lock according to the arbitration result specifically includes: If the priority of the current thread warp is equal to or lower than the priority of the thread warp that is occupying the mutex lock, the current thread warp is made to wait for the mutex lock, and all the mutex locks that have been acquired are released.
[0015] On the other hand, an embodiment of the present invention further provides a synchronization system for GPU thread warps supporting priorities, the system comprising: A priority setting module, used to assign tasks to a plurality of thread warps in the same thread block, and set the priority of each thread warp based on the assigned tasks; An arbitration module is used to detect the locking state of the mutex lock applied for by the current thread warp; wherein the locking state is unlocked or locked; if the mutex lock is locked, the current thread warp and the thread warp that is occupying the mutex lock are arbitrated based on the priority of the thread warp; and according to the arbitration result, it is determined whether the current thread warp can obtain the mutex lock.
[0016] Compared with the prior art, the priority-supporting GPU thread warp synchronization method and system provided by the embodiment of the present invention has the following beneficial effects: The present invention proposes a method of combining priority and time slices to synchronize thread bundles, setting a competitive priority register (CPR) for each thread bundle in a thread block, and specifying the priority of each thread bundle assigned a task by setting the CPR when the host assigns tasks to the thread bundle. At the same time, an arbitration device is set in each thread block to arbitrate the execution of thread bundles that need and have obtained mutex locks. When a thread bundle fails to synchronize when executing a task with synchronization operations, it will not immediately release all the mutex locks that have been obtained, but will find the ID of the thread bundle that has currently obtained the mutex lock through the thread bundle ID value stored in the mutex lock, and send the ID and the thread bundle ID itself to the arbitration device. The arbitration device determines whether to make the thread bundle that has obtained the mutex lock release the mutex lock or to make the thread bundle that requests to obtain the mutex lock wait according to the priorities of the two thread bundles.
[0017] The present invention ensures the real-time performance of thread bundles with higher priorities by setting priorities, thereby solving the problem that thread bundles that fail to synchronize in the current mutex lock scheme must wait for other thread bundles to release the mutex lock before continuing to run downward, thereby improving the running efficiency of tasks with higher real-time requirements and meeting the running requirements of different real-time tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings: Figure 1 A flowchart of a priority-supporting GPU thread warp synchronization method provided by an embodiment of the present invention; Figure 2A flowchart of a specific implementation method of a priority-supporting GPU thread warp synchronization method provided by an embodiment of the present invention; Figure 3 A schematic diagram of a specific architecture of a synchronization system for GPU thread warps supporting priorities provided by an embodiment of the present invention; Figure 4 A schematic diagram of the basic structure of a synchronization system for GPU thread warps supporting priorities provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0020] The embodiment of the present invention provides a method for synchronizing GPU thread bundles that supports priorities, such as Figure 1 As shown, the synchronization method of GPU thread bundles supporting priorities specifically includes steps S101-S104: S101 . Allocate tasks to a plurality of thread warps in the same thread block, and set the priority of each thread warp based on the allocated tasks.
[0021] Specifically, the real-time requirement level of the task assigned to each thread warp is obtained. According to the order of the real-time requirement level from high to low, corresponding priorities are set for the thread warps assigned with the tasks through the competition priority register. Among them, the thread warp that receives the task with a high real-time requirement level is set to a high priority. The priorities of two or more thread warps that receive the task with the same real-time requirement level are also the same.
[0022] As a feasible implementation, the present invention sets a competitive priority register (CPR) for each thread warp in a thread block. When the host assigns tasks to the thread warp, the priority of each thread warp assigned a task is specified by setting the CPR. The priority can be represented by a positive integer, 0 represents the highest priority, and the larger the value, the lower the priority.
[0023] In one embodiment, it is assumed that two tasks with different real-time requirements are task A and task B, which are respectively assigned to warp A and warp B. If the real-time requirement level of task A is higher than that of task B, the priority of warp A is higher than that of warp B. If the real-time requirement level of task A is equal to that of task B, the priority of warp A is equal to that of warp B. If the real-time requirement level of task A is lower than that of task B, the priority of warp A is lower than that of warp B.
[0024] S102: Detect the locking state of the mutex lock applied for by the current thread warp; wherein the locking state is unlocked or locked.
[0025] Specifically, the value of the highest storage bit of the mutex lock applied by the current thread warp is obtained. If the value of the highest storage bit is 0, it is determined that the mutex lock is not locked, that is, no thread warp currently occupies the mutex lock. If the value of the highest storage bit is 1, it is determined that the mutex lock is locked, that is, a thread warp currently occupies the mutex lock.
[0026] Furthermore, if the mutex lock is not locked, the mutex lock is directly acquired to execute the mutex task, and the ID of the current thread warp is stored in the remaining storage bits of the mutex lock.
[0027] As a feasible implementation method, after the current thread bundle acquires the mutex lock, each time a task instruction is executed forward, the count value of the counting thread in the current thread bundle is increased by one; the initial value of the count value is 0. When the count value reaches a preset upper limit, the current thread bundle is controlled to release the mutex lock and the count value is cleared.
[0028] S103: If the mutex lock has been locked, arbitrate between the current warp and the warp that is occupying the mutex lock based on the priorities of the warps.
[0029] Specifically, an arbitration device is set in the thread block, and a FIFO queue is set in the arbitration device. If the mutex lock is being occupied, the ID of the thread warp that is occupying the mutex lock is obtained in the mutex lock.
[0030] Furthermore, the ID of the thread warp currently occupying the mutex lock and the ID of the current thread warp are stored in the arbitration device. Then, the arbitration device compares the priorities of the thread warp currently occupying the mutex lock and the current thread warp to perform arbitration.
[0031] As a feasible implementation method, the ID of the thread warp that is occupying the mutex lock and the ID of the current thread warp are stored in the arbitration device, which specifically includes: The ID of the thread warp that is occupying the mutex lock and the ID of the current thread warp are combined into a thread warp ID pair, and stored as an element in the FIFO queue of the arbitration device. The elements in the FIFO queue are sequentially taken out by the arbitration device and arbitrated.
[0032] S104: According to the arbitration result, determine whether the current thread warp can acquire the mutex lock.
[0033] Specifically, if the priority of the current thread warp is higher than the priority of the thread warp occupying the mutex, a signal to release the mutex is sent to the thread warp occupying the mutex, so that the thread warp releases all acquired mutexes and the current thread warp acquires the mutex to execute the mutex task.
[0034] If the priority of the current thread warp is equal to or lower than the priority of the thread warp that is occupying the mutex, the current thread warp is made to wait for the mutex and all the mutexes that have been acquired are released.
[0035] As a specific implementation method, Figure 2 A flowchart of a specific implementation method of a priority-supporting GPU thread bundle synchronization method provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the specific process of this method is as follows: 1. Figure 3 A schematic diagram of a specific architecture of a synchronization system for GPU thread bundles supporting priorities provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, a competitive priority register (CPR) is set for each thread warp in the thread block. When the host assigns tasks to the thread warp, the priority of each thread warp assigned with a task is specified by setting the CPR. Here, the priority is represented by a positive integer, 0 represents the highest priority, and the larger the value, the lower the priority.
[0036] 2. Execute the synchronization task of each thread bundle and apply for a mutex lock.
[0037] 3. Check whether the mutex is available. The highest bit of the mutex indicates whether it is currently locked, 0 for unlocked and 1 for locked, and the remaining bits store the thread warp ID that obtains the mutex.
[0038] 4. If the mutex lock is available, execute the mutex task directly.
[0039] 5. If the mutex is unavailable, the thread warp fails to synchronize when executing a task with synchronization operations. It will not immediately release all the acquired mutexes, but will find the thread warp ID that has currently acquired the mutex through the thread warp ID value stored in the mutex, and send the ID and the thread warp ID to the arbitration device. Figure 3As shown, the present invention sets an arbitration device in the thread block to arbitrate the execution of the thread warps that need and have obtained the mutex lock. The arbitration device determines whether to make the thread warp that has obtained the mutex lock release the mutex lock or to make the thread warp that requests to obtain the mutex lock wait according to the priorities of the two thread warps.
[0040] 6. Assuming that warp A is the warp requesting to obtain the mutex lock, and warp B is the warp that has obtained the mutex lock, the determination method is as follows: If the priority of thread warp A is higher than that of thread warp B, the arbitration device sends a signal to release the mutex to thread warp B, and thread warp B releases all acquired mutexes after receiving the signal.
[0041] If the priority of thread warp B is equal to or higher than that of thread warp A, thread warp A is made to wait and release all mutex locks it has acquired.
[0042] In order to adapt to the situation where multiple thread warps apply for arbitration at the same time, such as Figure 3 As shown, the present invention sets a FIFO queue in the arbitration device, and each element in the FIFO queue is a thread warp ID pair consisting of the ID of the thread warp requesting to obtain the mutex lock and the ID of the thread warp that has obtained the mutex lock. The arbitration device will process the requests in the FIFO in sequence.
[0043] Furthermore, the present invention reserves a thread in each warp. After the warp acquires the mutex lock, each time an instruction is executed forward, the thread count is increased by 1. After the warp releases the mutex lock, the count value is cleared to 0. When the count value reaches the upper limit, the warp releases all acquired mutex locks to allow other waiting tasks of the same priority to continue to execute.
[0044] In order to make the process of the present invention more clear, the synchronization process is described below by taking an example of synchronization of two thread warps: Assume that two tasks with different real-time requirements are task A and task B, and the real-time requirement of task A is higher than that of task B. Thread bundle B applies for the mutex first.
[0045] S1. Assign tasks A and B to warps 0 and 1, and set the priority of warp 0 to 0 and the priority of warp 1 to 1.
[0046] S2, Thread Warp 1 applies for a mutex lock. At this time, the highest bit value of the mutex lock is 0, indicating that the mutex lock is available. Thread Warp 1 obtains the mutex lock, changes the highest bit value of the mutex lock to 1, and stores the ID of Thread Warp 1: 0x1 in the remaining storage bits of the mutex lock. At the same time, the counting thread in Thread Warp 1 starts counting.
[0047] S3. During the execution of warp 1, warp 0 applies for the same mutex, and the mutex is now occupied by warp 1.
[0048] S4. Warp 0 stores the warp ID 0x1 stored in the mutex and the ID 0x0 of the warp itself into the request FIFO queue of the arbitration device.
[0049] S5. The arbitration device detects that the FIFO queue is not empty, starts processing the arbitration request, and determines that the priority of thread warp 0 is higher than that of thread warp 1.
[0050] S6. The arbitration device sends a signal to warp 1 to release the mutex lock.
[0051] S7: Thread warp 1 receives a signal to release the mutex lock and releases the mutex lock.
[0052] S8. Thread warp 0 successfully requests arbitration, acquires the mutex lock, and continues to execute tasks. At the same time, the counting thread in thread warp 0 starts counting.
[0053] In addition, an embodiment of the present invention further provides a synchronization system for GPU thread bundles supporting priorities, such as Figure 4 As shown, the synchronization system 400 for GPU thread warps supporting priorities specifically includes: A priority setting module 410, for assigning tasks to a plurality of thread warps in the same thread block, and setting the priority of each thread warp based on the assigned tasks; The arbitration module 420 is used to detect the locking state of the mutex lock applied for by the current thread warp; wherein the locking state is unlocked or locked; if the mutex lock is locked, then based on the priority of the thread warp, the current thread warp and the thread warp that is occupying the mutex lock are arbitrated; based on the arbitration result, it is determined whether the current thread warp can obtain the mutex lock.
[0054] like Figure 3 As shown, the present invention sets an arbitration device in each thread block to arbitrate the execution of the thread warps that need and have obtained the mutex lock, which includes the set arbitration logic. In order to adapt to the situation where multiple thread warps apply for arbitration at the same time, a FIFO first-in-first-out queue is set in the arbitration device. Each element in the FIFO is a thread warp ID pair consisting of the ID of the thread warp requesting to obtain the mutex lock and the ID of the thread warp that has obtained the mutex lock. The arbitration device will process the requests in the FIFO in sequence.
[0055] The present invention also reserves a counting thread in each thread bundle. After the thread bundle obtains the mutex lock, each time an instruction is executed forward, the count of the counting thread is increased by 1. After the thread bundle releases the mutex lock, the count value is cleared to 0. When the count value reaches the upper limit, the thread bundle releases all the acquired mutex locks to allow other waiting tasks of the same priority to continue to execute. The setting of the counting thread can ensure that the mutex lock will not be occupied by the same thread bundle for too long, and the real-time performance of other thread bundles is guaranteed.
[0056] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0057] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0058] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0059] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0060] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0061] Each embodiment of the present invention is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0062] The above describes specific embodiments of the present invention. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0063] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for synchronizing GPU thread warps supporting priorities, characterized in that: The method comprises: Assign tasks to several warps in the same thread block and set the priority of each warp based on the assigned tasks; Detecting the locking state of the mutex lock applied for by the current thread warp; wherein the locking state is unlocked or locked; If the mutex lock is locked, arbitrating the current thread warp and the thread warp that is occupying the mutex lock based on the priority of the thread warp; According to the arbitration result, it is determined whether the current thread warp can acquire the mutex lock.
2. The method for synchronizing GPU thread warps supporting priorities according to claim 1, characterized in that: Assign tasks to several warps in the same thread block and set the priority of each warp based on the assigned tasks, including: Get the real-time requirement level of the tasks assigned to each thread warp; According to the order of the real-time requirement level from high to low, corresponding priorities are set for a plurality of thread warps to which tasks are assigned through a competitive priority register; Among them, the thread warp that receives the task with high real-time requirement level is set to high priority; Two or more thread warps that receive tasks with the same real-time requirement level also have the same priority.
3. The method for synchronizing GPU thread warps supporting priorities according to claim 1, characterized in that: Check the lock status of the mutex lock applied by the current thread warp, including: Get the value of the highest storage bit of the mutex lock applied by the current thread warp; If the value of the highest storage bit is 0, it is determined that the mutex lock is not locked, that is, no thread warp currently occupies the mutex lock; If the value of the highest storage bit is 1, it is determined that the mutex lock has been locked, that is, a thread warp currently occupies the mutex lock.
4. The method for synchronizing GPU thread warps supporting priorities according to claim 3, characterized in that: After detecting the locking state of the mutex lock applied for by the current warp, the method further includes: If the mutex lock is not locked, the mutex lock is directly acquired to execute the mutex task, and the ID of the current thread warp is stored in the remaining storage bits of the mutex lock.
5. The method for synchronizing GPU thread warps supporting priorities according to claim 4, characterized in that: After directly acquiring the mutex lock to execute the mutex task, the method further includes: After the current thread warp acquires the mutex lock, each time a task instruction is executed forward, the count value of the counting thread in the current thread warp is increased by one; the initial value of the count value is 0; When the count value reaches a preset upper limit, the current thread warp is controlled to release the mutex lock and the count value is cleared.
6. The method for synchronizing GPU thread warps supporting priorities according to claim 1, characterized in that: If the mutex lock is locked, the current thread warp and the thread warp that is occupying the mutex lock are arbitrated based on the priority of the thread warp, specifically including: An arbitration device is provided in the thread block, and a FIFO queue is provided in the arbitration device; If the mutex lock is currently occupied, obtaining the ID of the thread warp currently occupying the mutex lock in the mutex lock; storing the ID of the thread warp currently occupying the mutex lock and the ID of the current thread warp in the arbitration device; The arbitration device compares the priorities of the thread warp occupying the mutex lock and the current thread warp to perform arbitration.
7. The method for synchronizing GPU warps supporting priorities according to claim 6, characterized in that: Storing the ID of the thread warp that is occupying the mutex lock and the ID of the current thread warp in the arbitration device specifically includes: The ID of the thread warp currently occupying the mutex lock and the ID of the current thread warp form a thread warp ID pair, and store the pair as an element in the FIFO queue of the arbitration device; The elements in the FIFO queue are taken out in sequence by the arbitration device and arbitrated.
8. The method for synchronizing GPU warps supporting priorities according to claim 6, characterized in that: According to the arbitration result, it is determined whether the current thread warp can acquire the mutex lock, specifically including: If the priority of the current thread warp is higher than the priority of the thread warp currently occupying the mutex lock, a signal to release the mutex lock is sent to the thread warp currently occupying the mutex lock, so that the thread warp releases all acquired mutex locks and enables the current thread warp to acquire the mutex lock to perform a mutex task.
9. The method for synchronizing GPU warps supporting priorities according to claim 6, characterized in that: According to the arbitration result, it is determined whether the current thread warp can acquire the mutex lock, which specifically includes: If the priority of the current thread warp is equal to or lower than the priority of the thread warp that is occupying the mutex lock, the current thread warp is made to wait for the mutex lock, and all the mutex locks that have been acquired are released.
10. A synchronization system for GPU thread warps supporting priorities, characterized in that: The system comprises: A priority setting module, used to assign tasks to a plurality of thread warps in the same thread block, and set the priority of each thread warp based on the assigned tasks; An arbitration module is used to detect the locking state of the mutex lock applied for by the current thread warp; wherein the locking state is unlocked or locked; if the mutex lock is locked, the current thread warp and the thread warp that is occupying the mutex lock are arbitrated based on the priority of the thread warp; and according to the arbitration result, it is determined whether the current thread warp can obtain the mutex lock.
Citation Information
Patent Citations
Task processing method, device and equipment and computer readable storage medium
CN111400330A
Mutual exclusion resource access method based on single-chip microcomputer platform without operating system
CN112286697A
Process communication method and system, server and storage medium
CN112769640A
Mutual exclusion process scheduling method and device, electronic equipment and storage medium
CN117519928A
Multi-port communication system and method
CN117896201A
Cited By
GPGPU (General Purpose Graphics Processing Unit) thread block synchronization method and equipment based on thread lock and medium
CN119557115A
