Memory management method for computing integrated circuit, apparatus and computing integrated circuit

By adopting a memory management method in the computing integrated circuit, selecting thread memory pool or preset memory pool for memory allocation based on the memory application size of the thread, the problems of performance reduction and waste of memory resources caused by multi-thread access to the memory pool are solved, and efficient memory management and performance improvement are achieved.

WO2025112899A1PCT designated stage expired Publication Date: 2025-06-05INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
PCT/CN2024/122643
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-11-29
Filing Date
2024-09-30
Publication Date
2025-06-05

AI Technical Summary

Technical Problem

In the memory management of existing computing integrated circuits, multithread access to a single memory pool leads to degradation of performance, or each thread uses its own memory pool leads to wasted memory resources.

Method used

A memory management method is adopted to determine the target memory allocation method based on the size of the requested memory by obtaining the current thread's request. If the memory size of the application is small, use the thread memory pool of the current thread for allocation; if the memory size of the application is large, obtain the mutex of the target memory pool and use the preset memory pool for allocation.

Benefits of technology

It improves the memory application and release performance of computing integrated circuits, reduces the waste of memory resources, and improves the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024122643_05062025_PF_FP_ABST
    Figure CN2024122643_05062025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of artificial intelligence. Disclosed are a memory management method for a computing integrated circuit, an apparatus and a computing integrated circuit. The method comprises: acquiring a memory application request of a current thread; according to the size of an applied memory of the memory application request, determining a target memory allocation mode; if the target memory allocation mode is a first allocation mode, using a thread memory pool of the current thread to allocate to the current thread a memory space corresponding to the memory application request; and if the target memory allocation mode is a second allocation mode, acquiring a mutual exclusion lock of the target memory pool corresponding to the current thread, and using the target memory pool to allocate to the current thread a memory space corresponding to the memory application request. The present application uses a thread memory pool of each thread to process a memory request for a smaller memory without the need of acquiring a mutual exclusion lock, thus improving the memory application and release performance of computing integrated circuits; in addition, only a thread memory pool used by a memory request for a smaller memory is processed, thus reducing the waste of memory resources in computing integrated circuits.
Need to check novelty before this filing date? Find Prior Art

Description

A memory management method and device for computing integrated circuit and computing integrated circuit

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on November 29, 2023, with application number 202311608735.8, the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the field of artificial intelligence technology, and in particular to a memory management method and device for a computing integrated circuit, and a computing integrated circuit. Background Art

[0004] With the rise of artificial intelligence (AI) technology, solutions using CPUs (Central Processing Units) and GPUs (Graphics Processing Units), or CPUs and other integrated circuits, for AI model training and inference are becoming widely adopted across various industries. Memory management optimization technology has gained widespread application in integrated circuits because it can utilize memory blocks in a memory pool, reducing the time required to request and release computational memory.

[0005] In related technologies, memory management optimization for integrated circuits involves either having multiple threads access a single memory pool or having each thread use its own memory pool. However, the multi-threaded access to a single memory pool solution requires setting a mutex lock to maintain data consistency in the memory pool. Consequently, when a large number of threads simultaneously request or release memory, only one thread can obtain the mutex lock at a time, leaving the other threads waiting. This severely impacts the performance of the integrated circuit. In the case where each thread uses its own memory pool, each memory pool caches a certain number of memory blocks for use by each thread. This results in the entire program occupying a large amount of the integrated circuit's memory, resulting in a waste of memory resources.

[0006] Summary of the Invention

[0007] The present application provides a memory management method for a computing integrated circuit, comprising:

[0008] Obtaining a memory request of a current thread; wherein the current thread is any thread of a computing integrated circuit;

[0009] Determine the target memory allocation method according to the memory size requested by the memory application request;

[0010] In response to determining that the target memory allocation mode is the first allocation mode, using the thread memory pool of the current thread to allocate memory space corresponding to the memory request for the current thread; wherein a thread memory pool is set for each thread in the computing integrated circuit; or

[0011] In response to determining that the target memory allocation method is the second allocation method, a mutex lock corresponding to the current thread of the target memory pool is obtained, and the target memory pool is used to allocate memory space corresponding to the memory request for the current thread; wherein, the target memory pool is a preset memory pool corresponding to the memory size requested; the memory size requested corresponding to the target memory pool is larger than the memory size requested corresponding to the thread memory pool.

[0012] In some embodiments, using the thread memory pool of the current thread to allocate memory space corresponding to the memory request for the current thread includes:

[0013] Obtaining a target memory block from the thread memory pool of the current thread; wherein the target memory block is an idle preset memory block corresponding to the memory size requested by the memory application request; and

[0014] Allocates the target memory block to the current thread.

[0015] In some embodiments, obtaining a target memory block from a thread memory pool of a current thread includes:

[0016] Use the thread memory management instance of the current thread to obtain the target memory block from the thread memory pool of the current thread.

[0017] In some embodiments, the thread memory pool of the current thread includes preset memory blocks of multiple preset sizes, and the target memory block is an idle preset memory block of a preset size corresponding to the memory size requested by the memory application in the thread memory pool of the current thread.

[0018] In some embodiments, obtaining a target memory block from a thread memory pool of a current thread includes:

[0019] Determining a target array index based on the memory size requested by the memory request; wherein the thread memory pool of the current thread includes a free memory block array, the free memory block array includes array elements corresponding to array indexes of various preset sizes, each array element is a memory block linked list of free preset memory blocks of the preset size corresponding to the respective array index, and the target array index is the array index corresponding to any preset size; and

[0020] Search the target memory block from the memory block linked list of the target array index.

[0021] In some embodiments, obtaining a target memory block from a thread memory pool of a current thread includes:

[0022] Determine whether the target memory block exists in the thread memory pool of the current thread;

[0023] In response to determining that the target memory block does not exist in the thread memory pool of the current thread, a mutex corresponding to the current thread of the shared memory pool is acquired, and the target memory block is acquired from the shared memory pool.

[0024] In some embodiments, obtaining a target memory block from a shared memory pool includes:

[0025] Determine whether the target memory block exists in the shared memory pool; and

[0026] In response to determining that the target memory block does not exist in the shared memory pool, the target memory interval exists in the shared memory pool, and the target memory block is obtained by splitting from the target memory interval; in response to determining that the target memory interval does not exist in the shared memory pool, the mutex corresponding to the current thread of the page cache pool is obtained, the target page is allocated from the page cache pool to the shared memory pool, and the target page is used as the memory interval of the shared memory pool; wherein the target page is an idle preset page space corresponding to the memory size of the target memory block, and the target memory interval is any memory interval in the shared memory pool that is greater than or equal to the memory size of the target memory block.

[0027] In some embodiments, the page cache pool includes preset page spaces of multiple preset page space sizes, the preset page space sizes including preset memory page sizes incremented by the preset memory page size to n preset memory page sizes, and allocating a target page from the page cache pool to the shared memory pool includes:

[0028] Determine whether there is free preset page space in the page cache pool that is greater than or equal to the target memory block;

[0029] In response to determining that there is a free preset page space greater than or equal to the target memory block in the page cache pool, selecting a minimum free preset page space greater than or equal to the target memory block as the target page, and allocating the target page to the shared memory pool; or

[0030] In response to determining that there is no free preset page space greater than or equal to the target memory block in the page cache pool, a memory space of a preset memory application size is requested from the remaining memory of the computing integrated circuit, and the target memory block is divided from the memory space of the preset memory application size to the shared memory pool, and the remaining memory space divided from the memory space of the preset memory application size is placed into the page cache pool; wherein the preset memory application size is greater than or equal to n preset memory page sizes.

[0031] In some embodiments, the preset sizes include 8 bytes to 128 bytes in increments of 8 bytes, 144 bytes to 1024 bytes in increments of 16 bytes, 1152 bytes to 8192 bytes in increments of 128 bytes, and 9216 bytes to 65536 bytes in increments of 1024 bytes. Determining the target memory allocation method based on the requested memory size of the memory request includes:

[0032] Determining whether the memory size requested by the memory application request is greater than a first size threshold, wherein the first size threshold is 65536 bytes;

[0033] In response to determining that the memory size requested by the memory application request is not greater than a first size threshold, determining the target memory allocation mode to be the first allocation mode; or

[0034] In response to determining that the memory size of the memory application request is greater than a first size threshold, the target memory allocation mode is determined to be a second allocation mode.

[0035] In some embodiments, the preset memory pool includes a first memory pool and a second memory pool, and before acquiring the mutex corresponding to the current thread of the target memory pool, the method further includes:

[0036] Determining whether the memory size requested by the memory application request is greater than a second size threshold;

[0037] In response to determining that the memory size of the memory application request is not greater than a second size threshold, determining the first memory pool as the target memory pool; or

[0038] In response to determining that the requested memory size of the memory request is greater than a second size threshold, the second memory pool is determined as the target memory pool; wherein the requested memory size corresponding to the second memory pool is greater than the requested memory size corresponding to the first memory pool.

[0039] In some embodiments, when the target memory pool is the first memory pool, allocating memory space corresponding to the memory request for the current thread using the target memory pool includes:

[0040] Determining a target memory size based on the memory size requested by the memory application request; wherein the target memory size is the product of the quotient of the memory size requested by the memory application request and the third size threshold, rounded up, and multiplied by the third size threshold; and

[0041] Determine whether there is a free memory block in the target memory pool that is greater than or equal to the target memory size;

[0042] In response to determining that the target memory pool has a free memory block that is larger than or equal to the target memory size, allocating the smallest memory block among the free memory blocks that are larger than or equal to the target memory size in the target memory pool to the current thread;

[0043] In response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, determining whether there is memory space of the target application size in the remaining memory of the computing integrated circuit; wherein the target application size is the maximum value of the quotient of the remaining memory of the computing integrated circuit and a preset value, and the target memory size, and the preset value is greater than 1; or

[0044] In response to determining that a memory space of the target application size exists in the remaining memory of the computing integrated circuit, a memory space of the target application size is applied for from the remaining memory of the computing integrated circuit, and a memory space of the target application size is divided from the memory space of the target application size and allocated to the current thread, and the remaining memory space divided from the memory space of the target application size is placed into a target memory pool.

[0045] In some embodiments, when the target memory pool is the second memory pool, allocating memory space corresponding to the memory request for the current thread using the target memory pool includes:

[0046] Determine whether there is a free memory block in the target memory pool that is greater than or equal to the target memory size;

[0047] In response to determining that the target memory pool has a free memory block that is larger than or equal to the target memory size, allocating the smallest memory block among the free memory blocks that are larger than or equal to the target memory size in the target memory pool to the current thread;

[0048] In response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, determining whether there is memory space of the target memory size in the remaining memory of the computing integrated circuit;

[0049] In response to determining that the remaining memory of the computing integrated circuit does not have memory space of the target memory size, controlling the first memory pool and the second memory pool to release their respective complete memory spaces; wherein the complete memory space is the entire free memory space previously requested from the computing integrated circuit;

[0050] In response to determining that the remaining memory of the computing integrated circuit has memory space of the target memory size, applying for the remaining memory of the computing integrated circuit, and determining whether a difference between the memory size of the remaining memory and the target memory size is greater than or equal to a second size threshold;

[0051] In response to determining that the difference between the memory size of the remaining memory and the target memory size is greater than or equal to a second size threshold, dividing a memory space of the target memory size from the remaining memory and allocating it to the current thread, and placing the remaining memory space divided from the remaining memory into the target memory pool; or

[0052] In response to determining that a difference between the memory size of the remaining memory and the target memory size is less than a second size threshold, the remaining memory is allocated to the current thread.

[0053] In some embodiments, the method further comprises:

[0054] Get the current thread's memory release request;

[0055] Determine the target memory allocation method according to the memory size released by the memory release request;

[0056] In response to determining that the target memory allocation mode is the first allocation mode, according to the memory pointer in the memory release request, releasing the memory space corresponding to the memory pointer to the thread memory pool of the current thread; or

[0057] In response to determining that the target memory allocation method is the second allocation method, a mutex lock corresponding to the current thread of the target memory pool is obtained, and according to the memory pointer in the memory release request, the memory space corresponding to the memory pointer is released to the target released memory pool; wherein, the target released memory pool is a preset memory pool corresponding to the released memory size; the released memory size corresponding to the target released memory pool is larger than the released memory size corresponding to the thread memory pool.

[0058] In some embodiments, after releasing the memory space corresponding to the memory pointer to the target released memory pool, the method further includes:

[0059] Determine whether the memory space corresponding to the memory pointer in the target released memory pool is a segmented memory space; and

[0060] In response to determining that the memory space corresponding to the memory pointer in the target released memory pool is a divided memory space, free memory spaces adjacent to the memory space corresponding to the memory pointer are recursively searched and merged in the target released memory pool.

[0061] In some embodiments, after obtaining the memory release request of the current thread, the method further includes:

[0062] Releases the memory of the current thread through the thread memory management instance of the current thread.

[0063] In some embodiments, the step of releasing the memory of the current thread through the thread memory management instance of the current thread includes:

[0064] Determine whether the number of free memory blocks in the thread memory pool corresponding to the current thread exceeds a preset number; and

[0065] In response to the number of free memory blocks in the thread memory pool corresponding to the current thread exceeding a preset number, the preset free memory blocks are returned to the shared memory pool.

[0066] In some embodiments, after determining the target memory allocation method based on the memory size requested by the memory request, the method further includes:

[0067] The target memory allocation method is forwarded to the corresponding memory allocator so that the thread memory pool in the corresponding memory allocator processes the memory request.

[0068] In some embodiments, obtaining a target memory block from a shared memory pool includes:

[0069] Determine whether the target memory block exists in the shared memory pool; and

[0070] In response to determining that the target memory block does not exist in the shared memory pool, the target memory block is acquired through the page cache pool.

[0071] The present application also provides a memory management device for a computing integrated circuit, comprising:

[0072] An application acquisition module, configured to acquire an application memory request of a current thread; wherein the current thread is any thread of the computing integrated circuit;

[0073] An allocation determination module is used to determine a target memory allocation method according to the memory size requested by the memory application request;

[0074] a first application module configured to allocate memory space corresponding to the memory request for the current thread using the thread memory pool of the current thread in response to determining that the target memory allocation mode is the first allocation mode; wherein a thread memory pool is set for each thread in the computing integrated circuit; or

[0075] The second application module is used to obtain the mutex lock corresponding to the current thread of the target memory pool in response to determining that the target memory allocation method is the second allocation method, and use the target memory pool to allocate memory space corresponding to the application memory request for the current thread; wherein, the target memory pool is a preset memory pool corresponding to the application memory size; the application memory size corresponding to the target memory pool is larger than the application memory size corresponding to the thread memory pool.

[0076] In addition, the present application also provides a computing integrated circuit, comprising:

[0077] one or more processors; and

[0078] A memory associated with one or more processors is used to store computer-readable instructions. When the computer-readable instructions are read and executed by the one or more processors, the steps of the memory management method for the computing integrated circuit are implemented.

[0079] A memory management method for a computing integrated circuit provided in the present application includes: obtaining a memory request of a current thread; wherein the current thread is any thread of the computing integrated circuit; determining a target memory allocation method based on the memory size of the memory request; in response to determining that the target memory allocation method is a first allocation method, allocating memory space corresponding to the memory request to the current thread using a thread memory pool of the current thread; wherein a thread memory pool is set for each thread in the computing integrated circuit; in response to determining that the target memory allocation method is a second allocation method, obtaining a mutex corresponding to the current thread of the target memory pool, and allocating memory space corresponding to the memory request to the current thread using the target memory pool; wherein the target memory pool is a preset memory pool corresponding to the memory size; and the memory size corresponding to the target memory pool is larger than the memory size corresponding to the thread memory pool. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.

[0081] FIG1 is a flowchart of a memory management method for a computing integrated circuit provided in an embodiment of the present application;

[0082] FIG2 is a schematic diagram of the system architecture of another memory management method for a computing integrated circuit provided in an embodiment of the present application;

[0083] FIG3 is a schematic diagram of some preset memory blocks of another memory management method for a computing integrated circuit provided by an embodiment of the present application;

[0084] FIG4 is a schematic diagram of another part of a preset memory block of another memory management method for a computing integrated circuit provided by an embodiment of the present application;

[0085] FIG5 is a schematic diagram of a preset page space of another memory management method for a computing integrated circuit provided by an embodiment of the present application;

[0086] FIG6 is a flowchart of another memory management method for a computing integrated circuit provided in an embodiment of the present application;

[0087] FIG7 is a structural block diagram of a memory management device for a computing integrated circuit provided in an embodiment of the present application;

[0088] FIG8 is a schematic diagram of the structure of a computing integrated circuit provided in an embodiment of the present application;

[0089] FIG9 is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0090] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0091] Please refer to Figure 1, which is a flow chart of a memory management method for a computing integrated circuit provided by an embodiment of the present application. The method may include:

[0092] Step 101: Obtain a memory request of a current thread; wherein the current thread is any thread of a computing integrated circuit.

[0093] It is understood that the current thread in this embodiment can be any thread in the computing integrated circuit, such as threads 1 to N in FIG2 . The memory request in this embodiment can be a memory request from a thread. This embodiment uses the processing of a memory request from any thread in the computing integrated circuit as an example for demonstration. The processing of other memory requests from the thread and other threads by the computing integrated circuit, such as the parallel processing of memory requests from multiple threads, can be implemented using the same or similar methods as those provided in this embodiment, and this embodiment does not impose any limitations on this.

[0094] Correspondingly, the way in which the computing integrated circuit obtains the memory request of the current thread in this embodiment can be set by the designer according to the practical scenario and user needs. For example, it can be implemented in the same or similar way as the memory application method of the computing integrated circuit in the related technology. As shown in Figure 2, the computing integrated circuit can use the memory application and release forwarder to obtain the application memory size of the thread's application memory request, determine the corresponding memory allocation method, and forward it to the corresponding memory allocator (i.e., memory allocator 1-3) for processing.

[0095] Step 102: Determine a target memory allocation method according to the memory size requested in the memory application request.

[0096] The memory size requested in this embodiment may be the memory size requested by the memory request. The target memory allocation method in this embodiment may be the memory allocation method used to process the memory request. The target memory allocation method may be a first allocation method that utilizes the thread memory pool of the current thread for processing or a second allocation method that utilizes a target memory pool for processing.

[0097] Correspondingly, the method by which the computing integrated circuit determines the target memory allocation method based on the memory size of the memory request in this step can be set by the designer. For example, in response to determining that the memory size of the memory request (i.e., the requested memory size) is less than or equal to a first threshold, the computing integrated circuit determines the target memory allocation method to be the first allocation method; in response to determining that the memory size of the memory request is greater than the first threshold, the computing integrated circuit determines the target memory allocation method to be the second allocation method. As shown in FIG2 , when the first threshold is 64KB (kilobytes), i.e., 65536 bytes, in this step, the computing integrated circuit can determine whether the memory size of the memory request is greater than 64KB; in response to determining that the memory size of the memory request is not greater than 64KB, the target memory allocation method is determined to be the first allocation method, so as to utilize the thread memory pool (i.e., thread memory pool 1-N) in memory allocator 1 to process the memory request; in response to determining that the memory size of the memory request is greater than 64KB, the target memory allocation method is determined to be the second allocation method, so as to utilize the memory pool (i.e., the preset memory pool) in memory allocator 2 or memory allocator 3 to process the memory request.

[0098] Step 103: In response to determining that the target memory allocation mode is the first allocation mode, use the thread memory pool of the current thread to allocate memory space corresponding to the memory request for the current thread; wherein a thread memory pool is set for each thread in the computing integrated circuit.

[0099] In this embodiment, in response to determining that the target memory allocation method corresponding to the memory application request is the first allocation method, the computing integrated circuit uses the thread memory pool of the current thread to allocate memory space corresponding to the memory application request to the current thread, that is, allocates a memory block with a memory size greater than or equal to the memory application size of the memory application request from the free memory blocks (that is, memory space) in the thread memory pool of the current thread.

[0100] Correspondingly, for the computing integrated circuit in this embodiment, the method of using the thread memory pool of the current thread to allocate memory space corresponding to the memory request for the current thread can be set by the designer according to the practical usage scenario and user needs. For example, multiple memory blocks can be set in the thread memory pool of each thread. In this step, the computing integrated circuit can obtain the target memory block from the thread memory pool of the current thread; wherein the target memory block is an idle preset memory block corresponding to the memory size of the memory request; and the target memory block is allocated to the current thread; for example, the computing integrated circuit can use the thread memory management instance of the current thread to obtain the target memory block from the thread memory pool of the current thread and allocate the target memory block to the current thread; as shown in Figure 2, when the current thread is thread 1, the thread memory management instance 1 in the memory allocator 1 can be used to obtain the target memory block from the thread memory pool 1 and return it to thread 1. That is, in this embodiment, a thread memory management instance can be created for each thread, which is responsible for the memory application and release operations of the corresponding thread. Each thread memory management instance is connected to a thread memory pool. In response to receiving a memory application request, the thread memory management instance will search for a free memory block of appropriate size in the connected thread memory pool and return it. In response to receiving a memory release request, the thread memory management instance will return the released memory to the connected thread memory pool. The computing integrated circuit can also divide the memory space of the requested memory size from the free memory space in the thread memory pool of the current thread and allocate it to the current thread. This embodiment does not impose any restrictions on this.

[0101] Furthermore, in this embodiment, a plurality of memory blocks of preset sizes (i.e., preset memory blocks) can be set in the thread memory pool of the thread, and the target memory block can be a free preset memory block of a preset size corresponding to the applied memory size of the memory request applied for in the thread memory pool of the current thread, such as a free preset memory block of the smallest preset size that is greater than or equal to the preset size of the applied memory size.

[0102] Correspondingly, the settings of preset memory blocks of various preset sizes in the thread memory pool of each thread can be set by the designer according to the usage scenario and user needs. For example, when the above-mentioned first threshold is 64KB (i.e., 65536 bytes), the preset sizes include 8 bytes to 128 bytes in increments of 8 bytes, 144 bytes to 1024 bytes in increments of 16, 1152 bytes to 8192 bytes in increments of 128 bytes, and 9216 bytes to 65536 bytes in increments of 1024 bytes. For example, each thread memory pool can contain an array of free memory blocks. Each array element of the free memory block array is a linked list of memory blocks with the same memory size (i.e., the preset size). The correspondence between the array subscript and the corresponding array element (memory block linked list) is as follows: When the array subscript is [0, 15], as shown in Figure 3, the size of the memory block (i.e., the preset memory block) in the memory block linked list corresponding to the array element increases by 8 bytes. That is, when the subscript is 0, the memory block size is 8 bytes; when the subscript is 1, the memory block size is 16 bytes; when the subscript is 2, the memory block size is 24 bytes; and when the subscript is 15, the memory block size is 128 bytes. When the array subscript is [16, 71], the size of the memory block in the memory block linked list corresponding to the array element increases by 16 bytes. That is, when the subscript is 16, the memory block size is 144 bytes; when the subscript is 17, the memory block size is 160 bytes; and when the subscript is 71, the memory block size is 1024 bytes. When the array index is between [72, 127], the memory block size in the memory block linked list corresponding to the array element increases by 128 bytes. That is, when the index is 72, the memory block size is 1152 bytes; when the index is 73, the memory block size is 1280 bytes; and when the index is 127, the memory block size is 8192 bytes. When the array index is between [128, 183], as shown in Figure 4, the memory block size in the memory block linked list corresponding to the array element increases by 1024 bytes. That is, when the index is 128, the memory block size is 9216 bytes; when the index is 129, the memory block size is 10240 bytes; and when the index is 183, the memory block size is 65536 bytes (i.e., 64KB). When requesting memory less than or equal to 64KB, the thread memory pool maps the memory size passed by the thread memory management instance to the corresponding array index and finds a free memory block for that array index and returns it.

[0103] That is to say, the above process of obtaining the target memory block from the thread memory pool of the current thread may include: determining the target array index based on the memory size requested by the memory application request; wherein, the thread memory pool of the current thread includes a free memory block array, and the free memory block array includes array elements with array indexes corresponding to various preset sizes, each array element is a memory block linked list of free preset memory blocks of the preset size corresponding to its own array index, and the target array subscript is an array subscript corresponding to any preset size; searching for the target memory block from the memory block linked list of the target array subscript.

[0104] Furthermore, in the above process of obtaining the target memory block from the thread memory pool of the current thread, if the target memory block does not exist in the thread memory pool of the current thread, such as if the target memory block cannot be found in the memory block linked list of the target array index, the designer can set it up according to practical scenarios and user needs, such as directly applying for the target memory block from the remaining memory of the computing integrated circuit, applying for a memory size or a fixed-size memory space larger than the applied memory size, so as to allocate all or part of the memory space applied for from the remaining memory of the computing integrated circuit to the current thread. In order to reduce the time of memory application and release, as shown in Figure 2, in this embodiment, a shared memory pool connected to each thread memory pool can also be set up, so that when the memory space in each thread memory pool is insufficient, memory can be applied from the shared memory pool; accordingly, in the above-mentioned process of obtaining the target memory block from the thread memory pool of the current thread, the computing integrated circuit can determine whether the target memory block exists in the thread memory pool of the current thread; in response to determining that the target memory block exists in the thread memory pool of the current thread, the target memory block can be directly obtained from the thread memory pool; in response to determining that the target memory block does not exist in the thread memory pool of the current thread, the mutex lock corresponding to the current thread of the shared memory pool is obtained, and the target memory block is obtained from the shared memory pool to be allocated to the current thread through the thread memory pool of the current thread.

[0105] That is, as shown in Figure 2, when each thread memory pool applies for memory, the thread memory management instance searches for free memory blocks in the thread memory pool. In response to determining that free memory blocks are found in the thread memory pool, the thread memory pool directly returns the memory. In response to determining that no free memory blocks are found in the thread memory pool, the thread memory pool may apply for memory from the shared memory pool and return the memory to the thread memory management instance. When releasing memory, in response to determining that there are too many free memory blocks in the thread memory pool, the excess free memory blocks may be returned to the shared memory pool.

[0106] Correspondingly, in the above process of obtaining the target memory block from the shared memory pool, if the target memory block does not exist in the shared memory pool, the target memory block or a memory space of a fixed size larger than the target memory block can be directly requested from the remaining memory of the computing integrated circuit to allocate all or part of the memory space requested from the remaining memory of the computing integrated circuit to the current thread. To reduce the time required for memory application and release, as shown in FIG2 , in this embodiment, a page cache pool connected to a shared memory pool may be provided so that when the memory space in the shared memory pool is insufficient, memory can be applied for from the page cache pool. Accordingly, the process of obtaining a target memory block from the shared memory pool may include: determining whether the target memory block exists in the shared memory pool; in response to determining that the target memory block exists in the shared memory pool, allocating the target memory block to the thread memory pool of the current thread; in response to determining that the target memory block does not exist in the shared memory pool, if a target memory interval exists in the shared memory pool, segmenting and obtaining the target memory block from the target memory interval; if the target memory interval does not exist in the shared memory pool, acquiring a mutex corresponding to the current thread of the page cache pool, allocating a target page from the page cache pool to the shared memory pool, and using the target page as a memory interval of the shared memory pool; wherein the target page is an idle preset page space corresponding to the memory size of the target memory block, and the target memory interval is any memory interval in the shared memory pool that is greater than or equal to the memory size of the target memory block.

[0107] That is, as shown in Figure 2, the shared memory pool can be a thread-shared memory pool. Only when there are no suitable memory blocks in the thread memory pools will memory be allocated from the shared memory pool. If it is determined that there are no suitable free memory blocks in the shared memory pool, the shared memory pool will request memory from the page cache pool. The free memory blocks requested by the shared memory pool from the page cache pool are called "memory intervals (i.e., target pages)." Memory intervals are divided into small blocks (e.g., target memory blocks) and provided to the thread memory pool. That is, after allocating the target page from the page cache pool to the shared memory pool, the shared memory pool can use the newly allocated target page as the target memory interval, and then obtain the target memory block from the target memory interval to allocate to the current thread through the thread memory pool. If it is determined that a small block of the same memory interval is subsequently returned to the shared memory pool, the memory interval is in an idle state and can be returned to the page cache pool. Like the thread memory pool, the shared memory pool can also contain an array of free memory blocks. Each array element of the free memory block array is a linked list of memory blocks of the same size. The correspondence between the array subscript and the corresponding array element (memory block linked list) is the same as that of the thread memory pool. That is, the shared memory pool can include preset memory blocks of multiple preset sizes. The memory size (i.e., preset size) of each preset memory block in the shared memory pool can adopt the same memory size specification as the preset memory block in the thread memory pool, which will not be repeated here. The target memory block can be a free preset memory block of a preset size corresponding to the memory size of the application memory request passed from the shared memory pool to the thread memory pool of the current thread.

[0108] It should be noted that the memory size specification settings of the preset page spaces in the page cache pool can be set by the designer according to practical scenarios and user needs. For example, the page cache pool can include preset page spaces of one or more page space sizes (i.e., memory size specifications). For example, when the page cache pool includes preset page spaces of multiple preset page space sizes, the n preset page space sizes can include preset memory page sizes that increase in increments of the preset memory page size to n preset memory page sizes; wherein the preset memory page size can be the size of one memory page defined in the computing integrated circuit, such as the memory page size of the Cambrian MLU370 integrated circuit (a computing integrated circuit) is 8KB. For example, the preset memory page size is 8KB, the number of preset memory pools (i.e., the memory pools in memory allocators 1 and 2) is 2, and the use of the two preset memory pools is distinguished by 1 megabyte (MB), that is, when the second size threshold is 1MB, the value of n in this embodiment can be 128, that is, n can be the quotient of the second size threshold and the preset memory page size; the page cache pool can include a free memory interval array, each array element of the free memory interval array is a memory interval linked list of the same size (i.e., the preset memory page size), and the corresponding relationship between the array subscript and the corresponding array element (memory interval linked list) is shown in Figure 5. The memory interval size in the array element corresponding to the array subscript 1 is 1 page (i.e., the preset memory page size), the memory interval size in the array element corresponding to the array subscript 2 is 2 pages, and the memory interval size in the array element corresponding to the array subscript 128 is 128 pages, that is, 128×8KB=1MB.

[0109] Correspondingly, the above-mentioned method of allocating the target page from the page cache pool to the shared memory pool can be set by the designer according to practical scenarios and user needs. For example, the target page can be a free preset page space with a minimum page space size greater than or equal to the memory size of the target memory block, that is, the page space size of the target page can be fixed; that is, in response to determining that there is a free preset page space with the target page space size in the page cache pool, the computing integrated circuit selects a free preset page space with the target page space size as the target page and allocates the target page to the shared memory pool; wherein the target page space size is the minimum page space size greater than or equal to the memory size of the target memory block. The target page can also be a minimum free preset page space greater than or equal to the target memory block, that is, a minimum preset page space greater than or equal to the free preset page space of the target memory block, that is, the page space size of the target page can be fluid and change with the status of the free preset page space; that is, in response to determining that there is a free preset page space greater than or equal to the target memory block in the page cache pool, the computing integrated circuit selects a free preset page space with the target page space size as the target page and allocates the target page to the shared memory pool.

[0110] Furthermore, in the above-mentioned process of allocating the target page from the page cache pool to the shared memory pool, if the target page does not exist in the page cache pool, the memory space of the target memory block can be directly requested from the remaining memory of the computing integrated circuit to allocate the memory space requested from the remaining memory of the computing integrated circuit to the current thread; or a fixed size (i.e., a preset memory request size) of memory space can be requested from the remaining memory of the computing integrated circuit to allocate part of the memory space requested from the remaining memory of the computing integrated circuit to the current thread. For example, the computing integrated circuit may determine whether there is free preset page space greater than or equal to the target memory block in the page cache pool; in response to determining that there is free preset page space greater than or equal to the target memory block in the page cache pool, select a smallest free preset page space greater than or equal to the target memory block as the target page, and allocate the target page to the shared memory pool; in response to determining that there is no free preset page space greater than or equal to the target memory block in the page cache pool, apply for memory space of a preset memory application size from the remaining memory of the computing integrated circuit, divide the target memory block from the memory space of the preset memory application size and assign it to the shared memory pool, and place the remaining memory space divided from the memory space of the preset memory application size into the page cache pool; wherein the preset memory application size is greater than the memory size of the target memory block, for example, the preset memory application size may be greater than or equal to n preset memory page sizes, for example, both n preset memory page sizes and the preset memory application size are a second size threshold (e.g., 1MB), or the preset memory application size may be less than n preset memory page sizes. As long as the preset memory application size is greater than the memory size of the target memory block, this embodiment does not impose any restrictions on this.

[0111] Accordingly, before applying for memory space of the preset memory application size from the remaining memory of the computing integrated circuit, it can also be determined whether there is free memory space (i.e., previously divided memory space) in the page cache pool that is greater than or equal to the target memory block; in response to determining that there is free memory space in the page cache pool that is greater than or equal to the target memory block, the target memory block is divided into the shared memory pool from the smallest memory space among these memory spaces; in response to determining that there is no free memory space in the page cache pool that is greater than or equal to the target memory block, the above-mentioned step of applying for memory space of the preset memory application size from the remaining memory of the computing integrated circuit is executed.

[0112] For example, when the shared memory pool applies for memory (i.e., target memory block) from the page cache pool, the page cache pool will search for a memory interval of appropriate size (e.g., target page) and return it to the shared memory pool. When searching for the target page, the page cache pool will convert the requested memory size (i.e., the memory size of the target memory block) into an integer multiple (rounded up) of the memory page size (i.e., the preset memory page size). For example, if m memory pages are ultimately required, the memory interval (i.e., the preset page space) will be searched from the array element with subscript m of the free memory interval array of the page cache pool. In response to determining that the memory interval has not been searched from the array element with subscript m of the free memory interval array of the page cache pool, interval, and then search from the array element with the m+1 index; in response to determining that the memory interval has not been found from the array element with the m+1 index of the free memory interval array of the page cache pool, then search from the array element with the m+2 index; if the m+1 index is searched to the array element with the subscript 128 and still no free memory interval is found, the page cache pool will call the memory request function in the runtime provided by the computing integrated circuit to request a fixed size (i.e., a preset memory request size, such as 1MB) of memory, and then this memory will be split out of the memory size requested by the shared memory pool and returned to the shared memory pool, and the remaining part will be split as a new memory interval and placed in the page cache pool. In response to determining that the memory is released, the shared memory pool may return the split memory interval to the page cache pool, and the returned memory interval will be cached in the page cache pool for subsequent use.

[0113] Step 104: In response to determining that the target memory allocation method is the second allocation method, obtain the mutex lock corresponding to the current thread of the target memory pool, and use the target memory pool to allocate memory space corresponding to the memory request for the current thread; wherein, the target memory pool is a preset memory pool corresponding to the memory size requested; the memory size requested corresponding to the target memory pool is larger than the memory size requested corresponding to the thread memory pool.

[0114] It should be noted that, in this embodiment, the preset memory pool can be a memory pool used to process memory requests with a large memory size (such as greater than a first size threshold). The number of preset memory pools in this embodiment can be set by the designer according to the usage scenario and user needs. For example, the number of preset memory pools can be 1, that is, the target memory pool is a fixed preset memory pool; the number of preset memory pools can also be a positive integer greater than 1, such as 2 or 3, that is, the target memory pool can be any preset memory pool, so that by setting multiple preset memory pools, multiple memory requests with large memory sizes can be processed in parallel. As shown in FIG2 , the number of preset memory pools can be 2, that is, one memory pool (i.e., preset memory pool) in each of memory allocator 1 and memory allocator 2.

[0115] Correspondingly, when the number of preset memory pools is not 1, before obtaining the mutex lock corresponding to the current thread of the target memory pool in this step, the following may also be included: a target memory pool determination process, such as determining the target memory pool by using a preset threshold range for selecting the preset memory pool. For example, when the number of preset memory pools is 2, that is, the preset memory pool includes a first memory pool and a second memory pool, the target memory pool determination process may include: determining whether the requested memory size of the memory application request is greater than a second size threshold (such as 1MB in Figure 2); in response to determining that the requested memory size of the memory application request is not greater than the second size threshold, determining the first memory pool as the target memory pool; in response to determining that the requested memory size of the memory application request is greater than the second size threshold, determining the second memory pool as the target memory pool; wherein the requested memory size corresponding to the second memory pool is greater than the requested memory size corresponding to the first memory pool. As shown in Figure 2, in response to determining that the applied memory size of the applied memory request is less than or equal to 64KB (i.e., the first size threshold), the memory application and release forwarder determines that the target memory allocation mode is the first allocation mode, so as to forward the applied memory request to the memory allocator 1 for processing; in response to determining that the applied memory size of the applied memory request is greater than 64KB, the memory application and release forwarder determines that the target memory allocation mode is the second allocation mode, and in response to determining that the applied memory size of the applied memory request is greater than 64KB and less than or equal to 1MB (i.e., the second size threshold), determines that the memory pool in the memory allocator 2 (i.e., the first memory pool) is the target memory pool, so as to forward the applied memory request to the memory allocator 2 for processing; in response to determining that the applied memory size of the applied memory request is greater than 1MB, determines that the memory pool in the memory allocator 3 (i.e., the second memory pool) is the target memory pool, so as to forward the applied memory request to the memory allocator 3 for processing.

[0116] It can be understood that, for the computing integrated circuit obtaining the mutex lock corresponding to the current thread of the target memory pool in this step, the method of using the target memory pool to allocate the memory space corresponding to the memory request for the current thread can be set by the designer according to practical scenarios and user needs. For example, in response to determining that the target memory pool has free memory blocks (i.e., memory space) greater than or equal to the memory size requested, the computing integrated circuit allocates the smallest memory block among these memory blocks to the current thread; in response to determining that the target memory pool does not have free memory blocks greater than or equal to the memory size requested, memory space of the memory size requested is applied for from the remaining memory of the computing integrated circuit and allocated to the current thread. The computing integrated circuit may also determine a target memory size based on the requested memory size of the requested memory request; wherein the target memory size is the product of the quotient of the requested memory size of the requested memory request and a third size threshold (such as 512) rounded up and multiplied by the third size threshold, that is, the target memory size is an integer multiple of the third size threshold; in response to determining that the target memory pool has free memory blocks (that is, memory space) greater than or equal to the target memory size, the smallest memory block among these memory blocks is allocated to the current thread; in response to determining that the target memory pool does not have free memory blocks greater than or equal to the target memory size, the target memory size is applied for from the remaining memory of the computing integrated circuit and allocated to the current thread.

[0117] Correspondingly, different preset memory pools may allocate memory space corresponding to the memory request for the current thread in different ways. For example, when the preset memory pool includes the first memory pool and the second memory pool, and the target memory pool is the first memory pool, the process of using the target memory pool to allocate memory space corresponding to the memory request for the current thread may include: determining the target memory size according to the memory size of the memory request; determining whether there is a free memory block greater than or equal to the target memory size in the target memory pool; in response to determining that there is a free memory block greater than or equal to the target memory size in the target memory pool, allocating the smallest memory block among the free memory blocks greater than or equal to the target memory size in the target memory pool to the current thread; In response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, it is determined whether the remaining memory of the computing integrated circuit has memory space of the target application size; wherein the target application size is the maximum value of the quotient of the remaining memory of the computing integrated circuit and a preset value (such as 4) and the target memory size, and the preset value is greater than 1; in response to determining that the remaining memory of the computing integrated circuit has memory space of the target application size, memory space of the target application size is applied for from the remaining memory of the computing integrated circuit, and memory space of the target application size is divided from the memory space of the target application size and allocated to the current thread, and the remaining memory space (i.e., memory block) divided from the memory space of the target application size is placed into the target memory pool.

[0118] Correspondingly, before the above-mentioned memory space of the target memory size is divided from the memory space of the target application size and allocated to the current thread, it may include: judging whether the quotient of the target application size and the target memory size is greater than or equal to a third size threshold; in response to determining that the quotient of the target application size and the target memory size is less than the third size threshold, allocating the memory space of the target application size to the current thread; in response to determining that the quotient of the target application size and the target memory size is greater than or equal to the third size threshold, dividing the memory space of the target memory size from the memory space of the target application size and allocating it to the current thread, and placing the remaining memory space divided from the memory space of the target application size into the target memory pool.

[0119] As shown in Figure 2, the memory allocator 2 can be responsible for the application and release of memory above 64KB and below 1MB; the memory allocator 2 can include a memory manager and a memory pool (i.e., the first memory pool). During the memory application process, the memory application request first passes through the memory manager. The memory manager will round up the size of the memory application to the third size threshold, that is, the memory application size becomes a multiple of 512, and this memory size (i.e., the target memory size) is set to a; then, the memory manager will search for a free memory block equal to or greater than a in the memory pool, and in response to determining that a free memory block equal to or greater than a is found in the memory pool, it returns; in response to determining that a free memory block equal to or greater than a is not found in the memory pool, the memory manager will call the memory application function during the operation of the computing integrated circuit to apply for memory, and the calculation method of the memory application size is the maximum value of a and one-quarter of the remaining memory of the computing integrated circuit (i.e., the preset value is 4), and in response to determining that the remaining memory of the computing integrated circuit is If the application fails due to insufficient memory, the memory manager will release the previously applied free complete memory blocks (i.e., complete memory space) cached in each memory pool (such as the first memory pool, the second memory pool, and the page cache pool) to the computing integrated circuit, and then reapply for memory; finally, the memory manager will determine whether the currently acquired memory size minus a is greater than or equal to 512 bytes. In response to determining that the currently acquired memory size minus a is less than 512 bytes, the acquired memory is returned; in response to determining that the currently acquired memory size minus a is greater than or equal to 512 bytes, the acquired memory is split into two memory blocks, the size of the first memory block is a, and the size of the second memory block is the remaining memory size. The first memory block is then returned, and the second memory block is placed in the memory pool.

[0120] Correspondingly, during the memory release process, the memory release request forwarded to the memory allocator 2 first passes through the memory manager. The parameters of the memory release request include a memory pointer (i.e., a memory pointer). The memory manager will search for this pointer in the allocated memory block, and after finding it, it will return the memory block to the memory pool (i.e., the first memory pool); then, the memory manager will determine whether this memory block is a memory block that has been split before. In response to determining that this memory block is a memory block that has been split before, it will recursively search for the previous memory block in the memory pool. In response to determining that the previous memory block exists in the memory pool, multiple memory blocks will be merged into one memory block; similarly, it will also recursively search for the next memory block in the memory pool. In response to determining that the next memory block exists in the memory pool, multiple memory blocks will be merged into one memory block, until the split memory blocks are released and can be merged into a complete memory block (i.e., a complete memory space).

[0121] Correspondingly, in the above-mentioned process of applying for memory space of the target application size from the remaining memory of the computing integrated circuit, it can be determined whether there is memory space of the target application size in the remaining memory of the computing integrated circuit; in response to determining that there is no memory space of the target application size in the remaining memory of the computing integrated circuit, the first memory pool and the second memory pool (or the first memory pool, the second memory pool and the page cache pool) are controlled to release their respective complete memory space; wherein, the complete memory space is the entire free memory space previously applied for from the computing integrated circuit; in response to determining that there is memory space of the target application size in the remaining memory of the computing integrated circuit, the memory space of the target application size of the computing integrated circuit is applied for.

[0122] Similarly, in the above-mentioned process of applying for memory space of the preset memory application size from the remaining memory of the computing integrated circuit, it can be determined whether there is memory space of the preset memory application size in the remaining memory of the computing integrated circuit; in response to determining that there is no memory space of the preset memory application size in the remaining memory of the computing integrated circuit, each preset memory pool and page cache pool is controlled to release their respective complete memory space; in response to determining that there is memory space of the preset memory application size in the remaining memory of the computing integrated circuit, memory space of the preset memory application size of the computing integrated circuit is applied for.

[0123] Accordingly, when the target memory pool is the second memory pool, the process of using the target memory pool to allocate memory space corresponding to the memory request for the current thread may include: determining whether the target memory pool has free memory blocks that are greater than or equal to the target memory size; in response to determining that the target memory pool has free memory blocks that are greater than or equal to the target memory size, allocating the smallest memory block among the free memory blocks that are greater than or equal to the target memory size in the target memory pool to the current thread; in response to determining that the target memory pool does not have free memory blocks that are greater than or equal to the target memory size, determining whether the remaining memory of the computing integrated circuit has memory space of the target memory size; in response to determining that the remaining memory of the computing integrated circuit does not have memory space of the target memory size, controlling the first memory pool and the second memory pool (or the first memory pool) to allocate memory space to the current thread. a memory pool, a second memory pool, and a page cache pool) to release their respective complete memory spaces; wherein the complete memory space is the entire free memory space previously applied for the computing integrated circuit; in response to determining that the remaining memory of the computing integrated circuit has memory space of the target memory size, applying for the remaining memory of the computing integrated circuit, and determining whether the difference between the memory size of the remaining memory and the target memory size is greater than or equal to a second size threshold; in response to determining that the difference between the memory size of the remaining memory and the target memory size is greater than or equal to the second size threshold, dividing the memory space of the target memory size from the remaining memory and allocating it to the current thread, and putting the remaining memory space divided from the remaining memory into the target memory pool; in response to determining that the difference between the memory size of the remaining memory and the target memory size is less than the second size threshold, allocating the remaining memory to the current thread.

[0124] As shown in FIG2 , the memory allocator 3 can be responsible for the application and release of memory larger than 1MB. During the memory application process, the memory application request first passes through the memory manager. The memory manager will round up the size of the memory application to 512, that is, the memory application size becomes a multiple of 512, and this memory size (that is, the target memory size) is set to a. Then, the memory manager will search for free memory blocks equal to or larger than a in the memory pool. In response to determining that free memory blocks equal to or larger than a are found in the memory pool, the memory manager returns. In response to determining that free memory blocks equal to or larger than a are not found in the memory pool, the memory manager will call the memory application function of the computing integrated circuit during operation to apply for memory. In response to determining that the remaining memory of the computing integrated circuit is If the application fails due to insufficient memory, the memory manager releases the previously applied free complete memory blocks cached in each memory pool (such as the first memory pool, the second memory pool and the page cache pool) to the computing integrated circuit; finally, the memory manager determines whether the currently acquired memory size minus a is greater than or equal to 1MB (i.e., the second size threshold), and in response to determining that the currently acquired memory size minus a is less than 1MB, the acquired memory is returned; in response to determining that the currently acquired memory size minus a is greater than or equal to 1MB, the acquired memory is split into two memory blocks, the size of the first memory block is a, and the size of the second memory block is the remaining memory size, and then the first memory block is returned, and the second memory block is placed in the memory pool.

[0125] Correspondingly, during the memory release process, the memory release request forwarded to the memory allocator 3 first passes through the memory manager. The parameters of the memory release request include a memory pointer. The memory manager will search for this pointer in the allocated memory block, and after finding it, it will return the memory block to the memory pool (i.e., the second memory pool); then, the memory manager will determine whether this memory block is a memory block that has been split before. In response to determining that this memory block is a memory block that has been split before, it will recursively search for the previous memory block in the memory pool. In response to determining that the previous memory block exists in the memory pool, multiple memory blocks will be merged into one memory block; similarly, it will also recursively search for the next memory block in the memory pool. In response to determining that the next memory block exists in the memory pool, multiple memory blocks will be merged into one memory block, until the split memory blocks are released and can be merged into a complete memory block (i.e., a complete memory space).

[0126] In this embodiment, the embodiment of the present application uses a preset memory pool and a thread memory pool for each thread to process memory requests with smaller memory size without acquiring a mutex lock, thereby reducing the time for memory application and release of the computing integrated circuit and improving the performance of memory application and release of the computing integrated circuit; and processes the preset memory pool with a mutex lock used for memory requests with larger memory size, and only processes the thread memory pool used for memory requests with smaller memory size, thereby reducing the waste of memory resources in the computing integrated circuit.

[0127] Based on the above embodiments, embodiments of the present application also provide a memory management method for a memory release process of a computing integrated circuit. In some embodiments, please refer to Figure 6, which is a flowchart of another memory management method for a computing integrated circuit provided by embodiments of the present application. The method may include:

[0128] Step 201: Get the memory release request of the current thread.

[0129] The memory release request in this embodiment may be a request for a thread to release memory.

[0130] Step 202: Determine a target memory allocation method according to the memory size released in the memory release request.

[0131] It is understood that the released memory size in this embodiment may be the memory size released by the memory release request. The target memory release method in this embodiment may be the memory allocation method used to process the memory release request; the target memory allocation method may be a first allocation method that uses the thread memory pool of the current thread for processing, or a second allocation method that uses a target memory pool for processing.

[0132] Step 203: In response to determining that the target memory allocation mode is the first allocation mode, according to the memory pointer in the memory release request, the memory space corresponding to the memory pointer is released to the thread memory pool of the current thread.

[0133] Correspondingly, as shown in Figure 2, after the memory space corresponding to the memory pointer is released to the thread memory pool of the current thread, it can be determined whether the memory space is the memory space previously obtained from the shared memory pool (that is, the above-mentioned target memory block); in response to determining that the memory space is the memory space previously obtained from the shared memory pool, the memory space is released to the shared memory pool.

[0134] Correspondingly, after releasing the memory space to the shared memory pool, it is also possible to determine whether the memory space is a segmented memory space; in response to determining that the memory space is a segmented memory space, recursively search and merge the free memory space adjacent to the memory space in the shared memory pool to obtain the complete memory space obtained from the page cache (such as the above-mentioned target page), and after obtaining the complete memory space obtained from the page cache, release the complete memory space to the page cache. After the complete memory space is released to the page cache, it is also possible to determine whether the memory space released to the page cache is a segmented memory space; in response to determining that the memory space released to the page cache is a segmented memory space, recursively search and merge the free memory space adjacent to the segmented memory space in the page cache to obtain the complete memory space previously requested from the computing integrated circuit (such as the above-mentioned complete memory space), and in response to determining that the remaining memory of the computing integrated circuit is insufficient, return it to the computing integrated circuit.

[0135] Step 204: In response to determining that the target memory allocation method is the second allocation method, a mutex lock corresponding to the current thread of the target memory pool is obtained, and according to the memory pointer in the memory release request, the memory space corresponding to the memory pointer is released to the target released memory pool; wherein, the target released memory pool is a preset memory pool corresponding to the released memory size; the released memory size corresponding to the target released memory pool is larger than the released memory size corresponding to the thread memory pool.

[0136] It is understandable that the memory management method for the memory release process provided in this embodiment can be implemented in a manner corresponding to the memory management method for the memory application process provided in the previous embodiment, and this embodiment does not impose any limitation on this.

[0137] Correspondingly, in this embodiment, after the computing integrated circuit releases the memory space corresponding to the memory pointer to the target released memory pool (such as the memory pool in the memory allocator 1 or 2 in Figure 2), it also includes: determining whether the memory space corresponding to the memory pointer in the target released memory pool is a segmented memory space; in response to determining that the memory space corresponding to the memory pointer in the target released memory pool is a segmented memory space, recursively searching and merging the free memory space adjacent to the memory space corresponding to the memory pointer in the target released memory pool to obtain the complete memory space previously requested from the computing integrated circuit (such as the above-mentioned complete memory space), and in response to determining that the remaining memory of the computing integrated circuit is insufficient, returning it to the computing integrated circuit.

[0138] Corresponding to the above method embodiment, an embodiment of the present application also provides a memory management device for a computing integrated circuit. The memory management device for a computing integrated circuit described below and the memory management method for a computing integrated circuit described above can refer to each other.

[0139] Please refer to Figure 7, which is a block diagram of a memory management device for a computing integrated circuit provided by an embodiment of the present application. The device may include:

[0140] An application acquisition module 10 is used to acquire an application memory request of a current thread; wherein the current thread is any thread of the computing integrated circuit;

[0141] An allocation determination module 20 is configured to determine a target memory allocation method based on the memory size requested by the memory application request;

[0142] A first application module 30 is configured to allocate memory space corresponding to the memory request for the current thread using a thread memory pool of the current thread in response to determining that the target memory allocation mode is the first allocation mode; wherein a thread memory pool is set for each thread in the computing integrated circuit;

[0143] The second application module 40 is used to obtain the mutex lock corresponding to the current thread of the target memory pool in response to determining that the target memory allocation method is the second allocation method, and use the target memory pool to allocate memory space corresponding to the application memory request for the current thread; wherein, the target memory pool is a preset memory pool corresponding to the application memory size; the application memory size corresponding to the target memory pool is larger than the application memory size corresponding to the thread memory pool.

[0144] In some embodiments, the first application module 30 can be used to obtain a target memory block from the thread memory pool of the current thread; wherein the target memory block is an idle preset memory block corresponding to the application memory size of the application memory request; and allocate the target memory block to the current thread.

[0145] In some embodiments, the first application module 30 may be configured to utilize the thread memory management instance of the current thread to obtain the target memory block from the thread memory pool of the current thread; and allocate the target memory block to the current thread.

[0146] In some embodiments, the thread memory pool of the current thread includes preset memory blocks of multiple preset sizes, and the target memory block is an idle preset memory block of a preset size corresponding to the memory size requested by the memory application in the thread memory pool of the current thread.

[0147] In some embodiments, the first application module 30 can be used to determine the target array index based on the application memory size of the application memory request; wherein, the thread memory pool of the current thread includes a free memory block array, and the free memory block array includes array elements with array indexes corresponding to various preset sizes, each array element is a memory block linked list of free preset memory blocks of the preset size corresponding to its own array index, and the target array subscript is the array subscript corresponding to any preset size; the target memory block is searched from the memory block linked list of the target array subscript.

[0148] In some embodiments, the first application module 30 may include:

[0149] The thread memory pool judgment submodule is used to judge whether the target memory block exists in the thread memory pool of the current thread;

[0150] The shared memory pool acquisition submodule is used to obtain the mutex lock corresponding to the current thread of the shared memory pool in response to determining that the target memory block does not exist in the thread memory pool of the current thread, and obtain the target memory block from the shared memory pool.

[0151] In some embodiments, the shared memory pool acquisition submodule may include:

[0152] A shared memory pool determination unit, configured to determine whether a target memory block exists in the shared memory pool;

[0153] The shared memory pool acquisition unit is configured to, in response to determining that the target memory block does not exist in the shared memory pool, split and acquire the target memory block from the target memory interval when the target memory interval exists in the shared memory pool; and, if the target memory interval does not exist in the shared memory pool, acquire a mutex corresponding to the current thread of the page cache pool, allocate a target page from the page cache pool to the shared memory pool, and use the target page as a memory interval of the shared memory pool; wherein the target page is an idle preset page space corresponding to the memory size of the target memory block, and the target memory interval is any memory interval in the shared memory pool that is greater than or equal to the memory size of the target memory block.

[0154] In some embodiments, the page cache pool includes preset page spaces of multiple preset page space sizes, the preset page space sizes including preset memory page sizes incremented by the preset memory page size to n preset memory page sizes, and the shared memory pool acquisition unit may include:

[0155] The page cache pool judgment subunit is used to judge whether there is free preset page space in the page cache pool that is greater than or equal to the target memory block;

[0156] a page cache pool allocation subunit, configured to, in response to determining that there is free preset page space greater than or equal to the target memory block in the page cache pool, select a minimum free preset page space greater than or equal to the target memory block as a target page, and allocate the target page to the shared memory pool;

[0157] The page cache pool application sub-unit is configured to, in response to determining that there is no free preset page space greater than or equal to the target memory block in the page cache pool, apply for memory space of a preset memory application size from the remaining memory of the computing integrated circuit, divide the target memory block from the memory space of the preset memory application size to the shared memory pool, and place the remaining memory space divided from the memory space of the preset memory application size into the page cache pool; wherein the preset memory application size is greater than or equal to n preset memory page sizes.

[0158] In some embodiments, the preset sizes include 8 bytes to 128 bytes in increments of 8 bytes, 144 bytes to 1024 bytes in increments of 16, 1152 bytes to 8192 bytes in increments of 128 bytes, and 9216 bytes to 65536 bytes in increments of 1024 bytes. The allocation determination module 20 can be used to determine whether the requested memory size of the memory application request is greater than a first size threshold; wherein the first size threshold is 65536 bytes; in response to determining that the requested memory size of the memory application request is not greater than the first size threshold, determining that the target memory allocation method is the first allocation method; in response to determining that the requested memory size of the memory application request is greater than the first size threshold, determining that the target memory allocation method is the second allocation method.

[0159] In some embodiments, the preset memory pool includes a first memory pool and a second memory pool, and the second application module 40 may include:

[0160] The storage pool determination submodule is used to determine whether the requested memory size of the memory application request is greater than a second size threshold; in response to determining that the requested memory size of the memory application request is not greater than the second size threshold, determine the first memory pool as the target memory pool; in response to determining that the requested memory size of the memory application request is greater than the second size threshold, determine the second memory pool as the target memory pool; wherein the requested memory size corresponding to the second memory pool is greater than the requested memory size corresponding to the first memory pool.

[0161] In some embodiments, when the target memory pool is the first memory pool, the second application module 40 may include:

[0162] A first determining submodule is configured to determine a target memory size according to a memory size requested by the memory application request; wherein the target memory size is the product of the quotient of the memory size requested by the memory application request and a third size threshold, rounded up, and multiplied by the third size threshold;

[0163] The first judgment submodule is used to judge whether there is a free memory block greater than or equal to the target memory size in the target memory pool;

[0164] a first allocation submodule, configured to allocate, in response to determining that a free memory block greater than or equal to the target memory size exists in the target memory pool, the smallest memory block among the free memory blocks greater than or equal to the target memory size in the target memory pool to the current thread;

[0165] a second determination submodule, configured to, in response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, determine whether there is memory space of the target application size in the remaining memory of the computing integrated circuit; wherein the target application size is the maximum value of the quotient of the remaining memory of the computing integrated circuit and a preset value, and the target memory size, where the preset value is greater than 1;

[0166] The second allocation submodule is used to apply for memory space of the target application size from the remaining memory of the computing integrated circuit in response to determining that there is memory space of the target application size in the remaining memory of the computing integrated circuit, and to divide the memory space of the target application size from the memory space of the target application size and allocate it to the current thread, and put the remaining memory space divided from the memory space of the target application size into the target memory pool.

[0167] In some embodiments, when the target memory pool is the second memory pool, the second application module 40 may include:

[0168] The third judgment submodule is used to judge whether there is a free memory block greater than or equal to the target memory size in the target memory pool;

[0169] a third allocation submodule, configured to allocate, in response to determining that the target memory pool has free memory blocks that are larger than or equal to the target memory size, the smallest memory block among the free memory blocks that are larger than or equal to the target memory size in the target memory pool to the current thread;

[0170] a fourth determination submodule, configured to, in response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, determine whether there is memory space of the target memory size in the remaining memory of the computing integrated circuit;

[0171] a release submodule, configured to control the first memory pool and the second memory pool to release their respective complete memory spaces in response to determining that the remaining memory of the computing integrated circuit does not have memory space of the target memory size; wherein the complete memory space is the entire free memory space previously requested from the computing integrated circuit;

[0172] a fifth determination submodule, configured to, in response to determining that the remaining memory of the computing integrated circuit has memory space of the target memory size, apply for the remaining memory of the computing integrated circuit, and determine whether a difference between the memory size of the remaining memory and the target memory size is greater than or equal to a second size threshold;

[0173] a fourth allocation submodule, configured to, in response to determining that a difference between a memory size of the remaining memory and a target memory size is greater than or equal to a second size threshold, split a memory space of the target memory size from the remaining memory and allocate it to the current thread, and place the remaining memory space split from the remaining memory into a target memory pool;

[0174] The fifth allocation submodule is configured to allocate the remaining memory to the current thread in response to determining that the difference between the memory size of the remaining memory and the target memory size is smaller than a second size threshold.

[0175] In some embodiments, the apparatus further comprises:

[0176] Release acquisition module, used to obtain the release memory request of the current thread;

[0177] A release determination module is used to determine a target memory allocation method according to a memory release size requested by the memory release request;

[0178] a first releasing module, configured to, in response to determining that the target memory allocation mode is the first allocation mode, release the memory space corresponding to the memory pointer to the thread memory pool of the current thread according to the memory pointer in the memory release request;

[0179] The second release module is used to, in response to determining that the target memory allocation method is the second allocation method, obtain the mutex lock corresponding to the current thread of the target memory pool, and release the memory space corresponding to the memory pointer to the target release memory pool according to the memory pointer in the memory release request; wherein the target release memory pool is a preset memory pool corresponding to the released memory size; the released memory size corresponding to the target release memory pool is larger than the released memory size corresponding to the thread memory pool.

[0180] In some embodiments, the second release module can also be used to determine whether the memory space corresponding to the memory pointer in the target release memory pool is a split memory space after releasing the memory space corresponding to the memory pointer to the target release memory pool; in response to determining that the memory space corresponding to the memory pointer in the target release memory pool is a split memory space, recursively search and merge the free memory space adjacent to the memory space corresponding to the memory pointer in the target release memory pool.

[0181] In this embodiment, the embodiment of the present application uses a preset memory pool and a thread memory pool for each thread to process memory requests with smaller memory size without acquiring a mutex lock, thereby reducing the time for memory application and release of the computing integrated circuit and improving the performance of memory application and release of the computing integrated circuit; and processes the preset memory pool with a mutex lock used for memory requests with larger memory size, and only processes the thread memory pool used for memory requests with smaller memory size, thereby reducing the waste of memory resources in the computing integrated circuit.

[0182] Corresponding to the above method embodiment, an embodiment of the present application further provides a computing integrated circuit. The computing integrated circuit described below and the memory management method of the computing integrated circuit described above can refer to each other.

[0183] Please refer to Figure 8, which is a schematic diagram of the structure of a computing integrated circuit provided in an embodiment of the present application. The computing integrated circuit may include one or more processors D2; and a memory D1 associated with the one or more processors. The memory is used to store computer-readable instructions, which, when read and executed by the one or more processors, implement the steps of the memory management method for the computing integrated circuit provided in the above method embodiment.

[0184] Corresponding to the above method embodiment, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium described below and the memory management method of a computing integrated circuit described above can refer to each other.

[0185] Please refer to Figure 9, which is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable storage medium 50 stores computer-readable instructions 51, which, when executed by a processor, implement the steps of the memory management method for a computing integrated circuit provided in the above method embodiment.

[0186] In some embodiments, the computer-readable storage medium 50 is a non-transitory computer-readable storage medium. The computer-readable storage medium 50 can be a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, among other storage media capable of storing program code.

[0187] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference will be made to the descriptions of the devices, integrated circuits, and computer-readable storage media disclosed in the embodiments for similarities and differences. Since these devices, integrated circuits, and computer-readable storage media, correspond to the methods disclosed in the embodiments, their descriptions are relatively brief. For relevant details, refer to the descriptions of the methods.

[0188] The above is a detailed introduction to the memory management method, device and computing integrated circuit provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A memory management method for a computing integrated circuit, characterized in that: include: Obtaining a memory request of a current thread; wherein the current thread is any thread of a computing integrated circuit; Determining a target memory allocation method according to the memory size requested by the memory application request; In response to determining that the target memory allocation mode is the first allocation mode, using the thread memory pool of the current thread to allocate the memory space corresponding to the application memory request to the current thread; wherein a thread memory pool is set for each of the threads in the computing integrated circuit; or In response to determining that the target memory allocation method is the second allocation method, a mutex lock corresponding to the current thread of the target memory pool is acquired, and the target memory pool is used to allocate memory space corresponding to the applied memory request to the current thread; wherein the target memory pool is a preset memory pool corresponding to the applied memory size; and the applied memory size corresponding to the target memory pool is larger than the applied memory size corresponding to the thread memory pool.

2. The memory management method of a computing integrated circuit according to claim 1, characterized in that: The utilizing the thread memory pool of the current thread to allocate the memory space corresponding to the memory application request to the current thread includes: Obtaining a target memory block from the thread memory pool of the current thread; wherein the target memory block is an idle preset memory block corresponding to the memory size requested by the memory request; and Allocates the target memory block to the current thread.

3. The memory management method of a computing integrated circuit according to claim 2, characterized in that: The step of obtaining the target memory block from the thread memory pool of the current thread includes: The target memory block is obtained from the thread memory pool of the current thread using the thread memory management instance of the current thread.

4. The memory management method of a computing integrated circuit according to claim 2, characterized in that: The thread memory pool of the current thread includes preset memory blocks of multiple preset sizes, and the target memory block is an idle preset memory block of a preset size corresponding to the application memory size of the application memory request in the thread memory pool of the current thread.

5. The memory management method of a computing integrated circuit according to claim 4, characterized in that: The step of obtaining the target memory block from the thread memory pool of the current thread includes: Determine the target array index according to the memory size requested by the memory application request; wherein the thread memory pool of the current thread includes a free memory block array, the free memory block array includes array elements of array indexes corresponding to various preset sizes, each of the array elements is a memory block linked list of free preset memory blocks of the preset size corresponding to the respective array index, and the target array index is an array index corresponding to any of the preset sizes; and The target memory block is searched from the memory block linked list of the target array index.

6. The memory management method of a computing integrated circuit according to claim 4, characterized in that: The step of obtaining the target memory block from the thread memory pool of the current thread includes: Determine whether the target memory block exists in the thread memory pool of the current thread; and In response to determining that the target memory block does not exist in the thread memory pool of the current thread, a mutex corresponding to the current thread of the shared memory pool is acquired, and the target memory block is acquired from the shared memory pool.

7. The memory management method of a computing integrated circuit according to claim 6, characterized in that: The obtaining the target memory block from the shared memory pool includes: Determine whether the target memory block exists in the shared memory pool; In response to determining that the target memory block does not exist in the shared memory pool, determining whether a target memory interval exists in the shared memory pool; In response to determining that a target memory interval exists in the shared memory pool, the target memory is obtained by segmenting the target memory interval. block; or In response to determining that the target memory interval does not exist in the shared memory pool, a mutex corresponding to the current thread of the page cache pool is acquired, a target page is allocated from the page cache pool to the shared memory pool, and the target page is used as the memory interval of the shared memory pool; wherein the target page is an idle preset page space corresponding to the memory size of the target memory block, and the target memory interval is any memory interval in the shared memory pool that is greater than or equal to the memory size of the target memory block.

8. The memory management method of a computing integrated circuit according to claim 7, characterized in that: The page cache pool includes preset page spaces of multiple preset page space sizes, wherein the preset page space sizes include the preset memory page size increasing by a preset memory page size to n preset memory page sizes, and the allocating a target page from the page cache pool to the shared memory pool includes: Determine whether there is a preset free page space in the page cache pool that is greater than or equal to the target memory block; In response to determining that there is a free preset page space greater than or equal to the target memory block in the page cache pool, selecting a minimum free preset page space greater than or equal to the target memory block as the target page, and allocating the target page to the shared memory pool; or In response to determining that there is no free preset page space greater than or equal to the target memory block in the page cache pool, a memory space of a preset memory application size is applied for from the remaining memory of the computing integrated circuit, and the target memory block is divided from the memory space of the preset memory application size to the shared memory pool, and the remaining memory space divided from the memory space of the preset memory application size is placed in the page cache pool; wherein the preset memory application size is greater than or equal to n preset memory page sizes.

9. The memory management method of a computing integrated circuit according to claim 4, characterized in that: The preset size includes 8 bytes to 128 bytes in increments of 8 bytes, 144 bytes to 1024 bytes in increments of 16 bytes, 1152 bytes to 8192 bytes in increments of 128 bytes, and 9216 bytes to 65536 bytes in increments of 1024 bytes. The target memory allocation method is determined according to the memory size requested by the memory application, including: Determine whether the memory size of the memory application request is greater than a first size threshold; wherein the first size threshold is 65536 bytes; In response to determining that the memory size requested by the memory request is not greater than a first size threshold, determining that the target memory allocation mode is the first allocation mode; or In response to determining that the memory size of the memory application request is greater than a first size threshold, determining that the target memory allocation mode is the second allocation mode.

10. The memory management method of a computing integrated circuit according to claim 1, characterized in that: The preset memory pool includes a first memory pool and a second memory pool. Before acquiring the mutex corresponding to the current thread of the target memory pool, the method further includes: Determine whether the memory size requested by the memory application request is greater than a second size threshold; In response to determining that the memory size of the memory application request is not greater than the second size threshold, determining the first memory pool as the target memory pool; or In response to determining that the requested memory size of the requested memory request is greater than the second size threshold, the second memory pool is determined as the target memory pool; wherein the requested memory size corresponding to the second memory pool is greater than the requested memory size corresponding to the first memory pool.

11. The memory management method of a computing integrated circuit according to claim 10, characterized in that: When the target memory pool is the first memory pool, allocating the memory space corresponding to the memory application request to the current thread by using the target memory pool includes: Determine a target memory size according to the memory size requested by the memory application request; wherein the target memory size is the product of the quotient of the memory size requested by the memory application request and a third size threshold value, rounded up, and the third size threshold value; Determine whether the target memory pool has a free memory block that is greater than or equal to the target memory size; In response to determining that the target memory pool has a free memory block that is greater than or equal to the target memory size, the target memory The smallest memory block among the free memory blocks in the pool that is greater than or equal to the target memory size is allocated to the current thread; In response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, determining whether there is memory space of a target application size in the remaining memory of the computing integrated circuit; wherein the target application size is a maximum value of a quotient of the remaining memory of the computing integrated circuit and a preset value and the target memory size, and the preset value is greater than 1; and In response to determining that the remaining memory of the computing integrated circuit has memory space of the target application size, applying for memory space of the target application size from the remaining memory of the computing integrated circuit, dividing the memory space of the target application size from the memory space of the target application size and allocating it to the current thread, and putting the remaining memory space divided from the memory space of the target application size into the target memory pool.

12. The memory management method of a computing integrated circuit according to claim 11, characterized in that: When the target memory pool is the second memory pool, allocating the memory space corresponding to the memory application request to the current thread by using the target memory pool includes: Determine whether the target memory pool has a free memory block that is greater than or equal to the target memory size; In response to determining that there are free memory blocks in the target memory pool that are larger than or equal to the target memory size, allocating the smallest memory block among the free memory blocks in the target memory pool that are larger than or equal to the target memory size to the current thread; In response to determining that the target memory pool does not have a free memory block greater than or equal to the target memory size, determining whether there is memory space of the target memory size in the remaining memory of the computing integrated circuit; In response to determining that the remaining memory of the computing integrated circuit does not have the memory space of the target memory size, controlling the first memory pool and the second memory pool to release their respective complete memory spaces; wherein the complete memory space is the entire free memory space previously applied to the computing integrated circuit; In response to determining that the remaining memory of the computing integrated circuit has memory space of the target memory size, applying for the remaining memory of the computing integrated circuit, and determining whether the difference between the memory size of the remaining memory and the target memory size is greater than or equal to the second size threshold; In response to determining that the difference between the memory size of the remaining memory and the target memory size is greater than or equal to the second size threshold, a memory space of the target memory size is divided from the remaining memory and allocated to the current thread, and the remaining memory space divided from the remaining memory is placed in the target memory pool; or In response to determining that the difference between the memory size of the remaining memory and the target memory size is less than the second size threshold, the remaining memory is allocated to the current thread.

13. The memory management method of a computing integrated circuit according to any one of claims 1 to 12, characterized in that: Also includes: Get the current thread's request to release memory; Determining a target memory allocation mode according to the memory size released by the memory release request; In response to determining that the target memory allocation mode is the first allocation mode, according to the memory pointer in the memory release request, the memory space corresponding to the memory pointer is released to the thread memory pool of the current thread; wherein a thread memory pool is set for each of the threads in the computing integrated circuit; or In response to determining that the target memory allocation method is the second allocation method, a mutex lock corresponding to the current thread of the target memory pool is obtained, and according to the memory pointer in the memory release request, the memory space corresponding to the memory pointer is released to the target released memory pool; wherein the target released memory pool is a preset memory pool corresponding to the released memory size; and the released memory size corresponding to the target released memory pool is larger than the released memory size corresponding to the thread memory pool.

14. The memory management method of a computing integrated circuit according to claim 13, characterized in that: After releasing the memory space corresponding to the memory pointer to the target released memory pool, the method further includes: Determining whether the memory space corresponding to the memory pointer in the target released memory pool is a segmented memory space; and In response to determining that the memory space corresponding to the memory pointer in the target released memory pool is a segmented memory space, recursively searching for and merging free memory spaces adjacent to the memory space corresponding to the memory pointer in the target released memory pool.

15. The memory management method of a computing integrated circuit according to claim 13, characterized in that: After the step of obtaining the memory release request of the current thread, the method further includes: The memory of the current thread is released through the thread memory management instance of the current thread.

16. The memory management method of a computing integrated circuit according to claim 15, characterized in that: The step of releasing the memory of the current thread through the thread memory management instance of the current thread includes: Determining whether the number of free memory blocks in the thread memory pool corresponding to the current thread exceeds a preset number; and In response to the number of free memory blocks in the thread memory pool corresponding to the current thread exceeding a preset number, the preset free memory blocks are returned to the shared memory pool.

17. The memory management method of a computing integrated circuit according to claim 1, characterized in that: After the step of determining the target memory allocation method according to the memory size requested for the memory application, the method further includes: The target memory allocation mode is forwarded to a corresponding memory allocator, so that a thread memory pool in the corresponding memory allocator processes the memory application request.

18. The memory management method of a computing integrated circuit according to claim 6, characterized in that: The obtaining the target memory block from the shared memory pool includes: Determining whether the target memory block exists in the shared memory pool; and In response to determining that the target memory block does not exist in the shared memory pool, the target memory block is acquired through the page cache pool.

19. A memory management device for a computing integrated circuit, characterized in that: include: An application acquisition module, used to acquire an application memory request of a current thread; wherein the current thread is any thread of a computing integrated circuit; An allocation determination module, used for determining a target memory allocation method according to the memory size requested by the memory application request; A first application module is configured to allocate memory space corresponding to the application memory request to the current thread using a thread memory pool of the current thread in response to determining that the target memory allocation mode is the first allocation mode; or The second application module is used to obtain the mutex lock corresponding to the current thread of the target memory pool in response to determining that the target memory allocation method is the second allocation method, and use the target memory pool to allocate the memory space corresponding to the applied memory request to the current thread; wherein the target memory pool is a preset memory pool corresponding to the applied memory size; the applied memory size corresponding to the target memory pool is larger than the applied memory size corresponding to the thread memory pool.

20. A computing integrated circuit, characterized in that: include: one or more processors; as well as A memory associated with the one or more processors, the memory being used to store computer-readable instructions, wherein the computer-readable instructions, when read and executed by the one or more processors, implement the steps of the memory management method for a computing integrated circuit as described in any one of claims 1 to 18.

Citation Information

Patent Citations

  • Internal memory operation management method and system

    CN101493787A

  • Memory allocation method and related equipment

    CN112214313A

  • Memory management method and device, equipment and storage medium

    CN117033002A

  • Memory management method and device for computing chip and computing chip

    CN117311997A

  • A memory management method for embedded system

    CN1635482A

Cited By

  • User mode memory management method, product, electronic equipment and storage medium

    CN120849136A