Task processing method and device, computer equipment and readable storage medium
By dynamically allocating and updating memory, the problem of inefficient memory usage in traditional computing mode is solved, and higher memory utilization and computing efficiency are achieved.
Patent Information
- Application Number
- CN202411206353.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-03-11
AI Technical Summary
Traditional computing models are difficult to meet the needs of efficiently processing big data and complex algorithms, especially in the low memory utilization problem that the processor is low in memory utilization.
By responding to the startup of the task to be executed, determine its memory requirements, and allocate the target memory according to the memory requirements and memory operation policies, dynamically allocate and update the target memory until the task is completed, to improve memory utilization.
By dynamically allocating and updating memory, memory allocation can be adjusted in time according to task execution, thereby improving memory utilization and improving computing efficiency.
Smart Images

Figure CN119597439A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the rapid development of computer technology, fields such as big data, artificial intelligence (AI) and machine learning (ML) are undergoing unprecedented changes. The development of these fields has profoundly affected the production methods and business models of various industries. With the explosive growth of data volume and the sharp increase in computing complexity, traditional computing models can no longer meet the needs of efficient processing of big data and complex algorithms. In this context, parallel accelerated computing technology has quickly become a key means to improve computing efficiency. Parallel computing achieves effective utilization of computing resources and a significant increase in computing speed by decomposing computing tasks into multiple subtasks and using multiple processors or computing units to perform independent computing at the same time.
[0003] However, in the process of the processor performing computing tasks, the technical problem of inefficient memory usage is prone to occur, resulting in low utilization of the processor memory. Summary of the invention
[0004] Based on this, it is necessary to provide a task processing method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve memory utilization in response to the above technical problems.
[0005] In a first aspect, the present application provides a task processing method, comprising:
[0006] In response to the initiation of the task to be executed, determining the memory requirement of the task to be executed;
[0007] Allocate target memory for tasks to be executed according to memory requirements and memory operation policies, and execute the tasks to be executed through the target memory;
[0008] During the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed.
[0009] In some embodiments, allocating target memory for the task to be executed according to the memory requirement and the memory operation policy includes: querying the corresponding memory operation policy according to the memory requirement and the task to be executed; determining the memory block for the task to be executed from various candidate memory blocks of the processor memory according to the memory requirement and the memory operation policy; using the memory block as the target memory, and allocating the target memory to the task to be executed.
[0010] In some embodiments, the method further includes: when the processor memory includes memory fragments that meet the merging conditions, merging the memory fragments to obtain a merged memory block; and updating the merged memory block to each candidate memory block of the processor memory.
[0011] In some embodiments, during the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed, including: during the execution of the task to be executed, determining the memory operation associated with the target memory; determining the memory status information of the target memory according to the memory operation; and dynamically allocating and updating the target memory based on the memory status information and the immediate memory requirements of the task to be executed until the task to be executed is completed.
[0012] In some embodiments, the method further includes: generating a memory log of the task to be executed during execution according to the memory status information; optimizing and updating the memory operation strategy based on the memory log to obtain an optimized and updated memory operation strategy.
[0013] In some embodiments, the method further includes at least one of the following: during execution of the task to be executed, determining reclaimable memory blocks in the target memory that meet the recycling conditions, and recycling the reclaimable memory blocks; when it is determined that the task to be executed is completed, releasing the target memory.
[0014] In a second aspect, the present application further provides a task processing device, comprising:
[0015] A memory requirement determination module, configured to determine the memory requirement of the task to be executed in response to the initiation of the task to be executed;
[0016] A target memory allocation module is used to allocate target memory for tasks to be executed according to memory requirements and memory operation strategies, and execute the tasks to be executed through the target memory;
[0017] The memory dynamic update module is used to dynamically allocate and update the target memory according to the memory status information of the target memory during the execution of the task to be executed, until the task to be executed is completed.
[0018] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0019] In response to the initiation of the task to be executed, determining the memory requirement of the task to be executed;
[0020] Allocate target memory for tasks to be executed according to memory requirements and memory operation policies, and execute the tasks to be executed through the target memory;
[0021] During the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed.
[0022] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0023] In response to the initiation of the task to be executed, determining the memory requirement of the task to be executed;
[0024] Allocate target memory for tasks to be executed according to memory requirements and memory operation policies, and execute the tasks to be executed through the target memory;
[0025] During the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed.
[0026] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0027] In response to the initiation of the task to be executed, determining the memory requirement of the task to be executed;
[0028] Allocate target memory for tasks to be executed according to memory requirements and memory operation policies, and execute the tasks to be executed through the target memory;
[0029] During the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed.
[0030] The above-mentioned task processing method, device, computer equipment, computer-readable storage medium and computer program product allocate target memory for the task to be executed according to the memory requirements and memory operation strategy of the task to be executed when the task to be executed is started, and execute the task to be executed through the target memory. In the process of executing the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed. According to the memory requirements and memory operation strategy of the task to be executed, the corresponding target memory is allocated for execution, and in the process of executing the task to be executed, the memory status information of the target memory is dynamically allocated and updated. The memory allocation can be adjusted dynamically and timely according to the task execution situation, thereby improving the memory utilization rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 An application environment diagram of a task processing method in an embodiment;
[0033] Figure 2 is a flowchart of a task processing method in one embodiment;
[0034] Figure 3 A schematic diagram of a process of allocating target memory in one embodiment;
[0035] Figure 4 is a schematic diagram of the architecture of a task processing system in one embodiment;
[0036] Figure 5 is a flowchart of a task processing method in another embodiment;
[0037] Figure 6 is a structural block diagram of a task processing device in one embodiment;
[0038] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0040] The task processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers.
[0041] The user can configure the tasks to be executed through the terminal 102. For example, the user can write the tasks to be executed that are suitable for execution by the server. The terminal 102 can send the tasks to be executed to the server 104 so that the server 104 can process the tasks to be executed. Specifically, when starting the tasks to be executed, the server 104 can determine the memory requirements of the tasks to be executed and obtain the pre-set memory operation policy. The server 104 can allocate the target memory for the tasks to be executed according to the memory requirements and the memory operation policy, and execute the tasks to be executed through the target memory. In the process of executing the tasks to be executed, the server 104 can determine the memory status information of the target memory, and dynamically allocate and update the target memory according to the memory status information, so as to execute the tasks to be executed through the dynamically allocated updated target memory until the tasks to be executed are completed.
[0042] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.
[0043] In an exemplary embodiment, Figure 2 As shown, a task processing method is provided, which is applied to Figure 1 The server in the example is used to illustrate, including the following steps 202 to 206. Among them:
[0044] Step 202: In response to the start of the task to be executed, determine the memory requirement of the task to be executed.
[0045] The task to be executed may be a computing task that needs to be executed, which may specifically include but is not limited to computing tasks including data preprocessing, feature extraction, model training, etc. Memory requirements refer to the memory information required during the execution of the task to be executed, which may specifically include the required memory size. Memory requirements are related to factors such as the task type, data volume, algorithm used, data structure, and programming language characteristics of the task to be executed.
[0046] Exemplarily, the server can start the task to be executed, thereby triggering the start of the task to be executed, and the task to be executed may include a computing task that needs to be triggered for execution. The server can determine the memory requirements of the task to be executed, and the specific server can analyze the task to be executed to determine the memory requirements of the task to be executed. In some embodiments, for the task to be executed, the server can estimate the space occupied by the data in the memory based on the data volume and data structure, thereby calculating the data memory requirements; the server can analyze the spatial complexity of the algorithm, and consider the temporary storage space that may be required during the execution of the algorithm, thereby calculating the algorithm memory requirements; the server can also add the additional memory overhead brought by the programming language, library and framework, and reserve a certain memory margin according to the importance of the task to be executed and the size of the data volume, thereby comprehensively obtaining the memory requirements of the task to be executed.
[0047] Step 204 , allocating target memory for the task to be executed according to the memory requirement and the memory operation policy, and executing the task to be executed through the target memory.
[0048] The memory operation strategy is an allocation strategy for the memory of the processor, which may include but is not limited to at least one memory allocation method including memory pool technology, first fit algorithm (First Fit), best fit algorithm (Best Fit), worst fit algorithm (Worst Fit), buddy system (Buddy System) or separated fit algorithm (Segregated Fit). The target memory is the memory of the processor allocated to the task to be executed, that is, the target content is used to execute the task to be executed.
[0049] Optionally, the server can allocate memory for the task to be executed according to the memory requirements and the memory operation policy, so as to allocate target memory to the task to be executed, and execute the task to be executed through the allocated target memory. In some embodiments, the server can obtain the memory operation policy, which can be pre-set according to actual needs, or matched based on the task to be executed, so as to obtain a memory operation policy suitable for allocating memory for the task to be executed. The server can allocate memory according to the memory operation policy and memory requirements, so as to allocate corresponding target memory for the task to be executed, and execute the task to be executed through the target memory.
[0050] Step 206: During the execution of the task to be executed, dynamically allocate and update the target memory according to the memory status information of the target memory until the task to be executed is completed.
[0051] The memory status information may represent the memory usage of the target memory during the execution of the task to be executed, and may specifically include but is not limited to at least one of various status information including total amount and usage parameters, allocation and reservation status, memory statistics, etc. Dynamic allocation update refers to a process of dynamically updating the allocation of the target memory based on the memory status information of the target memory, so as to execute the task to be executed through the updated target memory.
[0052] Exemplarily, during the execution of the task to be executed, the server can query the memory status information of the target memory, and the server can specifically monitor the target memory to obtain the memory status information of the target memory. In some embodiments, the server can also monitor the global memory of the processor to obtain the global memory status information of the processor, and the server can extract the memory status information of the target memory from the global memory status information. The server can dynamically allocate and update the target memory based on the memory status information, and specifically can dynamically allocate and update the target memory based on the memory status information and the real-time memory requirements of the task to be executed. In some embodiments, the server can combine the real-time memory requirements of the task to be executed, the memory operation policy and the memory status information of the target memory, comprehensively dynamically allocate and update the target memory, and execute the task to be executed through the updated target memory.
[0053] In a specific application, the task to be executed may include multiple calculation processes. For each calculation process, the server can dynamically allocate and update the target memory, and execute the task to be executed through the updated target memory until the task to be executed is completed. In some embodiments, an update cycle or update times can also be set, that is, when the update cycle is reached, or the number of executions of the calculation process reaches the update times, a dynamic allocation update for the target memory can be triggered to execute the task to be executed through the updated target memory until the task to be executed is completed.
[0054] In the above task processing method, when the task to be executed is started, the target memory for the task to be executed is allocated according to the memory requirements and memory operation strategy of the task to be executed, and the task to be executed is executed through the target memory. In the process of executing the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed. According to the memory requirements and memory operation strategy of the task to be executed, the corresponding target memory is allocated for execution, and in the process of executing the task to be executed, the memory status information of the target memory is dynamically allocated and updated. The memory allocation can be adjusted dynamically and timely according to the task execution situation, thereby improving the memory utilization.
[0055] In an exemplary embodiment, Figure 3 As shown, the process of allocating target memory, that is, allocating target memory for tasks to be executed according to memory requirements and memory operation policies, includes steps 302 to 306. Among them:
[0056] Step 302: query the corresponding memory operation strategy according to the memory demand and the task to be executed.
[0057] Among them, the memory operation strategy can correspond to the tasks to be executed and the memory requirements. The memory operation strategy can be pre-configured according to the tasks to be executed and the memory requirements. Specifically, it can include a memory allocation strategy, such as including memory pool technology, so as to allocate memory for the tasks to be executed based on the memory pool technology.
[0058] Exemplarily, the server can query the corresponding memory operation strategy in combination with the memory demand and the task to be executed, such as querying the memory operation strategy corresponding to the memory demand and the task to be executed from the pre-set operation strategy mapping relationship according to the parameters of the memory demand and the task to be executed. The operation strategy mapping relationship may include the correspondence between different memory demands and different tasks to be executed and the corresponding memory operation strategy, and the correspondence may be determined by the user based on analysis of historical data.
[0059] Step 304 : Determine a memory block for the task to be executed from each candidate memory block in the processor memory according to the memory requirement and the memory operation policy.
[0060] Among them, the processor memory may include memory that can be allocated in the processor, such as the processor may include a graphics processing unit, and the processor memory may be the memory of the graphics processing unit. A memory block is a continuous memory area in the processor memory for storing data. Different memory blocks may carry data of different sizes, which may be variables, structures, arrays, etc. Candidate memory blocks are memory blocks that can be allocated in the processor memory. Optionally, the server may determine the processor memory, which may include candidate memory blocks that can be allocated. The server may filter from each candidate memory block based on memory requirements and memory operation policies to determine the memory block for the task to be executed. For example, the server may determine the memory block for the task to be executed from each candidate memory block according to memory requirements based on memory pool technology.
[0061] Step 306: Use the memory block as the target memory, and allocate the target memory to the task to be executed.
[0062] Exemplarily, the server may use the determined memory block as the target memory for the task to be executed, and allocate the target memory to the task to be executed, so as to execute the task to be executed through the target memory.
[0063] In this embodiment, the server can query the corresponding memory operation strategy based on the memory requirements and the tasks to be executed, and determine the target memory from the candidate memory blocks of the processor memory according to the memory requirements and the memory operation strategy to allocate the target memory to the tasks to be executed. This can accurately screen out the target memory suitable for the tasks to be executed, which is beneficial to improving the memory utilization of the processor.
[0064] In an exemplary embodiment, the task processing method further includes: when the processor memory includes memory fragments that meet the merging conditions, merging the memory fragments to obtain a merged memory block; and updating the merged memory block to each candidate memory block of the processor memory.
[0065] Memory fragments are small memory blocks that are generated during the memory allocation process and cannot be effectively used. Memory fragments can include memory spaces that have been allocated but cannot be effectively used and free memory areas that have not been allocated but are too small to be allocated. The merging condition is used to determine whether the memory fragments need to be merged, such as the location of the memory fragments. When the location of the memory fragments meets the location condition, such as when the memory fragments are adjacent, the merging condition can be considered to be met.
[0066] Optionally, the server may monitor the processor memory, and when it is detected that the processor memory includes memory fragments, the server may make a determination for each memory fragment to determine whether the merging condition is met. For example, the server may determine the memory addresses of each memory fragment, and when it is determined that the memory fragments are adjacent to each other based on the memory addresses of each memory fragment, it can be considered that the memory fragments meet the merging condition, and the server may merge the memory fragments that meet the merging condition to obtain a merged memory block, that is, by merging adjacent small memory blocks into a larger memory block. The server may further refine the merged memory block as a candidate memory block into the processor memory, and the specific server may update the merged memory block to each candidate memory block of the processor memory, so that the server can subsequently dynamically allocate and update the target memory based on the updated candidate memory block.
[0067] In this embodiment, the server can merge memory fragments that meet the merging conditions, and update the merged memory blocks to each candidate memory block of the processor memory, which can timely reduce memory fragments and help improve the memory utilization of the processor.
[0068] In an exemplary embodiment, during the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed, including: during the execution of the task to be executed, determining the memory operation associated with the target memory; determining the memory status information of the target memory according to the memory operation; and dynamically allocating and updating the target memory based on the memory status information and the immediate memory requirements of the task to be executed until the task to be executed is completed.
[0069] The memory operation is an operation triggered on the target memory during the execution of the task to be executed, and may specifically include a use operation on the target memory. As the task to be executed is executed, the memory requirement of the task to be executed may change, and the immediate memory requirement is the memory requirement at the current moment during the execution of the task to be executed.
[0070] Exemplarily, in the process of executing the task to be executed through the target memory, the server can determine the memory operation associated with the target memory. The memory operation is an interactive operation triggered for the target memory during the execution of the task to be executed, and specifically can include the use of the target memory. The server can determine the memory state information of the target memory based on the memory operation. Specifically, the server can trigger the corresponding operation for the target memory according to the memory operation for the target memory to determine the memory state information of the target memory, such as determining the use information of the target memory. The server can determine the immediate memory demand of the task to be executed, and the immediate memory demand can be the memory demand of the task to be executed at the current moment. The server can dynamically allocate and update the target memory based on the immediate memory demand and the memory state information, such as performing update processing such as memory increase or memory release to obtain the updated target memory, and execute the task to be executed at the current moment through the updated target memory. After completing the execution of the task at the current moment, the server can execute the task at the next moment, and return to the step of determining the memory operation associated with the target memory, until the execution of the task to be executed is completed, the server can end the execution processing for the task to be executed.
[0071] In this embodiment, the server can determine the memory status information based on the memory operations associated with the target memory, and dynamically allocate and update the target memory in combination with the immediate memory requirements of the task to be executed. The memory allocation can be dynamically adjusted in a timely manner according to the task execution status, thereby improving memory utilization.
[0072] In an exemplary embodiment, the task processing method further includes: generating a memory log of the task to be executed during execution according to the memory status information; optimizing and updating the memory operation strategy based on the memory log to obtain an optimized and updated memory operation strategy.
[0073] Among them, the memory log is used to record the memory status information of the task to be executed at different times during the execution process. Based on the memory log, the memory operation strategy can be optimized and updated to obtain a memory operation strategy that is more suitable for the task to be executed. Exemplarily, during the process of the task to be executed, the server can obtain the memory status information of the target memory, and generate a memory log of the task to be executed during the execution process based on the memory status information obtained at each moment. The memory log can record the memory usage information of the task to be executed during the execution process. The server can optimize and update the memory operation strategy based on the memory log, such as optimizing and updating the memory allocation algorithm included in the memory operation strategy to obtain an optimized and updated memory operation strategy, and the optimized and updated memory operation strategy can be used in subsequent memory allocation processing.
[0074] In this embodiment, the server generates a memory log according to the memory status information, and optimizes and updates the memory operation policy based on the memory log, so that the memory operation policy can be adjusted in time according to the memory log, which is beneficial to ensure the reliability of the memory operation policy. Memory allocation can be accurately adjusted based on the memory operation policy, which is beneficial to improve memory utilization.
[0075] In an exemplary embodiment, the task processing method further includes: in the process of executing the to-be-executed task, determining a reclaimable memory block in the target memory that meets a recycling condition, and recycling the reclaimable memory block.
[0076] Among them, the recycling condition is used to determine whether the memory block needs to be recycled. For example, for a memory block that has ended its use, it can be considered that the recycling condition is met, and the recyclable memory block is the memory block in the target memory that meets the recycling condition. Optionally, in the process of executing the task to be executed, the server can monitor each memory block in the target memory to monitor whether there is a memory block that meets the recycling condition. When it is determined that the target memory includes recyclable memory blocks that meet the recycling condition, the server can recycle the recyclable memory blocks, and specifically clear and release the memory blocks to ensure memory utilization.
[0077] In this embodiment, the server can timely recycle the recyclable memory blocks that meet the recycling conditions in the target memory, thereby ensuring the memory utilization of the processor.
[0078] In an exemplary embodiment, the task processing method further includes: when it is determined that the to-be-executed task is completed, releasing the target memory.
[0079] Exemplarily, when it is detected that the execution of the task is completed, it indicates that the target memory is no longer needed, and the server can release the target memory, thereby determining the memory utilization of the processor.
[0080] The present application also provides an application scenario, and the application scenario applies the above-mentioned task processing method. Specifically, the application of the task processing method in the application scenario is as follows:
[0081] This embodiment relates to a dynamic memory management and optimization method based on CUDA (Compute Unified Device Architecture). With the development of fields such as big data, artificial intelligence, and high-performance computing (HPC), the parallel computing capabilities of GPUs (Graphics Processing Units) are widely used to accelerate computing processes. However, the complexity and efficiency of GPU memory management have become important factors limiting GPU computing performance. Existing GPU memory management methods usually require manual memory allocation and release, which can easily lead to problems such as memory fragmentation, memory leaks, and inefficient memory use. Among them, CUDA is a general parallel computing architecture that uses GPUs for high-performance computing; GPUs are used to accelerate graphics and parallel computing tasks.
[0082] Specifically, the existing technologies mainly include the basic memory management functions provided by CUDA (such as cudaMalloc, cudaFree, etc.) and some preliminary memory pool management tools. However, these methods usually require programmers to manually manage memory, lack dynamic memory management and optimization mechanisms, and are difficult to meet the needs of complex computing tasks. That is, manual memory management in traditional technologies is complex and error-prone, which can easily lead to memory leaks and fragmentation. In addition, traditional technologies lack dynamic memory management mechanisms, and the efficiency of memory allocation and release is low. In addition, traditional technologies have low memory utilization efficiency, cannot fully utilize the GPU's memory resources, and are difficult to monitor and optimize memory usage in real time, and cannot dynamically adjust memory allocation strategies according to demand.
[0083] Based on this, the task processing method provided in this embodiment achieves efficient GPU memory allocation, use and release by introducing dynamic memory management and optimization methods, solves the complexity and efficiency problems in the prior art, and improves the utilization rate and computing performance of GPU memory resources.
[0084] Specifically, Figure 4 As shown, the task processing method provided in this embodiment corresponds to the task processing system architecture including the following modules:
[0085] Memory allocation module, used to dynamically allocate GPU memory and reduce memory fragmentation;
[0086] Memory monitoring module, used to monitor GPU memory usage in real time and record memory operations;
[0087] Memory recycling module, used to automatically recycle unused memory blocks to avoid memory leaks;
[0088] The memory optimization module is used to optimize the memory allocation strategy and improve memory utilization and access speed.
[0089] The memory allocation module is responsible for dynamically allocating GPU memory according to the needs of computing tasks. The main functions include:
[0090] Efficient allocation: Through memory pool technology, the required memory blocks can be quickly allocated to reduce the overhead of memory allocation;
[0091] Memory merging: Merge adjacent small memory blocks into larger memory blocks to reduce memory fragmentation.
[0092] Among them, memory pool is a memory management technology that improves the efficiency of memory allocation and release by pre-allocating and reusing memory blocks; memory fragmentation is caused by frequent memory allocation and release operations, resulting in many small free memory blocks in the memory, and memory fragmentation will reduce memory utilization. In addition, for memory allocation strategies, in addition to using memory pool technology and memory merging to reduce memory fragmentation, more memory allocation algorithms can be introduced, such as the buddy system allocation algorithm, to improve memory allocation efficiency and flexibility.
[0093] The memory monitoring module is used to monitor the GPU memory usage in real time and record the time and size of each memory allocation and release. Its main functions include:
[0094] Memory usage record: record each memory allocation and release operation and generate memory usage log;
[0095] Memory usage analysis: Analyze memory usage patterns, identify memory hot spots, and provide a basis for memory optimization.
[0096] In addition, for the memory monitoring mechanism, in addition to real-time monitoring of memory usage and recording memory operations, hardware-based memory monitoring technology can also be used to improve the accuracy and efficiency of monitoring.
[0097] The memory recycling module uses a garbage collection algorithm to automatically recycle unused memory blocks. Its main functions include:
[0098] Mark and sweep: mark memory blocks that are no longer used and clear them when appropriate;
[0099] Reference counting: Use reference counting technology to determine whether a memory block is still in use. When the number of references is 0, it is considered unused and the useless memory is automatically reclaimed.
[0100] Among them, garbage collection is an automatic memory management technology that uses marking and recycling. In addition, for the memory recycling mechanism, in addition to using garbage collection and reference counting technology to automatically recycle memory, more memory recycling strategies can be introduced, such as the mark-compact algorithm, to further reduce memory fragmentation and recycling overhead.
[0101] The memory optimization module is used to optimize memory allocation and access to improve memory usage efficiency. Its main functions include:
[0102] Memory alignment: ensure memory access alignment and improve memory access speed;
[0103] Preallocation: Based on the memory usage pattern, preallocate the memory blocks that may be needed to reduce the number of dynamic allocations.
[0104] In the task processing method provided in this embodiment, the terminal performs memory allocation, monitoring, recovery and optimization operations. The specific data generation process includes when the computing task is started, the system initializes the memory allocation module according to the task requirements; the data processing process includes the memory allocation module dynamically allocating the required memory, the memory monitoring module recording the memory operation and analyzing the memory usage pattern, the memory recovery module automatically recovering the memory blocks that are no longer used, and the memory optimization module optimizing the memory allocation and access; and the data output process includes after the computing task is completed, outputting the memory usage report and releasing all memory blocks.
[0105] The execution sequence of the task processing method provided in this embodiment includes: task initialization, specifically initializing the memory allocation module and analyzing the memory requirements; memory allocation, specifically dynamically allocating the required GPU memory; task execution, specifically executing the computing task, and the memory monitoring module recording the memory usage in real time; memory recycling, specifically after the computing task is completed, the memory recycling module automatically recycles the memory blocks that are no longer used; task completion, specifically outputting a memory usage report and releasing all memory blocks.
[0106] The task processing method provided in this embodiment can be applied to high-performance computing, specifically in large-scale scientific computing, to improve memory management efficiency and enhance computing performance. The task processing method provided in this embodiment can also be applied to artificial intelligence and machine learning, specifically in the training and reasoning stages, to improve memory usage efficiency and shorten training time. The task processing method provided in this embodiment can also be applied to big data processing and analysis, specifically in the data preprocessing and analysis stages, to improve memory management efficiency and enhance processing capabilities.
[0107] like Figure 5As shown, the process of the task processing method provided by this embodiment includes: task initialization; analysis of memory requirements; execution of computing tasks; dynamic allocation of memory during the execution of computing tasks, specifically allocation of GPU memory; monitoring memory usage; optimizing memory allocation strategy; recycling and releasing memory until the task is completed. The task processing method provided by this embodiment overcomes the problem that manual memory management in the prior art is complex and error-prone, realizes dynamic memory management and optimization, and improves memory utilization efficiency and GPU computing performance. Specific technical effects include: reducing memory fragmentation: reducing memory fragmentation and improving memory utilization through memory pool technology and memory merging; avoiding memory leaks: avoiding memory leaks and ensuring system stability through automatic memory recycling mechanism; improving memory access speed: improving memory access speed and enhancing computing performance through memory alignment and pre-allocation technology; real-time monitoring and optimization: through memory monitoring and optimization modules, real-time monitoring and dynamic optimization of memory usage are realized to meet the needs of different computing tasks.
[0108] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0109] Based on the same inventive concept, the embodiment of the present application also provides a task processing device for implementing the task processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more task processing device embodiments provided below can refer to the limitations on the task processing method above, and will not be repeated here.
[0110] In an exemplary embodiment, Figure 6 As shown, a task processing device 600 is provided, comprising: a memory requirement determination module 602, a target memory allocation module 604 and a memory dynamic update module 606, wherein:
[0111] A memory requirement determination module 602, configured to determine the memory requirement of the task to be executed in response to the initiation of the task to be executed;
[0112] A target memory allocation module 604 is used to allocate target memory for the task to be executed according to the memory requirement and the memory operation strategy, and execute the task to be executed through the target memory;
[0113] The memory dynamic update module 606 is used to dynamically allocate and update the target memory according to the memory status information of the target memory during the execution of the task to be executed, until the task to be executed is completed.
[0114] In some embodiments, the target memory allocation module 604 is also used to query the corresponding memory operation strategy based on the memory requirements and the task to be executed; determine the memory block for the task to be executed from the candidate memory blocks of the processor memory according to the memory requirements and the memory operation strategy; use the memory block as the target memory, and allocate the target memory to the task to be executed.
[0115] In some embodiments, a memory fragment merging module is also included, which is used to merge the memory fragments to obtain a merged memory block when the processor memory includes memory fragments that meet the merging conditions; and update the merged memory block to each candidate memory block of the processor memory.
[0116] In some embodiments, the memory dynamic update module 606 is also used to determine the memory operation associated with the target memory during the execution of the task to be executed; determine the memory status information of the target memory based on the memory operation; and dynamically allocate and update the target memory based on the memory status information and the immediate memory requirements of the task to be executed until the task to be executed is completed.
[0117] In some embodiments, a memory operation strategy optimization module is also included, which is used to generate a memory log of the task to be executed during the execution process according to the memory status information; based on the memory log, the memory operation strategy is optimized and updated to obtain an optimized and updated memory operation strategy.
[0118] In some embodiments, a memory recycling module is also included, which is used to determine the recyclable memory blocks in the target memory that meet the recycling conditions during the execution of the task to be executed, and recycle the recyclable memory blocks.
[0119] In some embodiments, a memory release module is also included, which is used to release the target memory when it is determined that the task to be executed is completed.
[0120] Each module in the above task processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0121] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data involved in the task processing method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a task processing method is implemented.
[0122] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0123] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0124] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0125] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0126] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0127] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0128] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0129] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A task processing method, characterized in that: The method comprises: In response to starting a task to be executed, determining a memory requirement of the task to be executed; Allocate a target memory for the task to be executed according to the memory requirement and the memory operation policy, and execute the task to be executed through the target memory; During the execution of the task to be executed, the target memory is dynamically allocated and updated according to the memory status information of the target memory until the task to be executed is completed.
2. The method according to claim 1, characterized in that The allocating target memory for the task to be executed according to the memory requirement and the memory operation policy includes: Querying a corresponding memory operation strategy according to the memory demand and the task to be executed; According to the memory requirement and the memory operation policy, determining a memory block for the task to be executed from each candidate memory block of the processor memory; The memory block is used as a target memory, and the target memory is allocated to the task to be executed.
3. The method according to claim 2, characterized in that The method further comprises: When the processor memory includes memory fragments that meet the merging condition, merging the memory fragments to obtain a merged memory block; The merged memory blocks are updated to each candidate memory block of the processor memory.
4. The method according to claim 1, characterized in that: In the process of executing the task to be executed, dynamically allocating and updating the target memory according to the memory status information of the target memory until the task to be executed is completed, including: In the process of executing the task to be executed, determining a memory operation associated with the target memory; Determine memory state information of the target memory according to the memory operation; Based on the memory status information and the immediate memory demand of the task to be executed, the target memory is dynamically allocated and updated until the task to be executed is completed.
5. The method according to claim 1, characterized in that: The method further comprises: Generate a memory log of the task to be executed during execution according to the memory status information; The memory operation strategy is optimized and updated based on the memory log to obtain an optimized and updated memory operation strategy.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises at least one of the following: In the process of executing the task to be executed, determining a reclaimable memory block in the target memory that meets a recycling condition, and recycling the reclaimable memory block; When it is determined that the to-be-executed task is completed, the target memory is released.
7. A task processing device, characterized in that: The device comprises: A memory requirement determination module, configured to determine the memory requirement of the task to be executed in response to the initiation of the task to be executed; A target memory allocation module, used to allocate a target memory for the task to be executed according to the memory requirement and the memory operation strategy, and execute the task to be executed through the target memory; The memory dynamic update module is used to dynamically allocate and update the target memory according to the memory status information of the target memory during the execution of the task to be executed, until the task to be executed is completed.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Computer video memory sharing method and device, equipment and storage medium
CN120276874A