A dynamic shared memory multiplexing method and device suitable for GPGPU
Through the dynamic shared memory multiplexing method, the problem of inefficient shared memory management in GPGPU is solved, more efficient memory resource utilization and computing throughput are achieved, and the performance of GPGPU is improved.
Patent Information
- Application Number
- CN202411000879.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-25
AI Technical Summary
The shared memory management in the GPGPU architecture adopts a static allocation strategy, which results in inefficiency during concurrent access by multiple threads, limits performance, and makes it difficult to support the simultaneous execution of more thread blocks, affecting thread-level parallelism and computing throughput.
Through the dynamic shared memory multiplexing method, thread blocks with the same data access requirements are allowed to share reusable shared memory partitions in the shared memory pool, and read-write locks are allocated to thread blocks without the same data access requirements to achieve memory Flexible management and scheduling of resources ensure that memory allocation and quick release are only performed when actually needed.
Significantly improves the utilization efficiency of shared memory and the computing throughput of GPGPU, reduces the delay caused by thread blocks waiting for memory resources, improves the response speed of thread scheduling and the concurrent access capability of memory, and achieves more efficient resource utilization and Performance.
Smart Images

Figure CN118535356B_ABST
Abstract
Description
Technical Field
[0001] The invention discloses a dynamic shared memory multiplexing method and device suitable for GPGPU, and relates to the technical field of memory resource allocation. Background Art
[0002] As an efficient parallel computing platform, general-purpose graphics processing units (GPGPUs) are widely used in scientific computing, graphics processing, big data analysis and other fields. However, the shared memory management method in the GPGPU architecture often adopts a static allocation strategy, which is inefficient when accessed by multiple threads concurrently, limiting the performance of GPGPU. In existing GPGPU designs, the allocation of shared memory is bound to the life cycle of thread blocks. Even if the actual usage time is much less than the allocation time, once allocated, it will occupy the entire execution period. This leads to low utilization of shared memory resources and makes it difficult to support the simultaneous execution of more thread blocks, affecting the thread-level parallelism and overall computing throughput of GPGPU. Summary of the invention
[0003] The present invention aims at solving the problems of the prior art and provides a method and device for dynamic shared memory multiplexing suitable for GPGPU, which can significantly improve the utilization efficiency of shared memory and the computing throughput of GPGPU without increasing hardware resources. Through the present invention, shared memory resources can be managed and scheduled more flexibly, allowing multiple thread blocks to efficiently share and reuse limited shared memory space, thereby breaking through performance bottlenecks.
[0004] The specific scheme proposed by the present invention is:
[0005] The present invention provides a dynamic shared memory multiplexing method applicable to GPGPU, comprising:
[0006] Step 1: Based on the GPGPU framework, perform memory requirement analysis on thread blocks according to the memory task requests issued by each thread block:
[0007] Step 11: Allow thread blocks with the same data access requirements to share reusable shared memory partitions in the shared memory pool.
[0008] Step 12: for thread blocks that do not have the same data access requirements, a read-write lock is allocated to lock access to a non-reused shared memory partition in the shared memory pool at a given time, wherein the thread block read-write lock is allocated using a read-write lock index table. When the corresponding shared memory segment signal in the read-write lock index table is pulled high, it indicates that a thread block in the shared memory partition has been allocated a read-write lock and needs to wait for the read-write lock to be released. When the corresponding shared memory partition signal in the read-write lock index table is pulled low, it indicates that the read-write lock corresponding to the shared memory partition has been released.
[0009] Step 2: When the thread block completes the memory task request, the shared memory is released and provided to other thread blocks.
[0010] Furthermore, step 1 of the dynamic shared memory multiplexing method applicable to GPGPU also includes step 10: judging whether there is valid data in the address space corresponding to the memory task request and whether there is sufficient allocation space in the shared memory pool according to the memory requirements of the thread block, and if so, proceeding to steps 11 and 12.
[0011] Furthermore, in step 10 of the dynamic shared memory multiplexing method applicable to GPGPU, a shared memory scoreboard is used to record a valid signal of the address space in the shared memory. When data is written into the address space, the valid signal is pulled high, and it is regarded that there is valid data in the address space. Otherwise, it is regarded that there is no valid data in the address space.
[0012] At the same time, the register is used to record the size of the remaining space of the shared memory to determine whether the remaining space of the shared memory is sufficient for allocation.
[0013] Furthermore, in step 11 of the dynamic shared memory multiplexing method applicable to GPGPU, it is determined whether the thread blocks have the same data access requirements based on the addresses of the thread blocks accessing the shared memory in the memory task request. If the addresses of the thread blocks accessing the shared memory are the same, they have the same data access requirements; otherwise, the thread blocks do not have the same data access requirements.
[0014] Furthermore, in step 2 of the dynamic shared memory multiplexing method applicable to GPGPU, the released scattered address space of the shared memory is remapped so that the address space is concentrated in a continuous shared memory partition, so that the shared memory pool can subsequently allocate a continuous address space and read the continuous address space.
[0015] The present invention also provides a dynamic shared memory multiplexing device suitable for GPGPU, including a demand allocation module and a resource adjustment module.
[0016] The demand allocation module is based on the GPGPU framework and performs memory demand analysis of thread blocks according to the memory task requests issued by each thread block:
[0017] Step 11: Allow thread blocks with the same data access requirements to share reusable shared memory partitions in the shared memory pool.
[0018] Step 12: for thread blocks that do not have the same data access requirements, a read-write lock is allocated to lock access to a non-reused shared memory partition in the shared memory pool at a given time, wherein the thread block read-write lock is allocated using a read-write lock index table. When the corresponding shared memory segment signal in the read-write lock index table is pulled high, it indicates that a thread block in the shared memory partition has been allocated a read-write lock and needs to wait for the read-write lock to be released. When the corresponding shared memory partition signal in the read-write lock index table is pulled low, it indicates that the read-write lock corresponding to the shared memory partition has been released.
[0019] When a thread block completes a memory task request, the resource adjustment module releases the shared memory and provides it to other thread blocks.
[0020] Furthermore, the demand allocation module of the dynamic shared memory multiplexing device suitable for GPGPU also executes step 10: according to the memory demand of the thread block, it is determined whether there is valid data in the address space corresponding to the memory task request and whether the shared memory pool has sufficient allocation space, and if so, steps 11 and 12 are executed.
[0021] Furthermore, when the demand allocation module of the dynamic shared memory multiplexing device suitable for GPGPU executes step 10, the shared memory scoreboard is used to record the valid signal of the address space in the shared memory. When data is written into the address space, the valid signal is pulled high, and it is regarded that there is valid data in the address space. Otherwise, it is regarded that there is no valid data in the address space.
[0022] At the same time, the register is used to record the size of the remaining space of the shared memory to determine whether the remaining space of the shared memory is sufficient for allocation.
[0023] Furthermore, when the demand allocation module of the dynamic shared memory multiplexing device suitable for GPGPU executes step 11, it determines whether the thread blocks have the same data access requirements based on the addresses of the thread blocks accessing the shared memory in the memory task request. If the addresses of the thread blocks accessing the shared memory are the same, they have the same data access requirements; otherwise, the thread blocks do not have the same data access requirements.
[0024] Furthermore, the resource adjustment module of the dynamic shared memory multiplexing device suitable for GPGPU remaps the released scattered address space of the shared memory so that the address space is concentrated in a continuous shared memory partition, so that the shared memory pool can subsequently allocate continuous address space and read the continuous address space.
[0025] The benefits of the present invention are:
[0026] The present invention reuses and dynamically allocates memory resources, ensuring that memory is allocated only when actually needed, effectively avoiding unnecessary memory occupation and waste, and achieving efficient circulation of memory resources. In addition, the fast release mechanism ensures that the memory resources occupied by the thread block are immediately recovered after the computing task is completed, significantly reducing the delay caused by the thread block waiting for memory resources and improving the response speed of thread scheduling;
[0027] The multiplexing strategy allows multiple thread blocks to share the same memory resource, reducing the idle time caused by waiting for memory allocation, thereby speeding up the execution of thread blocks. This overlapping use of time reduces the idleness of memory resources, allowing more computing tasks to be performed simultaneously, and improving the overall computing throughput;
[0028] With adaptive memory adjustment capability, the system can adaptively adjust memory allocation strategies according to the specific characteristics and runtime behavior of applications to achieve optimal resource utilization and performance. This flexibility and scalability enables the system to adapt to GPGPU applications of different sizes and characteristics.
[0029] Overall, the present invention effectively improves the computing efficiency of GPGPU and the utilization of memory resources, significantly increases the throughput of the system, reduces the waiting time of thread blocks, improves the concurrent access capability of memory, and provides users with a more efficient, stable and reliable computing environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 Schematic diagram of the process of the present invention.
[0031] Figure 2 The present invention relates to a flow chart of a reusable shared memory partition shared by thread blocks with the same data access requirements.
[0032] Figure 3 The present invention relates to a flow chart of dynamically allocating memory. DETAILED DESCRIPTION
[0033] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0034] Embodiment 1: The present invention provides a dynamic shared memory multiplexing method applicable to GPGPU, comprising:
[0035] Step 1: Based on the GPGPU framework, perform memory requirement analysis on thread blocks according to the memory task requests issued by each thread block:
[0036] Step 11: Allow thread blocks with the same data access requirements to share reusable shared memory partitions in the shared memory pool.
[0037] Whether the thread blocks have the same data access requirements is determined based on the addresses of the thread blocks accessing the shared memory in the memory task request. If the addresses of the thread blocks accessing the shared memory are the same, they have the same data access requirements. Otherwise, the thread blocks do not have the same data access requirements.
[0038] When one of the thread blocks with the same data access requirement reads the data in the address space of the reusable shared memory partition, the data can be directly returned to other thread blocks with the same data access requirement, thereby achieving a multiplexing effect.
[0039] Step 12: For thread blocks that do not have the same data access requirements, a read-write lock is allocated to lock access to a non-reused shared memory partition in the shared memory pool at a given time, wherein the thread block read-write lock is allocated using a read-write lock index table. When the corresponding shared memory segmentation signal in the read-write lock index table is pulled high, it indicates that a thread block in the shared memory partition has been allocated a read-write lock and needs to wait for the read-write lock to be released. When the corresponding shared memory partition signal in the read-write lock index table is pulled low, it indicates that the read-write lock corresponding to the shared memory partition has been released.
[0040] Step 2: When the thread block completes the memory task request, the shared memory is released and provided to other thread blocks.
[0041] For example, combined with Figure 2 , thread blocks 1 to n request memory, and perform demand analysis on thread blocks 1 to n. For example, thread blocks 1 and n have the same data access requirements, and share a reusable shared memory partition in the shared memory pool. When thread blocks 1 and n complete the memory request task, release the corresponding shared memory partition. At the same time, it can be determined whether there are other thread blocks that need this shared memory partition. If there is thread block 2 that needs this shared memory partition, it is assigned to thread block 2 to perform the memory task. After completing the memory task of thread block 2, release this shared memory partition and return it to the shared memory pool.
[0042] Embodiment 2: Based on embodiment 1, step 1 of the method of the present invention also includes step 10: according to the memory requirements of the thread block, determine whether there is valid data in the address space corresponding to the memory task request and whether the shared memory pool has sufficient allocation space, and if so, proceed to steps 11 and 12.
[0043] The shared memory scoreboard can be further used to record the valid signal of the address space in the shared memory. When data is written to the address space, the valid signal is pulled high, which is regarded as valid data in the address space, otherwise it is regarded as no valid data in the address space. If the valid bit of the corresponding address is not set to 1, it is regarded as the address does not have data, the allocation fails, an error is reported, and the memory task request is returned, waiting for the next request to be sent.
[0044] At the same time, the register is used to record the remaining space of the shared memory to determine whether the remaining space of the shared memory is sufficient for allocation. If the remaining size is less than the requested space size, it is considered that there is insufficient space and the allocation fails. The memory task request is temporarily suspended until there is enough memory in the shared memory pool to meet the request. At this time, the request is responded to and memory is allocated to the thread block that issued the request.
[0045] For example, combined with Figure 3 When a thread block initiates a memory access request, it first determines whether there is valid data in the address space corresponding to the shared memory to be accessed. If so, it determines the size of the space that can be allocated in the shared memory pool. If the space is insufficient, it waits. If the space meets the allocation requirements, it allocates memory for the thread block to execute the task. If the task is completed, the memory is quickly released to achieve resource recovery. At the same time, it detects whether there are other memory access requests. If not, the task is terminated. If so, the memory is adaptively adjusted. For example, in step 2, the scattered address space of the released shared memory is remapped so that the address space is concentrated in a continuous shared memory partition, so that the shared memory pool can allocate continuous address space and read the continuous address space in the future.
[0046] Embodiment 3: The present invention also provides a dynamic shared memory multiplexing device suitable for GPGPU, including a demand allocation module and a resource adjustment module.
[0047] The demand allocation module is based on the GPGPU framework and performs memory demand analysis of thread blocks according to the memory task requests issued by each thread block:
[0048] Step 11: Allow thread blocks with the same data access requirements to share reusable shared memory partitions in the shared memory pool.
[0049] Step 12: for thread blocks that do not have the same data access requirements, a read-write lock is allocated to lock access to a non-reused shared memory partition in the shared memory pool at a given time, wherein the thread block read-write lock is allocated using a read-write lock index table. When the corresponding shared memory segment signal in the read-write lock index table is pulled high, it indicates that a thread block in the shared memory partition has been allocated a read-write lock and needs to wait for the read-write lock to be released. When the corresponding shared memory partition signal in the read-write lock index table is pulled low, it indicates that the read-write lock corresponding to the shared memory partition has been released.
[0050] When a thread block completes a memory task request, the resource adjustment module releases the shared memory and provides it to other thread blocks.
[0051] As the information interaction and execution process between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention, the specific contents can be found in the description of the embodiment of the method of the present invention and will not be repeated here.
[0052] Similarly, the device of the present invention reuses and dynamically allocates memory resources, ensuring that memory allocation is performed only when actually needed, effectively avoiding unnecessary memory occupation and waste, and achieving efficient circulation of memory resources. In addition, the fast release mechanism ensures that the memory resources occupied by the thread block are immediately recovered after the computing task is completed, significantly reducing the delay caused by the thread block waiting for memory resources and improving the response speed of thread scheduling;
[0053] The multiplexing strategy allows multiple thread blocks to share the same memory resource, reducing the idle time caused by waiting for memory allocation, thereby speeding up the execution of thread blocks. This overlapping use of time reduces the idleness of memory resources, allowing more computing tasks to be performed simultaneously, and improving the overall computing throughput;
[0054] With adaptive memory adjustment capability, the system can adaptively adjust memory allocation strategies according to the specific characteristics and runtime behavior of applications to achieve optimal resource utilization and performance. This flexibility and scalability enables the system to adapt to GPGPU applications of different sizes and characteristics.
[0055] In general, the device of the present invention effectively improves the computing efficiency of GPGPU and the utilization rate of memory resources, significantly increases the throughput of the system, reduces the waiting time of thread blocks, improves the concurrent access capability of memory, and provides users with a more efficient, stable and reliable computing environment.
[0056] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0057] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A dynamic shared memory multiplexing method suitable for GPGPU, characterized by include: Step 1: Based on the GPGPU framework, perform memory requirement analysis on thread blocks according to the memory task requests issued by each thread block: Step 10: According to the memory requirements of the thread block, first determine whether there is valid data in the address space corresponding to the memory task request: Use the shared memory scoreboard to record the valid signal of the address space in the shared memory. When data is written to the address space, the valid signal is pulled high, which is regarded as valid data in the address space. Otherwise, it is regarded as no valid data in the address space. If there is valid data, determine whether the shared memory pool has enough allocation space: use registers to record the remaining space size of the shared memory. If the remaining space size is less than the requested space size, it is considered that there is insufficient space and the allocation fails. The memory task request is temporarily suspended until there is enough memory in the shared memory pool to meet the request. Then respond to the request and allocate memory to the thread block that issued the request. If the remaining space size has enough allocation space, proceed to step 11 and step 12. Step 11: Allow thread blocks with the same data access requirements to share reusable shared memory partitions in the shared memory pool. Step 12: for thread blocks that do not have the same data access requirements, a read-write lock is allocated to lock access to a non-reused shared memory partition in the shared memory pool at a given time, wherein the thread block read-write lock is allocated using a read-write lock index table. When the corresponding shared memory segment signal in the read-write lock index table is pulled high, it indicates that a thread block in the shared memory partition has been allocated a read-write lock and needs to wait for the read-write lock to be released. When the corresponding shared memory partition signal in the read-write lock index table is pulled low, it indicates that the read-write lock corresponding to the shared memory partition has been released. Step 2: When the thread block completes the memory task request, the shared memory is released and provided to other thread blocks.
2. A dynamic shared memory multiplexing method suitable for GPGPU according to claim 1, characterized in that In step 11, it is determined whether the thread blocks have the same data access requirements based on the addresses of the thread blocks accessing the shared memory in the memory task request. If the addresses of the thread blocks accessing the shared memory are the same, they have the same data access requirements, otherwise the thread blocks do not have the same data access requirements.
3. The method for dynamic shared memory multiplexing suitable for GPGPU according to claim 1, characterized in that In step 2, the scattered address space of the released shared memory is remapped so that the address space is concentrated in a continuous shared memory partition, so that the shared memory pool can subsequently allocate a continuous address space and read the continuous address space.
4. A dynamic shared memory multiplexing device suitable for GPGPU, characterized in that Including demand allocation module and resource adjustment module, The demand allocation module is based on the GPGPU framework and performs memory demand analysis of thread blocks according to the memory task requests issued by each thread block, including: Step 10: According to the memory requirements of the thread block, first determine whether there is valid data in the address space corresponding to the memory task request: Use the shared memory scoreboard to record the valid signal of the address space in the shared memory. When data is written to the address space, the valid signal is pulled high, which is regarded as valid data in the address space. Otherwise, it is regarded as no valid data in the address space. If there is valid data, determine whether the shared memory pool has enough allocation space: use registers to record the remaining space size of the shared memory. If the remaining space size is less than the requested space size, it is considered that there is insufficient space and the allocation fails. The memory task request is temporarily suspended until there is enough memory in the shared memory pool to meet the request. Then respond to the request and allocate memory to the thread block that issued the request. If the remaining space size has enough allocation space, proceed to step 11 and step 12. Step 11: Allow thread blocks with the same data access requirements to share reusable shared memory partitions in the shared memory pool. Step 12: for thread blocks that do not have the same data access requirements, a read-write lock is allocated to lock access to a non-reused shared memory partition in the shared memory pool at a given time, wherein the thread block read-write lock is allocated using a read-write lock index table. When the corresponding shared memory segment signal in the read-write lock index table is pulled high, it indicates that a thread block in the shared memory partition has been allocated a read-write lock and needs to wait for the read-write lock to be released. When the corresponding shared memory partition signal in the read-write lock index table is pulled low, it indicates that the read-write lock corresponding to the shared memory partition has been released. When a thread block completes a memory task request, the resource adjustment module releases the shared memory and provides it to other thread blocks.
5. A dynamic shared memory multiplexing device suitable for GPGPU according to claim 4, characterized in that: When the allocation module executes step 11, it determines whether the thread blocks have the same data access requirements based on the addresses of the thread blocks accessing the shared memory in the memory task request. If the addresses of the thread blocks accessing the shared memory are the same, they have the same data access requirements; otherwise, the thread blocks do not have the same data access requirements.
6. A dynamic shared memory multiplexing device suitable for GPGPU according to claim 4, characterized in that the resource The adjustment module remaps the scattered address space of the released shared memory so that the address space is concentrated in a continuous shared memory partition, so that the subsequent shared memory pool allocates continuous address space and reads the continuous address space.
Citation Information
Patent Citations
GPU (Graphics Processing Unit) sharing method and device oriented to server non-perceptual reasoning load
CN118113471A
