Graphics processor resource management methods, apparatus, electronic devices, and readable media
By merging the memory resources of the stagnant streaming multiprocessors in the graphics processor and allocating memory resources to the target thread bundle, the access conflicts and thread deadlocks caused by the uncoordinated resource allocation in the prior art are resolved, thereby improving the operating efficiency and performance of the graphics processor.
Patent Information
- Application Number
- CN202211376222.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2042-11-04
AI Technical Summary
Existing graphics processor memory resource allocation mechanisms fail to effectively coordinate resource demands, leading to access conflicts and thread deadlocks, which reduces the operating efficiency of graphics processors.
By detecting stagnant streaming multiprocessors in the graphics processing unit, merging their remaining memory resources with those of other streaming multiprocessors, and using the thread scheduler to allocate memory resources to the target thread bundle, the goal is to ensure that the thread bundle can execute instructions efficiently.
It improves the resource utilization efficiency of streaming processors in the graphics processor, reduces resource allocation errors and access errors, avoids thread termination, and enhances the performance of the graphics processor.
Smart Images

Figure CN115760541B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of testing technology, and in particular to a memory resource management method for a graphics processor, a memory resource management device for a graphics processor, an electronic device, and a computer-readable medium. Background Technology
[0002] In recent years, with the development of high-performance computing, large-scale computing has placed significant demands on the capabilities of the central processing unit (CPU). Graphics processing units (GPUs) have gradually demonstrated their advantages in computing performance, and optimizing GPU performance has become a hot research topic. GPU resources are divided into two parts: computing resources and memory resources. Compared to computing resources, memory resources are one of the most crucial resources for GPUs.
[0003] In existing technologies, the allocation of memory resources in a graphics processing unit (GPU) typically employs a memory resource pool mechanism. This mechanism groups the available memory resources within the GPU into a pool and uses function interfaces and scheduling algorithms to achieve dynamic allocation. Different threads can access different memory resources, reducing resource access conflicts that can occur during multi-threaded execution.
[0004] However, existing memory resource allocation mechanisms primarily optimize resource allocation and scheduling based on the dependencies between threads, without considering the coordination of resource demands. When resource allocation errors occur or a large number of concurrent threads request resource allocation, access conflicts and memory contention can easily arise, leading to thread deadlocks in the graphics processor and reducing its operating efficiency. Summary of the Invention
[0005] In view of the above problems, embodiments of the present invention are proposed to provide a memory resource management method for a graphics processor, a memory resource management device for a graphics processor, an electronic device, and a computer-readable medium.
[0006] This invention provides a method for managing memory resources of a graphics processor, wherein the graphics processor includes a plurality of streaming multiprocessors, and at least one thread bundle runs in the streaming multiprocessor;
[0007] The method includes:
[0008] Detect whether there is a stagnant streaming multiprocessor in the graphics processor;
[0009] If there is a streaming multiprocessor in a stagnant state, the remaining memory resources of the stagnant streaming multiprocessor are merged with the remaining memory resources of at least one other streaming multiprocessor.
[0010] Identify at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle;
[0011] Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle through a preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources.
[0012] Optionally, the streaming multiprocessors are sequentially configured with a first sequence number;
[0013] The step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor includes:
[0014] According to the first sequence number, the remaining memory resources of the stagnant streaming multiprocessor are merged with the remaining memory resources of at least one other streaming multiprocessor.
[0015] Optionally, the step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor according to the first sequence number includes:
[0016] The streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor in the stagnant state are designated as the streaming multiprocessors to be merged.
[0017] The remaining memory resources of the stream multiprocessor that is in a stagnant state are used as the remaining memory resources to be used;
[0018] The remaining memory resources to be used are merged with the remaining memory resources of the streaming multiprocessors to be merged to obtain new remaining memory resources to be used.
[0019] Determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor.
[0020] If the remaining memory resources after merging do not meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged is taken as the new streaming multiprocessor to be merged. The step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used is repeated until the remaining memory resources to be used meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor.
[0021] Optionally, the thread bundles in the streaming processor are sequentially configured with a second sequence number;
[0022] The step of determining whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor includes:
[0023] Sequentially determine whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor.
[0024] Optionally, the step of detecting whether there is a stagnant streaming multiprocessor in the graphics processor includes:
[0025] Detect whether the thread bundles in the streaming multiprocessor can acquire memory resources;
[0026] If the thread bundle in the streaming multiprocessor cannot acquire memory resources, it is determined that there is a stagnant streaming multiprocessor in the graphics processor.
[0027] Optionally, the method further includes:
[0028] If the target thread bundle completes the execution of the instruction, the memory resources occupied by the target thread bundle are released.
[0029] Optionally, the method further includes:
[0030] Calculate the remaining memory resources for each streaming multiprocessor in the graphics processor.
[0031] This invention also provides a memory resource management device for a graphics processor, the graphics processor including a plurality of streaming multiprocessors, wherein at least one thread bundle runs in the streaming multiprocessor;
[0032] The device includes:
[0033] The detection module is used to detect whether there is a stagnant streaming multiprocessor in the graphics processor;
[0034] The resource merging module is used to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor if there is a stagnant streaming multiprocessor.
[0035] The target thread bundle determination module is used to determine at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle;
[0036] The reallocation module is used to allocate memory resources to the target thread bundle based on the merged remaining memory resources through a preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources.
[0037] Optionally, the streaming multiprocessors are sequentially configured with a first sequence number; the resource merging module includes:
[0038] The resource merging submodule is used to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor in the order of the first sequence number.
[0039] Optionally, the resource merging submodule includes:
[0040] The streaming processor determination unit is used to identify streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor in the stagnant state as streaming multiprocessors to be merged.
[0041] The unit for determining remaining memory resources to be used is used to determine the remaining memory resources of the streaming multiprocessor in a stagnant state as remaining memory resources to be used.
[0042] The first resource merging unit is used to merge the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used.
[0043] The demand determination unit is used to determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor.
[0044] The second resource merging unit is used to, if the merged remaining memory resources do not meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, take the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged as the new streaming multiprocessor to be merged, and repeat the step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used, until the remaining memory resources to be used meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor.
[0045] Optionally, the thread bundles in the streaming processor are sequentially configured with a second sequence number; the demand determination unit includes:
[0046] The demand determination subunit is used to sequentially determine whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor.
[0047] Optionally, the detection module includes:
[0048] The thread bundle detection submodule is used to detect whether the thread bundle in the streaming multiprocessor can acquire memory resources.
[0049] The detection and determination submodule is used to determine that there is a stagnant streaming multiprocessor in the graphics processor if the thread bundle in the streaming multiprocessor cannot acquire memory resources.
[0050] Optionally, the device further includes:
[0051] The resource release module is used to release the memory resources occupied by the target thread bundle if the target thread bundle completes the execution of the instruction.
[0052] Optionally, the device further includes:
[0053] The remaining memory resource calculation module is used to calculate the remaining memory resources of each streaming multiprocessor in the graphics processor.
[0054] This invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0055] The memory is used to store computer programs;
[0056] When the processor executes the program stored in the memory, it implements the heterogeneous server stability testing method as described in the embodiments of the present invention.
[0057] This invention also discloses one or more computer-readable media storing instructions that, when executed by one or more processors, cause the processors to perform the heterogeneous server stability testing method as described in this invention.
[0058] The embodiments of the present invention have the following advantages:
[0059] The memory resource management method for a graphics processing unit (GPU) according to embodiments of the present invention detects whether there are any stagnant streaming multiprocessors in the GPU. If such stagnant streaming multiprocessors exist, their remaining memory resources are merged with the remaining memory resources of at least one other streaming multiprocessor. At least one thread bundle to be executed from the stagnant streaming multiprocessor is identified as a target thread bundle. Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle by a preset thread scheduler in the GPU, so that the target thread bundle executes preset instructions based on the reallocated memory resources. This allows for the rational allocation of remaining memory resources in the streaming multiprocessor, enabling the thread bundles in the streaming multiprocessor to run efficiently, improving the resource utilization efficiency of the streaming multiprocessors in the GPU, reducing resource allocation and access errors within the GPU, and preventing thread termination in the GPU, thereby effectively improving the performance of the GPU. Attached Figure Description
[0060] Figure 1 This is a flowchart of the steps of a memory resource management method for a graphics processor provided in an embodiment of the present invention;
[0061] Figure 2 This is a flowchart of another method for managing memory resources of a graphics processor provided in an embodiment of the present invention;
[0062] Figure 3 This is a flowchart illustrating a memory resource management method for a graphics processor provided in an embodiment of the present invention;
[0063] Figure 4 This is a structural block diagram of a memory resource management device for a graphics processor provided in an embodiment of the present invention;
[0064] Figure 5 This is a block diagram of an electronic device provided in an embodiment of the present invention;
[0065] Figure 6 This is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. Detailed Implementation
[0066] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0067] Reference Figure 1 The diagram illustrates a flowchart of a memory resource management method for a graphics processor provided in an embodiment of the present invention. The graphics processor includes several streaming multiprocessors, and at least one thread bundle runs in each streaming multiprocessor.
[0068] A graphics processing unit (GPU) can include several streaming processors (SPs), which are the most basic processing units in a GPU. A GPU achieves parallel computing by having multiple streaming processors run simultaneously. Multiple streaming processors, along with control units, registers, caches, and other resources, can form a streaming multiprocessor (SM). Within a streaming multiprocessor, streaming processors can be divided into several warps. A warp is the scheduling unit for program execution in a GPU; threads within the same warp can execute the same instructions.
[0069] The memory resource management method for a graphics processor according to embodiments of the present invention specifically includes the following steps:
[0070] Step 101: Detect whether there is a stagnant streaming multiprocessor in the graphics processor;
[0071] When a graphics processing unit (GPU) experiences resource allocation errors and a large number of concurrent threads requesting resource allocation, access conflicts and memory contention can easily occur, causing threads in the streaming multiprocessor to run out of memory resources, resulting in the streaming multiprocessor entering a stalled state where it cannot execute instructions. This invention can detect in real time whether there are any stalled streaming multiprocessors in the GPU to determine whether adjustments to the GPU's memory resources are needed.
[0072] Step 102: If there is a streaming multiprocessor in a stagnant state, merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor.
[0073] If there are stagnant streaming multiprocessors in the graphics processing unit (GPU), it can be assumed that memory resources need to be reallocated to the streaming multiprocessors that are unable to acquire memory resources so that the GPU can run normally and efficiently.
[0074] In a graphics processing unit (GPU), streaming multiprocessors can have unused spare memory resources. These spare memory resources can be those pre-requested for allocation by the streaming multiprocessor but remain unused, or those already used by the streaming multiprocessor but not released in a timely manner. In this case, the spare memory resources of at least one other streaming multiprocessor can be sequentially merged with the spare memory resources of the stagnant streaming multiprocessor. The merged spare memory resources are then allocated to the stagnant streaming multiprocessor, increasing the available spare memory resources for the stagnant streaming multiprocessor.
[0075] If there are no stalled streaming multiprocessors in the graphics processing unit, then there is no need to reallocate memory resources for the streaming multiprocessors, and the streaming multiprocessors can continue to run their thread bundles as they are currently.
[0076] Step 103: Determine at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle;
[0077] In a stagnant streaming multiprocessor, there can be at least one thread bundle awaiting execution. This thread bundle may be temporarily unable to run due to insufficient remaining memory resources in the streaming multiprocessor. After the streaming multiprocessor acquires more memory resources, the thread bundle awaiting execution is designated as the target thread bundle so that memory resources can be allocated to it subsequently.
[0078] Step 104: Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle through the preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources.
[0079] A thread scheduler may be pre-configured in the graphics processor. The thread scheduler can be used to schedule the thread bundles of each streaming multiprocessor in the graphics processor so that the thread bundles can be executed in the order specified by the thread scheduler.
[0080] After a stagnant streaming multiprocessor acquires the merged remaining memory resources, at least one target thread bundle within the streaming multiprocessor can run based on these merged remaining memory resources. In this case, the thread scheduler can allocate memory resources to the target thread bundle, allowing it to execute pre-configured instructions based on the allocated memory resources. At this point, the stagnant streaming multiprocessor can execute instructions, thus escaping its stagnant state and enabling efficient operation, thereby improving the resource utilization efficiency of the streaming multiprocessor.
[0081] After a stagnant streaming multiprocessor acquires the merged remaining memory resources, there may not be any target thread bundle in the streaming multiprocessor that can run based on the merged remaining memory resources. In this case, step 102 can be continued to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor, thereby continuing to increase the remaining memory resources in the stagnant streaming multiprocessor until an executable target thread bundle appears in the streaming multiprocessor.
[0082] The memory resource management method for a graphics processing unit (GPU) according to embodiments of the present invention detects whether there are any stagnant streaming multiprocessors in the GPU. If such stagnant streaming multiprocessors exist, their remaining memory resources are merged with the remaining memory resources of at least one other streaming multiprocessor. At least one thread bundle to be executed from the stagnant streaming multiprocessor is identified as a target thread bundle. Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle by a preset thread scheduler in the GPU, so that the target thread bundle executes preset instructions based on the reallocated memory resources. This allows for the rational allocation of remaining memory resources in the streaming multiprocessor, enabling the thread bundles in the streaming multiprocessor to run efficiently, improving the resource utilization efficiency of the streaming multiprocessors in the GPU, reducing resource allocation and access errors within the GPU, and preventing thread termination in the GPU, thereby effectively improving the performance of the GPU.
[0083] Reference Figure 2 The diagram illustrates a flowchart of a memory resource management method for a graphics processor according to an embodiment of the present invention. The graphics processor includes several streaming multiprocessors, and at least one thread bundle runs in each streaming multiprocessor. The memory resource management method for a graphics processor according to this embodiment of the present invention specifically includes the following steps:
[0084] Step 201: Detect whether there is a stagnant streaming multiprocessor in the graphics processor;
[0085] This invention can detect in real time whether there are stagnant streaming multiprocessors in the graphics processor, in order to determine whether the memory resources in the graphics processor need to be adjusted.
[0086] In one embodiment of the present invention, the step of detecting whether there is a stagnant streaming multiprocessor in the graphics processor includes:
[0087] S11, Detect whether the thread bundle in the streaming multiprocessor can acquire memory resources;
[0088] When a graphics processing unit (GPU) experiences resource allocation errors or a large number of concurrent threads requesting resource allocation, access conflicts and memory contention can easily occur. If a thread in a streaming multiprocessor attempts to access memory while executing predefined instructions, a situation may arise where no memory resources are available, causing the streaming multiprocessor to enter a stalled state where it cannot execute instructions. Therefore, it is possible to detect whether a thread in a streaming multiprocessor can acquire memory resources to determine if a streaming multiprocessor is in a stalled state.
[0089] S12, if the thread bundle in the streaming multiprocessor cannot acquire memory resources, it is determined that there is a streaming multiprocessor in the graphics processor that is in a stagnant state.
[0090] If a thread bundle in a streaming multiprocessor cannot acquire memory resources, then the thread bundle may not be able to run normally in the streaming multiprocessor, thus confirming that there is a stagnant streaming multiprocessor in the graphics processor.
[0091] In one embodiment of the present invention, the method further includes:
[0092] S21, calculate the remaining memory resources of each streaming multiprocessor in the graphics processor.
[0093] Specifically, before detecting whether there are any stagnant streaming multiprocessors in the graphics processor, the remaining memory resources of each streaming multiprocessor in the graphics processor can be calculated so that resource merging between streaming multiprocessors can be completed efficiently when resource merging is required.
[0094] Step 202: If there are any streaming multiprocessors in a stagnant state, the remaining memory resources of the stagnant streaming multiprocessors are merged with the remaining memory resources of at least one other streaming multiprocessor in the order of the first sequence number.
[0095] If there are stagnant streaming multiprocessors in the graphics processing unit (GPU), it can be assumed that memory resources need to be reallocated to the streaming multiprocessors that are unable to acquire memory resources so that the GPU can run normally and efficiently.
[0096] In a graphics processing unit (GPU), streaming multiprocessors can have unused spare memory resources. These spare memory resources can be those pre-requested for allocation by the streaming multiprocessor but remain unused, or those already used by the streaming multiprocessor but not released in a timely manner. In this case, the spare memory resources of at least one other streaming multiprocessor can be sequentially merged with the spare memory resources of the stagnant streaming multiprocessor. The merged spare memory resources are then allocated to the stagnant streaming multiprocessor, increasing the available spare memory resources for the stagnant streaming multiprocessor.
[0097] The streaming multiprocessors in the graphics processing unit (GPU) can be sequentially configured with a first sequence number, allowing them to be arranged according to this sequence. When a streaming multiprocessor is in a stalled state, to facilitate efficient merging of memory resources, the remaining memory resources of the stalled streaming multiprocessor can be merged with the remaining memory resources of at least one other streaming multiprocessor, according to the first sequence number. For example, the remaining memory resources of the streaming multiprocessor with the earlier sequence number can be merged with those of the stalled streaming multiprocessor; the remaining memory resources of the streaming multiprocessor with the later sequence number can be merged with those of the stalled streaming multiprocessor; or the remaining memory resources of the streaming multiprocessor whose sequence number is adjacent to that of the stalled streaming multiprocessor can be merged with those of the stalled streaming multiprocessor, etc. This invention does not limit the scope of these methods.
[0098] In one embodiment of the present invention, the step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor according to the first sequence number includes:
[0099] S31, the streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor in the stagnant state are taken as the streaming multiprocessors to be merged.
[0100] Specifically, to ensure that streaming multiprocessors in the graphics processor can function properly, streaming multiprocessors whose first sequence number is adjacent to the first sequence number of a stagnant streaming multiprocessor can be designated as streaming multiprocessors to be merged. For example, if the first sequence number of a stagnant streaming multiprocessor is SM5, then a streaming multiprocessor with the first sequence number SM6 can be designated as a streaming multiprocessor to be merged.
[0101] S32, the remaining memory resources of the stream multiprocessor that is in a stagnant state are used as remaining memory resources to be used;
[0102] In a stagnant streaming multiprocessor, there may be some remaining memory resources. These resources may be insufficient to support the execution of thread bundles within the streaming multiprocessor, but they are still usable and can be used by thread bundles after merging memory resources. Therefore, the remaining memory resources of a stagnant streaming multiprocessor can be considered as unused remaining memory resources.
[0103] S33, merge the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used;
[0104] After determining the remaining memory resources to be used, the remaining memory resources of the streaming multiprocessors to be merged can be allocated to the streaming multiprocessors that are in a stagnant state, and merged with the original remaining memory resources to be used, thereby obtaining new remaining memory resources to be used.
[0105] S34, determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor;
[0106] After acquiring new available remaining memory resources, it can be determined whether these new remaining memory resources meet the usage requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, so as to determine whether the thread bundles to be executed can continue to run and allow the streaming multiprocessor to get out of the stagnant state.
[0107] S35, if the merged remaining memory resources do not meet the requirements of the thread bundle to be executed in the stagnant streaming multiprocessor, the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged is taken as the new streaming multiprocessor to be merged, and the step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used is repeated until the remaining memory resources to be used meet the requirements of the thread bundle to be executed in the stagnant streaming multiprocessor.
[0108] If the remaining memory resources after merging are insufficient to meet the needs of the thread bundles awaiting execution in the stagnant streaming multiprocessor, further merging of more remaining memory resources is necessary to allow the streaming multiprocessor to escape the stagnant state. In this case, the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged can be designated as a new streaming multiprocessor to be merged. For example, if the first sequence number of the stagnant streaming multiprocessor is SM5, and the first sequence number of the current streaming multiprocessor to be merged is SM6, then the streaming multiprocessor whose first sequence number is adjacent to SM6, i.e., its first sequence number is SM7, can be designated as the new streaming multiprocessor to be merged.
[0109] Subsequently, steps S33 to S35 can be repeated to merge the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessors to be merged, resulting in new remaining memory resources to be used. Then, it is determined whether the remaining memory resources to be used meet the needs of the thread bundles to be executed in the stalled streaming multiprocessors. If the needs are not met, new streaming multiprocessors to be merged need to be identified, and the remaining memory resources are merged. If the needs are met, the merging of remaining memory resources can be stopped, thereby allocating sufficient remaining memory resources to the stalled streaming multiprocessors.
[0110] In one embodiment of the present invention, the step of determining whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor includes:
[0111] S41, sequentially determine whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor.
[0112] Specifically, the thread bundles to be executed in the streaming processor can be configured with a second sequence number in sequence. It can be determined in sequence whether the remaining memory resources to be used meet the needs of any of the target thread bundles in the streaming multiprocessor in the stagnant state, so as to confirm whether there is any target thread bundle in the streaming multiprocessor in the stopped state that can run based on the remaining memory resources to be used.
[0113] For example, a streaming multiprocessor may contain thread bundles W1, W2, and W3 to be executed. First, it can be determined whether thread bundle W1 can run based on the available remaining memory resources. If it can, then the available remaining memory resources can satisfy the needs of any thread bundle to be executed in the stalled streaming multiprocessor. If it cannot run, then it can be determined whether thread bundle W2 can run based on the available remaining memory resources. If, after iterating through thread bundles W1, W2, and W3, none of them can run based on the available remaining memory resources, then it can be considered that the available remaining memory resources do not satisfy the needs of any thread bundle to be executed in the stalled streaming multiprocessor.
[0114] Step 203: Determine at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle;
[0115] After the streaming multiprocessor acquires more memory resources, the thread bundle to be executed can be used as the target thread bundle so that memory resources can be allocated to the target thread bundle in the future.
[0116] In a specific implementation, after determining in sequence whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor, if there is a thread bundle to be executed that can run based on the remaining memory resources to be used, then the thread bundle to be executed can be taken as the target thread bundle.
[0117] Step 204: Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle through the preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources.
[0118] A thread scheduler may be pre-configured in the graphics processor. The thread scheduler can be used to schedule the thread bundles of each streaming multiprocessor in the graphics processor so that the thread bundles can be executed in the order specified by the thread scheduler.
[0119] After a stagnant streaming multiprocessor acquires the merged remaining memory resources, at least one target thread bundle within the streaming multiprocessor can run based on these merged remaining memory resources. In this case, the thread scheduler can allocate memory resources to the target thread bundle, allowing it to execute pre-configured instructions based on the allocated memory resources. At this point, the stagnant streaming multiprocessor can execute instructions, thus escaping its stagnant state and enabling efficient operation, thereby improving the resource utilization efficiency of the streaming multiprocessor.
[0120] After a stagnant streaming multiprocessor acquires the merged remaining memory resources, there may not be any target thread bundle in the streaming multiprocessor that can run based on the merged remaining memory resources. In this case, step 202 can be continued, merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor in the first sequence number order, thereby continuing to increase the remaining memory resources in the stagnant streaming multiprocessor until an executable target thread bundle appears in the streaming multiprocessor.
[0121] In one embodiment of the present invention, the method further includes:
[0122] S51, if the target thread bundle completes the execution of the instruction, release the memory resources occupied by the target thread bundle.
[0123] Once the target thread has completed the execution of its preset instructions, it can enter an idle state without needing to continue processing instructions. In this case, to prevent other thread bundles from running out of available memory resources, the memory resources occupied by the target thread bundle can be released promptly, thereby achieving efficient utilization of memory resources in the graphics processor.
[0124] The memory resource management method for a graphics processing unit (GPU) according to embodiments of the present invention detects whether there are any stagnant streaming multiprocessors in the GPU. If such stagnant streaming multiprocessors exist, their remaining memory resources are merged with the remaining memory resources of at least one other streaming multiprocessor according to the first sequence number. At least one thread bundle to be executed in the stagnant streaming multiprocessor is identified as the target thread bundle. Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle by a preset thread scheduler in the GPU, so that the target thread bundle executes preset instructions based on the reallocated memory resources. This allows for the rational allocation of remaining memory resources in the streaming multiprocessor, enabling the thread bundles in the streaming multiprocessor to run efficiently, improving the resource utilization efficiency of the streaming multiprocessors in the GPU, reducing resource allocation and access errors within the GPU, and preventing thread termination in the GPU, thereby effectively improving the performance of the GPU.
[0125] As a specific example of the present invention, refer to Figure 3 The diagram illustrates a flowchart of a memory resource management method for a graphics processor provided in an embodiment of the present invention. The graphics processor includes n streaming multiprocessors, and each streaming multiprocessor runs s threads.
[0126] The memory resource management methods of a graphics processor may include:
[0127] Step 301: Calculate the values of each streaming multiprocessor SM1, SM2, ..., SM in the graphics processor. n The remaining memory resources;
[0128] Step 302: Determine if there are any streaming multiprocessors (SMs) in a stagnant state. i If it exists, proceed to step 303; if it does not exist, proceed to step 311.
[0129] Step 303: Select the streaming multiprocessor SM adjacent to the stagnant streaming multiprocessor. j As a streaming multiprocessor to be merged; where j = i + 1;
[0130] Step 304, the streaming multiprocessor SM that is in a stagnant state... i The remaining memory resources are designated as unused remaining memory resources, and these unused remaining memory resources are combined with the streaming multiprocessors (SMs) to be merged. j The remaining memory resources are merged to obtain new remaining memory resources to be used; at the same time, the second sequence number a = 1 is set for the thread bundle to be executed.
[0131] Step 305: Determine whether the remaining memory resources to be used meet the requirements of the stagnant streaming multiprocessor (SM). i Warp thread bundles awaiting execution a The requirement is (a≤s). If satisfied, then Warp will be executed. a If the target thread bundle is not satisfied, then step 309 is executed; if not, then step 306 is executed.
[0132] Step 306: Execute a++ to increment the value of a, i.e., a = a + 1, thereby selecting the thread bundle to be executed that is adjacent to the currently judged thread bundle in the second sequence as the thread bundle to be judged.
[0133] Step 307: Determine if a is less than or equal to s. If so, the streaming multiprocessor SM is in a stagnant state. i If the pending thread bundle has not been traversed completely, return to step 305; otherwise, the streaming multiprocessor SM remains in a stalled state. i If the thread bundles to be executed have been traversed and there are no thread bundles to be executed that can run based on the remaining memory resources to be used, then continue to execute step 308.
[0134] Step 308: Execute j++ to increment the value of j, i.e., j = j + 1, thereby selecting the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged as the new streaming multiprocessor to be merged, and then return to execute step 304.
[0135] Step 309: Using a preset thread scheduler, based on the remaining memory resources to be used, create a warp for the thread bundle. a Allocate memory resources, thread bundle warp a It can execute preset commands;
[0136] Step 310, determine thread bundle Warp a Has the preset instruction been completed? If yes, proceed to step 313; otherwise, continue to step 310.
[0137] Step 311: Allocate resources to thread bundles in each streaming multiprocessor using a preset thread scheduler;
[0138] Step 312: The thread bundle executes preset instructions in the order specified by the thread scheduler;
[0139] Step 313: Release the memory resources occupied by the thread bundle;
[0140] Step 314: Determine whether the program has finished executing and whether it is necessary to continue managing the memory resources of the graphics processor; if yes, return to step 301; otherwise, the program will end.
[0141] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0142] Reference Figure 4 The diagram shows a structural block diagram of a memory resource management system for a graphics processor provided in an embodiment of the present invention. The graphics processor includes several streaming multiprocessors, and at least one thread bundle runs in each streaming multiprocessor.
[0143] The device includes:
[0144] Detection module 401 is used to detect whether there is a streaming multiprocessor in the graphics processor that is in a stagnant state;
[0145] The resource merging module 402 is used to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor if there is a stagnant streaming multiprocessor.
[0146] The target thread bundle determination module 403 is used to determine at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle;
[0147] The reallocation module 404 is used to allocate memory resources to the target thread bundle based on the merged remaining memory resources through a preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources.
[0148] Optionally, the streaming multiprocessors are sequentially configured with a first sequence number; the resource merging module includes:
[0149] The resource merging submodule is used to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor in the order of the first sequence number.
[0150] Optionally, the resource merging submodule includes:
[0151] The streaming processor determination unit is used to identify streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor in the stagnant state as streaming multiprocessors to be merged.
[0152] The unit for determining remaining memory resources to be used is used to determine the remaining memory resources of the streaming multiprocessor in a stagnant state as remaining memory resources to be used.
[0153] The first resource merging unit is used to merge the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used.
[0154] The demand determination unit is used to determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor.
[0155] The second resource merging unit is used to, if the merged remaining memory resources do not meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, take the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged as the new streaming multiprocessor to be merged, and repeat the step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used, until the remaining memory resources to be used meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor.
[0156] Optionally, the thread bundles in the streaming processor are sequentially configured with a second sequence number; the demand determination unit includes:
[0157] The demand determination subunit is used to sequentially determine whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor.
[0158] Optionally, the detection module includes:
[0159] The thread bundle detection submodule is used to detect whether the thread bundle in the streaming multiprocessor can acquire memory resources.
[0160] The detection and determination submodule is used to determine that there is a stagnant streaming multiprocessor in the graphics processor if the thread bundle in the streaming multiprocessor cannot acquire memory resources.
[0161] Optionally, the device further includes:
[0162] The resource release module is used to release the memory resources occupied by the target thread bundle if the target thread bundle completes the execution of the instruction.
[0163] Optionally, the device further includes:
[0164] The remaining memory resource calculation module is used to calculate the remaining memory resources of each streaming multiprocessor in the graphics processor.
[0165] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0166] In addition, embodiments of the present invention also provide an electronic device, such as... Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0167] Memory 503 is used to store computer programs;
[0168] When processor 501 executes the program stored in memory 503, it performs the following steps:
[0169] Detect whether there is a stagnant streaming multiprocessor in the graphics processor;
[0170] If there is a streaming multiprocessor in a stagnant state, the remaining memory resources of the stagnant streaming multiprocessor are merged with the remaining memory resources of at least one other streaming multiprocessor.
[0171] Identify at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle;
[0172] Based on the merged remaining memory resources, memory resources are allocated to the target thread bundle through a preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources.
[0173] Optionally, the streaming multiprocessors are sequentially configured with a first sequence number;
[0174] The step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor includes:
[0175] According to the first sequence number, the remaining memory resources of the stagnant streaming multiprocessor are merged with the remaining memory resources of at least one other streaming multiprocessor.
[0176] Optionally, the step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor according to the first sequence number includes:
[0177] The streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor in the stagnant state are designated as the streaming multiprocessors to be merged.
[0178] The remaining memory resources of the stream multiprocessor that is in a stagnant state are used as the remaining memory resources to be used;
[0179] The remaining memory resources to be used are merged with the remaining memory resources of the streaming multiprocessors to be merged to obtain new remaining memory resources to be used.
[0180] Determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor.
[0181] If the remaining memory resources after merging do not meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged is taken as the new streaming multiprocessor to be merged. The step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used is repeated until the remaining memory resources to be used meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor.
[0182] Optionally, the thread bundles in the streaming processor are sequentially configured with a second sequence number;
[0183] The step of determining whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor includes:
[0184] Sequentially determine whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor.
[0185] Optionally, the step of detecting whether there is a stagnant streaming multiprocessor in the graphics processor includes:
[0186] Detect whether the thread bundles in the streaming multiprocessor can acquire memory resources;
[0187] If the thread bundle in the streaming multiprocessor cannot acquire memory resources, it is determined that there is a stagnant streaming multiprocessor in the graphics processor.
[0188] Optionally, the method further includes:
[0189] If the target thread bundle completes the execution of the instruction, the memory resources occupied by the target thread bundle are released.
[0190] Optionally, the method further includes:
[0191] Calculate the remaining memory resources for each streaming multiprocessor in the graphics processor.
[0192] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0193] The communication interface is used for communication between the aforementioned terminal and other devices.
[0194] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0195] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0196] like Figure 6 As shown, in another embodiment of the present invention, a computer-readable storage medium 601 is also provided, which stores instructions that, when executed on a computer, cause the computer to perform the memory resource management method of the graphics processor described in the above embodiment.
[0197] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute the memory resource management method of the graphics processor described in the above embodiments.
[0198] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0199] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0200] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0201] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for managing memory resources of a graphics processor, characterized in that, The graphics processor includes several streaming multiprocessors, and at least one thread bundle runs in each streaming multiprocessor. The method includes: Detect whether there is a stagnant streaming multiprocessor in the graphics processor; If there is a streaming multiprocessor in a stagnant state, the remaining memory resources of the stagnant streaming multiprocessor are merged with the remaining memory resources of at least one other streaming multiprocessor. Identify at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle; Based on the remaining memory resources after merging, memory resources are allocated to the target thread bundle through a preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources; The streaming multiprocessors are sequentially configured with a first sequence number; The step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor includes: According to the first sequence number, the remaining memory resources of the stagnant streaming multiprocessor are merged with the remaining memory resources of at least one other streaming multiprocessor. The step of merging the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor according to the first sequence number includes: The streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor that is in a stagnant state are designated as the streaming multiprocessors to be merged. The remaining memory resources of the stream multiprocessor that is in a stagnant state are used as the remaining memory resources to be used; The remaining memory resources to be used are merged with the remaining memory resources of the streaming multiprocessors to be merged to obtain new remaining memory resources to be used. Determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor; If the remaining memory resources after merging do not meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged is taken as the new streaming multiprocessor to be merged. The step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used is repeated until the remaining memory resources to be used meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor.
2. The method according to claim 1, characterized in that, The thread bundles in the streaming multiprocessor are sequentially configured with a second sequence number; The step of determining whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor includes: Sequentially determine whether the remaining memory resources to be used meet the needs of any thread bundle to be executed in the stagnant streaming multiprocessor.
3. The method according to claim 1, characterized in that, The step of detecting whether there is a stagnant streaming multiprocessor in the graphics processor includes: Detect whether the thread bundles in the streaming multiprocessor can acquire memory resources; If the thread bundle in the streaming multiprocessor cannot acquire memory resources, it is determined that there is a stagnant streaming multiprocessor in the graphics processor.
4. The method according to claim 1, characterized in that, The method further includes: If the target thread bundle completes the execution of the instruction, the memory resources occupied by the target thread bundle are released.
5. The method according to claim 1, characterized in that, The method further includes: Calculate the remaining memory resources for each streaming multiprocessor in the graphics processor.
6. A memory resource management device for a graphics processor, characterized in that, The graphics processor includes several streaming multiprocessors, and at least one thread bundle runs in each streaming multiprocessor. The device includes: The detection module is used to detect whether there is a stagnant streaming multiprocessor in the graphics processor; The resource merging module is used to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor if there is a stagnant streaming multiprocessor. The target thread bundle determination module is used to determine at least one thread bundle to be executed in the stagnant streaming multiprocessor as the target thread bundle; The reallocation module is used to allocate memory resources to the target thread bundle based on the merged remaining memory resources through a preset thread scheduler in the graphics processor, so that the target thread bundle executes preset instructions based on the reallocated memory resources; The streaming multiprocessors are sequentially configured with a first sequence number; the resource merging module includes: The resource merging submodule is used to merge the remaining memory resources of the stagnant streaming multiprocessor with the remaining memory resources of at least one other streaming multiprocessor in the order of the first sequence number. The resource merging submodule includes: The streaming multiprocessor to be merged determination unit is used to identify streaming multiprocessors whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor in the stagnant state as streaming multiprocessors to be merged. The unit for determining remaining memory resources to be used is used to determine the remaining memory resources of the streaming multiprocessor in a stagnant state as remaining memory resources to be used. The first resource merging unit is used to merge the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used. The demand determination unit is used to determine whether the remaining memory resources to be used meet the needs of the thread bundle to be executed in the stagnant streaming multiprocessor. The second resource merging unit is used to, if the merged remaining memory resources do not meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor, take the streaming multiprocessor whose first sequence number is adjacent to the first sequence number of the streaming multiprocessor to be merged as the new streaming multiprocessor to be merged, and repeat the step of merging the remaining memory resources to be used with the remaining memory resources of the streaming multiprocessor to be merged to obtain new remaining memory resources to be used, until the remaining memory resources to be used meet the requirements of the thread bundles to be executed in the stagnant streaming multiprocessor.
7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the memory resource management method of the graphics processor as described in any one of claims 1-5.
8. One or more computer-readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the memory resource management method of a graphics processor as described in any one of claims 1-5.
Citation Information
Patent Citations
Graphic processor and resource scheduling method and device thereof
CN109840877A
Graphics processor resource management method and device, equipment and storage medium
CN114490082A