A video memory mapping window extension method, device, equipment, medium and product
Patent Information
- Application Number
- CN202610956594.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-29
- Publication Date
- 2026-10-20
AI Technical Summary
[0003]现有的GPU的显存映射窗口一般只提供较小的显存容量(如256MB),在显存需求量较高的场景下,如大规模人工智能(Artificial Intelligence,AI)模型加载、多GPU协同计算等,主机端软件需要频繁进行显存映射窗口切换,导致显存访问延迟增大、带宽利用率降低、虚拟化性能下降等
[0010]本公开可以响应于满足窗口扩展条件,释放目标GPU的显存资源占用,修改显存映射窗口的显存容量并重新分配显存资源,实现了将显存映射窗口扩展至更大显存容量的目的,使得修改后显存映射窗口更加适配于高显存需求任务,进而降低了因显存映射窗口的显存容量不足导致的频繁窗口切换开销,提升了显存访问效率和整体性能。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to the field of GPU memory management technology. Specifically, this disclosure relates to a method, apparatus, device, medium, and product for extending a memory mapping window. Background Technology
[0002] In the field of GPU memory management technology, the Graphics Processing Unit (GPU) is widely used for large model inference and high-performance computing tasks. The GPU exposes a memory mapping access interface to the host's Central Processing Unit (CPU) through a memory mapping window, that is, the host software can directly read and write the GPU's memory through the memory mapping window.
[0003] Existing GPU memory mapping windows typically provide only a small amount of memory (e.g., 256MB). In scenarios with high memory requirements, such as loading large-scale artificial intelligence (AI) models or multi-GPU collaborative computing, the host software needs to frequently switch memory mapping windows, leading to increased memory access latency, reduced bandwidth utilization, and decreased virtualization performance. Summary of the Invention
[0004] This disclosure provides a method, apparatus, device, medium, and product for expanding video memory mapping windows to improve video memory access efficiency and overall performance.
[0005] According to one aspect of this disclosure, a method for expanding a video memory mapping window is provided, comprising: In response to meeting the preset window expansion conditions, the target GPU's video memory resources are released; The memory capacity of the memory mapping window of the target GPU is modified to the target value to obtain the modified memory mapping window, wherein the target value is greater than the initial value of the memory capacity; Based on the target value, the target GPU's memory resources are allocated to the modified memory mapping window.
[0006] According to another aspect of this disclosure, a video memory mapping window expansion device is provided, comprising: The release unit is configured to release the video memory resources occupied by the target GPU in response to satisfying a preset window expansion condition; The modification unit is configured to modify the memory capacity of the memory mapping window of the target GPU to a target value, thereby obtaining a modified memory mapping window, wherein the target value is greater than the initial value of the memory capacity. The allocation unit is configured to allocate the target GPU's memory resources to the modified memory mapping window based on the target value.
[0007] According to another aspect of this disclosure, an electronic device is provided, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods described in the embodiments of this disclosure.
[0008] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the methods described in embodiments of this disclosure.
[0009] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the methods described in the embodiments of this disclosure.
[0010] This disclosure can respond to the window expansion condition, release the target GPU's video memory resource occupation, modify the video memory capacity of the video memory mapping window and reallocate video memory resources, thereby achieving the purpose of expanding the video memory mapping window to a larger video memory capacity. This makes the modified video memory mapping window more suitable for tasks with high video memory requirements, thereby reducing the overhead of frequent window switching caused by insufficient video memory capacity of the video memory mapping window, and improving video memory access efficiency and overall performance.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0012] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure.
[0013] Figure 1 This is a flowchart of the video memory mapping window expansion method provided in this disclosure.
[0014] Figure 2 This is a schematic diagram of the implementation environment provided in this disclosure.
[0015] Figure 3 This is a schematic diagram of the process of the video memory mapping window expansion method provided in this disclosure.
[0016] Figure 4 This is a schematic block diagram of the video memory mapping window extension device provided in this disclosure.
[0017] Figure 5 This is a block diagram of an electronic device used to implement the video memory mapping window expansion method of the embodiments of this disclosure. Detailed Implementation
[0018] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0019] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0020] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0021] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."
[0022] In the field of GPU memory management technology, the GPU's memory address space is mapped to the host CPU's memory address space through a memory mapping window. The memory mapping window is used to directly expose the GPU's memory address space to the host to achieve efficient data exchange. With the rapid development of applications such as artificial intelligence, deep learning, and high-performance computing, large model inference and training tasks performed in these applications often require accessing all or most of the GPU memory resources at once.
[0023] However, the memory capacity of the memory mapping window is usually set to a small initial value (e.g., 256MB). When the memory access requirements of the computing task exceed this memory capacity, the host must satisfy the access request through frequent window switching operations (i.e., remapping different segments of memory), which leads to serious address translation overhead and wasted bus bandwidth, significantly reducing memory access efficiency and overall performance.
[0024] To obtain a larger memory mapping window, solutions typically require making custom requests to GPU hardware manufacturers, demanding firmware modifications or the provision of dedicated drivers to adjust the memory capacity of the memory mapping window. In some cases, it may even necessitate replacing the GPU with a dedicated hardware model that supports a larger memory mapping window. This approach is not only time-consuming and costly, but also lacks the flexibility to adapt to changing requirements of different tasks or runtime environments.
[0025] In view of this, this disclosure provides a new approach. Figure 1 The flowchart illustrates a method for expanding a video memory mapping window provided in this embodiment. This method can be executed by a processor (e.g., CPU) in a computing system, specifically by a loadable kernel module (LKM) loaded into the operating system kernel. Figure 1 As shown, the method may include the following steps: Step 101: In response to satisfying the preset window expansion conditions, release the video memory resources occupied by the target GPU.
[0026] Step 102: Modify the memory capacity of the target GPU's memory mapping window to the target value to obtain the modified memory mapping window, where the target value is greater than the initial value of the memory capacity.
[0027] Step 103: Allocate the target GPU's memory resources to the modified memory mapping window based on the target value.
[0028] As can be seen from the above process, this disclosure can release the target GPU's video memory resource occupation in response to meeting the window expansion conditions, modify the video memory capacity of the video memory mapping window and reallocate video memory resources, thereby achieving the purpose of expanding the video memory mapping window to a larger video memory capacity. This makes the modified video memory mapping window more suitable for tasks with high video memory requirements, thereby reducing the overhead of frequent window switching caused by insufficient video memory capacity of the video memory mapping window, and improving video memory access efficiency and overall performance.
[0029] To illustrate this solution more clearly, a specific implementation environment is provided here, such as... Figure 2As shown. This implementation environment includes a CPU and a GPU connected to the CPU via a Peripheral Component Interconnect Express (PCIe) bus.
[0030] The following describes in detail each step of the above process and the effects that can be further produced, with reference to the embodiments.
[0031] First, the above step 101, namely "releasing the video memory resources occupied by the target GPU in response to satisfying the preset window expansion conditions", will be described in detail with reference to the embodiments.
[0032] In this embodiment, in response to meeting preset window expansion conditions, the memory resources occupied by the target GPU are first released; that is, all physical address space currently occupied by the target GPU related to memory is released. Furthermore, the physical address space occupied by the prefetch memory window of the communication bus connected to the target GPU (such as the upstream PCIe bridge of the target GPU) can also be released to free up contiguous physical address space for subsequent larger memory mapping windows. This avoids address conflicts with other devices when modifying the memory capacity of the memory mapping window, laying the foundation for accurate address space reallocation later.
[0033] The window expansion conditions include any of the following: First, the initial value of the memory capacity of the memory mapping window is lower than the memory requirement of the current access task (i.e., automatically triggered expansion). Specifically, when the operating system or upper-level application (such as an AI inference framework or virtual machine manager) in the target GPU's runtime environment initiates an access instruction to the target GPU's memory, it can first obtain the size of the memory address space required by the current access task, i.e., the memory requirement value corresponding to the current access task. If the memory requirement value is greater than the initial value of the memory capacity of the memory mapping window (e.g., the default 256MB), then the window expansion condition is determined to be met.
[0034] For example, when a large language model loading task requests the allocation of 8GB of contiguous video memory address space, this solution finds that the initial value of the video memory capacity of the current video memory mapping window is only 256MB, which is much smaller than 8GB, thus automatically triggering the subsequent process of releasing video memory resources, modifying video memory capacity, and reallocating addresses.
[0035] This automatic triggering method enables window expansion operations to dynamically respond to changes in business load without manual intervention, making it particularly suitable for scenarios where GPU resources are allocated on demand in cloud computing and virtualization environments.
[0036] Second, user-submitted window extension commands (i.e., manually triggered extensions). Specifically, users can submit a window extension command directly through the command-line interface, graphical management interface, or by writing to a specific configuration file. The window extension command can include a target value for the video memory capacity, or it can simply instruct the execution of the extension process, with the target value determined automatically by this solution.
[0037] This manual triggering method improves the flexibility of executing extension schemes, allowing them to proactively complete configuration during the initialization phase or maintenance window, avoiding the timing uncertainty that may result from automatic triggering.
[0038] It should be noted that the two conditions mentioned above can exist independently; that is, meeting either condition is considered to meet the window expansion condition. In practical applications, manually triggered expansions can be prioritized. For example, when a user submits a window expansion command, expansion can be forcibly executed even if the video memory requirement of the currently accessed task does not exceed the initial value of the video memory capacity. Alternatively, both conditions can be monitored in parallel, with the first triggered condition taking precedence for expansion. The two conditions can also be combined; for example, expansion can be executed only if the initial value of the video memory capacity is lower than the video memory requirement of the currently accessed task, and the user has submitted a window expansion command.
[0039] By setting window expansion conditions that are automatically triggered based on business needs, and setting window expansion conditions that can be manually triggered by users, the goal of executing the window expansion scheme on demand is achieved. This avoids blindly performing complex resource reallocation operations when there is sufficient video memory capacity, thereby improving operating efficiency and operational flexibility while meeting the needs of large-capacity windows.
[0040] The following describes in detail step 102, namely, "modifying the memory capacity of the target GPU's memory mapping window to the target value, and obtaining the modified memory mapping window, where the target value is greater than the initial value of the memory capacity," with reference to the embodiments.
[0041] It should be noted that in this solution, the memory mapping window can refer to a contiguous physical address space exposed by the target GPU to the CPU for direct access to its memory. The memory capacity refers to the size of the GPU memory address space that the memory mapping window can currently map. Its initial value is usually set by the firmware (e.g., 256MB), while the target value refers to a new capacity value (e.g., 64GB or 128GB) that expands the memory mapping window to.
[0042] In some embodiments, the memory requirement value corresponding to the current access task is first obtained, and a target value is determined based on the memory requirement value. The target value is not less than the memory requirement value. For example, the target value can be 1.5 times the memory requirement value.
[0043] One feasible approach is to extend the memory mapping window through a pre-defined interface provided by the operating system in the target GPU's runtime environment. Specifically, the target GPU's configuration space contains a set of registers, including but not limited to the following two types: a read-only capability register, used to declare the maximum declared value of the memory capacity of the memory mapping window supported by the target GPU (e.g., a maximum supported memory mapping window of 32GB); and a read-write control register, used to store the size of the memory capacity.
[0044] The following steps can be performed through the preset interface provided by the operating system in the target GPU runtime environment: obtain the target value of the video memory capacity, compare the target value with the maximum declared value declared in the capability register, if the target value is not greater than the maximum declared value, modify the video memory capacity of the video memory mapping window of the target GPU to the target value, if the target value is greater than the maximum declared value, refuse to modify the video memory capacity of the video memory mapping window.
[0045] It can be seen that the above method cannot expand the memory capacity of the memory mapping window when the target value is greater than the maximum declared value. Therefore, as another feasible method, the target value is written to the target storage location in the target GPU used to store the memory capacity. Here, the target storage location can refer to the readable and writable hardware register inside the target GPU used to actually store the memory capacity of the current memory mapping window. For example, the target storage location refers to a specific bit field (such as bits[13:8], that is, bits 8 to 13 in the control register, a total of 6 bits) in the configuration space of the target GPU. While ensuring that the other positions in the control register remain unchanged except for the target storage location, the target value is directly written to the target storage location. The writing method can be directly executed through the underlying configuration space write operation (such as "pci_write_config_dword").
[0046] It should be noted that the above modifications are to the volatile register state, meaning that the original settings can be restored when the target GPU is powered off or restarted. There is no risk of damaging the hardware structure of the target GPU, thus improving the flexibility of expansion.
[0047] To ensure the reliability of the write operation, after writing the target value to the target storage location, the stored value at the target storage location is read. If the stored value is the target value, it means that the target GPU has accepted the write operation and the memory capacity of the memory mapping window has been successfully modified to the target value. Then, the subsequent step 103 can be executed.
[0048] If the stored value is not the target value, which means that the target GPU has rejected the write operation, the steps of lowering the target value according to the preset strategy, writing the target value to the target storage location, and reading the stored value from the target storage location are repeated until the stored value is the target value.
[0049] By employing readback verification and downgrade retry after verification failure, when the target GPU rejects the large capacity window setting, it automatically adapts to a lower capacity value that the target GPU can actually accept, thereby improving the reliability and success rate of the configuration process and avoiding the direct stop of capacity expansion due to a one-time write failure.
[0050] The preset strategy can be a variety of degradation algorithms. As one possible approach, the target value can be tried sequentially according to a predefined fixed level (such as 128GB, 64GB, 32GB, 16GB, etc.).
[0051] As another possible approach, the target value can be reduced by a specified capacity value, where the reduced target value is not less than the memory requirement of the current access task. Here, the memory requirement of the current access task refers to the minimum memory capacity of the memory mapping window required by the access task (e.g., an AI inference task) waiting to use the target GPU memory, as detected when the current memory mapping window expansion process is triggered. This memory requirement value can be obtained in various ways, such as being provided by the resource request parameters when the access task is submitted, estimated by the system scheduler based on the task type, or deduced by the memory manager from the process's page allocation records. As a specific example, an AI inference task that needs to load a large language model with 7GB of parameters requires approximately 14GB of contiguous memory address space for its large language model parameters and buffer; therefore, the memory requirement of this AI inference task is 14GB.
[0052] The specified capacity value can be a fixed step (e.g., 32GB). However, since the video memory capacity of the memory mapping window is usually a power of two, the specified capacity value is usually half of the target value. For example, if the current target value is 128GB, the specified capacity value is 64GB. Reducing the target value by the specified capacity value results in a target value of 64GB. It is important to note that the reduced target value should not be less than the video memory requirement of the current access task. This is because if the rolled-back video memory capacity is less than the current access task's video memory requirement, although the modification operation may succeed, the memory mapping window still cannot meet the full mapping needs of the current access task. The current access task will still need to frequently switch windows, thus defeating the purpose of the expansion.
[0053] Of course, if the target value has been reduced to match the video memory requirement, but the read storage value is still different from the target value, meaning the target GPU has not accepted the expansion, the target value can be further reduced to the maximum declared value in the capability register.
[0054] By setting a gradual degradation strategy, the acceptable memory capacity of the target GPU is automatically determined, ensuring that the final determined memory capacity will not be lower than the memory requirement of the current access task, thus avoiding invalid expansion operations and improving the quality of expansion while ensuring the stability of the expansion.
[0055] The following describes step 103, namely "allocating the target GPU's memory resources to the modified memory mapping window based on the target value", in detail with reference to the embodiments.
[0056] After successfully modifying the memory capacity of the memory mapping window, it is necessary to allocate matching memory resources to the modified window. Specifically, this can be done by calling the operating system's reallocation function in the target GPU's runtime environment, such as "pci_assign_unassigned_bus_resources()". This reallocation function can traverse the entire PCIe bus domain and, based on the latest resource requirements of all devices (including the expanded target GPU and its upstream PCIe bridges), recalculate and allocate conflict-free physical address spaces for them. After this step, the modified memory mapping window obtains a physical address space of equal size to the target value, which the CPU can access to read and write to the target GPU's memory.
[0057] After allocating the target GPU's memory resources to the modified memory mapping window based on the target value, in order to enable the expanded GPU to immediately start working normally and provide data access services, the target GPU can be further enabled. This means accessing the target GPU based on the modified memory mapping window in response to access commands to the target GPU. Enabling the target GPU here can refer to restoring it from a state that was previously disabled for safety reasons to a working state that can normally respond to CPU access after the resource reallocation is completed.
[0058] After enabling the target GPU, when the host software issues an access command to the target GPU—for example, when the CPU executes a load or store instruction targeting the memory address space corresponding to the memory mapping window—the CPU is no longer limited by the previous memory capacity (e.g., 256MB) of the memory mapping window. Instead, it can directly access the target GPU's memory through the modified memory mapping window (e.g., 64GB). In other words, for an AI inference task requiring 14GB of memory, the CPU can complete the data transfer in a single large block of contiguous memory without repeatedly switching windows. Specifically, the CPU sends the access command directly to the PCIe bus, and the target GPU's hardware decoding logic intercepts and responds to the access command based on its modified memory mapping window (now 64GB), thereby completing the read and write operations on the corresponding location in the target GPU's memory.
[0059] By reactivating the target GPU after allocating resources, the hardware functions that were previously disabled for security modifications are reactivated, thereby restoring the target GPU to its normal working state and enabling the host to perform efficient memory access using the modified memory mapping window.
[0060] To ensure that video memory resources can be safely released during the expansion process, and that the driver can correctly identify and use the new video memory mapping window after the expansion is completed, as a specific implementation, the driver of the target GPU can be uninstalled before releasing the video memory resources occupied by the target GPU, and the driver of the target GPU can be reloaded after the target GPU is enabled.
[0061] The driver here refers to the operating system-level software component used to manage and operate the target GPU, such as the GPU kernel driver module of NVIDIA or AMD. This driver typically locks the target GPU's video memory resources during runtime. If the driver is not uninstalled beforehand, directly releasing and modifying these resources may lead to conflicts between the driver and the hardware state, causing system crashes or resource leaks. Therefore, before performing step 101 to release the video memory resources, the driver must first be uninstalled to release the driver's control and resource occupation of the target GPU. For example, in Linux systems, the NVIDIA driver can be uninstalled using the commands "rmmod nvidia" or "modprobe -r nvidia". This safely releases the video memory resources associated with the target GPU, freeing up complete physical address space for subsequent reallocation operations.
[0062] Then, after enabling the target GPU, reload the driver. For example, on Linux systems, the NVIDIA driver can be loaded using commands such as "modprobe nvidia" or "insmod".
[0063] By uninstalling and reloading the driver, the driver's lock on the hardware and resource occupation are released, thereby ensuring that the underlying video memory resources can be safely released, modified and reallocated, avoiding conflicts or errors caused by inconsistencies between the driver and the hardware state, and improving the reliability and security of the extended process.
[0064] It should be noted that, in order to ensure that the target GPU does not experience state inconsistency or hardware errors due to external concurrent access during the process of writing the target value to the target storage location, as an implementation method, the services related to memory space control in the target GPU can be disabled before writing the target value to the target storage location in the target GPU used to store the video memory capacity. After allocating the video memory resources of the target GPU to the modified video memory mapping window based on the target value, the services related to video memory space control in the target GPU can be enabled again.
[0065] The services related to memory space control can refer to the hardware functional modules or logic circuits within the target GPU responsible for responding to address access requests initiated by the CPU through the memory mapping window. As a specific example, the enabling and disabling of these memory space control-related services within the target GPU are manifested in the "Memory Space Enable" bit (i.e., bit 1) of the command register in the PCIe configuration space. When the "Memory Space Enable" bit is set to 1 (enabled), the target GPU can listen for address access requests on the PCIe bus. If the target address of the address access request falls within the range of the memory mapping window, it responds and performs read / write operations. When the "Memory Space Enable" bit is set to 0 (disabled), the target GPU ignores all address access requests targeting the range of the memory mapping window, even if the target address falls within the window, and does not respond.
[0066] Based on this, before writing the target value to the target memory location in the target GPU used to store the video memory capacity, the "memory space enable" bit in the command register of the PCIe configuration space can be set to 0 to disable the target GPU's ability to respond to address access requests. Subsequently, after allocating the target GPU's video memory resources to the modified video memory mapping window based on the target value, the "memory space enable" bit in the command register of the PCIe configuration space can be set to 1 to restore the target GPU's ability to respond to address access requests.
[0067] In some preferred embodiments, the services related to memory space control within the target GPU are also specifically manifested in the "Bus Master Enable" bit (i.e., bit 2) of the command register in the PCIe configuration space. When the "Bus Master Enable" bit is set to 1 (enabled state), the target GPU can actively initiate data transmission. When the "Bus Master Enable" bit is set to 0 (disabled state), the target GPU can only passively receive data transmission.
[0068] Based on this, after allocating the target GPU's memory resources to the modified memory mapping window based on the target value, the "bus master enable" bit in the command register in the PCIe configuration space is set to 1 to enable the target GPU's ability to actively initiate data transfer.
[0069] By enabling and disabling services related to memory space control within the target GPU before and after the expansion process, external access during the expansion process is isolated, thereby ensuring the security of write operations, avoiding data conflicts or system crashes caused by concurrent access, and improving the reliability of the entire expansion process.
[0070] To ensure that the operating system's software resource management layer can accurately perceive actual hardware changes, this solution also provides an embodiment to further modify the video memory capacity stored in the target GPU runtime environment to the target value.
[0071] The video memory capacity stored in the target GPU runtime environment refers to the software record maintained by the operating system kernel to manage the target GPU, representing the video memory capacity of the current video memory mapping window. As a specific implementation, in the Linux kernel, each PCIe device is described by a "pci_dev" structure, which contains a resource array "resource[]", and the resource entries recorded in resource[1] correspond to the video memory capacity of the video memory mapping window. Specifically, the "end" field and "flags" field in the resource entry record the video memory capacity, status and other information of the current video memory mapping window. For example, the "end" field in "resource[1]" is set to the video memory capacity of the video memory mapping window, and the "flags" field contains flags such as "IORESOURCE_UNSET" (used to indicate that the video memory mapping window has not been allocated video memory resources).
[0072] It is important to note that this step must be performed after the memory capacity of the memory mapping window has been modified to the target value and before step 103, because the operating system's reallocation function in the target GPU runtime environment (such as "pci_assign_unassigned_bus_resources()") relies on the information recorded in the resource array in the structure to complete the resource reallocation.
[0073] By synchronizing hardware modifications to the kernel-maintained resource structure, the kernel can accurately perceive hardware changes, thereby ensuring the correctness of subsequent address allocation and resource management and avoiding system errors caused by inconsistencies between hardware and software states.
[0074] It should also be noted that, in order to ensure that the physical address space in the entire PCIe topology can be correctly connected after the memory mapping window of the target GPU is expanded, this disclosure provides a preferred embodiment. Specifically, the prefetch memory window of the communication bus connected to the target GPU is expanded so that the window size of the prefetch memory window is at least a preset multiple of the target value.
[0075] The communication bus refers to the PCIe bus connecting the target GPU to its upstream PCIe root complex. Its core components typically include one or more PCIe bridges or root ports. Internally, each PCIe bridge maintains a prefetch memory window, defining a contiguous, prefetchable physical address space used to pass address access requests to downstream devices (i.e., the target GPU). If the prefetch memory window of the PCIe bridge has a smaller capacity than the modified memory mapping window of the target GPU, even if the target GPU hardware has successfully expanded the memory mapping window to the target value, the upstream PCIe bridge cannot correctly forward address access requests exceeding its prefetch memory window range to the target GPU. This results in the target GPU being unable to access the extended high address range by the CPU.
[0076] Therefore, this solution can also expand the prefetch memory window of the communication bus connected to the target GPU to a preset multiple of the target value. As a preferred implementation, this preset multiple is 2, meaning the expanded prefetch memory window size is at least twice the target value. For example, when the target GPU's memory mapping window is expanded to 64GB, its upstream PCIe bridge's prefetch memory window needs to be expanded to at least 128GB; when the target GPU's memory mapping window is expanded to 128GB, its upstream PCIe bridge's prefetch memory window needs to be expanded to at least 256GB. Using a preset multiple of 2 ensures that in most practical topologies, the expanded prefetch memory window can cover the memory capacity of the target GPU's memory mapping window, while avoiding excessive waste.
[0077] In practical applications, the expansion operation for the prefetch memory window can be performed after modifying the target GPU's memory mapping window but before allocating memory resources based on the target value. This allows subsequent reallocation functions to allocate addresses uniformly based on the expanded prefetch memory window's capacity. For example, after modifying the target GPU's memory mapping window and expanding the prefetch memory window, the information recorded in the resource array of the "pci_dev" structure of the upstream PCIe bridge and memory mapping window can be read, and the reallocation function "pci_assign_unassigned_bus_resources()" can be called to allocate resources together.
[0078] By synchronously expanding the prefetch memory window of the upstream PCIe bridge, the continuity of the address space in the PCIe topology is ensured, thereby solving the problem of resource allocation failure or device unavailability caused by only modifying the target GPU itself without processing the prefetch memory window of the upstream PCIe bridge, and improving the reliability of the entire signal transmission environment.
[0079] Next, to more clearly explain the memory mapping window expansion method, a relatively complete embodiment is provided here, such as... Figure 3 As shown.
[0080] First, uninstall the target GPU driver and disable services related to memory space control within the target GPU. In response to meeting preset window expansion conditions, release the target GPU's memory resource usage and modify the memory capacity of the target GPU's memory mapping window to the target value, resulting in a modified memory mapping window. Then, expand the prefetch memory window of the communication bus connected to the target GPU so that its window size is at least a preset multiple of the target value. Further, modify the memory capacity stored in the target GPU's runtime environment to the target value, and allocate target GPU memory resources to the modified memory mapping window based on the target value. Subsequently, enable services related to memory space control within the target GPU, activate the target GPU, and load the target GPU driver. In response to access commands to the target GPU, access the target GPU based on the modified memory mapping window.
[0081] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0082] The foregoing has described specific embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0083] According to another embodiment, a video memory mapping window extension device is provided. Figure 4 A schematic block diagram of a memory-mapped window expansion device according to one embodiment is shown, the device being disposed in a processor of a computing system. Figure 4 As shown, the device 400 includes a release unit 401, a modification unit 402, and an allocation unit 403, and further includes a creation unit 805, an analysis unit 806, and a chart unit 808. The main functions of each component are as follows: Release unit 401 is configured to release the video memory resources occupied by the target GPU in response to satisfying a preset window expansion condition.
[0084] Modification unit 402 is configured to modify the memory capacity of the target GPU's memory mapping window to a target value, resulting in a modified memory mapping window where the target value is greater than the initial value of the memory capacity.
[0085] Allocation unit 403 is configured to allocate the target GPU's memory resources to the modified memory mapping window based on the target value.
[0086] As one possible implementation, when modifying the memory capacity of the memory mapping window of the target GPU to the target value, the modification unit 402 can be specifically configured to: write the target value to the target storage location in the target GPU used to store the memory capacity; read the stored value at the target storage location; in response to the stored value being the target value, determine that the memory capacity of the memory mapping window has been modified to the target value; in response to the stored value not being the target value, repeat the steps of reducing the target value according to a preset strategy, writing the target value to the target storage location, and reading the stored value at the target storage location until the stored value is the target value.
[0087] One possible approach is to target a value greater than the memory requirement of the current access task.
[0088] Modification unit 402, when reducing the target value according to the preset strategy, can be specifically configured to: reduce the target value by a specified capacity value, wherein the reduced target value is not less than the video memory requirement value.
[0089] Furthermore, the preparation unit 404 can be specifically configured to disable services related to memory space control within the target GPU before writing the target value to the target storage location in the target GPU used to store the video memory capacity.
[0090] Enabling unit 405, after allocating the target GPU's memory resources to the modified memory mapping window based on the target value, can be specifically configured to enable services related to memory space control within the target GPU.
[0091] Furthermore, after determining that the memory capacity of the memory mapping window has been modified to the target value, the synchronization unit 406 can be specifically configured to modify the memory capacity stored in the target GPU runtime environment to the target value.
[0092] Furthermore, the expansion unit 407 can be specifically configured to: expand the prefetch memory window of the communication bus connected to the target GPU, so that the window size of the prefetch memory window is at least a preset multiple of the target value.
[0093] As one possible implementation, after allocating the target GPU's memory resources to the memory mapping window based on the target value, the enabling unit 405 can also be configured to: enable the target GPU; and access the target GPU based on the modified memory mapping window in response to an access command to the target GPU.
[0094] As one possible implementation, the preparation unit 404 can also be configured to uninstall the target GPU's driver before releasing the target GPU's video memory resources.
[0095] After enabling the target GPU, unit 405 can also be configured to load the target GPU's driver.
[0096] One possible implementation is a window expansion condition that includes any of the following: the initial value of the video memory capacity of the video memory-mapped window is lower than the video memory requirement value corresponding to the current access task; or a window expansion command submitted by the user.
[0097] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0098] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0099] like Figure 5 As shown, device 500 includes a computing unit 501, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 502 or a computer program loaded from storage unit 508 into random access memory (RAM) 503. RAM 503 may also store various programs and data required for the operation of device 500. The computing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. Input / output (I / O) interface 505 is also connected to bus 504.
[0100] Multiple components in device 500 are connected to I / O interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0101] The computing unit 501 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as the memory-mapped window expansion method. For example, in some embodiments, the memory-mapped window expansion method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed on device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the memory-mapped window expansion method described above can be performed. Alternatively, in other embodiments, the computing unit 501 can be configured to perform the memory-mapped window expansion method by any other suitable means (e.g., by means of firmware).
[0102] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0103] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0104] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0105] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0106] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0107] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0108] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0109] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for expanding a video memory mapping window, comprising: In response to meeting the preset window expansion conditions, the target GPU's video memory resources are released; The memory capacity of the memory mapping window of the target GPU is modified to the target value to obtain the modified memory mapping window, wherein the target value is greater than the initial value of the memory capacity; Based on the target value, the target GPU's memory resources are allocated to the modified memory mapping window.
2. The method according to claim 1, wherein, Modifying the memory capacity of the target GPU's memory mapping window to the target value includes: Write the target value to the target storage location in the target GPU used to store the video memory capacity; Read the stored value from the target storage location; In response to the stored value being the target value, it is determined that the video memory capacity of the video memory mapping window has been modified to the target value; In response to the stored value not being the target value, the steps of reducing the target value according to a preset strategy, writing the target value to the target storage location, and reading the stored value from the target storage location are repeated until the stored value is the target value.
3. The method according to claim 2, wherein, If the target value is greater than the memory requirement of the current access task, then reducing the target value according to a preset strategy includes: The target value is reduced by a specified capacity value, wherein the reduced target value is not less than the video memory requirement value.
4. The method according to claim 2, wherein before writing the target value to the target storage location in the target GPU used to store the video memory capacity, the method further comprises: Disable the services related to memory space control within the target GPU; After allocating the target GPU's memory resources to the modified memory mapping window based on the target value, the method further includes: Enable the services related to memory space control within the target GPU.
5. The method according to claim 2, after determining that the video memory capacity of the video memory mapping window has been modified to the target value, the method further includes: Modify the video memory capacity stored in the target GPU runtime environment to the target value.
6. The method according to claim 1, further comprising: Expand the prefetch memory window of the communication bus connected to the target GPU so that the window size of the prefetch memory window is at least a preset multiple of the target value.
7. The method according to claim 1, after allocating the target GPU's memory resources to the memory mapping window based on the target value, the method further includes: Enable the target GPU; In response to an access command to the target GPU, the target GPU is accessed based on the modified memory mapping window.
8. The method according to claim 7, further comprising, before releasing the video memory resources occupied by the target GPU: Uninstall the driver for the target GPU; After enabling the target GPU, the method further includes: Load the driver for the target GPU.
9. The method according to any one of claims 1-8, wherein, The window expansion condition includes any of the following: The initial value of the video memory capacity of the video memory mapping window is lower than the video memory requirement value corresponding to the current access task. User-submitted window expansion command.
10. A video memory mapping window expansion device, comprising: The release unit is configured to release the video memory resources occupied by the target GPU in response to satisfying a preset window expansion condition; The modification unit is configured to modify the memory capacity of the memory mapping window of the target GPU to a target value, thereby obtaining a modified memory mapping window, wherein the target value is greater than the initial value of the memory capacity. The allocation unit is configured to allocate the target GPU's memory resources to the modified memory mapping window based on the target value.
11. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-9.
13. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-9.