Video memory multiplexing method and device based on GPU multi-stream concurrency

By using the video memory pool and reuse strategy to determine and allocate video memory blocks in the GPU multi-stream concurrent scenario, the problem of low utilization efficiency of video memory resources is solved, the safe and efficient reuse of video memory resources is achieved, and the efficiency of large-scale computing tasks is improved. processing power.

CN118312333BActive Publication Date: 2024-10-18ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410743233.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-10-18
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

In tasks involving multiple GPU streams concurrently, the utilization efficiency of video memory resources is low. As a result, large-scale computing tasks are limited by the video memory capacity and it is difficult to fully reuse video memory resources.

Method used

By determining whether the released video memory blocks of the current GPU stream can be reused in the default stream reuse mode, and allocating and releasing video memory blocks based on the existence and status of candidate reusable blocks in the video memory pool, optimizing the use of video memory resources Reuse strategy.

Benefits of technology

It achieves safe and efficient reuse of video memory resources, improves the efficiency of GPU stream concurrent tasks, reduces the generation of video memory fragments, and improves the processing capabilities of large-scale computing tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312333B_ABST
    Figure CN118312333B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a method and device for video memory reuse based on GPU multi-stream concurrency. In the video memory reuse method based on GPU multi-stream concurrency, at least two GPU streams are executed concurrently, and each GPU stream includes GPU instructions arranged in execution order. In the default stream reuse mode, it can be determined whether there is a candidate reusable video memory block in the video memory pool for storing released video memory blocks according to the released video memory corresponding to the current GPU stream to which the GPU instruction to be allocated video memory belongs and whether the current GPU stream is the default stream; if there is a candidate reusable video memory block, the video memory block allocated for the GPU instruction to be allocated video memory is determined from the candidate reusable video memory blocks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification generally relate to the field of computer technology, and more particularly to a method and device for video memory multiplexing based on GPU multi-stream concurrency. Background Art

[0002] GPU (Graphics Processing Unit) is a type of acceleration hardware that can be used for graphics display, computing acceleration (such as deep learning), etc. GPU has the characteristics of high-speed parallel computing, and is suitable for working with CPU (Central Processing Unit) to form a CPU+GPU heterogeneous computing architecture, so that parallel tasks can be processed efficiently. As a high-speed memory medium on the GPU, video memory usually has a very high bandwidth (up to 3000GB+ / sec) but a small capacity (for example, 24~96GB). Its capacity directly restricts some large-scale computing tasks, such as deep learning tasks involving large models and large samples. Therefore, in tasks involving multiple concurrent GPU streams, how to make full use of the video memory occupied by each GPU stream is of great significance for improving the efficiency of video memory use and achieving large-scale computing. Summary of the invention

[0003] In view of the above, the embodiments of this specification provide a method and device for video memory reuse based on GPU multi-stream concurrency. By using this method and device, safe and efficient reuse of video memory resources can be achieved.

[0004] According to one aspect of an embodiment of the present specification, a video memory multiplexing method based on GPU multi-stream concurrency is provided, wherein at least two GPU streams are executed concurrently, and each GPU stream includes GPU instructions arranged in an execution order, and the video memory multiplexing method includes: in a default stream multiplexing mode, according to the released video memory corresponding to the current GPU stream to which the GPU instruction to be allocated video memory belongs and whether the current GPU stream is the default stream, judging whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks; and if the candidate reusable video memory block exists, determining the video memory block allocated for the GPU instruction to be allocated video memory from the candidate reusable video memory blocks.

[0005] According to another aspect of an embodiment of the present specification, a video memory multiplexing device based on GPU multi-stream concurrency is provided, wherein at least two GPU streams are executed concurrently, and each GPU stream includes GPU instructions arranged in an execution order, and the video memory multiplexing device includes: a candidate video memory block judgment unit, configured to, in a default stream multiplexing mode, judge whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks according to the released video memory corresponding to the current GPU stream to which the GPU instruction to be allocated video memory belongs and whether the current GPU stream is a default stream; and a video memory allocation unit, configured to determine, if the candidate reusable video memory block exists, a video memory block allocated to the GPU instruction to be allocated video memory from the candidate reusable video memory blocks.

[0006] According to another aspect of the embodiments of the present specification, there is provided a video memory multiplexing device based on GPU multi-stream concurrency, comprising: an analysis configuration unit, configured to determine a current stream multiplexing mode; a strategy selection unit, configured to determine a corresponding video memory multiplexing strategy according to the current stream multiplexing mode; determining a video memory block allocated to the GPU instruction for the video memory to be allocated according to the determined video memory multiplexing strategy; a video memory management unit, configured to perform a video memory allocation or video memory release operation; and a video memory status update unit, configured to update the status of the video memory block after the video memory block is allocated or released.

[0007] According to another aspect of an embodiment of the present specification, a video memory multiplexing device based on GPU multi-stream concurrency is provided, comprising: at least one processor, and a memory coupled to the at least one processor, the memory storing instructions, and when the instructions are executed by the at least one processor, the at least one processor executes the video memory multiplexing method based on GPU multi-stream concurrency as described above.

[0008] According to another aspect of the embodiments of the present specification, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the video memory multiplexing method based on GPU multi-stream concurrency as described above is implemented.

[0009] According to another aspect of the embodiments of the present specification, a computer program product is provided, including a computer program, wherein the computer program is executed by a processor to implement the video memory multiplexing method based on GPU multi-stream concurrency as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] A further understanding of the nature and advantages of the content of this specification may be achieved by referring to the following drawings. In the drawings, similar components or features may have the same reference numerals.

[0011] Figure 1 An exemplary architecture of a method and device for concurrently using a GPU multi-stream video memory according to an embodiment of the present specification is shown.

[0012] Figure 2 A schematic diagram showing an example of GPU multi-stream concurrency according to an embodiment of the present specification.

[0013] Figure 3 A schematic diagram showing an example of released video memory corresponding to concurrent GPU streams according to an embodiment of the present specification.

[0014] Figure 4 A flowchart of an example of a method for concurrently using video memory based on GPU multi-stream according to an embodiment of the present specification is shown.

[0015] Figure 5 A flowchart showing an example of a process for determining whether there is a candidate reusable video memory block in a video memory pool according to an embodiment of the present specification.

[0016] Figure 6 A flowchart showing another example of a process for determining whether there is a candidate reusable video memory block in a video memory pool according to an embodiment of the present specification.

[0017] Figure 7 A flowchart showing another example of a process for determining whether there is a candidate reusable video memory block in a video memory pool according to an embodiment of the present specification.

[0018] Figure 8 A schematic diagram showing an example of a video memory allocation process according to an embodiment of this specification.

[0019] Fig. 9 A schematic diagram showing another example of a video memory allocation process according to an embodiment of this specification.

[0020] Fig.10 A block diagram showing an example of a video memory multiplexing device based on GPU multi-stream concurrency according to an embodiment of the present specification.

[0021] Fig.11 A block diagram showing an example of a candidate determination unit in a video memory multiplexing device based on GPU multi-stream concurrency according to an embodiment of the present specification.

[0022] Fig.12A schematic diagram showing an example of a video memory multiplexing device based on GPU multi-stream concurrency according to an embodiment of the present specification. DETAILED DESCRIPTION

[0023] The subject matter described herein will be discussed below with reference to example implementations. It should be understood that the discussion of these implementations is only to enable those skilled in the art to better understand and implement the subject matter described herein, and is not a limitation of the scope of protection, applicability or examples set forth in the claims. The functions and arrangements of the elements discussed may be changed without departing from the scope of protection of the embodiments of this specification. Various processes or components may be omitted, substituted or added to each example as needed. In addition, the features described relative to some examples may also be combined in other examples.

[0024] As used herein, the term "including" and its variations represent open terms, meaning "including but not limited to". The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other definitions may be included below, whether explicit or implicit. Unless the context clearly indicates otherwise, the definition of a term is consistent throughout the specification.

[0025] In this specification, the term "GPU multi-stream concurrency" may refer to a technique for implementing parallelism and task scheduling in GPU programming. A stream can be viewed as an independent instruction queue, in which GPU instructions are executed sequentially, but can be executed concurrently with GPU instructions in other streams. In programming models such as CUDA (Compute Unified Device Architecture), streams can be used to efficiently organize concurrently executed workloads on the GPU to optimize performance. For example, in deep learning tasks, different streams can execute different operators concurrently, thereby achieving the effect of concurrent execution of operators (communication, computing, etc.) and improving GPU utilization efficiency.

[0026] In this specification, the term "computational graph" refers to a directed graph that represents and computes various operations of a neural network. The nodes in the computational graph represent operations, while the edges represent the flow of data (such as tensors) between operations. Computational graphs are a method used by deep learning frameworks to describe and optimize neural networks.

[0027] In this specification, the term "operator" refers to a function or method that implements a specific operation described in a computational graph node. In a deep learning framework, an operator defines how to perform a specific operation or transformation on input data. For example, one operator can be a matrix multiplication operation, and another operator can be a ReLU (Rectified Linear Unit) activation function.

[0028] In this specification, the term "video memory pool" refers to a software container for carrying video memory addresses that have been allocated and currently released. Video memory pool technology can cache the already applied video memory addresses, thereby effectively reducing the number of calls to the video memory allocation function in the underlying hardware driver and improving the allocation speed and utilization efficiency of video memory resources.

[0029] The following will describe in detail a method and device for GPU multi-stream concurrency based on video memory multiplexing according to an embodiment of the present specification in conjunction with the accompanying drawings.

[0030] Figure 1 An exemplary architecture 100 of a method and apparatus for GPU multi-stream concurrency based video memory multiplexing according to an embodiment of this specification is shown.

[0031] exist Figure 1 In the embodiment, the network 110 is used to interconnect the terminal device 120 and the application server 130 .

[0032] The network 110 may be any type of network capable of interconnecting network entities. The network 110 may be a single network or a combination of various networks. In terms of coverage, the network 110 may be a local area network (LAN), a wide area network (WAN), etc. In terms of carrier media, the network 110 may be a wired network, a wireless network, etc. In terms of data exchange technology, the network 110 may be a circuit switching network, a packet switching network, etc.

[0033] The terminal device 120 may be any type of electronic computing device that can connect to the network 110, access a server or website on the network 110, process data or signals, etc. For example, the terminal device 120 may be a desktop computer, a laptop computer, a tablet computer, a smart phone, etc. Figure 1 Only one terminal device is shown in FIG. 1 , but it should be understood that a different number of terminal devices may be connected to the network 110 .

[0034] In one embodiment, the terminal device 120 can be used by a user. The terminal device 120 can include an application client (e.g., application client 121) that can provide various services to the user. In some cases, the application client 121 can interact with the application server 130. For example, the application client 121 can transmit a message input by the user to the application server 130, and receive a response associated with the above message from the application server 130. However, it should be understood that in this article, "message" can refer to any input information, such as a computing task input from a user, etc.

[0035] The application server 130 can use a CPU+GPU heterogeneous computing architecture to efficiently execute computing tasks. In some examples, the data required for the computing task is first sent from the CPU memory to the GPU memory, and the GPU performs parallel computing through multiple GPU streams according to the CPU's instructions, and then passes the computing results back to the CPU memory. In this process, the data copy operation between the CPU and the GPU and the GPU's computing operation can be executed concurrently to improve efficiency.

[0036] It should be understood that Figure 1 All network entities shown in the figure are exemplary. Any other network entities may be involved in the architecture 100 according to specific application requirements.

[0037] Figure 2 FIG. 2 is a schematic diagram showing an example of GPU multi-stream concurrency 200 according to an embodiment of the present specification. In this embodiment, for a GPU computing task, at least two concurrently executed GPU streams (e.g. Figure 2 The GPU stream 1 and GPU stream 2 shown in FIG. 1 can jointly complete the task. Each GPU stream can include GPU instructions arranged in execution order. Figure 2 As shown in the figure, currently, GPU stream1 can include 2 GPU instructions (such as operators in the computation graph), and GPU stream2 can include 3 GPU instructions. The GPU instructions in GPU stream1 and GPU stream2 can be executed concurrently, but the GPU instructions in GPU stream1 and GPU stream2 are executed in sequence according to the order in which they are arranged in the GPU streams to which they belong. As the GPU computing task proceeds, the corresponding video memory can be allocated in advance for the GPU instructions to be executed for computing use.

[0038] In a CPU+GPU heterogeneous computing architecture that introduces the concept of a memory pool, corresponding memory resources can be allocated to each GPU instruction. The memory pool can be used to store released memory resources. In one example, the memory pool can be maintained by a CUDA driver. For example, when cudaFree is called, it means releasing the corresponding memory resources. In some examples, the released memory can be used to indicate the total amount of released memory. In some examples, the released memory can also be used to indicate the information of each released memory block, such as the starting address and capacity. In some examples, the information of each released memory block can be arranged in the order of the corresponding GPU instructions in the GPU stream. It can be understood that due to the fast execution speed of the CPU, after the memory resources are released from the perspective of the CPU, the actual execution process on the GPU may not be completed yet. In one example, such as Figure 2 As shown, the video memory pool may include released video memory blocks 1 to 4. Video memory block 1 may be used to store data targeted by the first GPU instruction in GPU stream 2. Video memory block 2 may be used to store the execution result of the first GPU instruction in GPU stream 2. In this example, the execution result may be used as both the data targeted by the first GPU instruction in GPU stream 1 and the data targeted by the second GPU instruction in GPU stream 2. Video memory block 3 may be used to store the execution result of the first GPU instruction in GPU stream 1. Video memory block 4 may be used to store the execution result of the second GPU instruction in GPU stream 2. Furthermore, video memory may continue to be allocated for the second GPU instruction in GPU stream 1 and the third GPU instruction in GPU stream 2.

[0039] In some examples, the released video memory may also be represented by information of each released video memory block arranged in sequence, wherein the arrangement order of the video memory block information is consistent with the arrangement order of the corresponding GPU instructions in the GPU stream. Figure 3 FIG. 1 is a schematic diagram showing an example of a released video memory 300 corresponding to concurrent GPU streams according to an embodiment of the present specification. Figure 3 As shown, the position of ☆ in each GPU stream can represent the position of the GPU instruction currently executed by the GPU stream in the entire GPU stream. The position of ? in the GPU stream can represent the position of the GPU instruction required to allocate video memory in the GPU stream in the entire GPU stream.

[0040] Figure 4A flowchart of an example of a method 400 for concurrently using a video memory based on GPU multi-streams according to an embodiment of the present specification is shown.

[0041] like Figure 4 As shown, at 410, in the default stream reuse mode, according to the released video memory corresponding to the current GPU stream to which the GPU instruction to allocate video memory belongs and whether the current GPU stream is the default stream, it is determined whether there is a candidate reusable video memory block in the video memory pool for storing the released video memory blocks.

[0042] In this embodiment, the default stream reuse mode can pre-specify a GPU stream as the default stream. The default stream reuse mode can be used to indicate that only other GPU streams are allowed to reuse the video memory resources allocated to the default stream, while the default stream is not allowed to reuse the video memory resources allocated to other GPU streams. In some examples, the user can pre-specify the use of the default stream reuse mode, and can also specify the identifier of the GPU stream as the default stream. In some examples, the stream reuse mode used can be determined based on the distribution of the allocated video memory corresponding to each GPU stream executed concurrently. In some examples, if there is a GPU stream that significantly occupies most of the video memory resources among at least two GPU streams executed concurrently (for example, a GPU stream whose allocated video memory resources account for more than 70% of the allocated video memory resources of all GPU streams), it can be determined to use the default stream reuse mode, and the above-mentioned GPU stream that significantly occupies most of the video memory resources can be determined as the default stream.

[0043] In this embodiment, the GPU instruction to allocate video memory may correspond to the video memory capacity requirement, such as 4MB, 16MB, 128MB, etc. In one example, Figure 2As shown, if it is necessary to allocate video memory for the second GPU instruction in GPU stream1, the current GPU stream to which the GPU instruction to be allocated video memory belongs may be stream1, so that it is possible to determine whether there is a candidate reusable video memory block in the video memory pool for storing released video memory blocks based on the released video memory corresponding to GPU stream1 and whether GPU stream1 is the default stream. Similarly, if it is necessary to allocate video memory for the third GPU instruction in GPU stream2, the current GPU stream to which the GPU instruction to be allocated video memory belongs may be stream2, so that it is possible to determine whether there is a candidate reusable video memory block in the video memory pool for storing released video memory blocks based on the released video memory corresponding to GPU stream2 and whether GPU stream2 is the default stream.

[0044] Figure 5 A flowchart of an example of a process 500 for determining whether there is a candidate reusable video memory block in a video memory pool according to an embodiment of the present specification is shown.

[0045] like Figure 5 As shown, at 510, it is determined whether the released video memory corresponding to the current GPU stream meets the video memory capacity requirement of the GPU instruction to allocate video memory.

[0046] In this embodiment, it can be determined whether there is a memory capacity requirement corresponding to the GPU instruction to allocate the memory in the released memory blocks corresponding to the current GPU stream that is not less than the memory capacity requirement. In some examples, it can be determined whether the capacity of the memory block after the fusion of the released memory blocks corresponding to the current GPU stream is not less than the memory capacity requirement. In some examples, the memory blocks with connected physical addresses can be directly spliced, or the physical addresses can be mapped to memory blocks with connected virtual addresses with the help of CUDA virtual address management. In one example, Figure 3 As shown, the released video memory corresponding to GPU stream 3 as the current GPU stream may include video memory block 5 and video memory block 7. It can be determined whether the capacity of video memory block 5 or video memory block 7 meets the above video memory capacity requirement. In some examples, if the addresses of video memory block 5 and video memory block 7 are continuous, it can be determined whether the sum of the capacities of video memory block 5 and video memory block 7 meets the above video memory capacity requirement. It can be understood that when other GPU streams are used as the current GPU stream, it can also be determined whether the capacity of the released video memory corresponding to the GPU stream meets the corresponding video memory capacity requirement.

[0047] If the judgment at 510 is no, execute 520 - 530 .

[0048] At 520 , it is determined whether the current GPU stream is a default stream.

[0049] If the determination at 520 is yes, at 530 , it is determined that there is no candidate reusable video memory block in the video memory pool.

[0050] In some examples, if the determination at 510 is yes, it is determined that there are candidate reusable video memory blocks in the video memory pool.

[0051] Figure 6 A flowchart of another example of a determination process 600 of whether there is a candidate reusable video memory block in a video memory pool according to an embodiment of the present specification is shown.

[0052] like Figure 6 As shown, at 610, it is determined whether the released video memory corresponding to the current GPU stream meets the video memory capacity requirement of the GPU instruction to allocate video memory.

[0053] If the judgment at 610 is no, execute 620 - 630 .

[0054] At 620 , it is determined whether the current GPU stream is a default stream.

[0055] The operations of 610-620 above can refer to the aforementioned Figure 5 The relevant descriptions of 510-520 in the embodiments are not repeated here.

[0056] If the determination at 620 is no, at 630, it is determined whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream and the released video memory corresponding to the default stream meets the video memory capacity requirement.

[0057] In some examples, if the total memory capacity indicated by the released memory corresponding to the current GPU stream and the released memory corresponding to the default stream meets the corresponding memory capacity requirement, it can be determined that there are candidate reusable memory blocks in the memory pool. If the total memory capacity indicated by the released memory corresponding to the current GPU stream and the released memory corresponding to the default stream does not meet the corresponding memory capacity requirement, it can be determined that there are no candidate reusable memory blocks in the memory pool.

[0058] Figure 7 A flowchart of another example of a determination process 700 of whether there is a candidate reusable video memory block in a video memory pool according to an embodiment of this specification is shown.

[0059] like Figure 7 As shown, at 710, it is determined whether the stream multiplexing mode is a multi-stream mutual multiplexing mode or a source multiplexing mode.

[0060] In this embodiment, the stream multiplexing mode pre-specified by the user can be used to determine whether the multi-stream mutual multiplexing mode or the source multiplexing mode is adopted. The multi-stream mutual multiplexing mode can be used to indicate that any GPU stream is allowed to reuse the video memory resources allocated to other GPU streams. The source multiplexing mode can be used to indicate that only the GPU stream is allowed to reuse the video memory resources allocated to the GPU stream, and is not allowed to reuse the video memory resources allocated to other GPU streams.

[0061] In some examples, whether the stream reuse mode is a multi-stream mutual reuse mode can be determined based on the distribution of the allocated video memory corresponding to each concurrently executed GPU stream. In some examples, if there is no GPU stream that significantly occupies most of the video memory resources among at least two concurrently executed GPU streams (for example, a GPU stream whose allocated video memory resources account for more than 70% of the allocated video memory resources of all GPU streams), it can be determined that the stream reuse mode is a multi-stream mutual reuse mode.

[0062] Through the above method, this solution can automatically select a suitable stream reuse mode according to different video memory resource distribution situations, and creatively proposes a stream reuse mode selection solution suitable for scenarios where multiple GPU streams are enabled at the same time to run different models respectively, and scenarios where multiple GPU streams are enabled at the same time to run the same operation respectively, thereby helping to achieve safe and efficient video memory reuse.

[0063] If 710 determines that the mode is a multi-stream mutual multiplexing mode, at 720, it is determined whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to each concurrently executed GPU stream meets the video memory capacity requirement of the GPU instruction to be allocated video memory.

[0064] In this embodiment, if the total video memory capacity indicated by the released video memory corresponding to each concurrently executed GPU stream meets the video memory capacity requirement of the GPU instruction to allocate video memory, it can be determined that there are candidate reusable video memory blocks in the video memory pool. If the total video memory capacity indicated by the released video memory corresponding to each concurrently executed GPU stream does not meet the video memory capacity requirement of the GPU instruction to allocate video memory, it can be determined that there are no candidate reusable video memory blocks in the video memory pool.

[0065] If 710 is determined to be the source multiplexing mode, at 730, it is determined whether there is a candidate reusable video memory block in the video memory pool based on whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream to which the GPU instruction to be allocated video memory belongs meets the video memory capacity requirement of the GPU instruction to be allocated video memory.

[0066] In this embodiment, if the video memory capacity indicated by the released video memory corresponding to the current GPU stream to which the GPU instruction to allocate video memory belongs meets the video memory capacity requirement of the GPU instruction to allocate video memory, it can be determined that there are candidate reusable video memory blocks in the video memory pool. If the video memory capacity indicated by the released video memory corresponding to the current GPU stream to which the GPU instruction to allocate video memory belongs does not meet the video memory capacity requirement of the GPU instruction to allocate video memory, it can be determined that there are no candidate reusable video memory blocks in the video memory pool.

[0067] Through the above method, this solution provides a solution that combines the stream reuse mode and the released video memory corresponding to each GPU stream to determine whether there is a candidate reusable video memory block in the video memory pool.

[0068] Back to Figure 4 , at 420 , if there are candidate reusable video memory blocks, a video memory block allocated for the GPU instruction to which video memory is to be allocated is determined from the candidate reusable video memory blocks.

[0069] In this embodiment, the memory block allocated to the GPU instruction to be allocated memory can be determined from the candidate reusable memory blocks in various ways, so that the GPU instruction can safely reuse the memory block that provides sufficient memory resources.

[0070] Figure 8 FIG. 8 is a schematic diagram showing an example of a video memory allocation process 800 according to an embodiment of the present specification.

[0071] like Figure 8As shown, the released video memory corresponding to each GPU stream can be arranged in a release order (consistent with the execution order of the corresponding instructions in the GPU stream). Each video memory block in the video memory pool can have a reusable status flag. The reusable status flag can be used to indicate whether the video memory block can be safely reused at present. It can be understood that the video memory block can be time-sharing reused in different GPU streams. In one example, for each video memory block, there can be a corresponding GPU instruction usage sequence. Among them, each video memory block is first assigned to the GPU stream to which the first GPU instruction in the corresponding GPU instruction usage sequence belongs. In one example, when all GPU instructions in the GPU instruction usage sequence corresponding to the video memory block are executed, the reusable status flag of the video memory block can be used to indicate that it is currently in a reusable state. In one example, when all GPU instructions in the GPU instruction usage sequence corresponding to the video memory block except the current GPU stream are executed, the reusable status flag of the video memory block can be used to indicate that it is currently in a reusable state. In one example, as Figure 8 As shown, the video memory pool may include released video memory blocks 1 to 7. The reusable status flags of video memory blocks 3, 5, and 7 are used to indicate that they are currently in a reusable state, and the reusable status flags of video memory blocks 1, 2, 4, and 6 are used to indicate that they are currently in a non-reusable state.

[0072] In this embodiment, it is assumed that the candidate reusable video memory blocks are video memory blocks 1 to video memory blocks 7. The first candidate video memory blocks, namely, video memory blocks 3, video memory blocks 5, and video memory blocks 7, can be determined from video memory blocks 1 to video memory blocks 7. In one example, if there is a video memory block whose video memory capacity is not less than the video memory capacity requirement of the GPU instruction to which the video memory is to be allocated among video memory blocks 3, video memory blocks 5, and video memory blocks 7, then the video memory block whose video memory capacity is closest to and not less than the above-mentioned video memory capacity requirement can be determined as the video memory block allocated for the GPU instruction to which the video memory is to be allocated. In one example, if there is no video memory block whose video memory capacity is not less than the above-mentioned video memory capacity requirement among video memory blocks 3, video memory blocks 5, and video memory blocks 7, then it can be further determined whether the video memory capacity after merging video memory blocks 3, video memory blocks 5, and video memory blocks 7 is not less than the above-mentioned video memory capacity requirement. If it is determined to be yes, then the video memory block whose video memory capacity after merging is closest to and not less than the above-mentioned video memory capacity requirement can be determined as the video memory block allocated for the GPU instruction to which the video memory is to be allocated.

[0073] If the video memory capacity after fusion is less than the above-mentioned video memory capacity requirement, the conditional multiplexing video memory block allocated for the GPU instruction to allocate the video memory can be determined based on the first candidate video memory block and the video memory block to be reused. Among them, the video memory block to be reused is a video memory block selected from the candidate reusable video memory blocks and having a reusable state flag indicating that it is currently in a non-reusable state (for example, video memory block 1, video memory block 2, video memory block 4 and video memory block 6). The conditional multiplexing video memory block is used to indicate that reuse is allowed when the reusable state flag of the video memory block to be reused is converted to indicate that it is currently in a reusable state. In one example, the conditional multiplexing video memory block can be selected based on the principle of the most matching capacity or the principle of the shortest waiting time. In one example, the conditional multiplexing video memory block can be composed of video memory block 5 and video memory block 6, and reuse is allowed only when the reusable state flag of video memory block 6 is converted from indicating that it is currently in a non-reusable state to indicating that it is currently in a reusable state.

[0074] Through the above method, the video memory blocks currently allowed to be used can be reused preferentially, thereby reducing the waiting time of the synchronization point and improving the task execution speed.

[0075] Fig. 9 FIG. 8 is a schematic diagram showing another example of a video memory allocation process 900 according to an embodiment of the present specification.

[0076] For the description of the released video memory corresponding to each GPU stream and the reusable status flag of each video memory block in the video memory pool, reference may be made to the foregoing description, which will not be repeated here.

[0077] like Fig. 9 As shown, it is assumed that the candidate reusable video memory blocks are video memory blocks 1 to 7. A second candidate video memory block that matches the video memory capacity requirement of the GPU instruction to which the video memory is to be allocated can be determined from video memory blocks 1 to 7. In one example, if there is a video memory block whose video memory capacity is not less than the above video memory capacity requirement among video memory blocks 1 to 7, then the video memory block whose video memory capacity is closest to and not less than the above video memory capacity requirement can be determined as the second candidate video memory block. If there is no video memory block whose video memory capacity is not less than the above video memory capacity requirement among video memory blocks 1 to 7, it can be further determined whether the video memory capacity of video memory blocks 1 to 7 after fusion is not less than the above video memory capacity requirement. If it is determined to be yes, then the video memory block whose video memory capacity after fusion is closest to and not less than the above video memory capacity requirement can be determined as the second candidate video memory block (for example, video memory block 4 and video memory block 5). If the fused video memory capacity is less than the above video memory capacity requirement, the video memory allocation function in the underlying hardware driver can be called to allocate new video memory blocks (i.e., video memory that is not in the video memory pool) according to the video memory capacity requirement of the GPU instruction to allocate video memory. For example, the CUDA video memory allocation interface can be called to allocate new video memory resources.

[0078] If the reusable state flags of each second candidate video memory block indicate that it is currently in a reusable state, then each determined second candidate video memory block can be determined as a video memory block allocated for the GPU instruction to allocate video memory. If there is a second candidate video memory block (for example, video memory block 4) with a reusable state flag indicating that it is currently in a non-reusable state, a conditional multiplexing video memory block allocated for the GPU instruction to allocate video memory can be determined based on the determined second candidate video memory block. The relevant description of the conditional multiplexing video memory block can refer to the above. In one example, the conditional multiplexing video memory block can be composed of video memory block 4 and video memory block 5, and reuse is allowed only when the reusable state flag of video memory block 4 is converted from indicating that it is currently in a non-reusable state to indicating that it is currently in a reusable state. The video memory block allocated for the GPU instruction to allocate video memory can also be determined based on the candidate reusable video memory block with a reusable state flag indicating that it is currently in a reusable state. In some examples, a memory block with a memory capacity closest to and not less than the memory capacity requirement may be selected from candidate reusable memory blocks having a reusable state flag indicating that the memory block is currently in a reusable state as the memory block allocated for the GPU instruction to allocate memory. The memory capacity may be the memory capacity of a single memory block or the memory capacity of at least two memory blocks after merging, which is not limited here.

[0079] Through the above method, the video memory resource with the best matching capacity can be reused preferentially, thereby reducing the generation of video memory fragments as much as possible and improving the utilization efficiency of video memory resources.

[0080] In some implementations, if the determination at 410 is no, a video memory allocation function in the underlying hardware driver may be called to allocate new video memory (i.e., video memory not in the video memory pool) according to the video memory capacity requirement of the GPU instruction to allocate video memory. For example, a CUDA video memory allocation interface may be called to allocate new video memory resources.

[0081] In some implementations, the released video memory blocks in the video memory pool may also be updated according to the video memory blocks allocated for the GPU instructions for video memory to be allocated. In these implementations, when the video memory blocks allocated for the GPU instructions for video memory to be allocated are reused video memory blocks determined from the video memory pool, the reused video memory blocks may be deleted from the video memory pool, so that the video memory blocks existing in the video memory pool are all released video memory resources.

[0082] use Figure 1-Figure 9The video memory reuse method based on GPU multi-stream concurrency disclosed in the disclosure can organically combine the released video memory corresponding to the GPU stream to which the GPU instruction to be allocated video memory belongs, the video memory capacity requirement of the GPU instruction to be allocated video memory, the released video memory corresponding to each GPU stream, and whether the current GPU stream is the default stream to determine whether the video memory block in the video memory pool can be reused for different stream reuse modes, thereby providing a safe and efficient video memory reuse method.

[0083] Fig.10 FIG. 1 is a block diagram showing an example of a GPU multi-stream concurrent video memory multiplexing device 1000 according to an embodiment of the present specification. The device embodiment can be used with Figure 2-Figure 9 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0084] like Fig.10 As shown, the GPU multi-stream concurrent video memory multiplexing device 1000 may include a candidate video memory block determination unit 1010 and a video memory allocation unit 1020. At least two GPU streams are executed concurrently, and each GPU stream includes GPU instructions arranged in an execution order.

[0085] The candidate memory block determination unit 1010 is configured to determine whether there is a candidate reusable memory block in the memory pool for storing released memory blocks in the default stream reuse mode according to the released memory corresponding to the current GPU stream to which the GPU instruction to allocate the memory belongs and whether the current GPU stream is the default stream. The operation of the candidate memory block determination unit 1010 can refer to the above Figure 4 The operation of 410 is described.

[0086] In some examples, the candidate video memory block judgment unit 1010 is further configured to: if the released video memory corresponding to the current GPU stream does not meet the video memory capacity requirement of the GPU instruction to allocate the video memory and the current GPU stream is a default stream, determine that there is no candidate reusable video memory block in the video memory pool.

[0087] In some examples, the candidate video memory block judgment unit 1010 is further configured to: if the released video memory corresponding to the current GPU stream does not meet the video memory capacity requirement of the GPU instruction for allocating video memory and the current GPU stream is not a default stream, determine whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream and the released video memory corresponding to the default stream meets the video memory capacity requirement.

[0088] In some examples, the candidate video memory block judgment unit 1010 is further configured to: in a multi-stream mutual multiplexing mode, determine whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to each concurrently executed GPU stream meets the video memory capacity requirement of the GPU instruction to allocate the video memory.

[0089] In some examples, the multi-stream mutual multiplexing mode is determined according to the distribution of the allocated video memory corresponding to each concurrently executed GPU stream.

[0090] In some examples, the candidate video memory block judgment unit 1010 is further configured to: in the source multiplexing mode, determine whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream to which the GPU instruction for the video memory to be allocated belongs meets the video memory capacity requirement of the GPU instruction for the video memory to be allocated.

[0091] The video memory allocation unit 1020 is configured to determine the video memory block to be allocated for the GPU instruction to allocate the video memory from the candidate reusable video memory blocks if the candidate reusable video memory blocks exist. The operation of the video memory allocation unit 1020 can refer to the above Figure 4 The operation of 420 is described.

[0092] In one example, each released video memory block in the video memory pool has a reusable state flag, and the video memory allocation unit 1020 can be further configured to: determine a first candidate video memory block having a reusable state flag indicating that it is currently in a reusable state from the candidate reusable video memory blocks; determine whether the first candidate video memory block meets the video memory capacity requirement of the GPU instruction of the video memory to be allocated; if the first candidate video memory block meets the video memory capacity requirement, determine from the first candidate video memory block the video memory capacity allocated to the GPU instruction of the video memory to be allocated a video memory block; and if the first candidate video memory block does not meet the video memory capacity requirement, determining a conditionally multiplexed video memory block allocated for the GPU instruction of the video memory to be allocated based on the first candidate video memory block and the video memory block to be reused, wherein the video memory block to be reused is a video memory block selected from the candidate reusable video memory blocks and having a reusable state flag indicating that it is currently in a non-reusable state, and the conditionally multiplexed video memory block is used to indicate that reuse is allowed when waiting for the reusable state flag of the video memory block to be reused to be converted to indicate that it is currently in a reusable state.

[0093] In one example, each released video memory block in the video memory pool has a reusable status flag, and the video memory allocation unit 1020 can be further configured to: determine a second candidate video memory block that matches the video memory capacity requirement of the GPU instruction to which the video memory is to be allocated from the candidate reusable video memory blocks; determine whether the reusable status flags of each determined second candidate video memory block all indicate that they are currently in a reusable state; if the reusable status flags of each second candidate video memory block all indicate that they are currently in a reusable state, determine the determined second candidate video memory block as the video memory block allocated for the GPU instruction to which the video memory is to be allocated; and if there is a second candidate video memory block with a reusable status flag indicating that it is currently in an unreusable state, determine the determined second candidate video memory block as the video memory block allocated for the GPU instruction to which the video memory is to be allocated. A second candidate video memory block with a reuseable state flag in a reuseable state, determining a conditional multiplexing video memory block allocated for the GPU instruction of the video memory to be allocated based on the determined second candidate video memory block, wherein the conditional multiplexing video memory block is used to indicate that reuse is allowed when waiting for the reuseable state flag of the video memory block to be reused to be converted to indicate that it is currently in a reuseable state, and the video memory block to be reused is a video memory block in the second candidate video memory block with a reuseable state flag indicating that it is currently in a non-reusable state; or determining a video memory block allocated for the GPU instruction of the video memory to be allocated based on a candidate reusable video memory block with a reuseable state flag indicating that it is currently in a reuseable state.

[0094] In some examples, the video memory multiplexing device 1000 may further include: a video memory pool management unit 1030 configured to update released video memory blocks in the video memory pool according to the video memory blocks allocated by the GPU instruction for the video memory to be allocated.

[0095] It should be noted that the operations of the candidate video memory block determination unit 1010, the video memory allocation unit 1020 and the video memory pool management unit 1030 can refer to the corresponding description in the aforementioned method embodiment, which will not be repeated here.

[0096] Fig.11 A block diagram showing another example of a video memory multiplexing device 1100 based on GPU multi-stream concurrency according to an embodiment of this specification.

[0097] like Fig.11 As shown, a video memory multiplexing device 1100 based on GPU multi-stream concurrency may include: an analysis configuration unit 1110, configured to determine a current stream multiplexing mode; a strategy selection unit 1120, configured to determine a corresponding video memory multiplexing strategy according to the current stream multiplexing mode; determine a video memory block allocated to the GPU instruction for the video memory to be allocated according to the determined video memory multiplexing strategy; a video memory management unit 1130, configured to perform a video memory allocation or video memory release operation; and a video memory status update unit 1140, configured to update the status of the video memory block after the video memory block is allocated or released.

[0098] It should be noted that the operations of the above-mentioned analysis configuration unit 1110, strategy selection unit 1120, video memory management unit 1130 and video memory status update unit 1140 can refer to the corresponding description in the above-mentioned method embodiment, which will not be repeated here.

[0099] Reference above Figures 1 to 11 , describes an embodiment of a method and device for video memory multiplexing based on GPU multi-stream concurrency according to an embodiment of this specification.

[0100] The GPU multi-stream concurrent video memory multiplexing device of the embodiment of this specification can be implemented by hardware, or by software or a combination of hardware and software. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the device in which it is located reading the corresponding computer program instructions in the memory into the memory and running them. In the embodiment of this specification, the GPU multi-stream concurrent video memory multiplexing device can be implemented, for example, using an electronic device.

[0101] Fig.12 A schematic diagram showing an example of a video memory multiplexing device 1200 based on GPU multi-stream concurrency according to an embodiment of the present specification.

[0102] like Fig.12As shown, the GPU multi-stream concurrent video memory multiplexing device 1200 may include at least one processor 1210, a memory (e.g., a non-volatile memory) 1220, a memory 1230, and a communication interface 1240, and the at least one processor 1210, the memory 1220, the memory 1230, and the communication interface 1240 are connected together via a bus 1250. At least one processor 1210 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).

[0103] In one embodiment, computer executable instructions are stored in a memory, which when executed cause at least one processor 1210 to: in a default stream reuse mode, determine whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks according to the released video memory corresponding to the current GPU stream to which the GPU instruction to be allocated video memory belongs and whether the current GPU stream is a default stream, wherein at least two GPU streams are executed concurrently and each GPU stream includes GPU instructions arranged in an execution order; and if the candidate reusable video memory block exists, determine the video memory block allocated to the GPU instruction to be allocated video memory from the candidate reusable video memory blocks.

[0104] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 1210 to perform the above combined operations in various embodiments of the present specification. Figure 1-Figure 9 Describes the various operations and functions.

[0105] According to one embodiment, a program product such as a computer-readable medium is provided. The computer-readable medium may have instructions (i.e., the above-mentioned elements implemented in the form of software), which, when executed by a computer, causes the computer to perform the above-mentioned combination of various embodiments of this specification. Figure 1-Figure 9 Describes the various operations and functions.

[0106] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.

[0107] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above-mentioned embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute a part of the present invention.

[0108] The computer program code required for the operation of each part of this specification can be written in any one or more programming languages, including object-oriented programming languages, such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB, NET and Python, conventional procedural programming languages ​​such as C language, Visual Basic 2003, Perl, COBOL 2002, PHP and ABAP, dynamic programming languages ​​such as Python, Ruby and Groovy, or other programming languages. The program code can be run on the user's computer, or run on the user's computer as an independent software package, or run partly on the user's computer and partly on a remote computer, or all on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer through any network form, such as a local area network (LAN) or a wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service, such as software as a service (SaaS).

[0109] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code may be downloaded from a server computer or a cloud via a communication network.

[0110] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0111] Not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined according to needs. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.

[0112] The term "exemplary" as used throughout this specification means "serving as an example, instance, or illustration" and does not imply "preferred" or "advantageous" over other embodiments. The detailed description includes specific details for the purpose of providing an understanding of the described techniques. However, the techniques may be implemented without these specific details. In some instances, in order to avoid obscuring the concepts of the described embodiments, well-known structures and devices are shown in block diagram form.

[0113] The optional implementation modes of the embodiments of the present specification are described in detail above in conjunction with the accompanying drawings. However, the embodiments of the present specification are not limited to the specific details in the above implementation modes. Within the technical concept of the embodiments of the present specification, various simple modifications can be made to the technical solutions of the embodiments of the present specification, and these simple modifications all belong to the protection scope of the embodiments of the present specification.

[0114] The above description of the contents of this specification is provided to enable any person of ordinary skill in the art to implement or use the contents of this specification. Various modifications to the contents of this specification will be apparent to those of ordinary skill in the art, and the general principles defined herein may be applied to other variations without departing from the scope of protection of the contents of this specification. Therefore, the contents of this specification are not limited to the examples and designs described herein, but are consistent with the widest range of principles and novel features disclosed herein.

Claims

1. A video memory reuse method based on GPU multi-stream concurrency, wherein: At least two GPU streams are executed concurrently, each GPU stream includes GPU instructions arranged in an execution order, and the video memory multiplexing method includes: In a default stream reuse mode, judging whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks according to released video memory corresponding to a current GPU stream to which a GPU instruction to allocate video memory belongs and whether the current GPU stream is a default stream, the default stream being a pre-specified GPU stream, and the default stream reuse mode being used to indicate that only other GPU streams are allowed to reuse video memory resources allocated to the default stream, and the default stream is not allowed to reuse video memory resources allocated to other GPU streams; and If the candidate reusable video memory blocks exist, a video memory block allocated for the GPU instruction to allocate video memory is determined from the candidate reusable video memory blocks.

2. The video memory multiplexing method according to claim 1, wherein: The step of judging whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks according to the released video memory corresponding to the current GPU stream to which the GPU instruction to allocate video memory belongs and whether the current GPU stream is a default stream comprises: If the released video memory corresponding to the current GPU stream does not meet the video memory capacity requirement of the GPU instruction for allocating video memory and the current GPU stream is a default stream, it is determined that there is no candidate reusable video memory block in the video memory pool.

3. The video memory multiplexing method according to claim 1, wherein: The step of judging whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks according to the released video memory corresponding to the current GPU stream to which the GPU instruction to allocate video memory belongs and whether the current GPU stream is a default stream comprises: If the released video memory corresponding to the current GPU stream does not meet the video memory capacity requirement of the GPU instruction for allocating video memory and the current GPU stream is not a default stream, determine whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream and the released video memory corresponding to the default stream meet the video memory capacity requirement.

4. The video memory multiplexing method according to claim 1, wherein: The method further comprises: In the multi-stream mutual multiplexing mode, it is determined whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to each concurrently executed GPU stream meets the video memory capacity requirement of the GPU instruction to allocate video memory. The multi-stream mutual multiplexing mode is used to indicate that any GPU stream is allowed to reuse the video memory resources allocated to other GPU streams.

5. The video memory multiplexing method according to claim 4, wherein: The multi-stream mutual multiplexing mode is determined according to the distribution of the allocated video memory corresponding to each GPU stream executed concurrently.

6. The video memory multiplexing method according to claim 1, wherein: The method further comprises: In the source reuse mode, it is determined whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream to which the GPU instruction for the video memory to be allocated belongs meets the video memory capacity requirement of the GPU instruction for the video memory to be allocated. The source reuse mode is used to indicate that only the GPU stream is allowed to reuse the video memory resources allocated to the GPU stream, while the video memory resources allocated to other GPU streams are not allowed to be reused.

7. The video memory multiplexing method according to claim 1, wherein: Each released video memory block in the video memory pool has a reusable status flag, The step of determining the video memory block allocated for the GPU instruction to allocate video memory from the candidate reusable video memory blocks comprises: Determine, from the candidate reusable video memory blocks, a first candidate video memory block having a reusable state flag indicating that the first candidate video memory block is currently in a reusable state; Determine whether the first candidate video memory block meets the video memory capacity requirement of the GPU instruction to allocate video memory; If the first candidate video memory block meets the video memory capacity requirement, determining a video memory block allocated for the GPU instruction to allocate video memory from the first candidate video memory blocks; and If the first candidate video memory block does not meet the video memory capacity requirement, a conditionally multiplexed video memory block allocated for the GPU instruction of the video memory to be allocated is determined based on the first candidate video memory block and the video memory block to be reused, wherein the video memory block to be reused is a video memory block selected from the candidate reusable video memory blocks and having a reusable state flag indicating that it is currently in a non-reusable state, and the conditionally multiplexed video memory block is used to indicate that reuse is allowed when waiting for the reusable state flag of the video memory block to be reused to be converted to indicate that it is currently in a reusable state.

8. The video memory multiplexing method according to claim 1, wherein: Each released video memory block in the video memory pool has a reusable status flag, The step of determining the video memory block allocated for the GPU instruction to allocate video memory from the candidate reusable video memory blocks comprises: Determine, from the candidate reusable video memory blocks, a second candidate video memory block that matches the video memory capacity requirement of the GPU instruction to which the video memory is to be allocated; Determining whether the reusable state flags of the determined second candidate video memory blocks all indicate that they are currently in a reusable state; If the reusable state flags of the second candidate video memory blocks all indicate that they are currently in a reusable state, determining the determined second candidate video memory block as the video memory block allocated for the GPU instruction to allocate the video memory; and If there is a second candidate video memory block having a reusable state flag indicating that it is currently in a non-reusable state, Determine a conditionally reused video memory block to be allocated for the GPU instruction of the video memory to be allocated based on the determined second candidate video memory block, wherein the conditionally reused video memory block is used to indicate that reuse is allowed when waiting for a reuse state flag of the video memory block to be reused to be converted to indicate that it is currently in a reuse state, and the video memory block to be reused is a video memory block in the second candidate video memory block that has a reuse state flag indicating that it is currently in a non-reusable state; or The video memory block allocated for the GPU instruction to allocate the video memory is determined based on the candidate reusable video memory blocks having a reusable state flag indicating that the reusable state is currently in a reusable state.

9. The video memory multiplexing method according to claim 1, wherein: After determining the video memory block allocated for the GPU instruction to allocate video memory from the candidate reusable video memory blocks, the video memory multiplexing method further includes: According to the video memory block allocated for the GPU instruction of the video memory to be allocated, the released video memory block in the video memory pool is updated.

10. A video memory multiplexing device based on GPU multi-stream concurrency, wherein: At least two GPU streams are executed concurrently, each GPU stream includes GPU instructions arranged in an execution order, and the video memory multiplexing device includes: a candidate video memory block determination unit configured to determine whether there is a candidate reusable video memory block in a video memory pool for storing released video memory blocks according to released video memory corresponding to a current GPU stream to which a GPU instruction to allocate video memory belongs and whether the current GPU stream is a default stream in a default stream reuse mode, wherein the default stream is a pre-specified GPU stream, and the default stream reuse mode is used to indicate that only other GPU streams are allowed to reuse video memory resources allocated to the default stream, and the default stream is not allowed to reuse video memory resources allocated to other GPU streams; and The video memory allocation unit is configured to determine, if the candidate reusable video memory blocks exist, a video memory block allocated to the GPU instruction for the video memory to be allocated from the candidate reusable video memory blocks.

11. The video memory multiplexing device according to claim 10, wherein the candidate video memory block determination unit is further configured to: If the released video memory corresponding to the current GPU stream does not meet the video memory capacity requirement of the GPU instruction for allocating video memory and the current GPU stream is not a default stream, determine whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to the current GPU stream and the released video memory corresponding to the default stream meet the video memory capacity requirement.

12. The video memory multiplexing device according to claim 10, wherein: The candidate video memory block determination unit is further configured to: In the multi-stream mutual multiplexing mode, it is determined whether there is a candidate reusable video memory block in the video memory pool according to whether the video memory capacity indicated by the released video memory corresponding to each concurrently executed GPU stream meets the video memory capacity requirement of the GPU instruction to allocate video memory. The multi-stream mutual multiplexing mode is used to indicate that any GPU stream is allowed to reuse the video memory resources allocated to other GPU streams.

13. The video memory multiplexing device according to claim 10, wherein: Each released video memory block in the video memory pool has a reusable status flag, and the video memory allocation unit is further configured to: Determine, from the candidate reusable video memory blocks, a first candidate video memory block having a reusable state flag indicating that the first candidate video memory block is currently in a reusable state; Determine whether the first candidate video memory block meets the video memory capacity requirement of the GPU instruction to allocate video memory; If the first candidate video memory block meets the video memory capacity requirement, determine a video memory block allocated for the GPU instruction to allocate video memory from the first candidate video memory blocks; as well as If the first candidate video memory block does not meet the video memory capacity requirement, a conditionally multiplexed video memory block allocated for the GPU instruction of the video memory to be allocated is determined based on the first candidate video memory block and the video memory block to be reused, wherein the video memory block to be reused is a video memory block selected from the candidate reusable video memory blocks and having a reusable state flag indicating that it is currently in a non-reusable state, and the conditionally multiplexed video memory block is used to indicate that reuse is allowed when waiting for the reusable state flag of the video memory block to be reused to be converted to indicate that it is currently in a reusable state.

14. The video memory multiplexing device according to claim 10, wherein: Each released video memory block in the video memory pool has a reusable status flag, and the video memory allocation unit is further configured to: Determine, from the candidate reusable video memory blocks, a second candidate video memory block that matches the video memory capacity requirement of the GPU instruction to which the video memory is to be allocated; Determining whether the reusable state flags of the determined second candidate video memory blocks all indicate that they are currently in a reusable state; If the reusable state flags of the second candidate video memory blocks all indicate that they are currently in a reusable state, the determined second candidate video memory block is determined as the video memory block allocated for the GPU instruction of the video memory to be allocated; as well as If there is a second candidate video memory block having a reusable state flag indicating that it is currently in a non-reusable state, Determine a conditional multiplexing video memory block to be allocated for the GPU instruction of the video memory to be allocated based on the determined second candidate video memory block, wherein the conditional multiplexing video memory block is used to indicate that multiplexing is allowed when waiting for the multiplexing state flag of the video memory block to be multiplexed to be converted to indicate that it is currently in a multiplexable state, and the video memory block to be multiplexed is a video memory block in the second candidate video memory block that has a multiplexable state flag indicating that it is currently in a non-reusable state; or The video memory block allocated for the GPU instruction to allocate the video memory is determined based on the candidate reusable video memory blocks having a reusable state flag indicating that the reusable state is currently in a reusable state.

15. A video memory multiplexing device based on GPU multi-stream concurrency, comprising: an analysis configuration unit, configured to determine a current stream multiplexing mode, wherein the stream multiplexing mode includes at least a default stream multiplexing mode or a multi-stream mutual multiplexing mode, wherein the default stream multiplexing mode is used to indicate that only other GPU streams are allowed to reuse video memory resources allocated to the default stream, and the default stream is not allowed to reuse video memory resources allocated to other GPU streams, wherein the default stream is a pre-specified GPU stream, and the multi-stream mutual multiplexing mode is used to indicate that any GPU stream is allowed to reuse video memory resources allocated to other GPU streams; A strategy selection unit is configured to determine a corresponding video memory multiplexing strategy according to the current stream multiplexing mode; and determine a video memory block to be allocated to the GPU instruction for the video memory to be allocated according to the determined video memory multiplexing strategy; A video memory management unit, configured to perform video memory allocation or video memory release operations; The video memory state updating unit is configured to update the state of the video memory block after the video memory block is allocated or released.

16. A video memory multiplexing device based on GPU multi-stream concurrency, comprising: At least one processor, a memory coupled to the at least one processor, and a computer program stored in the memory, wherein the at least one processor executes the computer program to implement the video memory multiplexing method based on GPU multi-stream concurrency as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and device for carrying out distribution management on physical memory pool and physical memory pool

    CN113485832A

  • Method and device for multiplexing GPU (Graphics Processing Unit) video memory

    CN114296945A

  • Method and device for optimizing GPU video memory multiplexing scheme

    CN114398182A

  • Video memory management method, device, equipment and system

    CN114443263A

  • GPU video memory management method and system, storage medium and electronic equipment

    CN117453423A