Display card multi-task cooperative processing system based on dynamic video memory allocation
By employing a dynamic memory allocation strategy, the problems of chained latency caused by preemption of urgent tasks and lack of resource guarantees for low-priority tasks in multi-task collaborative processing systems of graphics cards are solved, ensuring the basic execution capability of low-priority tasks and system response efficiency.
Patent Information
- Application Number
- CN202511365286.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-23
- Publication Date
- 2026-01-06
AI Technical Summary
In existing graphics card multitasking collaborative processing systems, the preemption of urgent tasks causes chain-like delays, low-priority tasks lack resource guarantees, and the lack of resource reservation mechanisms leads to fluctuations in task completion time.
A dynamic memory allocation strategy is adopted. The task classification module divides tasks into high-priority and low-priority tasks, the memory status scanning module generates a resource distribution map, the allocation strategy module dynamically adjusts resource allocation, and the resource reclamation and integration module performs preemption compensation to ensure the minimum guaranteed memory space for low-priority tasks and the urgent computing needs of high-priority tasks.
It ensures the basic execution capability of low-priority tasks, avoids the burden of chained delays and full data loading during task restarts, and improves system response efficiency and resource utilization.
Smart Images

Figure CN121277631A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer resource management technology, and in particular to a multi-task collaborative processing system for graphics cards based on dynamic video memory allocation. Background Technology
[0002] As AI models grow in size, GPUs need to handle both high-priority inference and low-priority training tasks simultaneously. Traditional memory management uses a static allocation strategy, which cannot adapt to the dynamically changing resource requirements of tasks.
[0003] Existing graphics card multi-task collaborative processing systems pre-allocate fixed memory blocks for tasks and do not adjust resource allocation during execution; when a high-priority task needs resources, it forcibly deprives the low-priority task of an entire memory block, triggering data migration and interrupting task execution.
[0004] The shortcomings of existing graphics card multitasking collaborative processing technology are as follows: On the one hand, the preemption of urgent tasks causes chain latency, and the concentrated deprivation of a single low-priority task causes the deprived task to need to fully load data when restarting; on the other hand, the low-priority task lacks resource guarantee, lacks resource reservation mechanism, and low-priority tasks are often completely deprived of video memory and cannot be executed, and the lack of compensation mechanism causes the task completion time to fluctuate.
[0005] Therefore, there is an urgent need to provide a graphics card multi-task collaborative processing system based on dynamic video memory allocation to solve the above problems. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art, namely, the chain delay caused by the preemption of emergency tasks, the concentrated deprivation of a single low-priority task which requires the full loading of data when the deprived task restarts; and the lack of resource guarantee for low-priority tasks, the lack of resource reservation mechanism, the fact that low-priority tasks are often completely deprived of video memory and cannot be executed, and the lack of compensation mechanism which leads to fluctuations in task completion time. The present invention provides a graphics card multi-task collaborative processing system based on dynamic video memory allocation.
[0007] To solve the above-mentioned technical problems, one technical solution adopted by the present invention is: to provide a graphics card multi-task collaborative processing system based on dynamic video memory allocation, including a task classification module, a video memory status scanning module, an allocation strategy module and a resource recycling and integration module;
[0008] The task classification module is used to acquire tasks and classify them into high-priority and low-priority tasks, and to establish independent resource pools based on the initial priority of the tasks.
[0009] The video memory status scanning module is used to scan the video memory usage status in the independent resource pool and generate a video memory resource distribution map.
[0010] The allocation strategy module, based on the memory resource distribution map and task priorities, merges unused blocks in the independent resource pool into contiguous blocks and generates allocation instructions: according to the allocation instructions, the contiguous blocks are preferentially allocated to high-priority tasks; if the contiguous blocks are insufficient to meet the computing needs of the high-priority tasks, a portion of blocks are deprived from the independent resource pools of the low-priority tasks according to a set ratio; and a deprivation compensation mechanism is executed on the deprived independent resource pools of the low-priority tasks.
[0011] The resource recycling and integration module is used to recycle the continuous blocks released after the high-priority task is completed, as well as the blocks marked by the deprivation compensation mechanism that need to be returned, and integrate them into the independent resource pool after cleaning, and update the video memory resource distribution map.
[0012] The present invention is further configured such that the specific content of the task classification module in classifying tasks into high-priority tasks and low-priority tasks according to task attributes is as follows: obtain the tasks to be processed within a preset period, divide them into main task nodes and secondary task nodes according to the capacity of the tasks to be processed, sort them according to the capacity of the main task nodes and the secondary task nodes, generate a first task set and a second task set, and take the first task set as high-priority tasks and the second task set as low-priority tasks.
[0013] For the high-priority tasks, the remaining unprocessed primary task nodes within a preset time range during the scheduling process, and the remaining unprocessed secondary task nodes of the low-priority tasks, the following operations are performed: a preset first virtual capacity is added to the secondary task nodes whose waiting time exceeds a preset threshold, and a preset second virtual capacity is added to the primary task nodes whose waiting time exceeds the threshold. After sorting, the first task set and the second task set are regenerated.
[0014] The present invention is further configured such that the steps for establishing the independent resource pool in the task classification module are as follows:
[0015] S1. Based on the division results of the first task set and the second task set, create a high-priority task channel and a low-priority task channel, register the main task node in the first task set to the task execution queue of the high-priority task channel, and simultaneously register the secondary task node in the second task set to the task suspension queue of the low-priority task channel.
[0016] S2. Allocate a preset minimum guaranteed video memory space to all the secondary task nodes in the task suspension queue of the low-priority task channel, generate a minimum guaranteed video memory space binding record table, and mark the non-preemptive attribute of the minimum guaranteed video memory space. Allocate a preset unified video memory space to all the primary task nodes in the task execution queue of the high-priority task channel, and generate a unified video memory space binding record table.
[0017] S3. Based on the minimum guaranteed video memory space binding record table and the unified video memory space binding record table, according to the waiting time distribution of the secondary task nodes in the task suspension queue of the low-priority task channel and the estimated remaining computing power of the primary task nodes in the task execution queue of the high-priority task channel, a preset first incremental virtual capacity is added to the minimum guaranteed video memory space, and a preset second incremental virtual capacity is added to the unified video memory space to generate a first virtual block and a second virtual block.
[0018] S4. Based on the first virtual block and the second virtual block, divide the total video memory block of the graphics card into physical video memory blocks, generate low-priority physical isolation blocks and high-priority physical isolation blocks, and bind the low-priority physical isolation blocks to the low-priority task channels to form a guaranteed resource pool based on a preset physical video memory block allocation map, and bind the high-priority physical isolation blocks to the high-priority task channels to form an elastic resource pool. The guaranteed resource pool and the elastic resource pool are both independent resource pools.
[0019] The present invention is further configured such that: the method for obtaining the estimated remaining computational load of the main task node in the task execution queue of the high-priority task channel in step S3 is as follows:
[0020] S31. For each master task node registered in the task execution queue of the high-priority task channel, extract the initial computational quantity estimate from the pre-associated task configuration file.
[0021] S32. During the execution of the main task node, the amount of computing resources consumed by the main task node is collected by a preset task status monitor at a preset sampling period.
[0022] S33. Subtract the amount of consumed computing resources from the initial estimated computational load to obtain the estimated remaining computational load of the main task node in the task execution queue of the high-priority task channel.
[0023] The present invention is further configured such that: the step of generating the memory resource distribution map in the memory status scanning module is as follows:
[0024] Q1. The video memory status scanning module scans all physical video memory blocks in the guaranteed resource pool and elastic resource pool in the independent resource pool, and obtains the starting address, length and status identifier of each physical video memory block.
[0025] Q2. Sort all the physical memory blocks based on the starting address to generate an ordered block sequence, and merge the physical memory blocks with adjacent starting addresses and the same status identifier into a continuous logical block.
[0026] Q3. Generate a block allocation vector based on the length and status identifier of the continuous logical block, and record the resource pool type to which the continuous logical block belongs. Based on the mapping relationship between the block allocation vector and the resource pool type, construct a memory resource distribution map.
[0027] The present invention is further configured such that: the memory resource distribution map includes the location index, length, status identifier and resource pool ownership mark of the continuous logical blocks.
[0028] The present invention is further configured such that the specific content of the allocation instruction in the allocation strategy module is as follows:
[0029] W1. Analyze the memory resource distribution map and perform a partition scan: scan the elastic resource pool and extract all free contiguous logical blocks; scan the guaranteed resource pool, exclude the non-preemptible blocks bound to the minimum guaranteed memory space, extract the preemptible blocks where the first incremental virtual capacity is located, and merge all free contiguous logical blocks and the preemptible blocks where the first incremental virtual capacity is located to generate an allocable block set.
[0030] W2. Based on the initial computational cost estimate and the remaining computational cost estimate of the main task node in the task execution queue of the high-priority task channel, filter the target main task node that needs to be executed immediately.
[0031] W3. Perform bidirectional matching based on the set of allocable blocks and the memory requirements of the target main task node:
[0032] If there exists a free contiguous logical block that matches the memory requirements of the target main task node, then a first allocation instruction is directly generated: bind the free contiguous logical block to the target main task node;
[0033] If there is no free contiguous logical block that matches the memory requirements of the target master task node, then adjacent free physical memory blocks in the allocable block set whose starting address interval does not exceed a preset range will be forcibly merged into a new contiguous block, and a second allocation instruction will be generated: bind the new contiguous block to the target master task node.
[0034] If the second allocation instruction still does not meet the computing requirements of the target primary task node, then it is checked whether the estimated remaining computing power of the target primary task node is greater than a preset preemption threshold. If the estimated remaining computing power of the target primary task node is greater than the preemption threshold, preemptible blocks are selected from the guaranteed resource pool, and physical memory blocks in the preemptible blocks are preempted according to a set ratio to generate return blocks. A return mark is attached to the return blocks, and a third allocation instruction is generated: the return blocks are bound to the target primary task node. If the estimated remaining computing power of the target primary task node is less than the preemption threshold, then preemption is prohibited.
[0035] The present invention is further configured such that: the return flag in step W3 establishes a connection index with the return block;
[0036] The specific content of the preemption compensation mechanism is as follows: based on the returned blocks released after the target main task node ends, physical video memory space is released at preset multiple intervals of the returned blocks, and the preemptible blocks are returned to the guaranteed resource pool according to the connection index.
[0037] The present invention is further configured such that: the specific content of the resource recycling and integration module is as follows: monitoring the end event of the main task node in the high-priority task channel, collecting the released physical memory blocks, and returning the remaining released physical memory blocks, except for the returned blocks returned through the preemption compensation mechanism, to the corresponding physical blocks of the elastic resource pool or the guaranteed resource pool according to the resource pool type; scanning the continuity of the starting address of the recycled physical memory blocks, merging adjacent free physical memory blocks to form new continuous logical blocks; and updating the block allocation vector, status identifier, and resource pool ownership marker in the memory resource distribution map.
[0038] The beneficial effects of this invention are as follows:
[0039] 1. This invention establishes a guaranteed resource pool through a task classification module, binding a minimum guaranteed video memory space to low-priority tasks and marking them with a non-preemptible attribute to prevent low-priority tasks from being completely preempted of video memory, thus ensuring their basic execution capabilities. At the same time, the allocation strategy module applies a method of preempting a portion of the blocks according to a set ratio when preempting blocks from the guaranteed resource pool, avoiding chain-like delays caused by concentrated preemption of a single low-priority task. Combined with a preemption compensation mechanism, blocks are released and returned at preset multiple intervals after high-priority tasks are completed, reducing the burden of full data loading when preempted tasks restart and improving system response efficiency.
[0040] 2. This invention creates a guaranteed resource pool to provide physical isolation blocks and minimum guaranteed video memory space binding for low-priority tasks, thereby implementing a resource reservation mechanism to ensure the executability of low-priority tasks during scheduling. The allocation strategy module introduces a preemption compensation mechanism to add compensation and release to the returned blocks collected by the resource recycling and integration module, effectively compensating for the task completion time fluctuations caused by preempted blocks. The resource recycling and integration module updates the video memory resource distribution map in real time, and merges consecutive logical blocks to form new free blocks, maintaining the stability of video memory allocation and the smoothness of continuous scheduling of low-priority tasks. Attached Figure Description
[0041] Figure 1 This is a system flowchart of the present invention;
[0042] Figure 2 This is a flowchart illustrating the steps for establishing an independent resource pool according to the present invention.
[0043] Figure 3 This is a flowchart of the method for obtaining the remaining computational quantity estimate of the present invention;
[0044] Figure 4 This is a flowchart illustrating the steps involved in generating the memory resource distribution map according to the present invention. Detailed Implementation
[0045] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby providing a clearer and more explicit definition of the scope of protection of the present invention.
[0046] Please see Figure 1 - Figure 4 A multi-task collaborative processing system for graphics cards based on dynamic video memory allocation includes a task classification module, a video memory status scanning module, an allocation strategy module, and a resource recycling and integration module.
[0047] The task classification module is used to acquire tasks and divide them into high-priority tasks and low-priority tasks, and to establish an independent resource pool based on the initial priority of the tasks. A task is a computing unit that needs to occupy physical video memory blocks of the graphics card.
[0048] The video memory status scanning module is used to scan the video memory usage status in the independent resource pool and generate a video memory resource distribution map.
[0049] The allocation strategy module, based on the memory resource distribution map and task priorities, merges unused blocks in the independent resource pool into contiguous blocks and generates allocation instructions: according to the allocation instructions, the contiguous blocks are preferentially allocated to high-priority tasks; if the contiguous blocks are insufficient to meet the computing needs of high-priority tasks, a portion of blocks are deprived from the independent resource pools of low-priority tasks according to a set ratio; and a deprivation compensation mechanism is executed on the independent resource pools of the deprived low-priority tasks.
[0050] The resource recycling and integration module is used to recycle consecutive blocks released after high-priority tasks are completed, as well as blocks marked as needing to be returned by the deprivation compensation mechanism. After cleaning, the blocks are integrated into an independent resource pool, and the memory resource distribution map is updated.
[0051] The priority-differentiated independent resource pool and dynamic priority adjustment mechanism established by the task classification module, combined with the real-time resource distribution map provided by the memory status scanning module, ensure that low-priority tasks receive the minimum guaranteed memory space. The free block merging and reorganization and preemption compensation mechanism implemented by the allocation strategy module effectively support the urgent computing needs of high-priority tasks. Together with the resource recycling and integration module, the precise recycling and reorganization of released blocks form a closed-loop management system, which together realizes the dynamic optimization and configuration of memory resources, multi-level task isolation protection and fragmentation elimination capabilities, significantly improving the efficiency of multi-task collaborative processing and the utilization rate of graphics card resources.
[0052] One embodiment of the present invention is as follows: The specific content of the task classification module in which tasks are divided into high-priority tasks and low-priority tasks according to task attributes is as follows: the tasks to be processed within a preset period are obtained, the tasks to be processed are divided into main task nodes and secondary task nodes according to their capacity, and sorted according to the capacity of the main task nodes and secondary task nodes to generate a first task set and a second task set. The first task set is regarded as high-priority tasks, and the second task set is regarded as low-priority tasks. The tasks to be processed are published by a preset terminal, which is specifically a computer or other intelligent device.
[0053] For high-priority tasks, the following operations are performed on unprocessed primary task nodes within a preset time range during scheduling, and for low-priority tasks, the following operations are performed on unprocessed secondary task nodes: a preset first virtual capacity is added to secondary task nodes whose waiting time exceeds a preset threshold, and a preset second virtual capacity is added to primary task nodes whose waiting time exceeds the threshold. After sorting, a first task set and a second task set are regenerated, thereby re-prioritizing the secondary task nodes and primary task nodes. After prioritization, the first and second virtual capacities are reclaimed for subsequent use. High-priority and low-priority tasks are temporarily upgraded to avoid indefinite waiting.
[0054] Specifically, the steps for establishing an independent resource pool in the task classification module are as follows:
[0055] S1. Based on the division results of the first task set and the second task set, create a high-priority task channel and a low-priority task channel. Register the main task nodes in the first task set to the task execution queue of the high-priority task channel, and simultaneously register the secondary task nodes in the second task set to the task suspension queue of the low-priority task channel.
[0056] S2. Allocate a preset minimum guaranteed video memory space to all secondary task nodes in the task suspension queue of the low-priority task channel, generate a minimum guaranteed video memory space binding record table, and mark the non-preemptive attribute of the minimum guaranteed video memory space. Allocate a preset unified video memory space to all primary task nodes in the task execution queue of the high-priority task channel, and generate a unified video memory space binding record table.
[0057] Minimum guaranteed video memory space is a fixed-size space with non-preemptible properties allocated to secondary task nodes in low-priority task channels, ensuring basic execution resources for low-priority tasks. Unified video memory space is a preset fixed-size space allocated to primary task nodes in high-priority task channels to support their computational needs. The specific values of minimum guaranteed video memory space and unified video memory space need to be determined during system deployment using preset configuration parameters and the total physical video memory space of the graphics card.
[0058] S3. Based on the minimum guaranteed video memory space binding record table and the unified video memory space binding record table, according to the waiting time distribution of the secondary task nodes in the task suspension queue of the low priority task channel and the estimated remaining computing power of the primary task nodes in the task execution queue of the high priority task channel, a preset first incremental virtual capacity is added to the minimum guaranteed video memory space, and a preset second incremental virtual capacity is added to the unified video memory space to generate the first virtual block and the second virtual block.
[0059] The additional steps for the first and second incremental virtual capacity are as follows: First, based on the memory allocation status of the secondary task nodes recorded in the minimum guaranteed memory space binding record table, and combined with the waiting time distribution data of the secondary task nodes in the task suspension queue of the low-priority task channel, the resource waiting urgency of the secondary task nodes is analyzed by the waiting time growth trend—the higher the waiting time, the larger the virtual capacity that needs to be expanded. The first incremental virtual capacity is dynamically calculated and added to the minimum guaranteed memory space to realize the virtual resource expansion of low-priority tasks. Then, based on the memory allocation status of the primary task nodes recorded in the unified memory space binding record table, and combined with the remaining computing power estimation data of the primary task nodes in the task execution queue of the high-priority task channel, the real-time resource demand intensity of the primary task nodes is assessed by the size of the remaining computing power—the larger the remaining computing power, the larger the virtual capacity that needs to be expanded. The second incremental virtual capacity is dynamically calculated and added to the unified memory space to support the computing expansion needs of high-priority tasks.
[0060] S4. Based on the first and second virtual blocks, physical memory blocks are divided within the total video memory area of the graphics card, generating low-priority physical isolation blocks and high-priority physical isolation blocks. Based on a preset physical memory block allocation map, low-priority physical isolation blocks are bound to low-priority task channels to form a guaranteed resource pool, while high-priority physical isolation blocks are bound to high-priority task channels to form an elastic resource pool. Both the guaranteed and elastic resource pools are independent resource pools. Preferably, when high-priority tasks in the elastic resource pool are idle, some physical blocks are temporarily shared to enhance resource reusability.
[0061] Preferably, in step S4, after generating low-priority physical isolation blocks and high-priority physical isolation blocks, the first virtual block and the second virtual block are reclaimed to avoid virtual resource inflation.
[0062] The physical memory block allocation map is a structured mapping table that predefines the physical space partitioning rules and binding relationships of the total graphics card memory. Its core includes space partitioning rules that record the starting address and space length of low-priority physical isolation blocks and the continuous address fields and boundary markers of high-priority physical isolation blocks. It defines channel binding mappings that bind low-priority blocks to low-priority task channels through address latch registers and high-priority blocks to high-priority task channels through dynamic pointer registers. It also marks the releaseable subfields that can be temporarily shared in high-priority blocks (marked as idle state by a flag bit matrix). This map enforces physical isolation (address isolation between guaranteed resource pools and elastic resource pools) and supports dynamic expansion based on the first and second incremental virtual capacities in step S3.
[0063] Specifically, the method for obtaining the estimated remaining computational load of the main task node in the task execution queue of the high-priority task channel in step S3 is as follows:
[0064] S31. For each master task node registered in the task execution queue of the high-priority task channel, extract the initial computational cost estimate from the pre-associated task configuration file.
[0065] S32. During the execution of the main task node, the amount of computing resources consumed by the main task node is collected by a preset task status monitor at a preset sampling period; the preset sampling period is preferably 0.5ms-10ms.
[0066] S33. Subtract the consumed computing resources from the initial estimated computational load to obtain the estimated remaining computational load of the main task node in the task execution queue of the high-priority task channel.
[0067] The beneficial effects of this embodiment are as follows: by ensuring the basic execution rights of low-priority tasks through minimum guaranteed video memory space and non-preemptive attributes, the unified video memory space guarantees the computing needs of high-priority tasks, and the resource allocation is dynamically adjusted by combining the first incremental virtual capacity triggered by the waiting time and the second incremental virtual capacity triggered by the remaining computing power. In conjunction with the guaranteed resource pool and elastic resource pool constructed based on the physical video memory block allocation map, physical isolation and temporary sharing are achieved. This not only prevents secondary task nodes from starving due to waiting timeouts but also optimizes the resource utilization efficiency of primary task nodes. Furthermore, the virtual block reclamation mechanism avoids the expansion of virtual resources.
[0068] One embodiment of the present invention is as follows: the steps for generating the memory resource distribution map in the memory status scanning module are as follows:
[0069] Q1. The video memory status scanning module scans all physical video memory blocks in the guaranteed resource pool and elastic resource pool in the independent resource pool, and obtains the starting address, length and status identifier of each physical video memory block. The status identifier includes allocated status, idle status and fragmentation mark status.
[0070] Q2. Sort all physical memory blocks based on their starting addresses to generate an ordered block sequence, and merge physical memory blocks with adjacent starting addresses and the same status identifier into consecutive logical blocks.
[0071] Q3. Generate a block allocation vector based on the length and status identifier of the consecutive logical blocks, and record the resource pool type (guaranteed resource pool or elastic resource pool) to which the consecutive logical blocks belong. Based on the mapping relationship between the block allocation vector and the resource pool type, construct a memory resource distribution map.
[0072] The specific content of the memory resource distribution map based on the mapping relationship between block allocation vectors and resource pool types is as follows: Based on the continuous logical blocks generated in step Q2 and their corresponding block allocation vectors (including length and status identifiers), combined with the guaranteed resource pool or elastic resource pool type to which the continuous logical block belongs, the following mapping relationship is established in the memory resource distribution map: For each continuous logical block, using its starting address as the index key, the length value and status identifier (allocated status, idle status, or fragmentation mark status) in the block allocation vector are associated and bound with its corresponding resource pool type to form a complete memory resource distribution map that describes the attributes of physical memory blocks and their resource pool affiliation.
[0073] Specifically, the memory resource distribution map includes the location index, length, status identifier, and resource pool ownership marker of consecutive logical blocks.
[0074] The beneficial effects of this embodiment are as follows: Based on the memory resource distribution map, the location index, length, status identifier and resource pool ownership mark of the continuous logical blocks are integrated. The global distribution status of all merged blocks in the guaranteed resource pool and the elastic resource pool (including allocated area, free area and fragmentation mark area) is presented intuitively through a unified view. The physical memory block attributes are accurately associated with the type of resource pool to which they belong, providing a complete decision basis for the rapid allocation, efficient management and defragmentation of memory resources.
[0075] One embodiment of the present invention is as follows: The specific content of the allocation instruction in the allocation strategy module is as follows:
[0076] W1. Analyze the distribution map of video memory resources and perform a partition scan: Scan the elastic resource pool and extract all free contiguous logical blocks; Scan the guaranteed resource pool, exclude non-preemptible blocks bound to the minimum guaranteed video memory space, extract the preemptible block where the first incremental virtual capacity is located, and merge all free contiguous logical blocks and the preemptible block where the first incremental virtual capacity is located to generate an allocable block set.
[0077] W2. Based on the initial and remaining computational estimates of the main task nodes in the task execution queue of the high-priority task channel, filter the target main task nodes that need to be executed immediately.
[0078] W3. Perform bidirectional matching based on the set of allocable blocks and the memory requirements of the target main task node:
[0079] If there is a free contiguous logical block that matches the memory requirements of the target master task node, then the first allocation instruction is generated directly: bind the free contiguous logical block to the target master task node.
[0080] If there is no free contiguous logical block that matches the memory requirements of the target master task node, then adjacent free physical memory blocks in the allocable block set whose starting address interval does not exceed the preset range will be forcibly merged into a new contiguous block, and a second allocation instruction will be generated: bind the new contiguous block to the target master task node.
[0081] If the second allocation instruction still does not meet the computing requirements of the target primary task node, then it checks whether the estimated remaining computing power of the target primary task node is greater than the preset preemption threshold. If the estimated remaining computing power of the target primary task node is greater than the preemption threshold, preemptible blocks are selected from the guaranteed resource pool, and physical memory blocks in the preemptible blocks are preempted according to a set ratio to generate return blocks. A return mark is attached to the return blocks, and a third allocation instruction is generated: the return blocks are bound to the target primary task node. If the estimated remaining computing power of the target primary task node is less than the preemption threshold, then preemption is prohibited.
[0082] The preemption threshold is determined based on the estimated average remaining computational load of each primary task node in the task execution queue and the proportion of preemptible blocks in the guaranteed resource pool.
[0083] Specifically, in step W3, the return marker is linked to the return block to establish a connection index;
[0084] The specific content of the preemption compensation mechanism is as follows: based on the returned blocks released after the target main task node ends, physical video memory space is released at preset multiple intervals (progressively) of the returned blocks, and the preemptible blocks are returned to the guaranteed resource pool according to the connection index.
[0085] The specific details of the preset multiple interval gradual release of video memory space are as follows: After the target main task node ends, the system gradually increases the time interval between adjacent release operations according to a preset multiple (preferably 1.2 times) for the returned blocks. That is, the first returned block is released immediately, and the release time interval of subsequent returned blocks is extended step by step according to the preset multiple. Through this gradual delayed release strategy, the physical video memory space is gradually reclaimed. Each release returns the physical video memory space occupied by the returned block to the preemptible block of the guaranteed resource pool according to the link index.
[0086] The beneficial effects of this embodiment are as follows: dynamic resource scanning is achieved by parsing the memory resource distribution map, generating a set of allocatable blocks, and high-priority target main task nodes are selected by combining the task execution queue. Bidirectional matching is performed based on memory demand to ensure timely resource allocation. A preemption compensation mechanism is adopted to gradually release the physical memory space of the returned blocks at preset multiple intervals after the target main task node ends. The preemptible blocks are returned to the guaranteed resource pool according to the connection index, which effectively reduces memory fragmentation, avoids priority inversion, and improves resource utilization efficiency and overall system performance.
[0087] One embodiment of the present invention is as follows: The specific content of the resource recycling and integration module is as follows: monitoring the end event of the main task node in the high-priority task channel, collecting the released physical memory blocks (including normally allocated elastic resource pool blocks and returned blocks carrying return tags), and returning the remaining released physical memory blocks, except for the returned blocks returned through the preemption compensation mechanism, to the corresponding physical blocks of the elastic resource pool or the guaranteed resource pool according to the resource pool type; scanning the continuity of the starting address of the recycled physical memory blocks, merging adjacent free physical memory blocks to form new continuous logical blocks; and updating the block allocation vector, status identifier, and resource pool ownership tag in the memory resource distribution map.
[0088] This embodiment monitors the end events of high-priority task channels, accurately collects and classifies released physical memory blocks, returns blocks from non-preemption compensation mechanisms to their original resource pools according to resource pool type, scans and merges adjacent free physical memory blocks to generate continuous logical blocks, and updates the allocation vector, status identifier, and resource pool affiliation in the memory resource distribution map in real time, effectively improving the efficiency of memory fragmentation consolidation and the accuracy of resource allocation.
[0089] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A multi-task collaborative processing system for graphics cards based on dynamic video memory allocation, characterized in that: The application comprises a task grading module, a video memory state scanning module, an allocation strategy module and a resource recycling and integration module. The task grading module is used for obtaining tasks and dividing them into high-priority tasks and low-priority tasks, and establishing independent resource pools according to the initial priorities of the tasks. The video memory state scanning module is used for scanning the video memory usage state in the independent resource pools and generating a video memory resource distribution map. The allocation strategy module is based on the video memory resource distribution map and the task priorities, and combines the unused blocks in the independent resource pools into continuous blocks, and generates allocation instructions: according to the allocation instructions, the continuous blocks are preferentially allocated to high-priority tasks, if the continuous blocks are insufficient to meet the computing requirements of the high-priority tasks, then a set proportion of blocks is deprived from the independent resource pools of low-priority tasks, and a deprivation compensation mechanism is performed on the independent resource pools of the low-priority tasks which are deprived. The resource recycling and integration module is used for recycling the continuous blocks released after the high-priority tasks end, and the blocks marked by the deprivation compensation mechanism to be returned, cleaning and integrating them into the independent resource pools, and updating the video memory resource distribution map.
2. The dynamic video memory allocation based multi-task cooperative processing system of graphics card according to claim 1, wherein: In the task grading module, the high-priority tasks and the low-priority tasks are divided according to the task attributes: obtaining the tasks to be processed in a preset period, dividing them into main task nodes and secondary task nodes according to the capacities of the tasks to be processed, sorting them according to the capacities of the main task nodes and the secondary task nodes, generating a first task set and a second task set, taking the first task set as high-priority tasks, and taking the second task set as low-priority tasks. In the scheduling process, the main task nodes remaining unprocessed in a preset time range of the high-priority tasks, and the secondary task nodes remaining unprocessed in the scheduling process of the low-priority tasks are operated as follows: a preset first virtual capacity is added to the secondary task nodes with a waiting time exceeding a preset threshold, a preset second virtual capacity is added to the main task nodes with a waiting time exceeding the threshold, and the first task set and the second task set are regenerated after sorting.
3. The dynamic video memory allocation based multi-task cooperative processing system of graphics card according to claim 2, wherein: The establishment steps of the independent resource pools in the task grading module are as follows: S1, based on the division results of the first task set and the second task set, creating a high-priority task channel and a low-priority task channel, registering the main task nodes in the first task set to the task execution queue of the high-priority task channel, and synchronously registering the secondary task nodes in the second task set to the task suspension queue of the low-priority task channel; S2, allocating a preset minimum guaranteed video memory space to all the secondary task nodes in the task suspension queue of the low-priority task channel, generating a minimum guaranteed video memory space binding record table, and marking the non-deprivable attribute of the minimum guaranteed video memory space, allocating a preset unified video memory space to all the main task nodes in the task execution queue of the high-priority task channel, and generating a unified video memory space binding record table; S3, based on the minimum guaranteed video memory space binding record table and the unified video memory space binding record table, according to the waiting time distribution of the secondary task nodes in the task suspension queue of the low priority task channel and the residual calculation amount estimate of the main task nodes in the task execution queue of the high priority task channel, a preset first incremental virtual capacity is added to the minimum guaranteed video memory space, and a preset second incremental virtual capacity is added to the unified video memory space, to generate a first virtual block and a second virtual block; S4, according to the first virtual block and the second virtual block, the physical video memory blocks in the total video memory block of the graphics card are divided to generate low priority physical isolation blocks and high priority physical isolation blocks, and based on a preset physical video memory block allocation map, the low priority physical isolation blocks are bound to the low priority task channel to form a guaranteed resource pool, and the high priority physical isolation blocks are bound to the high priority task channel to form an elastic resource pool, the guaranteed resource pool and the elastic resource pool are independent resource pools.
4. The dynamic video memory allocation based co-processing system of claim 3, wherein: The method for obtaining the residual calculation amount estimate of the main task nodes in the task execution queue of the high priority task channel in step S3 is: S31, for each main task node registered in the task execution queue of the high priority task channel, an initial calculation amount estimate is extracted from a pre-associated task configuration file; S32, in the execution process of the main task node, the consumed calculation resource amount of the main task node is collected by a preset task state monitor at a preset sampling period; S33, the initial calculation amount estimate is subtracted by the consumed calculation resource amount to obtain the residual calculation amount estimate of the main task nodes in the task execution queue of the high priority task channel.
5. The dynamic video memory allocation based co-processing system of claim 4, wherein: The generation step of the video memory resource distribution map in the video memory state scanning module is: Q1, the video memory state scanning module scans all the physical video memory blocks in the guaranteed resource pool and the elastic resource pool of the independent resource pool, obtains the starting address, length and state identifier of each physical video memory block; Q2, based on the starting address, all the physical video memory blocks are sorted to generate an ordered block sequence, and the physical video memory blocks with adjacent starting addresses and the same state identifier are merged into continuous logical blocks; Q3, a block allocation vector is generated according to the length and state identifier of the continuous logical blocks, and the resource pool type to which the continuous logical blocks belong is recorded, and based on the mapping relationship between the block allocation vector and the resource pool type, a video memory resource distribution map is constructed.
6. The dynamic video memory allocation based co-processing system of claim 5, wherein: The video memory resource distribution map includes the position index, length, state identifier and resource pool attribution mark of the continuous logical blocks.
7. The dynamic video memory allocation based co-processing system of claim 6, wherein: The specific content of the allocation instruction in the allocation strategy module is as follows: W1, analyze the graphics memory resource distribution map, execute partition scanning: scan the elastic resource pool, extract all free contiguous logical blocks; scan the guarantee type resource pool, exclude the inalienable blocks bound to the minimum guaranteed graphics memory space, extract the first incremental virtual capacity in the alienable blocks, and merge all free contiguous logical blocks and the first incremental virtual capacity in the alienable blocks to generate a set of allocable blocks; W2, based on the initial calculation amount estimate and the remaining calculation amount estimate of the main task node in the task execution queue of the high-priority task channel, screen the target main task node that needs to be executed immediately; W3, according to the graphics memory demand of the allocable block set and the target main task node, bidirectional matching is performed: If there is a free contiguous logical block matching the graphics memory demand of the target main task node, a first allocation instruction is directly generated: the free contiguous logical block is bound to the target main task node; If there is no free contiguous logical block matching the graphics memory demand of the target main task node, adjacent free physical graphics memory blocks in the set of allocable blocks whose starting address interval does not exceed a preset range are forced to be merged into a new contiguous block, and a second allocation instruction is generated: the new contiguous block is bound to the target main task node; If the second allocation instruction still does not meet the calculation demand of the target main task node, it is detected whether the remaining calculation amount estimate of the target main task node is greater than a preset deprivation threshold, if the remaining calculation amount estimate of the target main task node is greater than the deprivation threshold, an alienable block is screened from the guarantee type resource pool, physical graphics memory blocks in the alienable block are deprived at a set proportion, a returned block is generated, a returned mark is attached in the returned block, and a third allocation instruction is generated: the returned block is bound to the target main task node; If the remaining calculation amount estimate of the target main task node is less than the deprivation threshold, deprivation is prohibited.
8. The dynamic video memory allocation based co-processing system of claim 7, wherein: The returned mark in the step W3 and the connection index established in the returned block; The specific content of the deprivation compensation mechanism is: according to the returned block released after the target main task node ends, physical graphics memory space is released at a preset multiple interval of the returned block, and the connection index is returned to the alienable block of the guarantee type resource pool.
9. The dynamic video memory allocation based co-processing system of claim 8, wherein: The specific content of the resource recycling and integration module is: monitoring the end event of the main task node in the high-priority task channel, collecting the released physical graphics memory blocks, and returning the remaining released physical graphics memory blocks except the returned block returned by the deprivation compensation mechanism to the corresponding physical block of the elastic resource pool or the guarantee type resource pool according to the belonging of the resource pool type; The starting address continuity of the scanned recycled physical graphics memory blocks is scanned, adjacent free physical graphics memory blocks are merged to form a new contiguous logical block, and the block allocation vector, the state identifier and the resource pool belonging mark in the graphics memory resource distribution map are updated.
Citation Information
Cited By
Real-time interactive AI service-oriented low-delay scheduling method and system and medium
CN122111625A