Storage Space Management Method, Apparatus, Device, Storage Medium and Program Product

By dividing the shared storage space into static and dynamic parts in parallel computing of GPGPU, the waste problem caused by excessive allocation of shared storage space in traditional methods is solved, and more efficient space use and dynamic allocation capabilities are achieved.

CN118760620BActive Publication Date: 2025-05-27GLENFLY TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410883144.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2025-05-27
Estimated Expiration
2044-07-02

AI Technical Summary

Technical Problem

In parallel computing of GPGPUs, the traditional shared storage space allocation method needs to be determined before the workgroup is executed, resulting in excessive allocation, resulting in wasted space, and thus reducing the number of workgroups initiated on the execution unit.

Method used

A storage space management method is proposed, by dividing the shared storage space into static shared storage space and dynamic shared storage space, which is allocated and released before and during the execution of the work group, thereby improving the efficiency of space use.

Benefits of technology

Through the coordination of static and dynamic shared storage space, while improving the efficiency of shared storage space usage, the workgroup can dynamically allocate shared space at runtime to avoid wasting space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760620B_ABST
    Figure CN118760620B_ABST
Patent Text Reader

Abstract

The present application relates to a storage space management method, apparatus, computer device, storage medium, and computer program product. The method includes: receiving workgroup information; allocating static shared storage space for the workgroup before the execution of the workgroup corresponding to the workgroup information; during the execution of the workgroup, allocating dynamic shared storage space for the workgroup, or releasing the allocated dynamic shared storage space. By using this method, the utilization efficiency of the shared storage space can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In the parallel computing of general-purpose graphics processing units (GPGPU), threads in the same work group can access the same shared memory (SM) space.

[0003] The traditional SM space allocation method needs to be determined before the work group is executed, which may cause the SM space allocation to be too large. If the SM space allocation is too large, it will lead to a waste of SM space, which will lead to a reduction in the work group started on the execution unit ExecuteUnit. Summary of the invention

[0004] Based on this, it is necessary to provide a storage space management method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the utilization efficiency of shared storage space in response to the above technical problems.

[0005] In a first aspect, the present application provides a storage space management method, the method comprising:

[0006] Receive workgroup information;

[0007] Before the work group corresponding to the work group information is executed, a static shared storage space is allocated to the work group;

[0008] During the execution of the work group, a dynamic shared storage space is allocated to the work group, or the allocated dynamic shared storage space is released.

[0009] In one embodiment, the method further comprises:

[0010] Generate a number of execution threads based on the workgroup information;

[0011] When each of the execution threads executes a shared storage read and write instruction, a read and write operation is performed on the static shared storage space and / or the dynamic shared storage space of the work group corresponding to the execution thread.

[0012] In one embodiment, the performing read and write operations on the static shared storage space and the dynamic shared storage space of the work group corresponding to the execution thread includes:

[0013] In a case where the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is smaller than the size of the static shared storage space, based on the first base address of the static shared storage space of the working group corresponding to the execution thread, converting the logical address corresponding to the shared storage read / write instruction into a first physical address of the static shared storage space;

[0014] In a case where the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the size of the static shared storage space, and the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is less than the sum of the size of the static shared storage space and the size of the dynamic shared storage space, based on the second base address of the dynamic shared storage space of the working group corresponding to the execution thread, converting the logical address corresponding to the shared storage read / write instruction into a second physical address of the dynamic shared storage space;

[0015] Read and write operations are performed based on the first physical address and the second physical address.

[0016] In one embodiment, the method further comprises:

[0017] When the space size corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the sum of the size of the static shared storage space and the size of the dynamic shared storage space, an out-of-bounds prompt is output.

[0018] In one embodiment, performing the read and write operations based on the first physical address and the second physical address includes:

[0019] When the shared storage read / write instruction is a read operation, data is read based on the first physical address and the second physical address, and the read data is bypassed to the general register memory.

[0020] In one embodiment, converting the logical address corresponding to the shared storage read / write instruction into the first physical address of the static shared storage space includes:

[0021] The first physical address is obtained based on the sum of the first base address of the static shared storage space and the logical address corresponding to the shared storage read and write instructions.

[0022] In one embodiment, converting the logical address corresponding to the shared storage read / write instruction into the second physical address of the dynamic shared storage space includes:

[0023] Based on the total size of the static shared memory space and the size of the memory row, obtaining the base address of the dynamic shared memory space;

[0024] Based on the number of storage rows in the dynamic shared storage space and the storage row size, obtaining the storage row size allocated by the dynamic shared storage space;

[0025] Obtaining a shared storage address of the dynamic shared storage space based on a logical address corresponding to the shared storage read / write instruction, a size of the static shared storage space, and a size of a storage row allocated by the dynamic shared storage space;

[0026] The dynamic shared storage space offset is obtained based on the shared storage address of the dynamic shared storage space, the size of the storage row allocated by the dynamic shared storage space, the logical address corresponding to the shared storage read and write instruction, and the size of the static shared storage space;

[0027] The second physical address is obtained based on the dynamic shared memory space base address and the dynamic shared memory space offset.

[0028] In one embodiment, allocating static shared storage space to the work group includes:

[0029] Obtaining the static remaining space of the static shared storage space;

[0030] When the static remaining space is greater than or equal to the target static shared storage space corresponding to the workgroup information, determine the base address of the static shared storage space, allocate static shared storage space to the workgroup based on the base address of the static shared storage space, and adjust the first allocation pointer of the static shared storage space.

[0031] In one embodiment, determining the base address of the static shared storage space, allocating the static shared storage space to the work group based on the base address of the static shared storage space, and adjusting the first allocation pointer of the static shared storage space include:

[0032] Use the current first allocation pointer as the base address of the static shared storage space, allocate static shared storage space to the work group based on the base address of the static shared storage space, and adjust the current first allocation pointer based on the current first allocation pointer, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

[0033] In one embodiment, the method further comprises:

[0034] When the static remaining space is smaller than the target static shared storage space corresponding to the working group information, wait until other working groups are finished executing and then release the static shared storage space. When the static remaining space after release is greater than or equal to the target static shared storage space corresponding to the working group information, continue to execute the step of determining the base address of the static shared storage space.

[0035] In one embodiment, the obtaining of the static remaining space of the static shared storage space includes:

[0036] Get the current first allocation pointer and the current release pointer;

[0037] When the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the total storage rows of the static shared storage space and the first pointer, and the first pointer is the difference between the current first allocation pointer and the current release pointer;

[0038] When the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the current release pointer and the current first allocation pointer.

[0039] In one embodiment, the method further comprises:

[0040] When the work group is executed, the corresponding static shared storage space is released, and a release pointer of the static shared storage space is adjusted.

[0041] In one embodiment, adjusting the release pointer of the static shared storage space includes:

[0042] The release pointer is adjusted based on the release pointer of the static shared storage space, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

[0043] In one embodiment, allocating the dynamic shared storage space for the work group, or releasing the allocated dynamic shared storage space, comprises:

[0044] Generate an allocation instruction of the dynamic shared storage space through a main thread in the generated execution threads, and allocate the dynamic shared storage space to the work group based on the allocation instruction of the dynamic shared storage space; or

[0045] A release instruction of the dynamic shared storage space is generated by a main thread in the generated execution threads, and the allocated dynamic shared storage space is released based on the release instruction.

[0046] In one embodiment, allocating the dynamic shared memory space to the work group based on the allocation instruction of the dynamic shared memory space includes:

[0047] Checking a storage table corresponding to the dynamic shared storage space to determine whether there is a dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space;

[0048] When the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, the storage table corresponding to the dynamic shared storage space is adjusted, and the address of the dynamic shared storage space allocated to the working group is recorded.

[0049] In one embodiment, the method further comprises:

[0050] In the case that the dynamic remaining space does not satisfy the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, the allocation failure information is returned, and the threads of the work group are suspended until the dynamic remaining space satisfies the target dynamic shared space corresponding to the suspended threads of the work group, and the step of generating the allocation instruction of the dynamic shared storage space through the main thread in the generated execution thread is continued.

[0051] In one embodiment, checking the storage table corresponding to the dynamic shared storage space to determine whether there is dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space includes:

[0052] Traversing the storage table corresponding to the dynamic shared storage space to determine whether there is unallocated valid dynamic shared storage space;

[0053] In the case that there is unallocated effective dynamic shared storage space, counting the unallocated effective dynamic shared storage space to obtain dynamic remaining space;

[0054] When the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, it is determined that there is a dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space.

[0055] In one embodiment, releasing the allocated dynamic shared storage space based on the release instruction includes:

[0056] Based on the release instruction, the corresponding allocation bit and workgroup index in the storage table corresponding to the dynamic shared storage space are reset.

[0057] In a second aspect, the present application further provides a storage space management device, the device comprising:

[0058] A receiving module, used for receiving workgroup information;

[0059] A static shared storage space allocation module, used for allocating static shared storage space to the work group before the work group corresponding to the work group information is executed;

[0060] The dynamic shared storage space allocation module is used to allocate dynamic shared storage space to the working group during the execution of the working group, or release the allocated dynamic shared storage space.

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

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

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

[0064] The above-mentioned storage space management method, apparatus, computer equipment, storage medium and computer program product, after receiving work group information, allocates static shared storage space to the work group before the work group corresponding to the work group information is executed, and during the execution of the work group, allocates dynamic shared storage space to the work group, or releases the allocated dynamic shared storage space. In this way, a small amount of fixed static shared storage space can be allocated to the work group at the beginning, and dynamic shared storage space can be dynamically allocated based on the execution of the work group subsequently. Through the coordination of static shared storage space and dynamic shared storage space, the utilization efficiency of shared storage space can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0066] Figure 1a is a schematic diagram of a shared storage space in one embodiment;

[0067] Figure 1bA schematic diagram of an embodiment in which threads in a work group can share the same shared memory space;

[0068] Figure 2 It is a structural schematic diagram of an execution unit for executing a storage space management method in one embodiment;

[0069] Figure 3 is a flowchart of a storage space management method in one embodiment;

[0070] Figure 4 is a schematic diagram of an address control step in an embodiment;

[0071] Figure 5 An example diagram of a shared memory read / write control unit in one embodiment;

[0072] Figure 6 A schematic diagram of a process flow of static shared storage space management steps in one embodiment;

[0073] Figure 7 A schematic diagram of a flow chart of a static remaining space acquisition step in one embodiment;

[0074] Figure 8 A schematic diagram of a process flow of dynamic shared storage space management steps in one embodiment;

[0075] Fig. 9 A schematic diagram of a dynamic shared storage table of a dynamic shared storage space in one embodiment;

[0076] Fig.10 A schematic diagram of a process of obtaining a dynamic remaining space in one embodiment;

[0077] Fig.11 A schematic diagram of a dynamic shared storage table update rule in one embodiment;

[0078] Fig.12 A schematic diagram of recording address information of a dynamic shared storage space in one embodiment;

[0079] Fig.13 A schematic diagram of a rule for releasing a dynamic shared storage table update in one embodiment

[0080] Fig.14 is a structural block diagram of a storage space management device in one embodiment;

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

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

[0083] In a GPU or GPGPU, SM (Shared Memory) can provide fast read and write for the arithmetic logic unit ALU, and the read and write access latency of the shared memory space should be as short as possible.

[0084] Work items in the same work group can access the same shared memory space. The shared memory space can be configured based on three parameters (m, n, k) all of which are positive integers greater than 1: m is the number of banks, n is the byte index of the bank width, that is, the bank width, k is the storage line Line contained in the SM, and the size of the entire SM is: bytes. Figure 1a shown.

[0085] The shared storage space is divided into workgroups. Threads in the same workgroup can share the same shared storage space. For each workgroup, space is allocated according to the shared storage behavior unit. The shared storage space of the parallel executed workgroups is independent of each other. The threads in each workgroup share the space of the current workgroup. Figure 1b shown.

[0086] The current work group's allocation of shared storage space has the following problems: the size of the current work group's shared storage space needs to be determined before the work group is started; if the shared storage space is allocated too large, it will lead to a waste of shared storage space and a reduction in the number of work groups started on the execution unit; the work group cannot dynamically allocate shared storage space at runtime.

[0087] In view of the above problems, the present technical solution provides a storage space management method, which divides the shared storage space into static shared storage space and dynamic shared storage space, and manages the allocation and release of static and dynamic shared storage space through the management unit of static shared storage space and dynamic shared storage space. The method can improve the utilization rate of shared storage space and realize the allocation of shared space by workgroups at runtime.

[0088] The storage space management method provided in the embodiment of the present application can be applied to Figure 2 The execution unit shown in the figure includes a computing shader thread construction unit, a thread control unit, a shared storage control unit, a shared storage space, an instruction execution unit and a general register.

[0089] The compute shader thread construction unit is used to receive work group information, such as work group size, etc., and mainly includes two parts:

[0090] Workgroup thread generator: Generate threads based on workgroup information and thread templates;

[0091] Static shared storage space management unit: manages static shared storage space by allocating Allocation and releasing a set of pointers.

[0092] Before the work group (thread) is executed, the static shared memory space management unit allocates a static shared memory base address Static_SM_Base for the work group; when all the work groups (threads) are executed, the release pointer Release is adjusted to complete the release of the work group space.

[0093] The thread control unit is used to execute the threads generated by the compute shader thread construction unit. Upon receiving the application for dynamic shared storage space from the main thread of the work group thread generator, the thread control unit issues a dynamic shared storage space application SM_ALLOC to the shared storage control unit, and issues a dynamic shared storage space release request SM_RELS to the shared storage control unit. If the shared storage control unit returns that the dynamic shared storage space allocation fails, the current work group will be suspended until sufficient dynamic shared storage space is obtained from the shared storage control unit.

[0094] The instruction execution unit is used to receive the shared storage read and write instructions SM_RD / SM_WR from the thread control unit, and send the shared storage instruction related information (such as shared storage read and write address information, shared storage write data information) to the shared storage control unit.

[0095] Shared storage control unit: manages dynamic shared storage space and controls shared storage read and write instructions based on allocation requests in the dynamic shared storage space allocation queue, including:

[0096] Shared storage instruction information buffer: used to receive information of shared storage instructions sent by the instruction execution unit;

[0097] Dynamic shared memory space management unit: used to receive dynamic shared memory space allocation and release requests from the thread control unit, maintain the dynamic shared memory table Dynamic Shared Memory Table (DSMT), and generate the dynamic shared memory space address Dynamic_SM_Addr. If the dynamic shared memory space allocation is successful, it will return success to the thread control unit; if the dynamic shared memory space allocation fails, it will return failure to the thread control unit;

[0098] The address control unit: converts the logical address Logic Addr into a shared storage physical address Physical Addr according to the logical address Logic Addr information in the shared storage instruction information buffer, the static space base address Static_SM_Base generated by the static shared storage space management unit, and the dynamic address Dynamic_SM_Addr generated by the dynamic shared storage space management unit;

[0099] Shared memory read and write control unit: performs read and write operations on the shared memory according to the physical address of the shared memory generated by the address control unit and the data in the shared memory instruction information buffer (shared memory write operation); for the data of the read operation, it will be bypassed to the general register file for use by subsequent execution units.

[0100] The general register file is used to receive the shared storage read data bypassed by the shared storage read and write control unit for use by subsequent execution units;

[0101] Shared memory space: used to store data read and written by workgroup threads. It is divided into two parts: static shared memory space and dynamic shared memory space.

[0102] It should be noted that the storage space involved in the present application includes the memory space, and thus the static shared memory space Static Shared Memory Space and the dynamic shared memory space Dynamic Shared Memory Space are the static shared memory space and the dynamic shared memory space respectively.

[0103] In one embodiment, as shown in: 3, a storage space management method is provided. This embodiment takes the method applied to a terminal as an example for illustration. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0104] S302: Receive workgroup information.

[0105] The work group information includes the work group size, etc. In this embodiment, the work group information is received by the computing shader thread construction unit.

[0106] S304: Before the work group corresponding to the work group information is executed, a static shared storage space is allocated to the work group.

[0107] The static shared storage space is allocated before the work group is executed. The static shared memory space base address Static_SM_Base is allocated by the static shared memory space management unit and the base address is sent to the shared memory control unit.

[0108] S306: During the execution of the work group, a dynamic shared storage space is allocated to the work group, or the allocated dynamic shared storage space is released.

[0109] In order to realize dynamic allocation of storage space, a dynamic shared storage space is introduced, and the dynamic shared storage space is allocated during the execution of the work group.

[0110] Specifically, for the main thread in the compute shader thread generator, the thread control unit sends the issue dynamic shared storage space allocation SM_ALLOC instruction or the dynamic shared storage space release SM_RELS instruction to the shared memory control unit. The shared memory control unit receives the dynamic shared storage space allocation SM_ALLOC or release SM_RELS request from the thread control unit, and the dynamic shared memory space management unit allocates the dynamic shared memory space address Dynamic_SM_Addr or releases the dynamic memory space.

[0111] The above-mentioned storage space management method, after receiving the work group information, allocates static shared storage space to the work group before the work group corresponding to the work group information is executed, and during the execution of the work group, allocates dynamic shared storage space to the work group, or releases the allocated dynamic shared storage space. In this way, a small amount of fixed static shared storage space can be allocated to the work group at the beginning, and then the dynamic shared storage space can be dynamically allocated based on the execution of the work group. Through the coordination of static shared storage space and dynamic shared storage space, the utilization efficiency of shared storage space can be improved.

[0112] In one of the optional embodiments, the above method also includes: generating several execution threads based on the work group information; when each execution thread executes a shared storage read and write instruction, performing read and write operations on the static shared storage space and / or dynamic shared storage space of the work group corresponding to the execution thread.

[0113] The workgroup thread generator generates execution threads based on the received workgroup information. Each execution thread may be a parallel execution thread. When executing a workgroup task, each execution thread reads and writes data in a static shared storage space and / or a dynamic shared storage space.

[0114] Specifically, each execution thread in the thread control unit sends a shared memory read and write instruction to the instruction execution unit, and the instruction execution unit sends each shared memory read and write instruction to the shared memory instruction information buffer area to perform data read and write operations.

[0115] In one of the optional embodiments, read and write operations are performed on the static shared storage space and the dynamic shared storage space of the work group corresponding to the execution thread, including: when the space size corresponding to the logical address corresponding to the shared storage read and write instruction is smaller than the size of the static shared storage space, based on the first base address of the static shared storage space of the work group corresponding to the execution thread, converting the logical address corresponding to the shared storage read and write instruction into the first physical address of the static shared storage space; when the space size corresponding to the logical address corresponding to the shared storage read and write instruction is greater than or equal to the size of the static shared storage space, and the space size corresponding to the logical address corresponding to the shared storage read and write instruction is smaller than the sum of the size of the static shared storage space and the size of the dynamic shared storage space, based on the second base address of the dynamic shared storage space of the work group corresponding to the execution thread, converting the logical address corresponding to the shared storage read and write instruction into the second physical address of the dynamic shared storage space; and performing read and write operations based on the first physical address and the second physical address.

[0116] Specifically, combined Figure 4 As shown, Figure 4 It is a schematic diagram of the address control step in an embodiment. In this embodiment, the address control unit converts the logical address Logic Addr in the shared memory instruction into the shared memory physical address Physical Addr according to the static shared memory space base address Static_SM_Base and the dynamic shared memory space address Dynamic_SM_Addr, as well as the address information in the shared memory instruction information buffer.

[0117] Specifically, the logical address Logic Addr in the shared memory instruction is first obtained, and the space size corresponding to the logical address Logic Addr in the shared memory instruction is compared with the static shared memory space size Static_SM_Size. If the space size corresponding to the logical address Logic Addr in the shared memory instruction is smaller than the static shared memory space size Static_SM_Size, then based on the first base address of the static shared storage space of the working group corresponding to the execution thread, the logical address corresponding to the shared storage read and write instruction is converted into the first physical address of the static shared storage space.

[0118] Optionally, converting the logical address corresponding to the shared storage read / write instruction into the first physical address of the static shared storage space includes: obtaining the first physical address based on the sum of the first base address of the static shared storage space and the logical address corresponding to the shared storage read / write instruction.

[0119] In this embodiment, the first physical address (ie, the shared memory physical address) Physical Addr = Static_SM_Base (the first base address) + Logic Addr (the logical address corresponding to the shared memory read and write instructions).

[0120] When the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the size of the static shared storage space, and the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is less than the sum of the size of the static shared storage space and the size of the dynamic shared storage space, based on the second base address of the dynamic shared storage space of the working group corresponding to the execution thread, the logical address corresponding to the shared storage read / write instruction is converted into the second physical address of the dynamic shared storage space; and the read / write operation is performed based on the first physical address and the second physical address.

[0121] In this embodiment, when Logic Addr (logical address corresponding to the shared storage read and write instructions) < Static_SM_Size (size of the static shared storage space) and Logic Addr < (Static_SM_Size + Dynamic SM_Size (size of the dynamic shared storage space)), the shared memory physical address Physical Addr (second physical address) = Dynamic_SM_Base (base address of the dynamic shared storage space) + Dynamic_Offset (offset of the dynamic shared storage space).

[0122] In one of the optional embodiments, the logical address corresponding to the shared storage read and write instructions is converted into a second physical address of the dynamic shared storage space, including: obtaining a base address of the dynamic shared storage space based on the total size of the static shared storage space and the storage row size; obtaining a size of the allocated storage row of the dynamic shared storage space based on the number of storage rows and the storage row size of the dynamic shared storage space; obtaining a shared storage address of the dynamic shared storage space based on the logical address corresponding to the shared storage read and write instructions, the size of the static shared storage space, and the size of the allocated storage row of the dynamic shared storage space; obtaining a dynamic shared storage space offset based on the shared storage address of the dynamic shared storage space, the size of the allocated storage row of the dynamic shared storage space, the logical address corresponding to the shared storage read and write instructions, and the size of the static shared storage space; and obtaining a second physical address based on the base address of the dynamic shared storage space and the offset of the dynamic shared storage space.

[0123] In this embodiment, the dynamic shared memory space base address Dynamic_SM_Base can be based on the total size of the static shared space and the storage row size, that is,

[0124]

[0125] Dynamic memory address space allocation storage line size Dynamic_Alloc_Line_Size:

[0126]

[0127] Dynamic shared memory address Dynamic_SM_Addr:

[0128]

[0129] Dynamic shared storage space offset Dynamic_SM_Offset:

[0130]

[0131] In one of the optional embodiments, the method further includes: outputting an out-of-bounds prompt when the space size corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the sum of the size of the static shared storage space and the size of the dynamic shared storage space.

[0132] In this embodiment, Out-of-Range (OOR) judgment is performed according to the size of the static shared memory space and the size of the dynamic shared memory space. If it is out of range, the shared memory read or write operation is not performed.

[0133] In one of the optional embodiments, performing read and write operations based on the first physical address and the second physical address includes: when the shared storage read and write instruction is a read operation, reading data based on the first physical address and the second physical address, and bypassing the read data to the general register memory.

[0134] The shared memory read / write control unit performs read / write operations on the shared memory space according to the physical address Physical Addr generated by the address control unit. For the shared memory read operation SM_RD, the data returned by the shared memory is bypassed to the general register for use by other instructions in the work group thread in the execution unit Execute Unit.

[0135] For ease of understanding, combined Figure 5 As shown, Figure 5 1 is an example diagram of a shared memory read / write control unit in one embodiment. In this embodiment, the shared memory is read or written according to the shared memory physical address and the shared memory read SM_RD / write SM_WR operation. For the shared memory read operation SM_RD, the data returned by the shared memory is bypassed to the general register for use by other instructions in the workgroup thread in the execution unit Execute Unit. Figure 5 , taking the storage behavior as 1Kbyte, the shared memory read and write control unit accesses the hybrid shared memory space as follows:

[0136] Shared memory control unit: A set of logical addresses corresponding to the shared memory instruction received from the instruction execution unit is: ;

[0137] Current workgroup static shared memory size ; Dynamic shared memory size of the working group ;

[0138] Moreover, the total size of the static shared space Tot_Static_SM_Size = 32K bytes; the total size of the dynamic shared space Tot_Dynamic_SM_Size = 32K bytes.

[0139] The static shared memory base address allocated by the static shared memory space management unit ; Dynamic shared memory address allocated by the dynamic shared memory space management unit .

[0140] The address control unit converts the logical address into the shared memory physical address according to Static_SM_Base and Dynamic_SM_Base;

[0141] Logical address 100 bytes: 100 bytes < Static_SM_Size (4K bytes), so the logical address 100 bytes corresponds to the shared memory physical address Static_SM_Base + 100 bytes = 24K + 100 bytes (Static24);

[0142] Logical address 2K + 100 bytes: Logical address 2K + 100 bytes < Static_SM_Size (4Kbytes), so the logical address 2K + 100 bytes corresponds to the shared memory physical address Static_SM_Base + 2K +100 bytes = 24K + 2K + 100 bytes = 26K + 100 bytes (Static26);

[0143] Logical address 4K + 100 bytes: Logical address 4K + 100 bytes > Static_SM_Size and 4K + 100 bytes < (Static_SM_Size + Dynamic_SM_Size), so 4K + 100 bytes should be allocated in the dynamic shared memory space, and the corresponding dynamic memory space physical address is Dynamic_SM_Base + Dynamic_SM_Offset = 32K + 100 bytes (Dynamic0);

[0144] Logical address 5K + 100 bytes: (same as 4K + 100 bytes, should be allocated in dynamic memory space), 5K + 100 bytes corresponding to Dynamic_SM_Base + Dynamic_SM_Offset = 32K + 8K + 100 bytes = 40K + 100 bytes (Dynamic8);

[0145] Logical address 6K + 100 bytes: (same as 4K + 100 bytes, should be allocated in dynamic memory space), 6K + 100 bytes corresponding to Dynamic_SM_Base + Dynamic_SM_Offset = 32K + 21K + 100bytes = 53K + 100 bytes (Dynamic21);

[0146] For example, if 7K + 100 bytes > (Static_SM_Size + Dynamic_Size), the address is out of bounds and the shared memory read or write operation is not performed.

[0147] The shared memory read and write control unit accesses the shared memory according to the shared memory physical address and performs read and write operations on the shared memory.

[0148] In the above embodiment, the shared memory space is divided into static memory space and dynamic memory space; the shared memory space is managed by static and dynamic shared memory space management units; the address control unit can automatically convert the logical address of the shared memory instruction into the physical address of the shared memory.

[0149] In one of the optional embodiments, a static shared storage space is allocated to a work group, including: obtaining the static remaining space of the static shared storage space; when the static remaining space is greater than or equal to the target static shared storage space corresponding to the work group information, determining the base address of the static shared storage space, allocating the static shared storage space to the work group based on the base address of the static shared storage space, and adjusting the first allocation pointer of the static shared storage space.

[0150] In one of the optional embodiments, a base address of a static shared storage space is determined, static shared storage space is allocated to a work group based on the base address of the static shared storage space, and a first allocation pointer of the static shared storage space is adjusted, including: using a current first allocation pointer as the base address of the static shared storage space, allocating static shared storage space to the work group based on the base address of the static shared storage space, and adjusting the current first allocation pointer based on the current first allocation pointer, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

[0151] In one of the optional embodiments, the method also includes: when the static remaining space is smaller than the target static shared storage space corresponding to the work group information, wait for other work groups to finish execution, and then release the static shared storage space, until the static remaining space after release is greater than or equal to the target static shared storage space corresponding to the work group information, and then continue to execute the step of determining the base address of the static shared storage space.

[0152] In one of the optional embodiments, obtaining the static remaining space of the static shared storage space includes: obtaining the current first allocation pointer and the current release pointer; when the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the total storage rows of the static shared storage space and the first pointer, and the first pointer is the difference between the current first allocation pointer and the current release pointer; when the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the current release pointer and the current first allocation pointer.

[0153] In one of the optional embodiments, the method further includes: when the work group is executed, releasing the corresponding static shared storage space, and adjusting the release pointer of the static shared storage space.

[0154] For ease of understanding, combined Figure 6 As shown, the static shared memory space is allocated by the static shared memory space management unit before the work group is executed. The unit manages the static shared memory space of the work group through the static shared space allocation pointer Alloc_Ptr and the static shared space release pointer Release_Ptr:

[0155] First, the unit receives the work group information, receives the work group allocation space request, and obtains the work group static shared memory space size Static_SM_Size configuration information from the register.

[0156] Secondly, determine whether the current shared memory remaining space meets the Static_SM_Size of the current work group. The remaining space is determined as follows: Figure 7 As shown, when the address corresponding to the current first allocation pointer is less than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the total storage rows of the static shared storage space and the first pointer, and the first pointer is the difference between the current first allocation pointer Alloc_Ptr and the current release pointer Release_Ptr, specifically:

[0157] Static free space = total storage lines of static shared storage space – (Alloc_Ptr – Release_Ptr)

[0158] When the address corresponding to the current first allocation pointer is less than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the current release pointer Release_Ptr and the current first allocation pointer Alloc_Ptr, specifically:

[0159] Remaining space = Release_Ptr – Alloc_Ptr

[0160] The third step is to return the current static space base address to the shared memory control unit and adjust the static space allocation pointer to return the static space base address:

[0161]

[0162] Adjust the static space allocation pointer:

[0163]

[0164] Step 4: Wait for other working groups to finish and release the static shared memory space until the static shared memory storage space size Static_SM_Size required by the current working group is met;

[0165] Step 5: When all threads in the work group have finished executing, the thread control unit sends a work group end signal to the compute shader thread construction unit.

[0166] In one of the optional embodiments, adjusting the release pointer of the static shared storage space includes: adjusting the release pointer based on the release pointer of the static shared storage space, the target static shared storage space corresponding to the workgroup information, and the total storage rows of the static shared storage space.

[0167] Specifically, in the sixth step, upon receiving the work group end signal, the static shared memory space of the current work group is released, and the static shared memory space release pointer Release_Ptr is adjusted. The adjustment method is as follows:

[0168]

[0169] In one of the optional embodiments, dynamic shared storage space is allocated to a work group, or the allocated dynamic shared storage space is released, including: generating an allocation instruction for the dynamic shared storage space through a main thread in the generated execution thread, and allocating the dynamic shared storage space to the work group based on the allocation instruction for the dynamic shared storage space; or generating a release instruction for the dynamic shared storage space through the main thread in the generated execution thread, and releasing the allocated dynamic shared storage space based on the release instruction.

[0170] In one of the optional embodiments, dynamic shared storage space is allocated to a work group based on a dynamic shared storage space allocation instruction, including: checking a storage table corresponding to the dynamic shared storage space to determine whether there is dynamic remaining space that satisfies the target dynamic shared space corresponding to the dynamic shared storage space allocation instruction; when the dynamic remaining space satisfies the target dynamic shared space corresponding to the dynamic shared storage space allocation instruction, adjusting the storage table corresponding to the dynamic shared storage space, and recording the address of the dynamic shared storage space allocated to the work group.

[0171] In one of the optional embodiments, the method also includes: when the dynamic remaining space does not satisfy the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, returning allocation failure information and suspending the threads of the work group until the dynamic remaining space satisfies the target dynamic shared space corresponding to the threads of the suspended work group, and continuing to execute the step of generating the allocation instruction of the dynamic shared storage space through the main thread in the generated execution thread.

[0172] In one of the optional embodiments, a storage table corresponding to the dynamic shared storage space is checked to determine whether there is dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, including: traversing the storage table corresponding to the dynamic shared storage space to determine whether there is unallocated valid dynamic shared storage space; in the case where there is unallocated valid dynamic shared storage space, counting the unallocated valid dynamic shared storage space to obtain the dynamic remaining space; when the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, determining whether there is dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space.

[0173] In one of the optional embodiments, releasing the allocated dynamic shared storage space based on a release instruction includes: based on the release instruction, resetting a corresponding allocation bit and a workgroup index in a storage table corresponding to the dynamic shared storage space.

[0174] Specifically, combined Figure 8 As shown, the shared memory control unit receives the main thread dynamic shared storage space allocation SM_ALLOC instruction or release SM_RELS instruction sent by the thread control unit, allocates or releases the dynamic memory space of the work group, and the management of the dynamic shared storage space is completed through the dynamic shared memory table Dynamic Shared Memory Table (DSMT) in the shared memory control unit. Each table entry of DSMT will record: (valid bit: 1 indicates that the dynamic shared storage space is valid, 0 indicates that the dynamic shared storage space is invalid; allocation bit: 1 indicates that the dynamic shared storage space has been allocated, 0 indicates that the dynamic shared storage space has not been allocated, work group index ID: use the current dynamic shared storage space work group index, initially 0), as shown Fig. 9 shown.

[0175] The specific steps for dynamic shared space management are as follows:

[0176] First, the unit receives the dynamic shared memory allocation instruction SM_ALLOC and the dynamic shared memory size SM_SIZE received by the thread control unit;

[0177] Secondly, check the dynamic shared memory table DSMT to see if there is enough dynamic shared storage space to meet the requested dynamic shared storage space size SM_SIZE. The check steps are as follows: Fig.10 As shown:

[0178] First, the dynamic remaining space is set to 0 and the dynamic shared storage space allocation pointer is set to 0, that is, the dynamic shared storage space is traversed from the beginning. If there is a dynamic shared storage space with a valid bit of 1 and an allocation bit of 0, the dynamic remaining space is increased by one, otherwise the dynamic shared storage space allocation pointer is increased by one, and it is determined whether the dynamic shared storage space allocation pointer is larger than the dynamic shared storage space size. If so, the information that the dynamic remaining space is insufficient is output. Otherwise, the step of traversing the dynamic shared storage space is continued. After the dynamic remaining space is increased by one, it is determined whether the dynamic remaining space is equal to the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space. If so, the information that the dynamic remaining space is sufficient is output. Otherwise, the step of traversing the dynamic shared storage space is continued.

[0179] If the remaining dynamic shared storage space is sufficient, execute step 3, otherwise execute step 4.

[0180] The third step is to update DSMT and record the dynamic shared storage space allocation address, and notify the thread control unit that the dynamic shared storage space allocation is successful; for each table entry of DSMT, according to the dynamic allocation pointer, traverse DSMT, find the table entry with the valid bit as 1 and the allocation bit as 0, and update the corresponding table entry, that is, update the allocation bit and workgroup index ID. Taking workgroup index ID = 2 as an example, combined with Fig.11 As shown, Fig.11 To update the rules, for the current work group, record the dynamic shared storage space address Dynamic_SM_Addr of DSMT, such as Fig.12 Taking the work group index ID = 2 as an example, the base addresses of the dynamic shared storage space corresponding to work group 2 are 0, 8, and 21 respectively.

[0181] In the fourth step, the remaining dynamic shared storage space cannot satisfy the dynamic shared storage space request of the current work group, and a dynamic shared storage space allocation failure signal is returned to the thread control unit, which suspends the threads of the current work group until the dynamic shared storage space of other work groups that meet the conditions is released.

[0182] In the fifth step, the thread control unit sends a dynamic shared storage space release SM_RELS instruction and a released work group index ID.

[0183] Step 6: Update the item in the DSMT table whose workgroup index is the released workgroup index ID according to the workgroup index ID, that is, clear the allocation bit and workgroup index to 0. The update rules are as follows: Fig.13 shown.

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

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

[0186] In an exemplary embodiment, Fig.14 As shown, a storage space management device is provided, comprising:

[0187] Receiving module 1401, used for receiving work group information;

[0188] The static shared storage space allocation module 1402 is used to allocate static shared storage space to the work group before the work group corresponding to the work group information is executed;

[0189] The dynamic shared storage space allocation module 1403 is used to allocate dynamic shared storage space to the work group during the execution of the work group, or release the allocated dynamic shared storage space.

[0190] In one embodiment, the above-mentioned device also includes: an execution module, used to generate a number of execution threads based on the work group information; when each execution thread executes a shared storage read and write instruction, read and write operations are performed on the static shared storage space and / or dynamic shared storage space of the work group corresponding to the execution thread.

[0191] In one of the embodiments, the above-mentioned execution module is specifically used to convert the logical address corresponding to the shared storage read / write instruction into the first physical address of the static shared storage space based on the first base address of the static shared storage space of the working group corresponding to the execution thread when the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is smaller than the size of the static shared storage space; convert the logical address corresponding to the shared storage read / write instruction into the second physical address of the dynamic shared storage space based on the second base address of the dynamic shared storage space of the working group corresponding to the execution thread when the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the size of the static shared storage space and the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is smaller than the sum of the size of the static shared storage space and the size of the dynamic shared storage space; and perform read and write operations based on the first physical address and the second physical address.

[0192] In one of the embodiments, the execution module is specifically used to output an out-of-bounds prompt when the space size corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the sum of the size of the static shared storage space and the size of the dynamic shared storage space.

[0193] In one embodiment, the execution module is specifically used to read data based on the first physical address and the second physical address when the shared storage read / write instruction is a read operation, and bypass the read data to the general register memory.

[0194] In one of the embodiments, the execution module is specifically configured to obtain the first physical address based on the sum of the first base address of the static shared storage space and the logical address corresponding to the shared storage read and write instructions.

[0195] In one of the embodiments, the above-mentioned execution module is specifically used to obtain a base address of a dynamic shared storage space based on the total size of the static shared storage space and the storage row size; obtain a size of a dynamic shared storage space allocated storage row based on the number of storage rows and the storage row size of the dynamic shared storage space; obtain a shared storage address of the dynamic shared storage space based on a logical address corresponding to a shared storage read and write instruction, the size of the static shared storage space, and the size of a dynamic shared storage space allocated storage row; obtain a dynamic shared storage space offset based on a shared storage address of the dynamic shared storage space, the size of the dynamic shared storage space allocated storage row, the logical address corresponding to the shared storage read and write instruction, and the size of the static shared storage space; and obtain a second physical address based on the base address of the dynamic shared storage space and the dynamic shared storage space offset.

[0196] In one of the embodiments, the above-mentioned static shared storage space allocation module 1402 is specifically used to obtain the static remaining space of the static shared storage space; when the static remaining space is greater than or equal to the target static shared storage space corresponding to the work group information, determine the base address of the static shared storage space, allocate static shared storage space to the work group based on the base address of the static shared storage space, and adjust the first allocation pointer of the static shared storage space.

[0197] In one of the embodiments, the static shared storage space allocation module 1402 is specifically used to use the current first allocation pointer as the base address of the static shared storage space, allocate static shared storage space to the work group based on the base address of the static shared storage space, and adjust the current first allocation pointer based on the current first allocation pointer, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

[0198] In one of the embodiments, the static shared storage space allocation module 1402 is specifically used to release the static shared storage space after waiting for the execution of other work groups when the static remaining space is smaller than the target static shared storage space corresponding to the work group information, and continue to execute the step of determining the base address of the static shared storage space when the static remaining space after release is greater than or equal to the target static shared storage space corresponding to the work group information.

[0199] In one of the embodiments, the above-mentioned static shared storage space allocation module 1402 is specifically used to obtain the current first allocation pointer and the current release pointer; when the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the total storage rows of the static shared storage space and the first pointer, and the first pointer is the difference between the current first allocation pointer and the current release pointer; when the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the current release pointer and the current first allocation pointer.

[0200] In one embodiment, the static shared storage space allocation module 1402 is specifically used to release the corresponding static shared storage space and adjust the release pointer of the static shared storage space when the work group is executed.

[0201] In one embodiment, the static shared storage space allocation module 1402 is specifically used to adjust the release pointer based on the release pointer of the static shared storage space, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

[0202] In one of the embodiments, the above-mentioned dynamic shared storage space allocation module 1403 is specifically used to generate an allocation instruction of the dynamic shared storage space through the main thread in the generated execution thread, and allocate the dynamic shared storage space to the work group based on the allocation instruction of the dynamic shared storage space; or generate a release instruction of the dynamic shared storage space through the main thread in the generated execution thread, and release the allocated dynamic shared storage space based on the release instruction.

[0203] In one of the embodiments, the above-mentioned dynamic shared storage space allocation module 1403 is specifically used to check the storage table corresponding to the dynamic shared storage space to determine whether there is dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space; when the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, adjust the storage table corresponding to the dynamic shared storage space, and record the address of the dynamic shared storage space allocated to the working group.

[0204] In one of the embodiments, the above-mentioned dynamic shared storage space allocation module 1403 is specifically used to return allocation failure information and suspend the threads of the work group when the dynamic remaining space does not satisfy the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, until the dynamic remaining space satisfies the target dynamic shared space corresponding to the threads of the suspended work group, and then continue to execute the step of generating the allocation instruction of the dynamic shared storage space through the main thread in the generated execution thread.

[0205] In one of the embodiments, the dynamic shared storage space allocation module 1403 is specifically used to traverse the storage table corresponding to the dynamic shared storage space to determine whether there is unallocated valid dynamic shared storage space; in the case that there is unallocated valid dynamic shared storage space, count the unallocated valid dynamic shared storage space to obtain the dynamic remaining space; when the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, determine whether there is dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space.

[0206] In one embodiment, the dynamic shared storage space allocation module 1403 is specifically configured to reset the corresponding allocation bit and work group index in the storage table corresponding to the dynamic shared storage space based on the release instruction.

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

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

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

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

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

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

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

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

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

Claims

1. A storage space management method, characterized in that: The method comprises: Receiving work group information, wherein the computing shader thread construction unit is used to receive the work group information, generate threads according to the work group information and the thread template, and threads of the same work group access the same shared memory space; Before the work group corresponding to the work group information is executed, a static shared storage space is allocated to the work group; During the execution of the work group, allocating a dynamic shared storage space for the work group, or releasing the allocated dynamic shared storage space; The allocating static shared storage space to the working group includes: Obtaining the static remaining space of the static shared storage space; When the static remaining space is greater than or equal to the target static shared storage space corresponding to the workgroup information, determine the base address of the static shared storage space, allocate static shared storage space to the workgroup based on the base address of the static shared storage space, and adjust the first allocation pointer of the static shared storage space.

2. The method according to claim 1, characterized in that The method further comprises: Generate a number of execution threads based on the workgroup information; When each of the execution threads executes a shared storage read and write instruction, a read and write operation is performed on the static shared storage space and / or the dynamic shared storage space of the work group corresponding to the execution thread.

3. The method according to claim 2, characterized in that The performing a reading and writing operation on the static shared storage space and the dynamic shared storage space of the working group corresponding to the execution thread includes: In a case where the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is smaller than the size of the static shared storage space, based on the first base address of the static shared storage space of the working group corresponding to the execution thread, converting the logical address corresponding to the shared storage read / write instruction into a first physical address of the static shared storage space; In a case where the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the size of the static shared storage space, and the size of the space corresponding to the logical address corresponding to the shared storage read / write instruction is less than the sum of the size of the static shared storage space and the size of the dynamic shared storage space, based on the second base address of the dynamic shared storage space of the working group corresponding to the execution thread, converting the logical address corresponding to the shared storage read / write instruction into a second physical address of the dynamic shared storage space; Read and write operations are performed based on the first physical address and the second physical address.

4. The method according to claim 3, characterized in that The method further comprises: When the space size corresponding to the logical address corresponding to the shared storage read / write instruction is greater than or equal to the sum of the size of the static shared storage space and the size of the dynamic shared storage space, an out-of-bounds prompt is output.

5. The method according to claim 3, characterized in that: The performing a read and write operation based on the first physical address and the second physical address includes: When the shared storage read / write instruction is a read operation, data is read based on the first physical address and the second physical address, and the read data is bypassed to the general register memory.

6. The method according to claim 3, characterized in that: The converting the logical address corresponding to the shared storage read / write instruction into the first physical address of the static shared storage space includes: The first physical address is obtained based on the sum of the first base address of the static shared storage space and the logical address corresponding to the shared storage read and write instructions.

7. The method according to claim 3, characterized in that The converting the logical address corresponding to the shared storage read / write instruction into the second physical address of the dynamic shared storage space includes: Based on the total size of the static shared memory space and the size of the memory row, obtaining the base address of the dynamic shared memory space; Based on the number of storage rows in the dynamic shared storage space and the storage row size, obtaining the storage row size allocated by the dynamic shared storage space; Obtaining a shared storage address of the dynamic shared storage space based on a logical address corresponding to the shared storage read / write instruction, a size of the static shared storage space, and a size of a storage row allocated by the dynamic shared storage space; The dynamic shared storage space offset is obtained based on the shared storage address of the dynamic shared storage space, the size of the storage row allocated by the dynamic shared storage space, the logical address corresponding to the shared storage read and write instruction, and the size of the static shared storage space; The second physical address is obtained based on the dynamic shared memory space base address and the dynamic shared memory space offset.

8. The method according to claim 1, characterized in that The determining the base address of the static shared storage space, allocating the static shared storage space to the work group based on the base address of the static shared storage space, and adjusting the first allocation pointer of the static shared storage space include: Use the current first allocation pointer as the base address of the static shared storage space, allocate static shared storage space to the work group based on the base address of the static shared storage space, and adjust the current first allocation pointer based on the current first allocation pointer, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

9. The method according to claim 1, characterized in that: The method further comprises: When the static remaining space is smaller than the target static shared storage space corresponding to the working group information, wait until other working groups are finished executing and then release the static shared storage space. When the static remaining space after release is greater than or equal to the target static shared storage space corresponding to the working group information, continue to execute the step of determining the base address of the static shared storage space.

10. The method according to claim 1, characterized in that The obtaining of the static remaining space of the static shared storage space includes: Get the current first allocation pointer and the current release pointer; When the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the total storage rows of the static shared storage space and the first pointer, and the first pointer is the difference between the current first allocation pointer and the current release pointer; When the address corresponding to the current first allocation pointer is smaller than the address corresponding to the current release pointer, the static remaining space is equal to the difference between the current release pointer and the current first allocation pointer.

11. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: When the work group is executed, the corresponding static shared storage space is released, and a release pointer of the static shared storage space is adjusted.

12. The method according to claim 11, characterized in that The adjusting the release pointer of the static shared storage space includes: The release pointer is adjusted based on the release pointer of the static shared storage space, the target static shared storage space corresponding to the work group information, and the total storage rows of the static shared storage space.

13. The method according to any one of claims 2 to 7, characterized in that: The allocating the dynamic shared storage space for the working group, or releasing the allocated dynamic shared storage space, comprises: Generate an allocation instruction of the dynamic shared storage space through a main thread in the generated execution threads, and allocate the dynamic shared storage space to the work group based on the allocation instruction of the dynamic shared storage space; or A release instruction of the dynamic shared storage space is generated by a main thread in the generated execution threads, and the allocated dynamic shared storage space is released based on the release instruction.

14. The method according to claim 13, characterized in that The allocating the dynamic shared storage space to the working group based on the allocation instruction of the dynamic shared storage space includes: Checking a storage table corresponding to the dynamic shared storage space to determine whether there is a dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space; When the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, the storage table corresponding to the dynamic shared storage space is adjusted, and the address of the dynamic shared storage space allocated to the working group is recorded.

15. The method according to claim 14, characterized in that The method further comprises: In the case that the dynamic remaining space does not satisfy the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, the allocation failure information is returned, and the threads of the work group are suspended until the dynamic remaining space satisfies the target dynamic shared space corresponding to the suspended threads of the work group, and the step of generating the allocation instruction of the dynamic shared storage space through the main thread in the generated execution thread is continued.

16. The method according to claim 14, characterized in that The checking of the storage table corresponding to the dynamic shared storage space to determine whether there is a dynamic remaining space of the target dynamic shared space corresponding to the allocation instruction satisfying the dynamic shared storage space includes: Traversing the storage table corresponding to the dynamic shared storage space to determine whether there is unallocated valid dynamic shared storage space; In the case that there is unallocated effective dynamic shared storage space, counting the unallocated effective dynamic shared storage space to obtain dynamic remaining space; When the dynamic remaining space satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space, it is determined that there is a dynamic remaining space that satisfies the target dynamic shared space corresponding to the allocation instruction of the dynamic shared storage space.

17. The method according to claim 13, characterized in that The releasing the allocated dynamic shared storage space based on the release instruction comprises: Based on the release instruction, the corresponding allocation bit and workgroup index in the storage table corresponding to the dynamic shared storage space are reset.

18. A storage space management device, characterized in that: The device comprises: A receiving module is used to receive workgroup information, wherein the compute shader thread construction unit is used to receive the workgroup information, generate threads according to the workgroup information and the thread template, and threads of the same workgroup access the same shared memory space; A static shared storage space allocation module, used to allocate static shared storage space to the work group before the work group corresponding to the work group information is executed; A dynamic shared storage space allocation module, used to allocate dynamic shared storage space to the work group during the execution of the work group, or release the allocated dynamic shared storage space; The static shared storage space allocation module is used for: Obtaining the static remaining space of the static shared storage space; When the static remaining space is greater than or equal to the target static shared storage space corresponding to the workgroup information, determine the base address of the static shared storage space, allocate static shared storage space to the workgroup based on the base address of the static shared storage space, and adjust the first allocation pointer of the static shared storage space.

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

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

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

Citation Information

Patent Citations

  • Memory allocation method and device, computer equipment and storage medium

    CN111324461A