Video memory management method, system and equipment and storage medium
By preallocating and preloading storage objects when the kernel function is registered with the GPU, the performance degradation caused by page jitter in the prior art is solved, and the effect of efficiently managing storage objects between virtual and physical video memory is achieved.
Patent Information
- Application Number
- CN202411477886.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-22
AI Technical Summary
Video memory management in the prior art is prone to page jitter, resulting in system performance degradation, especially when pages are repeatedly moved between virtual video memory and physical video memory, the application has a high chance of crashing.
Page jitter is avoided by pre-allocating storage objects in virtual video memory when the kernel function is registered to the GPU, and pre-loading these objects into physical video memory before the kernel function is officially called.
It effectively solves the problem of repeated movement of pages between virtual video memory and physical video memory, improves the performance of the video memory system, and avoids the risk of application crashes.
Smart Images

Figure CN119473496A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of terminal video memory management, and in particular to a video memory management method, system, device and storage medium. Background Art
[0002] Most existing memory management technologies use the Unified Virtual Memory (UVM) solution. This relatively new programming model allows GPU applications to use a single pointer in CPU functions and GPU kernels, greatly simplifying memory management. After the emergence of UVM technology, a large number of UVM research goals are to improve the page swapping of cache and memory recycling strategies on CPUs, and technical indicators focus on page fluctuations and IPC improvements.
[0003] However, UVM technology is prone to over-subscription problems. The main reason for the performance loss of over-subscription is that when the kernel function runs to the relevant object, it is found that it is not in the physical video memory, and a page fault error is generated, which is submitted to the UVM driver for page swapping in and out. UVM only handles page faults and does not consider factors such as pre-loaded parallel management. This means that in complex situations, pages are repeatedly moved back and forth between the virtual video memory on the CPU memory and the GPU physical video memory. This phenomenon is called page jitter, which seriously affects system performance. In the case of frequent jitter, there is a high probability that the application will crash.
[0004] All GPU workloads suffer a performance penalty due to too large virtual memory, and this penalty increases as the oversubscription ratio between virtual and physical memory grows (the average performance slowdown for GPU applications at 125% oversubscription is 24.1%, with some applications (ATAX, NW, 2DCONV) crashing at 150% oversubscription). Summary of the invention
[0005] The embodiments of the present invention provide a video memory management method, system, device and storage medium, which can solve the problem of repeated movement of pages between virtual video memory and physical video memory and improve the performance of the video memory system.
[0006] In a first aspect, an embodiment of the present invention provides a video memory management method, which is applied to a virtual video memory management system, wherein the virtual video memory management system is set in the memory of a host; an object linked list is also created in the memory for tracking the status of storage objects associated with a kernel function; the method comprises:
[0007] When a kernel function is registered to the GPU, the storage object associated with the kernel function is obtained; the storage object is pre-allocated in the virtual video memory, and the object linked list is updated; before the kernel function is formally called, the storage object is pre-loaded from the virtual video memory to the physical video memory; the call of the kernel function is issued, and the object linked list is updated.
[0008] In a second aspect, an embodiment of the present invention provides a video memory management system, wherein the virtual video memory management system is set in the memory of the host; an object linked list is also created in the memory for tracking the status of storage objects associated with the kernel function; the system comprises:
[0009] A storage object determination module is used to obtain the storage object associated with the kernel function when the kernel function is registered to the GPU; a pre-allocation module is used to pre-allocate the storage object in the virtual video memory and update the object linked list; a pre-loading module is used to pre-load the storage object from the virtual video memory to the physical video memory before the kernel function is formally called; a kernel function calling module is used to issue the call of the kernel function and update the object linked list.
[0010] In a third aspect, an embodiment of the present invention provides a computer device, the computer device comprising:
[0011] one or more processors;
[0012] A memory for storing one or more programs;
[0013] When the one or more programs are executed by the one or more processors, the one or more processors implement the video memory management method described in any embodiment.
[0014] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the video memory management method described in any embodiment.
[0015] The technical solution provided by the embodiment of the present invention is as follows: when the kernel function is registered to the GPU, the storage object associated with the kernel function is obtained; the storage object is pre-allocated in the virtual video memory, and the object linked list is updated; before the kernel function is formally called, the storage object is pre-loaded from the virtual video memory to the physical video memory; the call of the kernel function is issued, and the object linked list is updated. The technical solution of the embodiment of the present invention solves the problem that the video memory management technology in the prior art is prone to page jitter, which affects the system performance. The storage object can be managed between the virtual video memory and the physical video memory according to the life cycle of the kernel function, and all the used storage objects are loaded into the physical video memory before the kernel function is actually run, which solves the problem of pages moving repeatedly between the virtual video memory and the physical video memory, and improves the performance of the video memory system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flow chart of a video memory management method provided by an embodiment of the present invention;
[0017] Figure 2 It is a flow chart of another video memory management method provided by an embodiment of the present invention;
[0018] Figure 3 is a flow chart of another video memory management method provided by an embodiment of the present invention;
[0019] Figure 4 This is a workflow diagram for video memory management provided by an embodiment of the present invention;
[0020] Figure 5 It is a test experiment effect diagram of the technical solution provided by the embodiment of the present invention;
[0021] Figure 6 It is a structural schematic diagram of a video memory management system provided by an embodiment of the present invention;
[0022] Figure 7 It is a structural schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] Figure 1 It is a flow chart of a video memory management method provided by an embodiment of the present invention. The embodiment of the present invention is applicable to the scenario of managing video memory data in a host. The method can be executed by a video memory management system. The virtual video memory management system is set in the memory of the host. An object linked list is also created in the memory for tracking the status of storage objects associated with kernel functions. The system can be implemented by software and / or hardware.
[0025] like Figure 1 As shown, the video memory management method includes the following steps:
[0026] S110. When a kernel function is registered to a GPU, a storage object associated with the kernel function is obtained.
[0027] Among them, the kernel function can be understood as an execution instruction that needs to call data. Specifically, the kernel function can be obtained by manual input by the user or remote reception, and the specific acquisition method is not limited here. Furthermore, the object data can be the target data that needs to be loaded into the host's video memory. Specifically, for each kernel function, the data associated with the kernel function can be searched from the host's memory, and the searched data can be used as the storage object associated with the kernel function. Among them, the storage object can be understood as the object data that needs to be called.
[0028] S120: pre-allocate the storage object in the virtual video memory, and update the object linked list.
[0029] Among them, after the storage objects associated with the kernel function, all storage objects can be pre-allocated from the internal memory to the virtual video memory. The object linked list can be used to track the status of the storage objects associated with the kernel function. Exemplarily, the object linked list can record storage status information such as the data size, the kernel function, the location pointer, the page, and the context of the storage object. Exemplarily, after the storage objects are pre-allocated in the virtual video memory, the current storage location of the storage objects in the object linked list can be updated to the allocated location in the virtual video memory.
[0030] S130: Before the kernel function is formally called, preload the storage object from the virtual video memory into the physical video memory.
[0031] Among them, by preloading all storage objects from virtual video memory to physical video memory before the kernel function is officially called, the page jitter problem caused by repeated movement of pages between virtual video memory and physical video memory after the existing technology finds that the data is not in the physical video memory can be avoided, thereby improving the operating performance of the video memory system.
[0032] S140: Issue a call to the kernel function and update the object linked list.
[0033] When receiving a feedback instruction that the storage object is successfully preloaded from the virtual video memory to the physical video memory, a call trigger instruction of the kernel function can be issued to enable the GPU to start calling the storage object. In addition, after the storage object is preloaded from the virtual video memory to the physical video memory, the current storage position of the storage object in the object linked list can be updated to the preload position in the physical video memory.
[0034] The technical solution provided by the embodiment of the present invention obtains the storage object associated with the kernel function when the kernel function is registered to the GPU; pre-allocates the storage object in the virtual video memory and updates the object list; pre-loads the storage object from the virtual video memory to the physical video memory before the kernel function is formally called; issues the call of the kernel function and updates the object list. The technical solution of the embodiment of the present invention solves the problem that the video memory management technology in the prior art is prone to page jitter and affects system performance. It can manage storage objects between the virtual video memory and the physical video memory according to the life cycle of the kernel function, and load all used storage objects into the physical video memory before the kernel function is actually run, solving the problem of pages repeatedly moving between the virtual video memory and the physical video memory, and improving the performance of the video memory system.
[0035] Figure 2 It is another flow chart of a video memory management method provided by an embodiment of the present invention. The embodiment of the present invention can be applied to the scenario of managing video memory data in a host. Based on the above embodiment, this embodiment further explains how to obtain the storage object associated with the kernel function when the kernel function is registered to the GPU; and how to pre-allocate the storage object in the virtual video memory. The system can be implemented by software and / or hardware and integrated in a computer device with application development capabilities.
[0036] like Figure 2 As shown, the video memory management method includes the following steps:
[0037] S210: When a registration instruction regarding the kernel function is received, determine a plurality of kernel functions to be registered according to the registration instruction.
[0038] Among them, the kernel function can be understood as an execution instruction that needs to call data. Specifically, the kernel function can be obtained by manual input or remote reception by the user, and the specific acquisition method is not limited here. The registration instruction can be an instruction that requires the kernel function to be registered with the GPU. The kernel function to be registered can be a kernel function that needs to be registered with the GPU. Specifically, the kernel function corresponding to the registration instruction can be used as the kernel function to be registered.
[0039] S220 . For each kernel function to be registered, search the memory for object data associated with the kernel function, and use the searched object data as a storage object associated with the kernel function.
[0040] The object data may be target data that needs to be loaded into the video memory of the host. Specifically, for each kernel function, data associated with the kernel function may be searched from the memory of the host, and the searched data may be used as a storage object associated with the kernel function. The storage object may be understood as object data that needs to be called.
[0041] S230: For each storage object, determine an object allocation position of the storage object in the virtual video memory.
[0042] The object allocation position may be the allocation position of the storage object in the virtual video memory. Exemplarily, the target allocation position of the storage object in the virtual video memory may be obtained from the kernel function, and the target allocation position may be used as the object allocation position of the storage object. In order to facilitate data management, a corresponding allocation path may be reserved for each kernel function to be registered in the virtual video memory, and for the storage object corresponding to the same kernel function to be registered, a sub-path corresponding to each storage object may be determined in the allocation path corresponding to the kernel function to be registered, and the sub-path may be used as the object allocation position corresponding to the storage object.
[0043] S240: pre-allocate storage objects of all kernel functions to be registered from the memory to object allocation locations in the virtual video memory, and update the object linked list.
[0044] Specifically, for each storage object corresponding to all kernel functions to be registered, the storage object can be pre-allocated from the internal memory to the object allocation position in the virtual video memory. Furthermore, the object linked list can be used to track the status of the storage object associated with the kernel function. Exemplarily, the object linked list can record storage status information such as the data size, the kernel function, the location pointer, the page, and the context of the storage object. Exemplarily, after the storage object is pre-allocated in the virtual video memory, the current storage position of the storage object in the object linked list can be updated to the object allocation position in the virtual video memory.
[0045] S250: Before the kernel function is formally called, preload the storage object from the virtual video memory into the physical video memory; issue a call to the kernel function, and update the object linked list.
[0046] Among them, by preloading all storage objects from virtual video memory to physical video memory before the kernel function is officially called, the page jitter problem caused by repeated movement of pages between virtual video memory and physical video memory after the existing technology finds that the data is not in the physical video memory can be avoided, thereby improving the operating performance of the video memory system.
[0047] Further, when a feedback instruction is received that the storage object is successfully preloaded from the virtual video memory to the physical video memory, a call trigger instruction of the kernel function can be issued to enable the GPU to start calling the storage object. In addition, after the storage object is preloaded from the virtual video memory to the physical video memory, the current storage position of the storage object in the object linked list can be updated to the preload position in the physical video memory.
[0048] The technical solution provided by the embodiment of the present invention determines multiple kernel functions to be registered according to the registration instruction when receiving the registration instruction about the kernel function; for each kernel function to be registered, searches the object data associated with the kernel function from the memory, and uses the searched object data as the storage object associated with the kernel function; for each storage object, determines the object allocation position of the storage object in the virtual video memory; pre-allocates the storage objects of all kernel functions to be registered from the memory to the object allocation position in the virtual video memory, and updates the object linked list; before the kernel function is formally called, pre-loads the storage object from the virtual video memory to the physical video memory; issues the call of the kernel function, and updates the object linked list. The technical solution of the embodiment of the present invention solves the problem that the video memory management technology of the prior art is prone to page jitter and affects the system performance. It can manage the storage objects between the virtual video memory and the physical video memory according to the life cycle of the kernel function, and load all the used storage objects into the physical video memory before the kernel function is actually run, which solves the problem of repeated movement of pages between the virtual video memory and the physical video memory, and improves the performance of the video memory system.
[0049] Figure 3 This is another flow chart of a video memory management method provided by an embodiment of the present invention. The embodiment of the present invention can be applied to the scenario of managing video memory data in a host. Based on the above embodiment, this embodiment further illustrates how to pre-allocate storage objects in virtual video memory and update the object linked list; how to pre-load storage objects from virtual video memory to physical video memory before the kernel function is formally called; and how to issue a kernel function call and update the object linked list. The system can be implemented by software and / or hardware and integrated into a computer device with application development capabilities.
[0050] like Figure 3 As shown, the video memory management method includes the following steps:
[0051] S310: When a registration instruction regarding the kernel function is received, determine a plurality of kernel functions to be registered according to the registration instruction.
[0052] S320: For each kernel function to be registered, search the memory for object data associated with the kernel function, and use the searched object data as a storage object associated with the kernel function.
[0053] S330: pre-allocate the storage object in a virtual video memory, and obtain a first storage location and a first occupied memory of the storage object in the virtual video memory.
[0054] The first storage location may be a storage location of the storage object in the virtual memory. The first occupied memory may be an occupied memory of the storage object in the virtual memory. Specifically, the storage state information of the storage object in the virtual video memory may be read to obtain the first storage location and the first occupied memory.
[0055] S340: Adjust the object storage location of the object stored in the object linked list to the first storage location, and adjust the memory occupied by the object to the first occupied memory.
[0056] The object storage location may be information for recording the current storage location of the storage object. The object memory usage may be information for recording the memory usage of the storage object at the object storage location. By timely updating the object storage location and object memory usage of the storage object in the object linked list after recording the storage state of the storage object changes, it is convenient to track the subsequent call state information of the storage object in a timely manner, thereby improving the consistency and security of the call state.
[0057] S350: When a pre-call instruction regarding the kernel function is received, determine a plurality of kernel functions to be called according to the call instruction.
[0058] The pre-call instruction may be a pre-processing preparation instruction for data calling. The kernel function to be called may be a kernel function that needs to be called. Specifically, based on the pre-call instruction, a corresponding kernel function may be determined from the kernel functions to be registered as the kernel function to be called.
[0059] S360: For each kernel function to be called, determine an object loading position of a storage object associated with the kernel function to be called in the physical video memory.
[0060] The object loading position may be the loading position of the storage object in the physical video memory. Exemplarily, the target loading position of the storage object in the physical video memory may be obtained from the kernel function, and the target loading position may be used as the object loading position of the storage object. In order to facilitate data management, a corresponding loading path may be reserved for each kernel function to be registered in the physical video memory, and for the storage object corresponding to the same kernel function to be registered, a sub-path corresponding to each storage object may be determined in the loading path corresponding to the kernel function to be registered, and the sub-path may be used as the object loading position corresponding to the storage object.
[0061] S370: preload all storage objects corresponding to the kernel functions to be called from the physical video memory to the object loading position in the physical video memory.
[0062] Specifically, for each storage object corresponding to all kernel functions to be registered, the storage object may be preloaded from the memory to the object loading position in the physical video memory.
[0063] S380: When a preloading completion instruction is received, a kernel function call instruction is issued, and a second storage location and a second occupied memory of the storage object in the physical memory are obtained.
[0064] Among them, the preload completion instruction may be an instruction indicating that the storage object corresponding to the kernel function to be called has been preloaded. The kernel function call instruction may be a call trigger instruction corresponding to the kernel function to be called. By issuing the kernel function call instruction, the GPU can start calling the storage object. Furthermore, the second storage location may be the storage location of the storage object in the physical memory. The second occupied memory may be the occupied memory of the storage object in the physical memory. Specifically, the storage status information of the storage object in the physical video memory may be read to obtain the second storage location and the second occupied memory.
[0065] S390: Adjust the object storage location of the object stored in the object linked list to the second storage location, and adjust the memory occupied by the object to the second memory occupied.
[0066] Optionally, during the process of transmitting the storage object corresponding to the current kernel function, if a call instruction of other kernel functions is received and the storage objects of other kernel functions have been preloaded, the callable instruction corresponding to the preloaded kernel function may be issued.
[0067] Among them, the current kernel function may be a kernel function that is currently undergoing data transmission processing. Other kernel functions may be other kernel functions except the current kernel function in the kernel functions to be registered. The callable instruction may be a call trigger instruction corresponding to the preloaded kernel function. The technical solution of the embodiment of the present invention can perform parallel transmission of the storage object of each kernel function. If the storage object of a kernel function has been preloaded, the callable instruction corresponding to the preloaded kernel function can be issued in advance, so that the GPU can start calling the storage object corresponding to the preloaded kernel function, thereby reducing the waiting time in the data calling process and improving the efficiency of data calling.
[0068] Optionally, if it is detected that the capacity of the physical video memory reaches a set capacity threshold, the storage object corresponding to the storage page in the physical video memory is obtained, and the storage object corresponding to the storage page is migrated to the virtual memory, and the object linked list is updated.
[0069] In the process of obtaining the storage object corresponding to the storage page in the physical video memory, the target storage object can be determined based on the historical call time and historical call frequency of the storage object corresponding to the storage page, and then the target storage object is migrated from the physical video memory to the virtual memory, and the storage status of the target storage object in the object linked list is updated. Exemplarily, a storage object with a later historical call time and / or a lower historical call frequency can be used as the target storage object. The historical call time can be the latest time when the storage object is called in the historical period. The historical call frequency can be the frequency at which the storage object is called in the historical period.
[0070] Optionally, if the kernel function calls an object physical memory page error, the storage object corresponding to the error storage page can be determined, and the storage object can be loaded from the virtual video memory to the physical video memory, and the object linked list can be updated.
[0071] The error in the physical memory page of the kernel function calling object includes but is not limited to an error in the storage location of the object data to be called. Further, the storage object corresponding to the error storage page can be determined, and then the storage object is reloaded from the virtual memory to the physical memory, and the storage state of the reloaded storage object in the object linked list is updated.
[0072] For example, in order to better understand the technical solution provided by the present invention, a specific embodiment is introduced below: Figure 4 FIG. 1 is a flowchart of a video memory management process provided by an embodiment of the present invention. Figure 4 As shown, the workflow for video memory management includes the following processes:
[0073] 1. Establish a unified management system for partitioning memory (virtual video memory) and physical video memory on the HOST side, and establish a global object linked list in the HOST memory to manage the storage status of all objects during CUDA runtime.
[0074] 2. When the kernel function is registered to the GPU, the objects involved in the kernel function are pre-allocated in the virtual video memory (memory), and the linked list object storage status such as size, belonging kernel function, location pointer, belonging page, belonging context, etc. are updated.
[0075] 3. Before the kernel function is formally called, the objects involved are preloaded from the virtual video memory to the physical video memory, and then the kernel function call is issued, and the storage object status such as pointers and ownership status are updated synchronously. While the object data is being transmitted, the kernel functions on other GPUs can be run.
[0076] 4. If the physical video memory is full, the objects in the storage pages in the physical video memory are migrated to the virtual video memory in the main memory using the latest least used algorithm, and the object status is synchronously updated in the object linked list.
[0077] 5. As a fallback measure, if the kernel function calls the object physical memory page error, the UVM mechanism will be used to notify the virtual memory error handler registered in the host through the I / O page fault, and the missing page will be loaded into the video memory. If the physical video memory page needs to be swapped out, the fourth step is used.
[0078] In the real environment of mobile cloud, the present invention achieves oversubscription of video memory capacity to 300% for three typical types of programs without affecting the normal use of the business, which can increase the utilization rate of GPU hardware computing power by more than 3 times and the overall utilization rate by 3-7 times.
[0079] For example, Figure 5 This is a test experiment effect diagram of the technical solution provided by the embodiment of the present invention. Figure 5 It can be seen that when the GPU is divided into 10 or 12 VGPUs, the video memory is oversubscribed to 300%, that is, in the case of 16G video memory, 32G memory is added as virtual video memory, and the scheduling system of the present invention is used to manage the video memory objects and call kernel functions. From the following test experiments, in the case of 10 VGPUs and 12 VGPUs, although the video memory oversubscription reaches 250% and 300%, the system runs smoothly without business jitter. At the same time, the GPU computing power is fully utilized, and the total computing power reaches more than 400% of the pure physical GPU computing power.
[0080] The technical solution provided by the embodiment of the present invention is as follows: when receiving a registration instruction about a kernel function, multiple kernel functions to be registered are determined according to the registration instruction; for each kernel function to be registered, object data associated with the kernel function is searched from the memory, and the searched object data is used as the storage object associated with the kernel function; the storage object is pre-allocated in the virtual video memory, and the first storage position and the first occupied memory of the storage object in the virtual memory are obtained; the object storage position of the storage object in the object linked list is adjusted to the first storage position, and the object occupied memory is adjusted to the first occupied memory; when receiving a pre-call instruction about the kernel function, multiple kernel functions to be called are determined according to the call instruction; for each kernel function to be called, the object loading position of the storage object associated with the kernel function to be called in the physical video memory is determined; the storage objects corresponding to all the kernel functions to be called are pre-loaded from the virtual video memory to the object loading position in the physical video memory; when receiving a pre-loading completion instruction, a kernel function call instruction is issued, and the second storage position and the second occupied memory of the storage object in the physical memory are obtained; the object storage position of the storage object in the object linked list is adjusted to the second storage position, and the object occupied memory is adjusted to the second occupied memory. The technical solution of the embodiment of the present invention solves the problem that the video memory management technology in the prior art is prone to page jitter, which affects system performance. It can manage storage objects between virtual video memory and physical video memory according to the life cycle of the kernel function, and load all used storage objects into the physical video memory before the kernel function is actually run, thereby solving the problem of pages moving repeatedly between virtual video memory and physical video memory and improving the performance of the video memory system.
[0081] Figure 6 It is a structural diagram of a video memory management system provided by an embodiment of the present invention. The embodiment of the present invention can be applied to the scenario of managing video memory data in a host. The virtual video memory management system is set in the memory of the host. An object linked list is also created in the memory for tracking the status of storage objects associated with kernel functions. The system can be implemented by software and / or hardware and integrated in a computer device with application development capabilities.
[0082] like Figure 6 As shown, the video memory management system includes: a storage object determination module 310 , a pre-allocation module 320 , a pre-loading module 330 and a kernel function calling module 340 .
[0083] Among them, the storage object determination module 310 is used to obtain the storage object associated with the kernel function when the kernel function is registered to the GPU; the pre-allocation module 320 is used to pre-allocate the storage object in the virtual video memory and update the object linked list; the pre-loading module 330 is used to pre-load the storage object from the virtual video memory to the physical video memory before the kernel function is formally called; the kernel function calling module 340 is used to issue the call of the kernel function and update the object linked list.
[0084] The technical solution provided by the embodiment of the present invention is as follows: when the kernel function is registered to the GPU, the storage object associated with the kernel function is obtained; the storage object is pre-allocated in the virtual video memory, and the object linked list is updated; before the kernel function is formally called, the storage object is pre-loaded from the virtual video memory to the physical video memory; the call of the kernel function is issued, and the object linked list is updated. The technical solution of the embodiment of the present invention solves the problem that the video memory management technology in the prior art is prone to page jitter, which affects the system performance. The storage object can be managed between the virtual video memory and the physical video memory according to the life cycle of the kernel function, and all the used storage objects are loaded into the physical video memory before the kernel function is actually run, which solves the problem of pages moving repeatedly between the virtual video memory and the physical video memory, and improves the performance of the video memory system.
[0085] In an optional embodiment, the storage object determination module 310 is specifically used to: upon receiving a registration instruction regarding the kernel function, determine a plurality of kernel functions to be registered according to the registration instruction; for each kernel function to be registered, search the memory for object data associated with the kernel function, and use the searched object data as the storage object associated with the kernel function.
[0086] In an optional embodiment, the pre-allocation module 320 includes: a first pre-allocation unit, used to: determine, for each storage object, the object allocation position of the storage object in the virtual video memory; and pre-allocate the storage objects of all kernel functions to be registered from the memory to the object allocation position in the virtual video memory.
[0087] In an optional embodiment, the pre-allocation module 320 also includes: a second pre-allocation unit, used to: pre-allocate the storage object in the virtual video memory, and obtain the first storage position and the first occupied memory of the storage object in the virtual memory; adjust the object storage position of the storage object in the object linked list to the first storage position, and adjust the object occupied memory to the first occupied memory.
[0088] In an optional embodiment, the preloading module 330 is specifically used to: upon receiving a pre-call instruction regarding the kernel function, determine a plurality of kernel functions to be called according to the call instruction; for each kernel function to be called, determine the object loading position of the storage object associated with the kernel function to be called in the physical video memory; and preload all storage objects corresponding to the kernel functions to be called from the virtual video memory to the object loading position in the physical video memory.
[0089] In an optional embodiment, the kernel function calling module 340 is specifically used to: upon receiving a preloading completion instruction, issue a kernel function calling instruction, and obtain the second storage location and second occupied memory of the storage object in the physical memory; adjust the object storage position of the storage object in the object linked list to the second storage position, and adjust the object occupied memory to the second occupied memory.
[0090] In an optional embodiment, the video memory management system also includes: a calling instruction management module, which is used to: during the process of transmitting the storage object corresponding to the current kernel function, if a calling instruction of other kernel functions is received and the storage objects of the other kernel functions have been preloaded, issue a callable instruction corresponding to the preloaded kernel function.
[0091] In an optional embodiment, the video memory management system also includes: a capacity threshold management module, which is used to: if it is detected that the capacity of the physical video memory reaches a set capacity threshold, obtain the storage object corresponding to the storage page in the physical video memory, migrate the storage object corresponding to the storage page to the virtual memory, and update the object linked list.
[0092] In an optional embodiment, the video memory management system also includes: a memory page exception handling module, which is used to: if the kernel function calls the object physical video memory page error, determine the storage object corresponding to the error storage page, load the storage object from the virtual video memory to the physical video memory, and update the object linked list.
[0093] The video memory management system provided in the embodiment of the present invention can execute the video memory management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0094] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 7 A block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 7The computer device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention. The computer device 12 can be any terminal device with computing capability and can be configured in a video memory management device.
[0095] like Figure 7 As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0096] The bus 18 may be one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0097] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0098] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0099] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0100] The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the computer device 12, and / or any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the computer device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter 20. Figure 7 As shown, the network adapter 20 communicates with other modules of the computer device 12 via the bus 18. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with computer device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0101] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, for example, implementing the video memory management method provided in the embodiment of the present invention, the method comprising:
[0102] When a kernel function is registered to the GPU, the storage object associated with the kernel function is obtained; the storage object is pre-allocated in the virtual video memory, and the object linked list is updated; before the kernel function is formally called, the storage object is pre-loaded from the virtual video memory to the physical video memory; the call of the kernel function is issued, and the object linked list is updated.
[0103] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the video memory management method provided by any embodiment of the present invention is implemented, including:
[0104] When a kernel function is registered to the GPU, the storage object associated with the kernel function is obtained; the storage object is pre-allocated in the virtual video memory, and the object linked list is updated; before the kernel function is formally called, the storage object is pre-loaded from the virtual video memory to the physical video memory; the call of the kernel function is issued, and the object linked list is updated.
[0105] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, system or device or used in combination with it.
[0106] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, system, or device.
[0107] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0108] Computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] It should be understood by those skilled in the art that the above modules or steps of the present invention can be implemented by a general-purpose computing system, they can be concentrated on a single computing system, or distributed on a network composed of multiple computing systems, optionally, they can be implemented by a program code executable by a computer system, so that they can be stored in a storage system and executed by the computing system, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0110] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A video memory management method, characterized in that: Applied to a virtual video memory management system, wherein the virtual video memory management system is arranged in the memory of a host; An object linked list is also created in the memory for tracking the status of storage objects associated with the kernel function; the method includes: When the kernel function is registered to the GPU, obtaining the storage object associated with the kernel function; Pre-allocating the storage object in the virtual video memory and updating the object linked list; Before the kernel function is formally called, preloading the storage object from the virtual video memory into the physical video memory; The kernel function is called and the object list is updated.
2. The method according to claim 1, characterized in that When the kernel function is registered to the GPU, obtaining the storage object associated with the kernel function includes: In case of receiving a registration instruction about the kernel function, determining a plurality of kernel functions to be registered according to the registration instruction; For each kernel function to be registered, object data associated with the kernel function is searched from the memory, and the searched object data is used as a storage object associated with the kernel function.
3. The method according to claim 2, characterized in that The pre-allocating the storage object in the virtual video memory includes: For each storage object, determining an object allocation position of the storage object in the virtual video memory; All storage objects of the kernel functions to be registered are pre-allocated from the memory to the object allocation position in the virtual video memory.
4. The method according to claim 1, characterized in that The object linked list includes the object storage location of the storage object and the memory occupied by the object; the pre-allocation of the storage object in the virtual video memory and updating the object linked list include: Pre-allocating the storage object in a virtual video memory, and obtaining a first storage location and a first occupied memory of the storage object in the virtual video memory; The object storage location of the object stored in the object linked list is adjusted to the first storage location, and the memory occupied by the object is adjusted to the first occupied memory.
5. The method according to claim 1, characterized in that Before the kernel function is formally called, the storage object is preloaded from the virtual video memory to the physical video memory, including: In case of receiving a pre-call instruction about the kernel function, determining a plurality of kernel functions to be called according to the call instruction; For each kernel function to be called, determining an object loading position of a storage object associated with the kernel function to be called in the physical video memory; All storage objects corresponding to the kernel functions to be called are preloaded from the virtual video memory to the object loading position in the physical video memory.
6. The method according to claim 1, characterized in that Sending the call of the kernel function and updating the object list includes: When receiving the preloading completion instruction, issuing a kernel function call instruction, and obtaining a second storage location and a second occupied memory of the storage object in the physical memory; The object storage location storing the object in the object linked list is adjusted to the second storage location, and the memory occupied by the object is adjusted to the second occupied memory.
7. The method according to claim 1, characterized in that The method further comprises: During the transmission of the storage object corresponding to the current kernel function, if a call instruction of other kernel functions is received and the storage object of the other kernel functions has been preloaded, a callable instruction corresponding to the preloaded kernel function is issued.
8. The method according to claim 1, characterized in that: The method further comprises: If it is detected that the capacity of the physical video memory reaches a set capacity threshold, a storage object corresponding to a storage page in the physical video memory is obtained, and the storage object corresponding to the storage page is migrated to the virtual memory, and the object linked list is updated.
9. The method according to claim 1, characterized in that: The method further comprises: If the kernel function calls the object physical video memory page error, determine the storage object corresponding to the error storage page, and load the storage object from the virtual video memory to the physical video memory, and update the object linked list.
10. A video memory management system, characterized in that: The virtual video memory management system is arranged in the memory of the host; An object linked list is also created in the memory for tracking the status of storage objects associated with the kernel function. The system includes: A storage object determination module, used for obtaining a storage object associated with a kernel function when the kernel function is registered to the GPU; A pre-allocation module, used for pre-allocating the storage object in the virtual video memory and updating the object linked list; A preloading module, used for preloading the storage object from the virtual video memory into the physical video memory before the kernel function is formally called; The kernel function calling module is used to issue the call of the kernel function and update the object linked list.
11. A computer device, characterized in that: The computer device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the video memory management method as described in any one of claims 1-9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the video memory management method as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Compute unified device architecture (CUDA) based grid digital elevation model (DEM) neighborhood analysis system and method
CN102880509A
Dynamic memory allocation method and device based on GPU (Graphics Processing Unit) and memory linked list
CN113296961A
Method and device for allocating GPU physical memories
CN113377545A
GPU resource usage method, GPU virtualization method, and job scheduling apparatus and cluster
WO2024032587A1
Cited By
GPU video memory management method, system and equipment based on excess subscription and storage medium
CN120670175A
Method, system and device for GPU memory management based on excess subscription and storage medium
CN120670175B