A method, apparatus, device and storage medium for allocating a buffer block
By identifying free buffer blocks in the processor's configured buffers and combining them with unconfigured buffers, the capacity of the buffer blocks is dynamically adjusted, thus solving the problem of low buffer utilization and achieving efficient utilization of buffer resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MOORE THREADS TECH CO LTD
- Filing Date
- 2025-09-17
- Publication Date
- 2026-06-09
AI Technical Summary
When the processor executes a task, the capacity of the statically partitioned buffer block is insufficient, causing the task to be unusable and resulting in low buffer utilization.
By identifying available buffer blocks to be allocated in the configured buffers and combining them with unconfigured buffers, the capacity of the buffer blocks can be dynamically adjusted to meet task requirements, thereby improving buffer utilization.
This improves the reuse rate of the buffer, reduces the need for additional buffer blocks, and lowers the overall resource requirements of the buffer.
Smart Images

Figure CN120821579B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage, and more particularly to a method, apparatus, device, and storage medium for allocating buffer blocks. Background Technology
[0002] When a processor executes a task, it needs to select a free buffer block from the pool of buffers that have been statically divided into multiple buffer blocks configured for the processor. Thus, if the capacity of the buffer block required by the task is greater than the capacity of the free buffer block, the task cannot use the free buffer block, resulting in low buffer utilization. Summary of the Invention
[0003] This application provides a buffer block allocation technology solution.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a method for allocating buffer blocks, the method comprising:
[0006] In response to the start of a task to be executed, a free buffer block to be allocated is determined from multiple buffer blocks in a configured buffer; wherein, the multiple buffer blocks in the configured buffer are divided based on historical tasks;
[0007] If the capacity of the demand buffer block required by the task to be executed is greater than the capacity of the free buffer block to be allocated, the demand buffer block is determined based on the free buffer block to be allocated and the unconfigured buffer.
[0008] This application embodiment also provides a buffer block allocation device, the buffer block allocation device comprising:
[0009] A response module is used to determine a free buffer block to be allocated among multiple buffer blocks in a configured buffer in response to the start of a task to be executed; wherein the multiple buffer blocks in the configured buffer are divided based on historical tasks;
[0010] The determination module is configured to determine the required buffer block based on the unallocated free buffer block and the unconfigured buffer block when the capacity of the required buffer block for the task to be executed is greater than the capacity of the free buffer block to be allocated.
[0011] Accordingly, this application also provides a computer device, which includes a memory and a processor. The memory stores computer-executable instructions, and the processor can implement the buffer block allocation method described above when it executes the computer-executable instructions in the memory.
[0012] This application embodiment also provides a computer storage medium storing computer-executable instructions, which, when executed, can implement the buffer block allocation method described above.
[0013] This application provides a method, apparatus, device, and storage medium for allocating buffer blocks. First, in response to the initiation of a task to be executed, a free buffer block to be allocated is determined from a plurality of buffer blocks in a configured buffer. The plurality of buffer blocks in the configured buffer are divided based on historical tasks. Then, if the capacity of the required buffer block for the task to be executed is greater than the capacity of the free buffer block to be allocated, the required buffer block is determined based on the free buffer block to be allocated and unconfigured buffers. Thus, when the capacity of the required buffer block for the task to be executed is greater than the capacity of the free buffer block to be allocated, a required buffer block matching the task to be executed is determined based on the free buffer block to be allocated and the unconfigured buffers in the configured buffer composed of multiple buffer blocks. In this way, by dividing the configured buffer based on historical tasks to obtain a plurality of buffer blocks, the requirement for buffers is reduced and the utilization rate of buffers is improved. This increases the reuse rate of buffer blocks in the configured buffer and reduces the need to request additional buffer blocks for tasks to be executed, thereby reducing the overall requirement for buffers.
[0014] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the technical solutions provided in the embodiments of this application. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein:
[0016] Figure 1 A flowchart illustrating a method for allocating buffer blocks according to an embodiment of this application;
[0017] Figure 2 A flowchart illustrating another method for allocating buffer blocks provided in an embodiment of this application;
[0018] Figure 3 A flowchart illustrating another method for allocating buffer blocks provided in an embodiment of this application;
[0019] Figure 4 A schematic diagram of a dedicated memory buffer configured for the maximum number of concurrent tasks in related technologies;
[0020] Figure 5 A schematic diagram of a dedicated memory buffer configured for the number of running tasks in related technologies;
[0021] Figure 6 A diagram illustrating the allocation of a corresponding buffer block for a launched task within a configured buffer.
[0022] Figure 7 A diagram illustrating the allocation of corresponding buffer blocks for a launched task based on both configured and unconfigured buffers;
[0023] Figure 8 A schematic diagram illustrating the structural composition of a buffer block distribution device provided in an embodiment of this application;
[0024] Figure 9 This is a schematic diagram of the structural composition of a computer device provided in an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of the invention will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate the embodiments of this application, but are not intended to limit the scope of the embodiments of this application.
[0026] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0027] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which embodiments of this application belong. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of embodiments of this application.
[0029] To facilitate understanding of this solution, the application background of the embodiments of this application will be explained before describing the embodiments of this application.
[0030] Dedicated memory buffers are commonly used in various Graphics Processing Units (GPUs) when the kernel executes tasks (threads in a program). GPUs typically execute threads in registers to ensure processing efficiency. However, register resources are limited. When a new thread needs to execute, the thread that is about to finish needs to be moved to a dedicated memory buffer, freeing up space in the registers for the new thread to use, thus improving processing efficiency. The moved-out thread can be reloaded back into the registers when needed.
[0031] In related technologies, dedicated memory buffers are typically configured based on the maximum number of concurrent tasks (which can be threads corresponding to a program) that a GPU can run. When a new task arrives, it can be allocated from a free block of the configured dedicated memory buffer. However, because most cores inside a GPU are usually limited by other resources within the GPU (e.g., registers, shared memory), the GPU cannot run the maximum number of concurrent tasks at all times, resulting in low utilization of the allocated dedicated buffers.
[0032] To address the aforementioned problems, embodiments of this application provide a method, apparatus, device, and storage medium for allocating buffer blocks. Specifically, when the capacity of the required buffer block for a task to be executed exceeds the capacity of the available free buffer block, the available free buffer block and the unconfigured buffer from a configured buffer (composed of multiple buffer blocks based on historical tasks) are used simultaneously to determine a matching required buffer block for the task to be executed. Thus, by using a configured buffer composed of multiple buffer blocks obtained from historical task partitioning, the requirement for buffer space is reduced while increasing buffer utilization. This improves the reuse rate of buffer blocks in the configured buffer and reduces the need for additional buffer blocks to be allocated for tasks to be executed, thereby reducing the overall buffer space requirement.
[0033] This application provides a method for allocating buffer blocks. Figure 1 A flowchart illustrating a buffer block allocation method provided in this application embodiment is shown below. Figure 1 As shown, combined with Figure 1 The steps shown are explained below:
[0034] S101. In response to the start of the task to be executed, determine the free buffer block to be allocated among the multiple buffer blocks of the configured buffer.
[0035] The configured buffer consists of multiple buffer blocks that are divided based on historical tasks.
[0036] In the embodiments of this application, the task to be executed can be any task received and started by any processor; wherein, the processor can be any of the following: Central Processing Unit (CPU), GPU, Digital Signal Processor (DSP).
[0037] Here, the task to be executed can be a thread within a program to be executed, and the number of such tasks can be one or multiple. If the task to be executed consists of multiple threads, these threads can be multiple threads running concurrently within a single program, multiple threads running according to a preset timing requirement, or multiple threads corresponding to multiple different programs. The program is a relevant program that can run on a processor (e.g., GPU, CPU, DSP).
[0038] In this embodiment of the application, in response to the start of the task to be executed, the GPU determines a free buffer block to be allocated from multiple buffer blocks of the configured buffer; wherein, the free buffer block to be allocated is a buffer block in an idle state, that is, a buffer block with empty storage information; the free buffer block to be allocated is used to allocate to the task to be executed.
[0039] It's important to note that a buffer is essentially a "temporary storage area." When multiple kernels within the GPU execute related tasks, they need to process data in registers. If a new task requires a register, and the registers are already occupied by the currently executing task, resulting in insufficient register capacity, the task nearing completion can be moved out of the register to free up space for the new task. In this case, the data corresponding to the moved-out task needs to continue execution within the buffer block until completion.
[0040] In this embodiment, the configured buffer blocks are divided based on historical tasks; historical tasks are tasks that started before the task to be executed; these historical tasks can be different threads within the same program as the task to be executed, or they can be threads within different programs. Here, the configured buffer blocks can be pre-defined, and these blocks cannot be merged or split. The attribute information of the multiple buffer blocks can be identical or different. The attribute information can include the capacity of the buffer block, which can be determined by the capacity of the historical buffer blocks required by the historical task.
[0041] In the embodiments of this application, the historical task can be a pre-defined started task (relative to the task to be executed). For example, the historical task can be the first task executed internally by the processor when it is running normally, i.e., the first task started internally by the processor, such as task 1; correspondingly, the multiple buffer blocks of the configured buffer are only divided based on task 1. Here, subsequent processor responses to the start of other tasks (including but not limited to: tasks received after task 1 and tasks to be executed before tasks to be executed, and tasks to be executed) will not have any impact on the configured buffer.
[0042] For example, if the historical task is task 1, the processor, in response to the start of task 1, determines the configured buffer, i.e., a configured buffer consisting of 120 buffer blocks of 5k each, based on the capacity of the initial buffer block required by task 1 (e.g., 5k), the maximum number of tasks that the execution units in the processor can support to run the initial program corresponding to task 1 (e.g., 10), and the number of execution units in the processor (e.g., 12).
[0043] It should be noted that if task 1 includes at least two tasks 11 belonging to different programs, the maximum capacity can be selected from the capacity of the allocated buffer required by the at least two tasks 11, and the maximum number of tasks can be selected from the maximum number of tasks that the execution unit can support running at least two programs. Thus, the processor can determine the configured buffer based on the selected maximum capacity and the maximum number of tasks.
[0044] In the embodiments of this application, the historical task can be all tasks that have been started inside the processor before the task to be executed starts, i.e., task 2 (including task 1 mentioned above); correspondingly, the multiple buffer blocks of the configured buffer are divided based on task 2. Here, subsequent processor responses to other tasks (such as the task to be executed) may affect the configured buffer.
[0045] For example, if the historical task is task 2, the configured buffer corresponding to task 1 (i.e., the buffer obtained by the processor based on the first received and executed task 1: a configured buffer consisting of 120 buffer blocks with a capacity of 5k) is adjusted based on the capacity of the buffer block required by task 3 (a task that is after task 1 and before the task to be executed). The adjustment includes, but is not limited to: if the capacity of the buffer block required by task 3 is greater than 5k, requesting additional buffer blocks from other areas and combining the requested additional buffer blocks with the buffer blocks with a capacity of 5k to form an indivisible buffer block for use by task 3.
[0046] Based on the above description, the division of the configured buffer into multiple buffer blocks, such as the capacity of multiple buffer blocks, is determined based on the attributes of historical tasks.
[0047] It should be noted that the address information between multiple buffer blocks in a configured buffer can be consecutive; for example, the end address of buffer block 1 can be consecutive to the start address of buffer block 2. Alternatively, the address information between multiple buffer blocks in a configured buffer can be non-consecutive.
[0048] In this embodiment of the application, in response to the start of the task to be executed, the GPU can determine a number of idle buffer blocks in an idle state among the multiple buffer blocks of the configured buffer, and then select an idle buffer block to be allocated from the multiple idle buffer blocks based on a preset selection principle; here, the preset selection principle may be: a selection principle based on the preset idle state duration, a selection principle based on a preset order, etc.
[0049] It should be noted that configured buffers can be memory buffers, which can be divided into hardware buffers and software buffers. Hardware buffers are provided by relevant chips or storage devices, and their storage location is usually within the device itself, such as video memory or disk cache. Software buffers, on the other hand, are provided by code, and their storage location is usually in computer memory, such as network packet buffers or file read / write caches.
[0050] S102. If the capacity of the demand buffer block required by the task to be executed is greater than the capacity of the free buffer block to be allocated, determine the demand buffer block based on the free buffer block to be allocated and the unconfigured buffer.
[0051] In this embodiment of the application, the capacity of the buffer block required by the task to be executed is the size of the buffer for temporarily storing data required by the task to be executed; similarly, the capacity of the free buffer block to be allocated is the maximum capacity that the free buffer block to be allocated can accommodate or store data.
[0052] For example, the demand buffer block has a capacity of 5k, and the available free buffer block to be allocated has a capacity of 3K.
[0053] In this embodiment, the unconfigured buffer can refer to the description above or be a memory buffer, which can be a hardware buffer or a software buffer. Here, the configured buffer and the unconfigured buffer can both be hardware buffers or software buffers, or one can be a hardware buffer and the other a software buffer. This embodiment does not limit this in any way.
[0054] In this embodiment of the application, the unconfigured buffer can be a buffer that can be flexibly divided into multiple different buffer blocks.
[0055] In this embodiment of the application, when the capacity of the demand buffer block is greater than the capacity of the free buffer block to be allocated, a selected buffer block can be selected from the unconfigured buffer based on the capacity of the free buffer block to be allocated and the capacity of the demand buffer block. Then, the set of the free buffer block to be allocated and the selected buffer block is used as the demand buffer block.
[0056] Understandably, since the GPU can determine the required buffer block for the task to be executed by using the available free buffer blocks and unconfigured buffers in the configured buffer (composed of multiple buffer blocks based on historical tasks) when the capacity of the required buffer block for the task to be executed is greater than the capacity of the available free buffer blocks, the GPU can reduce the need to re-partition buffer blocks and improve the reuse rate of buffer blocks in the configured buffer.
[0057] In some embodiments of this application, in S102, the implementation of the required buffer block is determined based on the unallocated free buffer block and the unconfigured buffer, such as... Figure 2 As shown, it may include:
[0058] S201. Determine the difference between the capacity of the demand buffer block and the capacity of the free buffer block to be allocated.
[0059] In this embodiment of the application, the difference capacity is the difference between the capacity of the demand buffer block and the capacity of the free buffer block to be allocated; for example, if the capacity of the demand buffer block is 6k and the capacity of the free buffer block to be allocated is 4k, then the difference capacity is 2k.
[0060] S202. The set of the unallocated free buffer block and the difference buffer block in the unconfigured buffer is taken as the demand buffer block.
[0061] Wherein, the capacity of the difference buffer block is the difference capacity.
[0062] In this embodiment of the application, a difference buffer block with a capacity equal to the difference capacity can be determined in the unconfigured buffer, and then the set of the free buffer block to be allocated and the difference buffer block can be used as the demand buffer block.
[0063] It should be noted that the difference buffer block with a capacity equal to the difference capacity in the unconfigured buffer can be selected randomly based on the difference capacity; or it can be selected and partitioned in the unconfigured buffer according to the address information corresponding to the difference capacity and the address information of the unconfigured buffer.
[0064] Here, the set of unallocated free buffer blocks and difference buffer blocks is regarded as an indivisible buffer block (actually composed of two parts of the buffer block), which serves as the required buffer block for the task to be executed.
[0065] Understandably, the GPU can determine a difference buffer block with a capacity equal to the difference between the capacity of the demand buffer block and the capacity of the available free buffer block in the unallocated buffer. Then, the set of available free buffer blocks and the difference buffer block is used as the demand buffer block required by the task to be executed. In this way, when the capacity of the demand buffer block required by the task to be executed is greater than the capacity of the available free buffer block, it can reuse the available free buffer block and more accurately find the difference buffer block in the unallocated buffer, thus making the determined demand buffer block more closely match the actual needs of the task to be executed.
[0066] In some embodiments of this application, the set of the unallocated free buffer block and the difference buffer block in the unconfigured buffer in S202 is used as the implementation of the demand buffer block, which may include: S2021 to S2022 (not shown in the figure).
[0067] S2021. Obtain the set of address information corresponding to the free buffer block to be allocated and the address information corresponding to the difference buffer block, and use it as the set address information.
[0068] In this embodiment, the GPU can directly combine the address information to be allocated corresponding to the free buffer block to be allocated and the difference address information corresponding to the difference buffer block to form a set address information.
[0069] Here, the address information corresponding to the unallocated free buffer block can be represented using the starting address information of the unallocated free buffer block, and the address information corresponding to the difference buffer block can be represented using the starting address information of the difference buffer block. For example: the starting address information is: address1: p+N to address1: p+2*N; the address information corresponding to the difference buffer block is: address2: q to address2: q+n; furthermore, the set address information is: address1: p+N to address1: p+2*N, and address2: q to address2: q+n.
[0070] S2022, The buffer block corresponding to the aggregate address information is used as the demand buffer block.
[0071] Here, corresponding to the description above, the buffer block corresponding to the aggregate address information, that is, the buffer block corresponding to the unallocated free buffer block and the difference buffer block as a whole, is used as the demand buffer block.
[0072] Understandably, the GPU can manage the address information of unallocated free buffer blocks and difference buffer blocks. For example, it can combine the address information of the two to form a set of address information, and then use this set of address information as the address information of the demand buffer, so that relevant data can be stored or data stored in the demand buffer block can be retrieved when the task to be executed is executed. In this way, the convenience of data management can be improved.
[0073] In some embodiments of this application, the combination of the unallocated free buffer block and the difference buffer block in the unconfigured buffer in step S202, as the implementation following the demand buffer block, may include:
[0074] A. In response to the completion of the task to be executed, release the unallocated free buffer block and the difference buffer block, and use the set of the unallocated free buffer block and the difference buffer block to update the unallocated free buffer block in the configured buffer to obtain the updated configured buffer.
[0075] In this embodiment, after the task to be executed ends, the unallocated free buffer block and the difference buffer block can be released synchronously, and the set of both—that is, the set of unallocated free buffer blocks and the difference buffer blocks—can be used to replace the unallocated free buffer blocks in the configured buffer, resulting in an updated configured buffer. Here, after the difference buffer block in the unconfigured buffer is released, it can also be used synchronously as part of the unallocated free buffer block in the configured buffer.
[0076] In this embodiment of the application, after taking the set of unallocated free buffer blocks and difference buffer blocks as the required buffer blocks for the task to be executed, that is, when reusing the unallocated free buffer blocks of the configured buffer, the difference buffer blocks in the unconfigured buffer are combined with the unallocated free buffer blocks. In this way, the set of unallocated free buffer blocks and difference buffer blocks can be synchronously used to update the unallocated free buffer blocks in the configured buffer, and the updated configured buffer is obtained.
[0077] Here, an update can be considered a replacement; and the update operation includes, but is not limited to: updating the capacity of the free buffer block to be allocated using the capacity corresponding to the set of the free buffer block to be allocated and the difference buffer block (the sum of the capacity of the free buffer block to be allocated and the capacity of the difference buffer block); and updating the address information corresponding to the free buffer block to be allocated using the address information corresponding to the set of the free buffer block to be allocated and the difference buffer block.
[0078] For example, the configured buffer includes: buffer block 1, buffer block 2, and buffer block 3 (i.e., the idle buffer block to be allocated). The updated configured buffer includes: buffer block 2, buffer block 2, and updated buffer block 3 (the idle buffer block to be allocated + the difference buffer block). Here, if a new task 1 arrives later, and the required buffer block capacity is still greater than the capacity of the idle buffer blocks (buffer block 2, buffer block 2, and updated buffer block 3) in the configured buffer, then the updated buffer block 3 can be used as the idle buffer block to be allocated for the new task 1. Thus, compared to buffer block 1 or buffer block 2 being used as the idle buffer block to be allocated, a difference buffer block with a relatively smaller capacity can be requested in the unconfigured buffer. Alternatively, if a new task 2 arrives later, and the capacity of the buffer block required by the new task 2 is equal to the capacity of the updated buffer block 3 in the configured buffer, then when the updated buffer block 3 is in an idle state, the updated buffer block 3 can be directly used as the idle buffer block to be allocated for the new task 2. Thus, compared to buffer block 1 or buffer block 2 being used as idle buffer blocks to be allocated, there is no need to request a difference buffer block in the unconfigured buffer.
[0079] Understandably, after using the combined set of unallocated free buffer blocks and difference buffer blocks in the unconfigured buffer as the required buffer block, after the task to be executed ends and the unallocated free buffer blocks and difference buffer blocks are released, the unallocated free buffer blocks in the configured buffer can be synchronously updated based on the combined set of unallocated free buffer blocks and difference buffer blocks, thus synchronously obtaining the updated configured buffer. In this way, after the task to be executed ends, the combined set of unallocated free buffer blocks and difference buffer blocks is synchronously released into the configured buffer to replace the unallocated free buffer blocks. This reduces the demand on the unconfigured buffer when a new task arrives and the required buffer block capacity is greater than the buffer block capacity in the configured buffer.
[0080] In some embodiments of this application, S202, which uses the set of the unallocated free buffer block and the difference buffer block in the unconfigured buffer as the implementation following the demand buffer block, may further include:
[0081] B. In response to the completion of the task to be executed, release the difference buffer block to the unconfigured buffer and release the unallocated free buffer block to the configured buffer.
[0082] In this embodiment of the application, after the task to be executed is completed, the unallocated free buffer block can be released to the configured buffer and the difference buffer block can be released to the unconfigured buffer.
[0083] Understandably, during the execution of a task, because the capacity of the available free buffer blocks in the configured buffer is less than the required buffer block capacity, it is necessary to utilize the difference buffer blocks in the unconfigured buffer to allocate corresponding buffer blocks for the task. After the task finishes, the difference buffer blocks requested from the unconfigured buffer are returned to the unconfigured buffer. In this way, after the task finishes, the available free buffer blocks are released to the configured buffer, and the difference buffer blocks are released to the unconfigured buffer, facilitating subsequent management of the data in the configured buffer and improving the convenience of data management.
[0084] In some embodiments of this application, the implementation prior to determining the allocation of a free buffer block among multiple buffer blocks of the configured buffer in S101 in response to the start of the task to be executed, such as... Figure 3 As shown, it may include: S301 to S302.
[0085] S301. In response to the initiation of the historical task, determine the capacity of the historical buffer block required by the historical task and the maximum number of tasks that the execution unit in the processor can support in running the program corresponding to the historical task.
[0086] In this embodiment, historical tasks differ from tasks to be executed, the difference being that the relevant processors start execution at different times. Furthermore, historical tasks and tasks to be executed can also differ in their task attributes, or, if the task is a thread, they can be threads corresponding to different programs.
[0087] In this embodiment, the processor can be any of GPU, CPU, or DSP. The execution unit is the processing unit in the processor. The maximum number of tasks that the execution unit can support in running the program corresponding to the historical task can be the maximum number of threads that the execution unit can support in running the program corresponding to the historical task. Here, the number of processing units included in the processor can be determined according to random requirements.
[0088] For example, when the processor is a GPU, the execution unit is the core in the GPU, namely the Arithmetic and Logic Unit (ALU); the number of cores in a GPU can reach hundreds or thousands.
[0089] It should be noted that the capacity of the historical buffer block required for historical tasks can be determined according to actual needs; for example, 7k.
[0090] In some embodiments, when the historical task is a thread A corresponding to a program running in the GPU, the GPU, in response to the start of thread A, determines that the capacity of the historical buffer block required by thread A is 7k, and the kernel in the GPU supports the maximum number of tasks running the program corresponding to thread A, i.e., the maximum number of threads is 10.
[0091] Here, by default, each execution unit within the same processor supports the same maximum number of tasks that can run the corresponding program.
[0092] S302. Determine the configured buffer based on the capacity of the historical buffer block, the maximum number of tasks, and the number of execution units in the processor.
[0093] In this embodiment, the GPU can determine the configured buffer based on the capacity of historical buffer blocks (e.g., 5k), the maximum number of tasks (e.g., 10), and the number of execution units in the processor (e.g., 10). Specifically, the required number of buffer blocks can be determined based on the product of the maximum number of tasks and the number of units, and the capacity of each buffer block can be determined based on the capacity of historical buffer blocks (assuming all buffer blocks have the same capacity). The processor can then request a configured buffer consisting of 100 buffer blocks with a capacity of 5k from the relevant memory buffer.
[0094] Here, the GPU can also adaptively increase the maximum number of tasks, the number of units, or the capacity of the historical buffer block, taking into account the capacity of the historical buffer block, the maximum number of tasks, and the number of execution units in the processor, in order to ensure the reliability of subsequent task execution. Then, based on the increased capacity of the historical buffer block, the increased maximum number of tasks, or the increased number of units, the corresponding configured buffer can be determined.
[0095] Furthermore, the configured buffer can respond to the start of any task and adaptively adjust the capacity of multiple buffer blocks in the configured buffer based on the capacity of the buffer blocks required by the task.
[0096] Understandably, the GPU can determine the configured buffers, divided into multiple buffer blocks, based on the capacity of the historical buffer blocks required by the historical task, the maximum number of tasks that the execution units in the processor can support in running the program corresponding to the historical task, and the number of execution units in the processor. In this way, the GPU can adaptively request configured buffers that match the resources required by the historical task (the capacity of the historical buffer blocks required by the historical task, the maximum number of tasks that the execution units can support in running the program corresponding to the historical task, and the number of execution units). Thus, the GPU can start based on the historical task, achieving a relatively accurate determination of a configured buffer with high utilization, thereby reducing the overall resource requirements for the buffers.
[0097] In some embodiments of this application, the historical task includes at least two intermediate tasks belonging to different historical programs. In step S301, in response to the initiation of the historical task, determining the capacity of the historical buffer block required by the historical task and the implementation of the maximum number of tasks that the execution unit in the processor can support in running the program corresponding to the historical task may include:
[0098] S3011. In response to the initiation of at least two intermediate tasks, determine the capacity of the buffer block to be allocated for each intermediate task to obtain a candidate capacity set, and determine the maximum number of tasks that the execution unit can support to run each historical program to obtain a candidate task number set.
[0099] In this embodiment, the response to the initiation of at least two intermediate tasks can be either the simultaneous initiation of at least two intermediate tasks or the sequential initiation of at least two intermediate tasks according to a preset timing sequence. The required buffer capacity for each intermediate task is then determined, resulting in a candidate capacity set (e.g., 6k, 7k, 8k). Simultaneously, the maximum number of tasks that the execution unit can support in running each historical program is determined, resulting in a candidate task number set (e.g., 10, 9; here, at least two intermediate tasks belong to two historical programs).
[0100] The historical tasks include at least two intermediate tasks belonging to different historical procedures; that is, the number of historical procedures and the number of intermediate tasks may be equal or unequal; for example, the at least two intermediate tasks are: intermediate task 1 of historical procedure 1, intermediate task 2 of historical procedure 1, and intermediate task 3 of historical procedure 2; or, the at least two intermediate tasks are: intermediate task 4 of historical procedure 4 and intermediate task 5 of historical procedure 5.
[0101] It should be noted that the candidate capacity set includes the number of candidate capacities (the same as the number of intermediate tasks); multiple candidate capacities can be partially the same, completely different, or completely identical. Similarly, the candidate task set includes the number of candidate tasks (the same as the number of intermediate tasks); multiple candidate tasks can be partially the same, completely different, or completely identical.
[0102] Based on S3011, S302 determines the implementation of the configured buffer based on the capacity of the historical buffer block, the maximum number of tasks, and the number of execution units in the processor, which may include S3021 to S3022.
[0103] S3021. The maximum capacity in the candidate capacity set is taken as the selected capacity, and the candidate task number with the largest value in the candidate task number set is taken as the selected task number.
[0104] In this embodiment, the GPU can directly select the largest capacity in the candidate capacity set as the selected capacity through numerical comparison, and the largest number of candidate tasks in the candidate task set as the selected task number. For example, the candidate capacity set is (5k, 8k, 10k, 4k), where the selected capacity is 10k; correspondingly, the candidate task set is (6, 7, 6, 5), where the selected task number is 7.
[0105] S3022. Based on the selected capacity, the number of selected tasks, and the number of units, determine the configured buffer.
[0106] In this embodiment, the GPU can determine the configured buffer based on the selected capacity, the number of selected tasks, and the number of units. For example, when the selected capacity is 7k, and the number of selected tasks and the number of units are 4 and 6 respectively, a configured buffer can be generated, which is internally statically divided into 24 buffer blocks, each with a capacity of 7k.
[0107] It should be noted that, based on the selected capacity, the number of selected tasks, and the number of units, and taking into account unforeseen or abnormal situations, the selected capacity, and / or the number of selected tasks, and / or the number of units can be further adaptively changed (usually increased), and the corresponding configured buffer is determined based on the changed selected capacity, the number of selected tasks, and the number of units.
[0108] Understandably, when a historical task includes at least two intermediate tasks belonging to different historical programs, the maximum capacity can be selected from the buffer capacity required by the at least two intermediate tasks, and the maximum number of tasks can be selected from the maximum number of tasks that the execution unit can support running the programs corresponding to the at least two intermediate tasks. The GPU can determine the configured buffer based on the selected maximum capacity and the maximum number of tasks. In this way, while reducing the overall buffer requirement, it is possible to match the required buffer block of the corresponding capacity for each intermediate task in the determined configured buffer after the start of any of the at least two intermediate tasks.
[0109] In some embodiments of this application, the implementation of determining the free buffer block to be allocated among the multiple buffer blocks of the configured buffer in S101 may include: C1 to C2.
[0110] C1. Identify multiple idle buffer blocks that are in an idle state among the multiple buffer blocks of the configured buffer.
[0111] In this embodiment of the application, multiple idle buffer blocks in an idle state are determined among multiple buffer blocks of configured buffers; wherein, the number of multiple idle buffer blocks can be two, three or more.
[0112] Here, the capacity of any two free buffer blocks among multiple free buffer blocks can be equal (as described above, the capacity of multiple buffer blocks within the configured buffer remains fixed, even if some buffer blocks in the unconfigured buffer are needed), or unequal (as described above, for example: the required buffer block for task 1 consists of buffer block i in the configured buffer and buffer block j in the unconfigured buffer, and after task 1 ends, the set of released buffer blocks i and j can be used to update buffer block i in the configured buffer, resulting in an updated configured buffer, where the multiple free buffer blocks included in the updated configured buffer may have unequal capacities). Furthermore, the address information of any two free buffer blocks among multiple free buffer blocks can be contiguous or non-contiguous.
[0113] C2. Determine the free buffer block to be allocated from the plurality of free buffer blocks.
[0114] In this embodiment of the application, the determination of the free buffer block to be allocated from multiple free buffer blocks can be based on preset selection conditions, such as capacity, duration of idle state, address information, etc.
[0115] For example, when multiple free buffer blocks have inconsistent capacities, the one with the largest capacity is selected. If there are multiple free buffer blocks with the largest capacity, the one with the earliest address among the configured buffers can be selected based on its address information. Alternatively, among multiple free buffer blocks, selection can be based on address information. For instance, if buffer block 1 in the configured buffer corresponds to an executed task (which may belong to the same program as the task to be executed), the free buffer block closest to it can be selected from among the multiple free buffer blocks based on its address information, thus facilitating subsequent data scheduling. Alternatively, among multiple free buffer blocks, the one that has been idle for the longest time can be selected as the free buffer block to be allocated.
[0116] Understandably, if multiple idle buffer blocks are identified among the allocated buffer blocks, a free buffer block to be allocated can be determined from these free buffer blocks based on a preset selection rule. In this way, selecting a free buffer block to be allocated from multiple idle buffer blocks can achieve adaptive determination of the free buffer block to be allocated, and is more in line with actual needs.
[0117] In some embodiments of this application, the implementation of determining the free buffer block to be allocated from the plurality of free buffer blocks in C2 may include:
[0118] The buffer block with the largest capacity among the multiple free buffer blocks is determined as the free buffer block to be allocated.
[0119] Here, based on capacity comparison, the buffer block with the largest capacity among multiple free buffer blocks is selected as the free buffer block to be allocated.
[0120] Here, if there are still multiple buffer blocks with the largest capacity, further selection can be made according to preset selection rules, such as: the attributes of the task to be executed, the address information of the free buffer block, the duration of the free buffer block in the idle state, etc.
[0121] It should be noted that the buffer block with the largest capacity among the free buffer blocks is taken as the free buffer block to be allocated. If the capacity of the required buffer block for the task to be executed is greater than the capacity of the free buffer block to be allocated, it can be indicated that in response to the start of the task to be executed, the capacity of the multiple free buffer blocks in the configured buffer at this moment is less than the capacity of the required buffer block.
[0122] Understandably, since the GPU can allocate buffers based on their capacity, it can select the buffer with the largest capacity from multiple free buffers as the available free buffer. In this way, when the capacity of the available free buffer is smaller than the capacity of the required buffer, it is possible to call the relatively smaller buffer from the unconfigured buffer, thereby further improving the reuse rate of the configured buffer and reducing the overall demand on the buffer.
[0123] In some embodiments of this application, the implementation of step S101, which determines a free buffer block to be allocated among multiple buffer blocks of the configured buffer in response to the start of the task to be executed, may include:
[0124] D. If the capacity of the demand buffer block is less than or equal to the capacity of the free buffer block to be allocated, the free buffer block to be allocated shall be used as the demand buffer block.
[0125] In some embodiments, if the capacity of the demand buffer block is less than or equal to the capacity of the free buffer block to be allocated, for example, the capacity of the demand buffer block is 5k and the capacity of the free buffer block to be allocated is 6k, the free buffer block to be allocated is directly used as the demand buffer block required by the task to be executed, and there is no need to supplement the buffer block with additional buffer blocks by means of the unconfigured buffer.
[0126] Here, since the unallocated free buffer block is directly used as the demand buffer block, that is, no changes or replacements are made to the unallocated free buffer block in the configured buffer, the division of multiple buffer blocks in the configured buffer can remain unchanged in response to the start of the task to be executed. The only change is that the unallocated free buffer block temporarily stores the data corresponding to the task to be executed.
[0127] Understandably, if the capacity of the buffer block required by the task to be executed is less than or equal to the capacity of the available free buffer block, the available free buffer block can be directly used as the buffer block required by the task. In this way, the available free buffer block of the configured buffer can be directly utilized, resulting in a higher utilization rate of the configured buffer and thus reducing the overall demand for buffers.
[0128] The above-described buffer block allocation method will be described below with reference to a specific embodiment. However, it is worth noting that this specific embodiment is only for better illustrating the embodiments of this application and does not constitute an improper limitation on the embodiments of this application.
[0129] Dedicated memory buffers are commonly used memory in various GPUs when the kernel executes related instructions. For example, when the GPU kernel uses too many registers to store data, the compiler can choose to store less frequently used data in a dedicated memory buffer (e.g., when a new task (thread) needs to be executed, and the new thread needs to store data in registers that can quickly store data, and the register resources are insufficient, the data of the thread that is almost finished but has not yet finished can be moved out of the registers to make use of the data of the new thread; in this case, the moved-out data needs to be stored in a dedicated memory buffer). The compiler loads the data in the dedicated memory buffer when needed, thus reserving more valuable register resources for more frequently used data.
[0130] In related technologies, there are typically two schemes for configuring a dedicated memory buffer:
[0131] Option 1, the software approach, configures a dedicated memory buffer based on the maximum number of concurrent tasks (which can refer to the threads of a program) that the GPU can run. However, because most cores within the GPU are typically limited by other internal resources (such as registers and shared memory), they cannot always run multiple tasks at the maximum possible concurrent capacity. Therefore, the actual number of concurrent tasks running on the GPU is usually far less than the maximum. This results in low resource utilization of the configured buffer (dedicated memory buffer) when using the software approach to configure a dedicated memory buffer based on the maximum number of concurrent tasks the GPU can run for temporary task data.
[0132] At the same time, such as Figure 4 The diagram illustrates a dedicated memory buffer configured for the maximum number of concurrent tasks in related technologies. The processor, such as a GPU, can run a maximum of M concurrent tasks, and each task requires a dedicated memory buffer of N bytes. A software solution would then configure a dedicated memory buffer consisting of M x N bytes. Figure 4 In the example, the address information begins with address: p and ends with address: p + M * N. For any given task _ID (q), the corresponding dedicated memory buffer address information is: address: p + (q-1) * N to address: p + q * N. Where, for example... Figure 4As shown, the tasks currently running are task_2 and task_M, while tasks_1 and task_(M-1) are not running. Therefore, preparing an M x N byte dedicated memory buffer to back up a limited number of concurrent tasks results in low utilization of this dedicated memory buffer. Furthermore, typical GPUs are usually designed to run a maximum of several hundred tasks concurrently, meaning M can be very large. When the GPU kernels require dedicated memory, the actual number of concurrently running tasks may be very small, further reducing the resource utilization of the configured dedicated memory buffer.
[0133] Option 2: A hardware solution. This solution addresses the issue by configuring a dedicated memory buffer during task execution and deallocating it upon task termination. Unlike the software solution, which statically allocates a dedicated buffer for each task the GPU might execute, this approach allocates a dedicated memory buffer for each task before it starts. It also creates a task_ID mapping to the starting address of the dedicated memory buffer, generating a fixed address mapping table. Therefore, when a task needs to access or call the dedicated memory buffer, it can directly check the starting address in the corresponding address mapping table. Figure 5 The diagram illustrates a dedicated memory buffer configured based on the number of running tasks in related technologies; where, as shown... Figure 5 As shown, at the current moment, only two tasks (task_2 and task_M) can run in parallel within the GPU, so only two dedicated memory buffers need to be allocated; the address information of the buffer block corresponding to task_2 is: address: p to address: p+N, and the address information of the buffer block corresponding to task_M is: address: p+N to address: p+2*N.
[0134] Here, a hardware-based approach allocates a dedicated memory buffer for each currently running task in the GPU. The GPU can contain multiple cores or multiple cores running tasks in parallel. If core A in the GPU is running two tasks concurrently, it has two dedicated memory buffers (1) corresponding to those two tasks. If core B in the GPU also needs to run a task, the capacity of its dedicated memory buffer (2) is greater than the capacity of dedicated memory buffer 2. However, because the address mapping table between the dedicated memory buffer and the relevant task is generated synchronously during the allocation of dedicated memory buffers in the hardware approach, it is fixed and immutable. That is, the two configured dedicated memory buffers (1) cannot be split or merged. This leads to core B in the GPU also needing to allocate an additional dedicated memory buffer (2), which in turn requires additional allocation of dedicated memory buffers, resulting in low utilization of the two configured dedicated memory buffers (1).
[0135] Given that both of the above-mentioned solutions (software and hardware) suffer from low utilization of dedicated memory buffers and high demand for them, this application provides a method for allocating buffer blocks, which is mainly achieved through the following steps:
[0136] The first step is to configure a pre-configured buffer. In this case, the processor (e.g., GPU) has multiple cores running multiple tasks concurrently. The system first determines the maximum number of threads that the GPU cores can support running the program corresponding to each task concurrently, as well as the required capacity of the dedicated memory buffer for each task. Taking into account the number of cores within the GPU, the pre-configured buffer is generated. For example, if program 1 is running on the GPU, and each core in the GPU can support a maximum of 6 concurrent threads running program 1, and each thread of program 1 requires a dedicated memory buffer of 8KB, and the GPU has 50 cores, then a pre-configured buffer consisting of 50 * 6 buffer blocks, each with a capacity of 8KB, can be configured.
[0137] It should be noted that if Program 1 and Program 2 need to run simultaneously, when Program 1 runs on the GPU kernels, each kernel can support a maximum of 6 concurrent threads running Program 1, and each thread of Program 1 requires a dedicated memory buffer of 8KB. When Program 2 runs on the GPU kernels, each kernel can support a maximum of 7 concurrent threads running Program 2, and each thread of Program 1 requires a dedicated memory buffer of 9KB. Since the GPU has 50 kernels, the maximum value of the dedicated memory buffer capacity required by each thread, the maximum number of concurrent threads supported by each kernel, and the 50 kernels in the GPU can be used to generate a configured buffer, consisting of 50 * 7 buffer blocks, each with a capacity of 9KB.
[0138] The second step involves allocating a corresponding buffer for each thread of a program based on the configured buffer consisting of multiple buffer blocks (here, by default, these multiple buffer blocks are statically configured and cannot be split or combined). Specifically, when allocating a required buffer for each thread, the system first checks if there are any idle buffer blocks in the configured buffers. If so, it allocates the corresponding buffer block to that thread based on the capacity of the idle buffer block and the required buffer capacity.
[0139] It should be noted that if there are multiple idle buffer blocks in the configured buffer that are in an idle state, any idle buffer block can be selected as the idle buffer block to be allocated based on the selection method such as the duration and capacity of the idle state.
[0140] Here, if the capacity of the available free buffer block to be allocated is greater than or equal to the capacity of the required buffer, the available free buffer block to be allocated is directly determined and allocated to the corresponding buffer block for that thread. See here for reference. Figure 6 The diagram illustrates the allocation of corresponding buffer blocks for launched tasks within a configured buffer. Both a and b show two buffer blocks: buffer block 1 (starting from address p to address p+N) and buffer block 2 (starting from address p+N to address p+2*N). In a, task _2 is allocated to buffer block 1, and the buffer block capacity required by task 2 is less than that of buffer block 1; task _M is allocated to buffer block 2, and the buffer block capacity required by task _M is less than that of buffer block 2. In b, task _3_kernel 1 is allocated to buffer block 1, and the buffer block capacity required by task _3_kernel 1 is the same as that of buffer block 1; task _M_kernel 0 is allocated to buffer block 2, and the buffer block capacity required by task _M_kernel 0 is the same as that of buffer block 2. Here, kernel 0 and kernel 1 are both kernels within the GPU.
[0141] Here, if the capacity of the available free buffer block to be allocated is smaller than the capacity of the required buffer, a corresponding buffer block cannot be allocated to the thread, and the available free buffer block to be allocated must be used. In this case, if... Figure 7 The diagram illustrates the allocation of buffer blocks for a startup task based on both configured and unconfigured buffers. Within the configured buffer, there are two buffer blocks: one corresponding to the start and end addresses p to p+N, and the other to the start address p+N to p+2*N. When task_3_kernel1 starts, buffer block 2 is idle (buffer block 1 still stores data related to task_2_kernel0). If the capacity of the buffer (block) required by task_3_kernel1 is greater than the capacity of buffer block 2, buffer block 2 can be reused. A new buffer block is then requested in the unconfigured buffer, with addresses q to q+n. Its capacity is the difference between the capacity (M) of the buffer (block) required by task_3_kernel1 and the capacity (N) of buffer block 2.
[0142] Here, when describing the task's address information using code, if the required buffer capacity is less than or equal to the capacity of the available free buffer block, the address information of the available free buffer block can be directly used as the address information of the data storage associated with the task. If the required buffer capacity is greater than the capacity of the available free buffer block, the combination of the address information of the available free buffer block and the address information of the selected buffer without configured buffer can be used as the address information of the data storage associated with the task, such as:
[0143] If (offset<= N){
[0144] addr = primary_addr_base + offset;
[0145] }else if (offset>N){
[0146] addr = secondary_address_base + (offset-N);
[0147] }
[0148] The buffer block allocation method provided in this application, when the capacity of the required buffer block for the task to be executed is greater than the capacity of the available free buffer block, simultaneously utilizes the available free buffer block and the unconfigured buffer from a configured buffer consisting of multiple buffer blocks divided based on historical tasks to determine the required buffer block that matches the task to be executed. Thus, by using a configured buffer consisting of multiple buffer blocks divided based on historical tasks to reduce the demand for buffers and improve buffer utilization, the method can increase the reuse rate of buffer blocks in the configured buffer, while reducing the need to request additional buffer blocks for the task to be executed, thereby reducing the overall demand for buffers.
[0149] Furthermore, if the capacity of the required buffer block for the task to be executed is less than or equal to the capacity of the available free buffer block to be allocated, the available free buffer block to be allocated can be reused directly, thereby also improving the reuse rate of the buffer blocks in the configured buffer.
[0150] This application provides a buffer block allocation device 800. Figure 8 This is a schematic diagram illustrating the structural composition of a buffer block distribution device provided in an embodiment of this application, as shown below. Figure 8 As shown, the buffer block distribution device 800 includes:
[0151] The response module 801 is used to determine a free buffer block to be allocated among multiple buffer blocks of the configured buffer in response to the start of the task to be executed; wherein the multiple buffer blocks of the configured buffer are divided based on historical tasks;
[0152] The determination module 802 is used to determine the required buffer block based on the unallocated free buffer block and the unconfigured buffer block when the capacity of the required buffer block for the task to be executed is greater than the capacity of the free buffer block to be allocated.
[0153] In some embodiments, the determining module 802 is further configured to determine the difference capacity between the capacity of the demand buffer block and the capacity of the unallocated free buffer block; and to take the set of the unallocated free buffer block and the difference buffer block in the unconfigured buffer as the demand buffer block; wherein the capacity of the difference buffer block is the difference capacity.
[0154] In some embodiments, the determining module 802 is further configured to obtain a set of address information corresponding to the free buffer block to be allocated and address information corresponding to the difference buffer block, as set address information; and to use the buffer block corresponding to the set address information as the required buffer block.
[0155] In some embodiments, the buffer block allocation device 800 further includes: an update module, configured to release the set of the unallocated free buffer block and the difference buffer block in response to the completion of the task to be executed, and update the unallocated free buffer block in the configured buffer using the unallocated free buffer block and the difference buffer block to obtain the updated configured buffer.
[0156] In some embodiments, the buffer block allocation device 800 further includes: a release module, configured to release the difference buffer block to the unconfigured buffer and release the unallocated free buffer block to the configured buffer in response to the completion of the task to be executed.
[0157] In some embodiments, the determining module 802 is further configured to, in response to the initiation of the historical task, determine the capacity of the historical buffer block required by the historical task, the maximum number of tasks supported by the execution unit in the processor to run the program corresponding to the historical task; and determine the configured buffer based on the capacity of the historical buffer block, the maximum number of tasks, and the number of execution units in the processor.
[0158] In some embodiments, the historical tasks include at least two intermediate tasks belonging to different historical programs. The determining module 802 is further configured to, in response to the initiation of at least two intermediate tasks, determine the capacity of the buffer block to be allocated for each intermediate task to obtain a candidate capacity set, and determine the maximum number of tasks that the execution unit can support to run each historical program to obtain a candidate task number set; take the maximum capacity in the candidate capacity set as the selected capacity, and take the candidate task number with the largest value in the candidate task number set as the selected task number; and determine the configured buffer based on the selected capacity, the selected task number, and the number of units.
[0159] In some embodiments, the response module 801 is further configured to determine a plurality of idle buffer blocks in an idle state among the plurality of buffer blocks of the configured buffer; and to determine the idle buffer block to be allocated from the plurality of idle buffer blocks.
[0160] In some embodiments, the determining module 802 is further configured to, when the capacity of the demand buffer block is less than or equal to the capacity of the free buffer block to be allocated, use the free buffer block to be allocated as the demand buffer block.
[0161] It should be noted that the description of the above device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0162] It should be noted that, in the embodiments of this application, if the above-described buffer block allocation method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a terminal, server, etc.) to execute all or part of the buffer block allocation method described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0163] Correspondingly, this application embodiment further provides a computer program product, which includes computer executable instructions. After the computer executable instructions are executed, they can implement the buffer block allocation method provided in this application embodiment.
[0164] Accordingly, embodiments of this application provide a computer device. Figure 9 This is a schematic diagram of the composition structure of the computer device according to an embodiment of this application, such as... Figure 9 As shown, the computer device 900 includes: a processor 901, at least one communication bus 904, a communication interface 902, at least one external communication interface, and a memory 903. The communication interface 902 is configured to enable communication between these components. The communication interface 902 may include a display screen, and the external communication interface may include standard wired and wireless interfaces. The processor 901 is configured to execute an information processing program in the memory to implement the buffer block allocation method provided in the above embodiments.
[0165] Accordingly, this application embodiment further provides a computer storage medium storing computer-executable instructions, which, when executed by a processor, implement the buffer block allocation method provided in the above embodiment.
[0166] The descriptions of the buffer block allocation apparatus, computer equipment, and storage medium embodiments above are similar to the descriptions of the method embodiments above, and have similar technical descriptions and beneficial effects. Due to space limitations, please refer to the descriptions of the method embodiments above, and therefore, they will not be repeated here. For technical details not disclosed in the embodiments of the buffer block allocation apparatus, computer equipment, and storage medium of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0167] It should be understood that the phrase "an embodiment" or "one embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the present application. Therefore, "in one embodiment" or "one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of the present application, the sequence number of the above-described processes does not imply the order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The sequence numbers of the above-described embodiments are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0168] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0169] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0170] Furthermore, in the embodiments of this application, all functional units can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units. Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0171] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application.
Claims
1. A method for allocating buffer blocks, characterized in that, The method for allocating the buffer block includes: In response to the start of a task to be executed, a free buffer block to be allocated is determined from multiple buffer blocks in a configured buffer; wherein, the multiple buffer blocks in the configured buffer are divided based on historical tasks; If the capacity of the required buffer block for the task to be executed is greater than the capacity of the available free buffer block to be allocated, the required buffer block is determined based on the available free buffer block to be allocated and the unconfigured buffer. In response to the completion of the task to be executed, the difference buffer block is released to the unconfigured buffer, and the unallocated free buffer block is released to the configured buffer; the capacity of the difference buffer block is the difference between the capacity of the required buffer block and the capacity of the unallocated free buffer block. The capacity of the multiple buffer blocks within the configured buffer is fixed; the required buffer block includes the unallocated free buffer block and the buffer block selected from the unconfigured buffer.
2. The method according to claim 1, characterized in that, The step of determining the required buffer block based on the unallocated free buffer block and the unconfigured buffer includes: Determine the difference between the capacity of the demand buffer block and the capacity of the free buffer block to be allocated; The set of the unallocated free buffer block and the difference buffer block in the unconfigured buffer is taken as the demand buffer block; wherein, the capacity of the difference buffer block is the difference capacity.
3. The method according to claim 2, characterized in that, The step of taking the set of the unallocated free buffer block and the difference buffer block in the unconfigured buffer as the demand buffer block includes: Obtain the set of address information corresponding to the free buffer block to be allocated and the address information corresponding to the difference buffer block, and use it as the set address information; The buffer block corresponding to the aggregate address information is used as the demand buffer block.
4. The method according to claim 1, characterized in that, The buffer block allocation method further includes, in response to the initiation of a task to be executed and before determining a free buffer block to be allocated among multiple buffer blocks in the configured buffer, the method further includes: In response to the initiation of the historical task, the capacity of the historical buffer block required by the historical task and the maximum number of tasks that the execution unit in the processor can support in running the program corresponding to the historical task are determined. The configured buffer is determined based on the capacity of the historical buffer block, the maximum number of tasks, and the number of execution units in the processor.
5. The method according to claim 4, characterized in that, The historical task includes at least two intermediate tasks belonging to different historical programs. In response to the initiation of the historical task, determining the capacity of the historical buffer block required by the historical task and the maximum number of tasks that the execution unit in the processor can support in running the program corresponding to the historical task includes: In response to the initiation of at least two intermediate tasks, the capacity of the buffer block to be allocated for each intermediate task is determined to obtain a candidate capacity set, and the maximum number of tasks that the execution unit can support to run each historical program is determined to obtain a candidate task number set. Determining the configured buffer based on the capacity of the historical buffer block, the maximum number of tasks, and the number of execution units in the processor includes: The maximum capacity in the candidate capacity set is taken as the selected capacity, and the candidate task number with the largest value in the candidate task number set is taken as the selected task number. The configured buffer is determined based on the selected capacity, the number of selected tasks, and the number of units.
6. The method according to any one of claims 1 to 3, characterized in that, The step of determining the free buffer block to be allocated among multiple buffer blocks of the configured buffer includes: Among the multiple buffer blocks of the configured buffer, identify a number of free buffer blocks that are in an idle state; The free buffer block to be allocated is determined from the plurality of free buffer blocks.
7. The method according to any one of claims 1 to 3, characterized in that, In response to the start of a task to be executed, after determining a free buffer block to be allocated from multiple buffer blocks in the configured buffer, the method for allocating the buffer block further includes: If the capacity of the demand buffer block is less than or equal to the capacity of the free buffer block to be allocated, the free buffer block to be allocated shall be used as the demand buffer block.
8. A buffer block distribution device, characterized in that, The buffer block distribution device includes: A response module is used to determine a free buffer block to be allocated among multiple buffer blocks in a configured buffer in response to the start of a task to be executed; wherein the multiple buffer blocks in the configured buffer are divided based on historical tasks; The determination module is used to determine the required buffer block based on the unallocated free buffer block and the unconfigured buffer when the capacity of the required buffer block for the task to be executed is greater than the capacity of the free buffer block to be allocated. A release module is configured to, in response to the completion of the task to be executed, release the difference buffer block to the unconfigured buffer and release the unallocated free buffer block to the configured buffer; the capacity of the difference buffer block is the difference between the capacity of the required buffer block and the capacity of the unallocated free buffer block. The capacity of the multiple buffer blocks within the configured buffer is fixed; the required buffer block includes the unallocated free buffer block and the buffer block selected from the unconfigured buffer.
9. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing computer-executable instructions, and the processor, when executing the computer-executable instructions in the memory, is able to implement the buffer block allocation method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that, The computer storage medium stores computer-executable instructions, which, when executed, enable the allocation method of the buffer block as described in any one of claims 1 to 7.