Storage space allocation method and apparatus, electronic device, storage medium, and product
By introducing GMAB storage space when OCAB storage space is insufficient, the pipeline stalling and deadlock issues in the OCAB storage space allocation process are resolved, thereby improving overall performance and data access efficiency.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- VERISILICON MICROELECTRONICS (SHANGHAI) CO LTD
- Filing Date
- 2024-12-05
- Publication Date
- 2026-06-11
AI Technical Summary
In existing technologies, the OCAB storage space allocation process causes the allocation pipeline to stall and deadlock when there is insufficient remaining space, and there is also a problem of overall performance degradation.
GMAB storage space is introduced to buffer and adjust when OCAB space is insufficient. By allocating GMAB storage space to the target object to replace OCAB storage space, the access speed is ensured to be no lower than OCAB. The storage space allocation process is optimized through permission checks and timing mechanisms.
This reduces pipeline stalls, avoids deadlock issues, and improves overall performance and data access efficiency.
Smart Images

Figure CN2024137215_11062026_PF_FP_ABST
Abstract
Description
Storage space allocation methods, devices, electronic devices, storage media and products Technical Field
[0001] This application relates to the field of electronic technology, and more specifically, to a storage space allocation method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology
[0002] In computer graphics, shading any point within a primitive requires utilizing the point's attribute value. These attribute values are typically stored in external memory, and transferring this data to the Graphics Processing Unit (GPU) consumes significant bandwidth and time. Storing attribute values in the GPU's on-chip attribute buffer (OCAB) facilitates access by the computation unit, improving access speed and efficiency. Before performing shading calculations, a portion of OCAB storage space needs to be allocated to store the attribute values.
[0003] The existing process for requesting OCAB storage space is as follows: When a storage space request is received, the remaining available OCAB space is first checked. If there is sufficient remaining available OCAB space, OCAB storage space is allocated to the request; otherwise, a blocking state is entered, and the request is placed in a waiting queue for orderly processing. When previously allocated storage space is released, the relevant resource manager updates its status and notifies the requests in the waiting queue. After each release operation, the remaining available OCAB space is recalculated and compared with the storage space requested by the pending requests. Once the remaining available OCAB space is greater than or equal to the required storage space, the required storage space is allocated to the blocked request, the status is updated to unblock the request, and the previously blocked request is allowed to continue.
[0004] In existing technologies, the allocation process for OCAB memory space can lead to pipeline stalls and overall performance degradation when OCAB space is insufficient. Furthermore, existing technologies are susceptible to deadlock during out-of-order execution. For example, consider two sets of draw data input sequentially, each containing a vertex shader (VS) and a geometry shader (GS). When the VS of the second draw set occupies all OCAB space, on the one hand, due to the requirement of maintaining order (i.e., the input and output shader order must match), the VS of the second draw set cannot be output before the GS of the first draw set, thus continuously occupying OCAB space. On the other hand, the GS of the first draw set cannot allocate enough OCAB space and is therefore blocked from entering the pipeline, resulting in a deadlock. Summary of the Invention
[0005] The purpose of this application is to provide a storage space allocation method, apparatus, electronic device, computer-readable storage medium, and computer program product to improve the problems existing in the OCAB storage space allocation method in the prior art.
[0006] The embodiments of this application are implemented as follows:
[0007] In a first aspect, embodiments of this application provide a storage space allocation method, comprising: obtaining an application request from a target object, wherein the application request is used to apply for OCAB storage space; checking whether the remaining OCAB storage space is greater than or equal to the OCAB storage space applied for by the application request; if the remaining OCAB storage space is less than the OCAB storage space applied for by the application request, allocating GMAB (Global Memory Attribute Buffer) storage space to the target object based on the application request, wherein the access speed of the OCAB storage space is greater than or equal to the access speed of the GMAB storage space.
[0008] In the above implementation, by introducing GMAB storage space, when the remaining space of OCAB is insufficient, GMAB storage space is used for buffering and adjustment, thereby reducing the possibility of pipeline stalls and improving overall performance. This can improve the problems existing in the OCAB storage space allocation method in the prior art.
[0009] In one possible implementation of the first aspect embodiment, before checking whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, the method further includes: checking the application permission of the target object for the OCAB storage space; and determining that the target object has the application permission for the OCAB storage space.
[0010] In the above implementation, before checking whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, the application permission of the target object for the OCAB storage space is checked first. Only when the target object has the application permission is the remaining OCAB storage space checked to see if it is greater than or equal to the OCAB storage space requested in the application request. In this way, the storage allocation performance can be improved by adjusting the permission parameters, and the flexibility of the solution can be enhanced.
[0011] In one possible implementation of the first aspect embodiment, the method further includes: if the target object does not have permission to apply for OCAB storage space, allocating GMAB storage space to the target object based on the application request.
[0012] In the above implementation, if the target object does not have permission to request OCAB storage space, GMAB storage space is allocated to the target object based on the request. Using GMAB storage space to replace OCAB storage space can ensure that the entire pipeline is not blocked, thereby further improving performance.
[0013] In one possible implementation of the first aspect embodiment, checking the OCAB storage space application permission of the target object includes: performing at least one of the following checks; checking whether the OCAB storage space requested in the application request exceeds the maximum single application value; checking whether the OCAB storage space currently being used by the target object at the time of application exceeds the maximum upper limit value; wherein, if each of the at least one checks is negative, it is determined that the target object has the OCAB storage space application permission.
[0014] In the above implementation, the above-described checking method is used to check whether the target object has the permission to apply for OCAB storage space. Flexible overflow judgment can be achieved by configuring the maximum single application value and the maximum upper limit value.
[0015] In one possible implementation of the first aspect embodiment, before allocating GMAB storage space to the target object based on the application request, the method further includes: if the remaining OCAB storage space is less than the OCAB storage space requested in the application request, entering a timing phase; if the timing duration exceeds the target duration, checking again whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request; and determining that the remaining OCAB storage space checked again is still less than the OCAB storage space requested in the application request.
[0016] In the above implementation, when the remaining OCAB storage space is less than the OCAB storage space requested in the application request, by waiting for a certain period of time, if during the timing phase, there is a possibility that previously allocated OCAB storage space may be released. After the release, the remaining OCAB storage space available for allocation may be greater than or equal to the OCAB storage space requested in the application request. At this time, OCAB storage space can be allocated to the target object immediately. This will prioritize the allocation of OCAB storage space to the target object. Since the access speed of OCAB storage space is greater than or equal to the access speed of GMAB storage space, this can maximize data access efficiency.
[0017] In a possible implementation of the first aspect embodiment, the method further includes: if the remaining OCAB storage space checked again is greater than or equal to the OCAB storage space requested in the application request, allocating OCAB storage space to the target object based on the application request.
[0018] In the above implementation, if the remaining OCAB storage space checked again is greater than or equal to the OCAB storage space requested in the application request, then OCAB storage space is immediately allocated to the target object based on the application request. Priority is given to allocating OCAB storage space to the target object. Since the access speed of OCAB storage space is greater than or equal to the access speed of GMAB storage space, this can maximize data access efficiency.
[0019] In a possible implementation of the first aspect embodiment, the method further includes: if the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, allocating OCAB storage space to the target object based on the application request.
[0020] In the above implementation, if the remaining OCAB storage space checked is greater than or equal to the OCAB storage space requested in the application request, then OCAB storage space is immediately allocated to the target object based on the application request. Priority is given to allocating OCAB storage space to the target object. Since the access speed of OCAB storage space is greater than or equal to the access speed of GMAB storage space, this can maximize data access efficiency.
[0021] In one possible implementation of the first aspect embodiment, before allocating GMAB storage space to the target object based on the application request, the method further includes: checking whether the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request; and determining that the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request.
[0022] In the above implementation, before allocating GMAB storage space to the target object based on the application request, it is first checked whether the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request. Only when it is determined that the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request is the remaining GMAB storage space allocated to it. This makes it unnecessary to set the GMAB storage space to be relatively large when setting the allocable GMAB storage space, thereby reducing area overhead.
[0023] In one possible implementation of the first aspect embodiment, the GMAB storage space allocated to the target object includes an L1 cache; after allocating the GMAB storage space of the L1 cache to the target object based on the application request, the method further includes: setting the replacement priority of data in each cache line in the GMAB storage space allocated to the target object to the lowest replacement priority.
[0024] In the above implementation, when the GMAB storage space allocated to the target object includes an L1 cache, the replacement priority of the data in each cache line in the GMAB storage space allocated to the target object is set to the lowest replacement priority to reduce the probability of it being replaced, thereby making full use of the L1 cache, resulting in less latency for the computing unit to obtain data and improving overall performance.
[0025] Secondly, embodiments of this application provide a storage space allocation device, including: an acquisition module, a checking module, and an allocation module; the acquisition module is used to acquire an application request from a target object, wherein the application request is used to apply for OCAB storage space; the checking module is used to check whether the remaining OCAB storage space is greater than or equal to the OCAB storage space applied for by the application request; the allocation module is used to allocate GMAB storage space to the target object based on the application request if the remaining OCAB storage space is less than the OCAB storage space applied for by the application request, wherein the access speed of the OCAB storage space is greater than or equal to the access speed of the GMAB storage space.
[0026] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor, the processor being connected to the memory; the memory being used to store a program; the processor being used to invoke the program stored in the memory to execute the storage space allocation method provided by any possible implementation of the first aspect above.
[0027] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a computer, performs the storage space allocation method provided by any possible implementation of the first aspect above.
[0028] Fifthly, embodiments of this application provide a computer program product, the computer program product including a computer program, which, when executed by a computer, performs the storage space allocation method provided by any possible implementation of the first aspect above.
[0029] The technical effects that can be achieved in aspects two through five are the same as those in aspect one, and will not be repeated here. Attached Figure Description
[0030] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 is a flowchart illustrating the first storage space allocation method provided in an embodiment of this application;
[0032] Figure 2 is a flowchart illustrating the second storage space allocation method provided in an embodiment of this application;
[0033] Figure 3 is a flowchart illustrating the third storage space allocation method provided in the embodiments of this application;
[0034] Figure 4 is a flowchart illustrating the fourth storage space allocation method provided in the embodiments of this application;
[0035] Figure 5 is a flowchart illustrating the fifth storage space allocation method provided in the embodiments of this application;
[0036] Figure 6 is a flowchart illustrating the sixth storage space allocation method provided in the embodiments of this application;
[0037] Figure 7 is a structural diagram of a storage space allocation device provided in an embodiment of this application;
[0038] Figure 8 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0039] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. The following embodiments are provided as examples to more clearly illustrate the technical solutions of this application, and should not be used to limit the scope of protection of this application. Those skilled in the art will understand that, without conflict, the following embodiments and features can be combined with each other.
[0040] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, relational terms such as "first," "second," etc., in the description of this application are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.
[0041] Furthermore, the term "and / or" in this application is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0042] In the description of the embodiments of this application, unless otherwise expressly specified and limited, the technical term "connection" can be a direct connection or an indirect connection through an intermediate medium.
[0043] This application provides a storage space allocation method. When the remaining space in the OCAB is insufficient, the method allocates GMAB storage space to the target object, thereby reducing pipeline stalls and overall chip performance degradation, and can also avoid deadlock problems during out-of-order execution.
[0044] The storage space allocation method provided in the embodiments of this application will be described below with reference to Figure 1. The storage space allocation method shown in this application can be applied to the processor in an electronic device. For example, in one embodiment, the method can be applied to a GPU (Graphics Processing Unit) to allocate storage space for shaders in the GPU.
[0045] S1: Obtain the request from the target object, where the request is used to request OCAB storage space.
[0046] This process retrieves a request from a target object (e.g., `client`, representing the shader type). This request is used to allocate OCAB storage space. The target object can be a shader, such as a vertex shader, geometry shader, or pixel shader. Shaders use various data during execution; for example, when coloring any point within a primitive, the point's attribute value is needed. To improve data access speed and efficiency, storage space needs to be allocated to the shader to store this data. For instance, OCAB storage space can be allocated to the shader to store attribute values.
[0047] The target object can request OCAB storage space by sending a request to the relevant resource manager in the GPU. The resource manager then receives the request from the target object, which is used to request OCAB storage space. OCAB storage space is typically an on-chip cache used to store image vertex attribute values and can be part of the L1 cache (Level 1 cache).
[0048] The relevant resource manager can be the GPU's Memory Management Unit (MMU) or an equivalent mechanism. For example, the relevant resource manager can also be a shader group allocation manager or a shader group allocation controller.
[0049] S2: Check if the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request.
[0050] After receiving the request from the target object, check whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the request. If the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the request, proceed to step S4; otherwise, if the remaining OCAB storage space is less than the OCAB storage space requested in the request, proceed to step S3.
[0051] S3: Allocate GMAB storage space for the target object based on the application request.
[0052] If the remaining OCAB storage space is less than the OCAB storage space requested in the application request, then GMAB storage space is allocated to the target object based on the application request, wherein the access speed of the OCAB storage space is greater than or equal to the access speed of the GMAB storage space. When allocating GMAB storage space to the target object, the size of the allocated GMAB storage space is the same as the size of the OCAB storage space requested in the application request.
[0053] When allocating GMAB storage space for target objects, different target objects are allocated independent storage spaces to avoid deadlock. Each target object is allocated an independent GMAB storage space, including a base address and space size, which is configurable. When using the GMAB storage space, the GMAB offset address needs to be calculated, and the actual GMAB address is obtained by adding the corresponding base address, thus achieving independent address control for each target object.
[0054] The GMAB storage space serves as a buffer to replace the OCAB storage space when the remaining OCAB space is insufficient. In existing technologies, once the remaining OCAB space is insufficient, subsequent allocation requests are immediately blocked, which can cause the entire pipeline to be blocked, thereby affecting the overall computing efficiency. This application introduces the GMAB storage space to perform buffering and adjustment when the remaining OCAB space is insufficient, thereby reducing pipeline stalls and improving overall performance.
[0055] GMAB storage space can cover multiple global storage spaces such as L1 cache, L2 cache (Level 2 cache), L3 cache (Level 3 cache), off-chip storage, etc. When allocating GMAB storage space for a target object, storage space with faster access speed is allocated first, that is, L1 cache and L2 cache are allocated first. Only when the storage space of L1 cache and L2 cache is insufficient is L3 cache allocated, so as to maximize data access efficiency.
[0056] In one possible implementation, the GMAB storage space allocated to the target object includes an L1 cache. After allocating GMAB storage space to the target object based on the request, the method further includes setting the replacement priority of data in each cache line of the GMAB storage space allocated to the target object to the lowest replacement priority. In this application, a cache control mechanism can be used when accessing the GMAB storage space. This cache control mechanism includes two aspects of control. First, a priority-based replacement algorithm is used in the L1 cache to assign different replacement priorities to each cache line of data, including evict_first, evict_normal, and evict_last. Here, evict_first indicates the highest replacement priority, evict_last indicates the lowest replacement priority, and evict_normal indicates the intermediate replacement priority. The thresholds for evict_normal and evict_last can be configured, thereby achieving more flexible control. Secondly, when allocating GMAB storage space, L1 cache is given priority and its replacement priority is set to evict_last to reduce the probability of it being replaced, thereby making full use of L1 cache, resulting in less latency for computing units to obtain data and improving overall performance.
[0057] When allocating GMAB storage space to a target object based on a request, one possible implementation is to directly allocate GMAB storage space to the target object based on the request. In this implementation, the available GMAB storage space can be set to a relatively large value to ensure that the available GMAB storage space is always greater than or equal to the OCAB storage space requested in the request.
[0058] In this application, the allocatable GMAB storage space is greater than the allocatable OCAB storage space, that is, the remaining GMAB storage space is greater than the remaining OCAB space. In this way, when the remaining OCAB space is insufficient, there is enough GMAB storage space available for allocation, thereby reducing pipeline stalls.
[0059] S4: Allocate OCAB storage space for the target object based on the request.
[0060] If the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, OCAB storage space is allocated to the target object based on the application request. The size of the allocated OCAB storage space is the same as the size of the OCAB storage space requested in the application request.
[0061] When allocating OCAB storage space for target objects, VOCAB addresses (Virtual OCAB) can be allocated first. The significance of using virtual addresses is that storage space virtualization allows different target objects to use the same storage address, thereby improving storage resource utilization. Next, POCAB addresses (Physical OCAB) are allocated, and a mapping from VOCAB addresses to POCAB addresses is established. POCABs are shared by all target objects, allowing different target objects to share data stored in GPU memory, reducing redundant storage and memory bandwidth consumption. This allocation method allows for dynamic allocation of storage space, which can be adjusted as needed, improving the efficiency and flexibility of storage resource management and avoiding storage resource waste.
[0062] In one possible implementation, before S3, the method further includes: checking whether the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request; if the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request, then S3 is executed: allocating GMAB storage space to the target object based on the application request. If the remaining GMAB storage space is less than the OCAB storage space requested in the application request, then the processing of the application request is suspended. When the GMAB storage space is released, and the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request, then the suspended application request is allocated GMAB storage space again. To facilitate understanding of the storage space allocation method shown in this embodiment, it will be described below with reference to FIG2. In the embodiment shown in FIG2, S23 is added between S2 and S3 shown in FIG1, that is, checking whether the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request; if yes, S23 is executed; if no, S5 is executed: suspending the processing of the application request.
[0063] In one possible implementation, prior to S2, the method further includes checking the target object's permission to request OCAB storage space to determine if the target object has the permission to request OCAB storage space. In this implementation, the step of checking whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request is only performed if it is determined that the target object has the permission to request OCAB storage space.
[0064] In one possible implementation, the method further includes allocating GMAB storage space to the target object based on the application request if the target object does not have the right to apply for OCAB storage space.
[0065] To facilitate understanding of the storage space allocation method shown in the above embodiments, the following explanation is provided in conjunction with Figure 3. The embodiment shown in Figure 3 adds a step S11 between S1 and S2 in Figure 1: checking whether the target object has permission to apply for OCAB storage space. That is, checking the target object's permission to apply for OCAB storage space. If it is determined that the target object has permission to apply for OCAB storage space, S2 is executed; otherwise, if it is determined that the target object does not have permission to apply for OCAB storage space, S3 is executed.
[0066] When checking the OCAB storage space application permissions of a target object, in one implementation, the detection process may include: performing at least one of the following checks: checking whether the OCAB storage space requested in the application request exceeds the maximum single application value; checking whether the OCAB storage space currently in use by the target object at the time of application exceeds the maximum upper limit value; wherein, if each of the at least one check is negative, it is determined that the target object has the permission to apply for OCAB storage space, otherwise, if any of the at least one check is positive, it is determined that the target object does not have the permission to apply for OCAB storage space.
[0067] In one possible implementation, the two checks described above can be performed simultaneously: checking whether the OCAB storage space requested in the application exceeds the maximum single request value, and checking whether the OCAB storage space currently being used by the target object at the time of application exceeds the maximum upper limit value. If the OCAB storage space requested in the application does not exceed the maximum single request value, and the OCAB storage space currently being used by the target object at the time of application does not exceed the maximum upper limit value, then the target object is determined to have the right to apply for OCAB storage space. Conversely, if the OCAB storage space requested in the application exceeds the maximum single request value, and / or the OCAB storage space currently being used by the target object at the time of application exceeds the maximum upper limit value, then the target object is determined not to have the right to apply for OCAB storage space.
[0068] The OCAB storage space currently used by the target object at the time of application will change with the allocation and release of OCAB storage space. When OCAB storage space is released, the OCAB storage space currently used will decrease accordingly. If OCAB storage space is allocated to the target object, the OCAB storage space currently used will increase accordingly.
[0069] In some implementations, the above-mentioned check of the application permission of the target object's OCAB storage space can also be called a spill check of the target object's OCAB storage space. That is, the check of the application permission of the OCAB storage space can be called the spill check of the OCAB storage space.
[0070] In one possible implementation, before S3, the method further includes entering a timing phase (also known as entering a timeout mechanism) if the remaining OCAB storage space is less than the OCAB storage space requested in the application request; if the timing duration exceeds the target duration, checking again whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request; and determining that the remaining OCAB storage space checked again is still less than the OCAB storage space requested in the application request. In this implementation, if the remaining OCAB storage space is less than the OCAB storage space requested in the application request, S3 is not executed immediately, but instead, a timing phase is entered. When the timing duration exceeds the target duration, checking again whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request; only when the remaining OCAB storage space checked again is still less than the OCAB storage space requested in the application request is S3 executed.
[0071] In one possible implementation, the method further includes: if the remaining OCAB storage space checked again is greater than or equal to the OCAB storage space requested in the application request, allocating OCAB storage space to the target object based on the application request. When the remaining OCAB storage space is less than the OCAB storage space requested in the application request, by waiting for a certain period of time, if previously allocated OCAB storage space is released during the timing phase, the available remaining OCAB storage space may then be greater than or equal to the OCAB storage space requested in the application request. In this case, OCAB storage space can be allocated to the target object immediately, thus prioritizing the allocation of OCAB storage space to the target object. Since the access speed of OCAB storage space is greater than or equal to the access speed of GMAB storage space, this can maximize data access efficiency. Simultaneously, the target duration is configurable. If, after the target duration, the remaining OCAB storage space is still less than the OCAB storage space requested in the application request, it indicates that the required OCAB storage space is indeed large and difficult to satisfy. In this case, GMAB storage space is used instead of OCAB storage space, ensuring that the entire pipeline is not blocked, thereby further improving performance.
[0072] To facilitate understanding of the storage space allocation method shown in the above embodiments, the following explanation is provided in conjunction with Figures 4 and 5. The embodiment shown in Figure 4 adds step S22 between S2 and S3 shown in Figure 1, and the embodiment shown in Figure 5 adds step S22 between S2 and S3 shown in Figure 3. Specifically, if the remaining OCAB storage space is less than the OCAB storage space requested in the application request, the timing phase begins; if the timing duration exceeds the target duration, the remaining OCAB storage space is checked again to see if it is greater than or equal to the OCAB storage space requested in the application request. If the remaining OCAB storage space checked again is still less than the OCAB storage space requested in the application request, then S3 is executed; otherwise, if the remaining OCAB storage space checked again is greater than or equal to the OCAB storage space requested in the application request, then S4 is executed.
[0073] The timeout mechanism for storage space proposed in this application can select more efficient L1 caches and reduce the use of unnecessary global storage space. By making full use of the L1 cache, the latency for computing units to retrieve data is reduced, thus improving overall performance.
[0074] The maximum upper limit, maximum single request value, and target duration mentioned above are all configurable. Flexible overflow checks and adjustments to the waiting time can be achieved through several configurable parameters. These parameters include the overflow threshold, client_throttle, and timeout parameters; different target objects have their own independent set of these three parameters.
[0075] The threshold parameter represents the maximum request value in a single request. When the requested OCAB storage space exceeds the threshold parameter, OCAB storage space will no longer be used, and GMAB storage space will be allocated directly instead.
[0076] The `client_throttle` parameter represents the maximum upper limit of OCAB storage space that the target object can use. If the OCAB storage space currently being used by the target object exceeds the `client_throttle` parameter, then OCAB storage space will no longer be used, and GMAB storage space will be used instead.
[0077] The `timeout` parameter represents the target duration of the timeout mechanism. If the overflow check (also known as the permission check) passes, but the requested OCAB storage space exceeds the remaining OCAB storage space, GMAB storage space is not used directly; instead, the timeout mechanism is invoked. The timeout mechanism is implemented through a configurable parameter `timeout`. When the timeout mechanism is invoked, a counter is reset to zero and begins counting. If the counter reaches `timeout`, a timeout is triggered, and the remaining OCAB storage space is checked again to see if it is greater than or equal to the requested OCAB storage space. GMAB storage space is allocated only if the requested OCAB storage space still exceeds the remaining OCAB storage space when the timeout is triggered.
[0078] In one possible implementation, the schematic diagram of the above-described storage space allocation method can be shown in Figure 6. After receiving a request from the target object, an overflow check is first performed. If the overflow check passes, an OCAB space allocation check is performed to confirm whether there is enough OCAB space available for allocation. If so, VOCAB and POCAB addresses are allocated, and address mapping is completed. If not, a timeout mechanism is entered. The timeout mechanism is implemented through a configurable parameter `timeout`. When the timeout mechanism is entered, a counter is reset to zero and starts counting. If the counter reaches `timeout`, a timeout is triggered, and the remaining OCAB storage space is checked again to see if it is greater than or equal to the OCAB storage space requested in the request. GMAB storage space is allocated only if the required OCAB storage space still exceeds the remaining OCAB space when the timeout is triggered. If the overflow check fails, a GMAB space allocation check is performed to confirm whether there is enough GMAB space available for allocation. If so, GMAB storage space is allocated instead of OCAB storage space; if not, the resource check fails, and the request must be blocked.
[0079] It is understood that the embodiment shown in Figure 6 is only one of the many embodiments of this application. Different parts of each embodiment can be combined with each other to form new embodiments. For those skilled in the art, other related figures can be obtained from these figures without creative effort.
[0080] This application also provides a storage space allocation device 100, as shown in FIG7. The storage space allocation device 100 includes: an acquisition module 110, an inspection module 120, and an allocation module 130. The storage space allocation device 100 shown in this application can run in the memory management unit, shader group allocation manager, or shader group allocation controller of the GPU.
[0081] The acquisition module 110 is used to acquire an application request from the target object, wherein the application request is used to apply for OCAB storage space.
[0082] The checking module 120 is used to check whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request.
[0083] The allocation module 130 is used to allocate GMAB storage space to the target object based on the application request if the remaining OCAB storage space is less than the OCAB storage space requested in the application request, wherein the access speed of the OCAB storage space is greater than or equal to the access speed of the GMAB storage space.
[0084] In one possible implementation, before checking whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, the checking module 120 is further configured to check the application permission of the target object for the OCAB storage space; and determine that the target object has the application permission for the OCAB storage space.
[0085] In one possible implementation, the inspection module 120 is configured to perform at least one of the following checks: check whether the OCAB storage space requested in the application request exceeds the maximum single application value; check whether the OCAB storage space currently in use by the target object at the time of application exceeds the maximum upper limit value; wherein, if each of the at least one checks is negative, it is determined that the target object has the right to apply for OCAB storage space.
[0086] In one possible implementation, the allocation module 130 is further configured to allocate GMAB storage space to the target object based on the application request if the target object does not have the permission to apply for OCAB storage space.
[0087] In one possible implementation, before the allocation module 130 allocates GMAB storage space to the target object based on the application request, the checking module 120 is further configured to: if the remaining OCAB storage space is less than the OCAB storage space requested in the application request, enter the timing stage; if the timing duration exceeds the target duration, check again whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request; and determine that the remaining OCAB storage space checked again is still less than the OCAB storage space requested in the application request.
[0088] In one possible implementation, the allocation module 130 is further configured to allocate OCAB storage space to the target object based on the application request if the remaining OCAB storage space checked again is greater than or equal to the OCAB storage space requested in the application request.
[0089] In one possible implementation, the allocation module 130 is further configured to allocate OCAB storage space to the target object based on the application request if the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request.
[0090] In one possible implementation, the checking module 120 is further configured to check whether the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request before the allocation module 130 allocates GMAB storage space to the target object based on the application request; and determine that the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request.
[0091] In one possible implementation, the GMAB storage space allocated to the target object includes an L1 cache. The allocation module 130 is further configured to set the replacement priority of the data in each cache line in the GMAB storage space allocated to the target object to the lowest replacement priority.
[0092] The storage space allocation device 100 provided in this application embodiment has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0093] As shown in Figure 8, Figure 8 illustrates a structural block diagram of an electronic device 200 provided in an embodiment of this application. The electronic device 200 includes: a transceiver 210, a memory 220, a communication bus 230, and a processor 240.
[0094] The transceiver 210, memory 220, and processor 240 are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected through one or more communication buses 230 or signal lines. The transceiver 210 is used to send and receive data. The memory 220 is used to store computer programs, such as the software functional modules shown in FIG. 7, i.e., the storage space allocation device 100. The storage space allocation device 100 includes at least one software functional module that can be stored in the memory 220 in the form of software or firmware or embedded in the operating system (OS) of the electronic device 200. The processor 240 is used to execute executable modules stored in the memory 220, such as the software functional modules or computer programs included in the storage space allocation device 100. For example, the processor 240 is used to execute the aforementioned storage space allocation method.
[0095] The memory 220 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0096] The processor 240 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor 240 may include a data processing core such as a GPU (Graphics Processing Unit), CPU (Central Processing Unit), AI (Artificial Intelligence), NPU (Neural Network Processing Unit), ISP (Image Signal Processor), DPU (Display Processing Unit), VPU (Video Processing Unit), or DSP (Digital Signal Processor), or a processor chip applied to scenarios such as large-scale data computation. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. Alternatively, the processor 240 may also be any conventional processor.
[0097] Among them, the aforementioned electronic devices 200 include, but are not limited to, mobile phones, tablets, laptops, computers, etc.
[0098] This application embodiment also provides a non-volatile computer-readable storage medium (hereinafter referred to as storage medium) storing a computer program, which is executed by a computer such as the electronic device 200 described above to perform the storage space allocation method described above.
[0099] This application also provides a computer program product, which includes a computer program. When the computer program is executed by a computer, it performs the storage space allocation method described above.
[0100] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0102] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0103] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a computer device (which may be a personal computer, laptop, server, or electronic device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned computer-readable storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0104] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A storage space allocation method, characterized in that, include: Obtain a request from the target object, wherein the request is for requesting OCAB storage space; Check whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request; If the remaining OCAB storage space is less than the OCAB storage space requested in the application request, GMAB storage space is allocated to the target object based on the application request, wherein the access speed of the OCAB storage space is greater than or equal to the access speed of the GMAB storage space.
2. The storage space allocation method according to claim 1, characterized in that, Before checking whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, the method further includes: Check the request permissions for the OCAB storage space of the target object; It is determined that the target object has the permission to apply for OCAB storage space.
3. The storage space allocation method according to claim 2, characterized in that, The method further includes: If the target object does not have permission to apply for OCAB storage space, GMAB storage space is allocated to the target object based on the application request.
4. The storage space allocation method according to claim 2, characterized in that, The permission to request OCAB storage space for the target object is checked, including: Perform at least one of the following checks: Check whether the OCAB storage space requested in the application request exceeds the maximum single request value; Check whether the OCAB storage space used when the target object was requested exceeds the maximum limit; If each of the at least one of the checks is negative, it is determined that the target object has the right to apply for OCAB storage space.
5. The storage space allocation method according to claim 1, characterized in that, Before allocating GMAB storage space to the target object based on the application request, the method further includes: If the remaining OCAB storage space is less than the OCAB storage space requested in the application request, the timing phase begins; If the timeout period exceeds the target duration, check again whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request. It was determined that the remaining OCAB storage space after the second check was still less than the OCAB storage space requested in the application request.
6. The storage space allocation method according to claim 5, characterized in that, The method further includes: If the remaining OCAB storage space checked again is greater than or equal to the OCAB storage space requested in the application request, OCAB storage space is allocated to the target object based on the application request.
7. The storage space allocation method according to claim 1, characterized in that, The method further includes: If the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request, OCAB storage space is allocated to the target object based on the application request.
8. The storage space allocation method according to any one of claims 1-7, characterized in that, Before allocating GMAB storage space to the target object based on the application request, the method further includes: Check whether the remaining GMAB storage space is greater than or equal to the OCAB storage space requested in the application request; It is determined that the remaining storage space of the GMAB is greater than or equal to the storage space of the OCAB requested in the application request.
9. The storage space allocation method according to any one of claims 1-7, characterized in that, The GMAB storage space allocated to the target object includes an L1 cache; after allocating GMAB storage space to the target object based on the application request, the method further includes: Set the replacement priority of the data in each cache line in the GMAB storage space allocated to the target object to the lowest replacement priority.
10. A storage space allocation device, characterized in that, include: The acquisition module is used to acquire an application request from the target object, wherein the application request is used to request OCAB storage space; The checking module is used to check whether the remaining OCAB storage space is greater than or equal to the OCAB storage space requested in the application request; The allocation module is used to allocate GMAB storage space to the target object based on the application request if the remaining OCAB storage space is less than the OCAB storage space requested in the application request, wherein the access speed of the OCAB storage space is greater than or equal to the access speed of the GMAB storage space.
11. An electronic device, characterized in that, include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is configured to invoke a program stored in the memory to execute the storage space allocation method as described in any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a computer, performs the storage space allocation method as described in any one of claims 1-9.
13. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a computer, performs the storage space allocation method as described in any one of claims 1-9.