Memory allocation method, device, equipment, medium and product

By migrating the memory allocation process to the CPU and using the CPU to handle memory allocation tasks, the problem of low memory allocation efficiency of GPU is solved, memory allocation efficiency and resource utilization are improved, and the GPU can still manage memory efficiently when physical memory is limited.

CN118626272BActive Publication Date: 2024-11-12XIAN JIAOTONG LIVERPOOL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410962722.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-12
Estimated Expiration
2044-07-18

AI Technical Summary

Technical Problem

The memory allocation efficiency of GPUs is low, mainly because its computing architecture is more suitable for handling multi-parallel tasks, but is not completely suitable for handling multi-branch serial memory allocation tasks, resulting in inefficient memory allocation.

Method used

By migrating the memory allocation process to the CPU, using the CPU's computing architecture to process the characteristics of multi-branch serial tasks, the CPU obtains the GPU's memory allocation request, determines the target start address information of the memory to be allocated, and sends it to the GPU, so that the GPUs can focus more on the execution of multiple parallel tasks.

Benefits of technology

It improves the efficiency of memory allocation, optimizes the use of memory resources, allows the GPU to expand to host-side memory when physical memory is insufficient, and improves the overall performance and resource utilization of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626272B_ABST
    Figure CN118626272B_ABST
Patent Text Reader

Abstract

The present invention discloses a memory allocation method, device, equipment, medium and product, which relates to the field of computer technology, including: obtaining a memory allocation request sent by a GPU, and determining memory request amount information according to the memory allocation request; determining target start address information of the memory to be allocated from the host end memory according to the memory request amount information; sending the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information. The present invention migrates the memory allocation process to the CPU, and uses the characteristics of the CPU computing architecture that is good at processing multi-branch serial tasks to replace the GPU to execute the memory allocation process, thereby improving the allocation efficiency of memory allocation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a memory allocation method, device, equipment, medium and product. Background Art

[0002] GPU dynamic memory allocation technology enables developers to break free from the constraints of traditional static memory allocation that pre-evaluates memory usage, allowing resources to be dynamically allocated and released at runtime based on actual needs. This not only improves the accuracy of memory allocation, but also optimizes resource utilization, and is particularly suitable for application areas where memory estimation is difficult and computing patterns are dynamic, such as graph analysis, genomics, and sparse matrix operations.

[0003] Currently, the GPU's memory allocation process is mostly executed by the GPU itself. However, since the GPU's computing architecture is more suitable for processing multiple parallel tasks, and is not fully suitable for processing multi-branch serial tasks such as memory allocation, this will undoubtedly affect the efficiency of memory allocation. Summary of the invention

[0004] The present invention provides a memory allocation method, device, equipment, medium and product to solve the problem of low allocation efficiency in current memory allocation to a GPU.

[0005] According to one aspect of the present invention, a memory allocation method is provided, which is executed by a CPU and includes:

[0006] Obtaining a memory allocation request sent by the GPU, and determining memory request amount information according to the memory allocation request;

[0007] Determining target starting address information of memory to be allocated from the host-side memory according to the memory request amount information;

[0008] The target start address information is sent to the GPU, so that the GPU calls the memory to be allocated according to the target start address information.

[0009] According to another aspect of the present invention, a memory allocation method is provided, which is executed by a GPU and includes:

[0010] Obtaining a memory allocation request generated by at least one thread block; wherein the memory allocation request generated by any thread block is formed by aggregating memory allocation sub-requests of each thread included in the thread block;

[0011] Sending the memory allocation request to a CPU so that the CPU determines target starting address information of the memory to be allocated according to the memory allocation request;

[0012] The target start address information sent by the CPU is obtained, and the memory to be allocated is called for each thread block according to the target start address information.

[0013] According to another aspect of the present invention, there is provided a memory allocation device, which is configured in a CPU and includes:

[0014] A memory allocation request acquisition module, used to acquire a memory allocation request sent by the GPU, and determine memory request amount information according to the memory allocation request;

[0015] A target start address information determination module, used to determine the target start address information of the memory to be allocated from the host end memory according to the memory request amount information;

[0016] The target start address information sending module is used to send the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information.

[0017] According to another aspect of the present invention, there is provided a memory allocation device, which is configured in a GPU and includes:

[0018] A memory allocation request acquisition module, used to acquire a memory allocation request generated by at least one thread block; wherein the memory allocation request generated by any thread block is formed by aggregating the memory allocation sub-requests of each thread included in the thread block;

[0019] A memory allocation request sending module, used to send the memory allocation request to the CPU, so that the CPU determines the target starting address information of the memory to be allocated according to the memory allocation request;

[0020] The target start address information acquisition module is used to acquire the target start address information sent by the CPU, and call the memory to be allocated for each thread block according to the target start address information.

[0021] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0022] at least one processor; and

[0023] a memory communicatively connected to the at least one processor; wherein,

[0024] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the memory allocation method described in any one of the present invention.

[0025] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement any one of the memory allocation methods of the present invention when executed.

[0026] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the memory allocation methods of the present invention.

[0027] The present invention obtains a memory allocation request sent by a GPU by a CPU, and determines memory request amount information according to the memory allocation request; determines target start address information of the memory to be allocated from a host-side memory according to the memory request amount information; and sends the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information, thereby migrating the memory allocation process to the CPU, and utilizing the characteristic that the CPU computing architecture is good at processing multi-branch serial tasks to replace the GPU to execute the memory allocation process, thereby improving the allocation efficiency of memory allocation.

[0028] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0030] Figure 1 A flowchart of a memory allocation method provided in Embodiment 1 of the present invention;

[0031] Figure 2A A flowchart of a method for determining starting address information provided in Embodiment 2 of the present invention;

[0032] Figure 2B A schematic diagram of the structure of a target linked list provided in Embodiment 2 of the present invention;

[0033] Figure 3 A flowchart of a method for determining starting address information provided in Embodiment 3 of the present invention;

[0034] Figure 4 A flowchart of a memory allocation method provided in Embodiment 4 of the present invention;

[0035] Figure 5 A flowchart of a memory allocation method provided in Embodiment 5 of the present invention;

[0036] Figure 6 A schematic diagram of the structure of a memory allocation device provided in Embodiment 6 of the present invention;

[0037] Figure 7 A schematic diagram of the structure of a memory allocation device provided in Embodiment 7 of the present invention;

[0038] Figure 8 It is a structural schematic diagram of an electronic device for implementing the memory allocation method of an embodiment of the present invention. DETAILED DESCRIPTION

[0039] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0040] It should be noted that the terms "candidate", "target", "to be selected", "first", "second", "available", "to be released", "to be allocated", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. Embodiment 1

[0041] Figure 1 This is a flowchart of a memory allocation method provided in the first embodiment of the present invention. This embodiment is applicable to the case where a CPU responds to a memory allocation request sent by a GPU to allocate memory for a GPU. The method can be executed by a memory allocation device, which is configured in the CPU and can be implemented in the form of hardware and / or software. Figure 1 As shown, the method includes:

[0042] S101. Obtain a memory allocation request sent by a GPU, and determine memory request amount information according to the memory allocation request.

[0043] The memory allocation request is generated by the GPU and is used to request the CPU for the starting address information of the host-side memory that can be called. Since the GPU usually includes multiple thread blocks, and the number of thread blocks with memory call requirements may be one or more, when the number of thread blocks with memory call requirements in the GPU is one, the number of memory allocation requests sent by the GPU to the CPU is also one; when the number of thread blocks with memory call requirements in the GPU is multiple, the number of memory allocation requests sent by the GPU to the CPU is also multiple. In other words, the number of memory allocation requests received by the CPU is the same as the number of thread blocks with memory call requirements in the GPU.

[0044] Any memory allocation request carries memory request amount information, which is used to represent the amount of host-side memory that the corresponding memory allocation request expects to request. For example, if the memory request amount information carried in a memory allocation request is "50MB", then it means that the amount of host-side memory that the memory allocation request expects to request is "50MB".

[0045] In one embodiment, the GPU sends at least one memory allocation request to the CPU via the PCI bus, and correspondingly, the CPU obtains at least one memory allocation request from the CPU via the PCI bus. The CPU parses each memory allocation request to determine the memory request amount information respectively carried in each memory allocation request.

[0046] S102: Determine target start address information of the memory to be allocated from the host memory according to the memory request amount information.

[0047] The host memory refers to the memory installed on the host. The memory to be allocated refers to the memory in the host memory that can be used by the GPU. The target start address information is used to represent the start position of the address of the memory to be allocated in the host memory.

[0048] In one embodiment, the CPU obtains a preset memory amount threshold, and compares the memory request amount information carried by each memory allocation request with the preset memory amount threshold. The preset memory amount threshold is used to measure the size of each memory request amount information. It can be understood that if any memory request amount information is greater than or equal to the preset memory amount threshold, it means that the memory request amount information is large, that is, the GPU expects to call a larger amount of memory; if any memory request amount information is less than the preset memory amount threshold, it means that the memory request amount information is small, that is, the GPU expects to call a smaller amount of memory. In order to ensure the efficiency of determining the target starting address information, different determination schemes for the target starting address information are triggered according to the size relationship between the memory request amount information and the preset memory amount threshold.

[0049] Optionally, if the memory request amount information of any memory allocation request is less than the preset memory amount threshold:

[0050] This indicates that the memory allocation request is a small memory allocation request, that is, a regular memory allocation request. In this case, the host-side memory is evenly divided in advance to obtain at least one memory segment, and a corresponding candidate memory page is generated for each memory segment, and the occupancy status information of each candidate memory page is maintained accordingly according to the occupancy status of each memory segment.

[0051] The number of memory segments required for the memory allocation request is determined based on the memory request amount information and the memory amount information of the memory segments. The memory amount information of the memory segments is usually at the "kb" level, so it is suitable for small memory allocation requests. According to the number of memory segments, a target memory page is selected from candidate memory pages in an unoccupied state, and then the memory segment corresponding to the target memory page is used as the memory to be allocated, and the target starting address information is determined based on the memory segment corresponding to the target memory page.

[0052] Optionally, if the memory request amount information of any memory allocation request is greater than or equal to the preset memory amount threshold:

[0053] This indicates that the memory allocation request is a large memory allocation request. If the above method is still used to determine the target starting address information, since the memory amount information of the memory fragment is usually at the "kb" level, a large number of memory fragments are required to meet the demand, which in turn requires traversing the occupancy status information of a large number of candidate memory pages to finally determine the target memory page that meets the demand, which is very time-consuming.

[0054] Therefore, in this case, a target linked list containing at least one candidate node is maintained, where each candidate node corresponds to a candidate memory block, which is used to store the occupancy status information, starting address information, and memory size information of the corresponding candidate memory block. The memory size information of the candidate memory block is usually at the "mb" level or even at the "gb" level, which is much larger than the memory size information of the memory fragment.

[0055] According to the memory amount information and occupancy status information of each candidate node, the target node that meets the memory request amount information and is not occupied is determined, and finally the starting address information stored in the target node is used as the target starting address information.

[0056] By determining the target start address information of the memory to be allocated from the host-side memory according to the memory request amount information, the efficiency of memory allocation is ensured, the needs of the GPU can be quickly responded to, and the delay caused by memory search is reduced.

[0057] S103: Send the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information.

[0058] In one implementation, the CPU sends the target start address information to the GPU via the PCI bus. After receiving the target start address information, the GPU calls the memory to be allocated for each thread in the corresponding thread block according to the target start address information.

[0059] This embodiment obtains a memory allocation request sent by a GPU, and determines memory request amount information according to the memory allocation request; determines target start address information of the memory to be allocated from the host memory according to the memory request amount information; and sends the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information. The beneficial effects are:

[0060] First, by migrating the memory allocation process to the CPU and taking advantage of the CPU computing architecture's ability to handle multi-branch serial tasks, the GPU is used to execute the memory allocation process, thereby improving the efficiency of memory allocation.

[0061] Secondly, by migrating the memory allocation process to the CPU, the GPU can focus more on the execution of multiple parallel tasks without diverting some computing and memory resources to the memory allocation process.

[0062] Third, by determining the target start address information of the memory to be allocated from the host memory, it allows expansion to the host memory when the GPU physical memory is insufficient. This method optimizes the use of memory resources and allows the GPU to efficiently expand and manage memory when physical memory is limited. Embodiment 2

[0063] Figure 2A A flowchart of a method for determining the starting address information is provided for the second embodiment of the present invention. This embodiment provides an optional execution method for determining the target starting address information when the memory request amount information is greater than or equal to the preset memory amount threshold, and can be combined with the above-mentioned various optional implementation methods. Among them, the preset memory amount threshold is used to measure the size of the memory request amount information. It can be understood that if any memory request amount information is greater than or equal to the preset memory amount threshold, it means that the memory request amount information is large, that is, the GPU expects to call a larger amount of memory. Figure 2A As shown, the method includes:

[0064] S201. Obtain a target linked list including at least one candidate node; wherein each candidate node stores first occupancy status information, start address information, and first memory quantity information of a corresponding candidate memory block.

[0065] The target linked list is composed of at least one candidate node, and there is a pointing relationship between the candidate nodes. The candidate node represents a memory control unit, each candidate node uniquely corresponds to a candidate memory block, and is used to store the first occupancy state information, the starting address information and the first memory quantity information of the corresponding candidate memory block.

[0066] The candidate memory blocks are obtained by dividing the host-side memory. The first occupancy status information includes an occupied state and an unoccupied state. When the first occupancy status information of any candidate memory block is an occupied state, it indicates that the candidate memory block is being called and is temporarily unavailable for the GPU to call; when the first occupancy status information of any candidate memory block is an unoccupied state, it indicates that the candidate memory block is free and can be called by the GPU. The starting address information of any candidate memory block indicates the starting position of the address of the candidate memory block in the host-side memory. The first memory quantity information of any candidate memory block indicates the memory size of the candidate memory block. The first memory quantity information of the candidate memory block is usually at the "mb" level or even at the "gb" level, which can meet the needs of large memory allocation requests.

[0067] S202: Determine a target node from candidate nodes according to the first occupancy status information and the first memory amount information.

[0068] In one implementation, a candidate node whose first occupancy state information is unoccupied and whose first memory amount information is greater than or equal to the memory request amount information is used as a target node.

[0069] Optionally, determining the target node from the candidate nodes according to the first occupancy state information and the first memory amount information includes:

[0070] 1) At least one candidate node whose first occupancy state information is unoccupied and whose first memory amount information is greater than or equal to the memory request amount information is selected as a candidate node.

[0071] Among them, if the first occupancy status information stored in any candidate node is unoccupied, it means that the candidate memory block corresponding to the candidate node is free and can be called by the GPU; at the same time, if the first memory quantity information stored in the candidate node is greater than or equal to the memory request quantity information, it means that the memory size of the candidate memory block corresponding to the candidate node can meet the memory request quantity information, and then the candidate node is used as a candidate node to further evaluate whether it can be used as the final target node.

[0072] 2) The first memory amount information stored in each candidate node is used as the target memory amount information, and the memory amount difference information between each target memory amount information and the memory request amount information is determined respectively.

[0073] In one embodiment, the target memory information (first memory information) stored in each candidate node is respectively calculated with the memory request information to determine the memory difference information between each target memory information and the memory request information. For example, assuming that the target memory information stored in any candidate node is "60mb" and the memory request information is "50mb", the memory difference information between the target memory information stored in the candidate node and the memory request information is "10mb".

[0074] 3) Determine the target node from the candidate nodes based on the memory difference information.

[0075] In one implementation, each memory difference information is sorted, the minimum memory difference information is selected as the minimum memory difference information, and the candidate node storing the minimum memory difference information is used as the target node.

[0076] For example, assuming that there are candidate nodes 1, 2 and 3 in total, and assuming that the memory difference information corresponding to these three candidate nodes is calculated to be "10mb", "15mb" and "20mb" respectively, then candidate node 1 is selected as the target node.

[0077] By setting at least one candidate node whose first occupied state information is unoccupied and whose first memory capacity information is greater than or equal to the memory request capacity information as a candidate node; using the first memory capacity information stored in each candidate node as the target memory capacity information, and respectively determining the memory capacity difference information between each target memory capacity information and the memory request capacity information; determining the target node from the candidate nodes according to the memory capacity difference information, thereby avoiding waste of memory allocation as much as possible and improving the rationality of memory allocation while ensuring that the candidate memory block corresponding to the target node can meet the demand.

[0078] S203: Use the candidate memory block corresponding to the target node as the memory to be allocated, and use the starting address information stored in the target node as the target starting address information.

[0079] By obtaining a target linked list including at least one candidate node; wherein each candidate node stores first occupancy status information, starting address information and first memory amount information of a corresponding candidate memory block; determining a target node from the candidate nodes according to the first occupancy status information and the first memory amount information; taking the candidate memory block corresponding to the target node as the memory to be allocated, and taking the starting address information stored in the target node as the target starting address information. Since the first memory amount information of the candidate memory block is usually at the "mb" level or even at the "gb" level, it can meet the needs of large memory allocation requests. Therefore, when the memory request amount information is greater than or equal to a preset memory amount threshold, the above scheme is triggered. On the one hand, it can ensure that the memory size of the memory to be allocated can meet the call requirements of the GPU. On the other hand, it improves the efficiency of determining the target starting address information of the memory to be allocated in the scenario of large memory allocation requests.

[0080] Optionally, during the host-side memory release phase, if there are two adjacent candidate nodes in the target linked list whose first occupancy status information is both unoccupied, the two adjacent candidate nodes are directly merged to generate a new candidate node. In addition, the starting address information stored in the new candidate node is the starting address information stored in the candidate node that comes first in the order of the two adjacent candidate nodes; the first memory amount information stored in the new candidate node is the sum of the first memory amount information stored by the two adjacent candidate nodes. By merging the candidate nodes in the unoccupied state, memory fragmentation can be effectively reduced.

[0081] Figure 2B A schematic diagram of the structure of a target linked list provided in the second embodiment of the present invention is shown in FIG. Figure 2BAs shown, the target linked list includes candidate node 20, candidate node 21 and candidate node 22. Among them, in candidate node 20, "P" indicates that the first occupancy status information of the candidate memory block corresponding to candidate node 20 is occupied, "0" indicates the starting address information of the candidate memory block corresponding to candidate node 20, and "5" indicates the first memory quantity information of the candidate memory block corresponding to candidate node 20. In candidate node 21, "H" indicates that the first occupancy status information of the candidate memory block corresponding to candidate node 21 is unoccupied, "5" indicates the starting address information of the candidate memory block corresponding to candidate node 21, and "3" indicates the first memory quantity information of the candidate memory block corresponding to candidate node 21. In candidate node 22, "P" indicates that the first occupancy status information of the candidate memory block corresponding to candidate node 22 is occupied, "8" indicates the starting address information of the candidate memory block corresponding to candidate node 22, and "6" indicates the first memory quantity information of the candidate memory block corresponding to candidate node 22.

[0082] Understandably, Figure 2B It is only a schematic illustration of the structure of the target linked list, and does not limit the specific structure of the target linked list. Embodiment 3

[0083] Figure 3 A flowchart of a method for determining the starting address information is provided for the third embodiment of the present invention. This embodiment provides an optional execution method for determining the target starting address information when the memory request amount information is less than the preset memory amount threshold, and can be combined with the above-mentioned various optional implementation methods. Among them, the preset memory amount threshold is used to measure the size of the memory request amount information. It can be understood that if any memory request amount information is less than the preset memory amount threshold, it means that the memory request amount information is small, that is, the GPU expects to call a smaller amount of memory. Figure 3 As shown, the method includes:

[0084] S301. Obtain at least one candidate memory page.

[0085] Each candidate memory page corresponds to a memory segment, and the memory segment is obtained by evenly dividing the host memory. The second memory amount information of the memory segment is usually at the "kb" level, so it is suitable for small memory allocation requests.

[0086] S302: Determine the required number of memory segments according to the second memory amount information of the memory segments and the memory request amount information, as the required number of memory pages of the candidate memory pages.

[0087] The second memory capacity information indicates the memory size of the memory segment, and the second memory capacity information of each memory segment is the same.

[0088] In one implementation, a ratio calculation is performed based on the second memory amount information of the memory segment and the memory request amount information, and the required number of memory segments is determined based on the ratio calculation result as the required number of candidate memory pages.

[0089] For example, assuming that the memory request amount information is 14kb, and the second memory amount information of the memory segment is 2kb, the number of memory segments required is 14 / 2 = 7. For another example, assuming that the memory request amount information is 15kb, and the second memory amount information of the memory segment is 2kb, then 15 / 2 = 7.5, and the number of memory segments required is 8.

[0090] S303: Determine a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy status information of each candidate memory page.

[0091] Among them, the second occupancy status information of the candidate memory page reflects the occupancy status of the corresponding memory fragment, and the second occupancy status information includes an occupied state and an unoccupied state. When the second occupancy status information of any candidate memory page is an occupied state, it indicates that the corresponding memory fragment of the candidate memory page is being called and is temporarily unavailable for the GPU to call; when the second occupancy status information of any candidate memory page is an unoccupied state, it indicates that the corresponding memory fragment of the candidate memory page is free and can be called by the GPU.

[0092] In one implementation, at least one candidate memory page whose second occupation status information is an unoccupied state and satisfies the number of memory pages is used as a target memory page.

[0093] Optionally, determining the target memory page from the candidate memory pages according to the number of memory pages and the second occupancy state information of each candidate memory page includes:

[0094] The candidate memory page whose second occupation state information is unoccupied state is used as an available memory page; and the available memory page that satisfies the number of memory pages and has a continuous relationship is selected from the available memory pages as the target memory page.

[0095] In one implementation, the second occupancy status information of each candidate memory page is tracked by using the Bitfield technology, and the candidate memory page whose second occupancy status information is unoccupied is used as an available memory page. Then, at least one available memory page that meets the number of memory pages and has a continuous relationship is used as the target memory page.

[0096] Exemplarily, assuming that the number of memory pages is "8", 8 consecutive available memory pages are used as target memory pages.

[0097] By taking the candidate memory page whose second occupation state information is unoccupied as the available memory page; and selecting the available memory page that meets the number of memory pages and has a continuous relationship from the available memory pages as the target memory page, the demand of the small memory allocation request is met.

[0098] S304: Use the memory segment corresponding to the target memory page as the memory to be allocated, and use the starting address information of the memory segment corresponding to the first memory page as the target starting address information.

[0099] The first memory page is the candidate memory page with the first order in the target memory page. For example, assuming that the target memory page is candidate memory page 1-7, the start address information of the memory segment corresponding to candidate memory page 1 is used as the target start address information.

[0100] By obtaining at least one candidate memory page; wherein each candidate memory page corresponds to a memory fragment, and the memory fragments are obtained by evenly dividing the host-side memory; according to the second memory amount information of the memory fragment and the memory request amount information, the number of fragments of the required memory fragment is determined as the number of memory pages of the required candidate memory page; according to the number of memory pages and the second occupancy status information of each candidate memory page, the target memory page is determined from the candidate memory pages; the memory fragment corresponding to the target memory page is used as the memory to be allocated, and the starting address information of the memory fragment corresponding to the first memory page is used as the target starting address information; wherein the first memory page is the first candidate memory page in the target memory page, which can ensure that the memory size of the memory to be allocated can meet the call requirement of the GPU on the one hand, and on the other hand, because the memory amount information of the memory fragment is usually at the "kb" level, it can avoid the problem of memory allocation waste that is easy to occur in the small memory allocation request scenario. Embodiment 4

[0101] Figure 4 This is a flowchart of a memory allocation method provided in Embodiment 4 of the present invention. This embodiment further expands and optimizes the above embodiment and can be combined with the above optional implementation modes. Figure 4 As shown, the method includes:

[0102] S401. Obtain a memory allocation request sent by a GPU, and determine memory request amount information according to the memory allocation request.

[0103] S402: Determine target start address information of the memory to be allocated from the host memory according to the memory request amount information.

[0104] S403: Send the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information.

[0105] S404: Obtain a memory release request sent by the GPU, and determine the starting address information of the memory to be released according to the memory release request as auxiliary starting address information.

[0106] The memory release request is generated by the GPU to notify the CPU that the relevant host-side memory that has been called by the GPU can be released so that the relevant host-side memory can continue to be called by other objects. The memory release request carries the starting address information of the memory to be released as auxiliary starting address information.

[0107] S405: Determine the amount of memory to be released corresponding to the memory to be released according to the auxiliary starting address information, and release the memory to be released according to the auxiliary starting address information and the amount of memory to be released.

[0108] In one implementation, a mapping relationship table is maintained on the host side to record the mapping relationship between the "target starting address information" and the "memory amount of the memory to be allocated" allocated by the CPU to the GPU each time. When the CPU receives the memory release request sent by the GPU, it searches in the mapping relationship table according to the parsed auxiliary starting address information, and determines the memory amount with a mapping relationship with the auxiliary starting address information as the memory amount to be released corresponding to the memory to be released. Then, according to the auxiliary starting address information and the memory amount to be released, the memory to be released is released in the host side memory.

[0109] By obtaining the memory release request sent by the GPU, and determining the starting address information of the memory to be released according to the memory release request as the auxiliary starting address information; determining the amount of memory to be released corresponding to the memory to be released according to the auxiliary starting address information, and releasing the memory to be released according to the auxiliary starting address information and the amount of memory to be released, thereby timely releasing the relevant host-side memory that has been called by the GPU to ensure that the host-side memory can be reused.

[0110] Optionally, determining the amount of memory to be released corresponding to the memory to be released according to the auxiliary start address information includes:

[0111] 1) Determine the memory segment corresponding to the auxiliary start address information as the starting memory segment.

[0112] In one implementation, the auxiliary start address information is matched with the start address information corresponding to each memory segment obtained by pre-division, and the memory segment corresponding to the auxiliary start address information is determined according to the matching result as the start memory segment.

[0113] 2) The candidate memory page corresponding to the starting memory fragment is used as the starting memory page, and a hash calculation is performed according to the page identification information of the starting memory page to generate a target hash value.

[0114] The page identification information is identification information used to distinguish different candidate memory pages, and each candidate memory page uniquely corresponds to a piece of page identification information.

[0115] In one embodiment, a candidate memory page corresponding to the starting memory segment is determined as the starting memory page, and page identification information corresponding to the starting memory page is obtained. A preset hash function is used to perform hash calculation on the page identification information corresponding to the starting memory page to generate a target hash value.

[0116] Optionally, the following hash function is used to perform hash calculation on the page identification information corresponding to the starting memory page:

[0117] ;

[0118] Among them, Key represents the page identification information corresponding to the starting memory page. p is 0x45d9f3b, which is a relatively large prime number.

[0119] 3) Using the target hash value as an index to search in the hash table, determine at least one candidate data node associated with the target hash value, and determine the target data node from the candidate data nodes based on the page identification information and the node identification information of each candidate data node.

[0120] The hash table contains at least one candidate data node, and each candidate data node has an associated index. An index can be associated with one candidate data node or multiple candidate data nodes. The index is obtained by performing a hash calculation on the node identification information of the candidate data node, that is, candidate data nodes with the same hash calculation result are associated with the same index. The node identification information is identification information used to distinguish different candidate data nodes, and each candidate data node uniquely corresponds to a node identification information.

[0121] In one embodiment, the target hash value is used as an index to search in the hash table to determine at least one candidate data node associated with the target hash value among all candidate data nodes. The page identification information is matched with the node identification information of each candidate data node associated with the target hash value, and the candidate data node to which the node identification information identical to the page identification information belongs is used as the target data node according to the matching result.

[0122] 4) Obtain the number of memory segments to be released from the target data node, and determine the amount of memory to be released according to the number of memory segments to be released and the second memory amount information.

[0123] The number of memory segments stored in each candidate storage data node is used to indicate the number of memory segments allocated in the memory allocation node. The memory segments to be released are memory segments to be released.

[0124] In one implementation, the number of memory segments to be released is obtained from the target data node, and the amount of memory to be released is determined according to a product result between the number of memory segments to be released and the second memory amount information.

[0125] The memory segment corresponding to the auxiliary starting address information is determined as the starting memory segment; the candidate memory page corresponding to the starting memory segment is used as the starting memory page, and a hash calculation is performed according to the page identification information of the starting memory page to generate a target hash value; the target hash value is used as an index to search in a hash table to determine at least one candidate data node associated with the target hash value, and the target data node is determined from each candidate data node according to the page identification information and the node identification information of each candidate data node; the number of segments of the memory segment to be released is obtained from the target data node, and the amount of memory to be released is determined according to the number of segments of the memory segment to be released and the second memory amount information. Since the target hash value is used as an index to search in the hash table, the problem of low search efficiency due to excessive data volume can be avoided, thereby improving the search efficiency. Embodiment 5

[0126] Figure 5 This is a flowchart of a memory allocation method provided in Embodiment 5 of the present invention. This embodiment is applicable to the case where the GPU sends a memory allocation request to the CPU for memory call. The method can be executed by a memory allocation device, which is configured on the GPU and can be implemented in the form of hardware and / or software. Figure 5 As shown, the method includes:

[0127] S501: Obtain a memory allocation request generated by at least one thread block.

[0128] Among them, thread blocks are also called blocks. Each thread block consists of multiple threads. Each thread block is used to perform parallel data processing through each thread. The memory allocation request generated by any thread block is formed by aggregating the memory allocation sub-requests of each thread included in the thread block. For example, assuming that thread block A includes thread A1, thread A2, thread A3 and thread A4, then the memory allocation request generated by thread block A is formed by aggregating the memory allocation sub-requests of thread A1, thread A2, thread A3 and thread A4. For example, the reduction algorithm is used to aggregate the memory allocation sub-requests of thread A1, thread A2, thread A3 and thread A4 to generate the memory allocation request of thread block A. This process uses the reduction algorithm to optimize the time overhead of thread parallel operation, thereby reducing the waiting time.

[0129] S502: Send a memory allocation request to the CPU, so that the CPU determines target start address information of the memory to be allocated according to the memory allocation request.

[0130] In one embodiment, the GPU obtains memory allocation requests generated by each memory block, and sends the memory allocation requests generated by each memory block to the CPU, so that the CPU can determine memory request amount information based on the memory allocation request, and determine the target starting address information of the memory to be allocated from the host memory based on the memory request amount information.

[0131] S503: Obtain the target start address information sent by the CPU, and call the memory to be allocated for each thread block according to the target start address information.

[0132] In one embodiment, the GPU receives the target starting address information fed back by the CPU, and calls the memory to be allocated for the corresponding thread block based on the target starting address information. That is, if the target address information is determined based on the memory allocation request generated by thread block A, then the GPU calls the memory to be allocated for thread block A based on the target starting address information.

[0133] Specifically, according to the amount of memory requested by the memory allocation subrequest of each thread in the thread block, the memory to be allocated is called for each thread respectively. For example, assuming that the amount of memory requested by the memory allocation subrequest of thread 1 is 1mb, 1mb of memory is called for thread 1 based on the target starting address information, and the offset address information at this time is recorded; assuming that the amount of memory requested by the memory allocation subrequest of thread 2 is 2mb, 2mb of memory is called for thread 2 based on the offset address information, and the offset address information at this time is recorded again, and so on, until the memory to be allocated is called for all threads.

[0134] By obtaining a memory allocation request generated by at least one thread block; sending the memory allocation request to a CPU, so that the CPU determines the target starting address information of the memory to be allocated according to the memory allocation request; obtaining the target starting address information sent by the CPU, and calling the memory to be allocated for each thread block according to the target starting address information, the beneficial effects are:

[0135] First, by migrating the memory allocation process to the CPU and taking advantage of the CPU computing architecture's ability to handle multi-branch serial tasks, the GPU is used to execute the memory allocation process, thereby improving the efficiency of memory allocation.

[0136] Secondly, by migrating the memory allocation process to the CPU, the GPU can focus more on the execution of multiple parallel tasks without diverting some computing and memory resources to the memory allocation process.

[0137] Third, by determining the target start address information of the memory to be allocated from the host memory, it allows expansion to the host memory when the GPU physical memory is insufficient. This method optimizes the use of memory resources and allows the GPU to efficiently expand and manage memory when physical memory is limited.

[0138] Fourthly, the memory allocation requests generated by each thread block are uniformly sent to the CPU for processing, so as to reduce the overhead of frequent communication with the CPU.

[0139] Fifthly, the global lock for memory allocation is delegated to each thread block for autonomous scheduling, thereby reducing the reliance on the synchronization mechanism and the overhead caused by global synchronization.

[0140] Optionally, after sending the memory allocation request to the CPU and before obtaining the target start address information sent by the CPU, the following further includes:

[0141] Thread registration is performed for each thread included in each thread block.

[0142] In one embodiment, after the GPU sends a memory allocation request to the CPU, the CPU performs corresponding processing based on the memory allocation request. During this period, that is, before the GPU obtains the target start address information sent by the CPU, the GPU registers threads for each thread block so that each thread can perform data processing tasks normally.

[0143] By registering each thread included in each thread block after sending the memory allocation request to the CPU and before obtaining the target start address information sent by the CPU, this design effectively utilizes the waiting time of the CPU processing the memory allocation request, realizes the overlap of task execution, and greatly improves the computing resource utilization of the GPU and the throughput of the overall system. Embodiment 6

[0144] Figure 6 This is a schematic diagram of the structure of a memory allocation device provided in Embodiment 6 of the present invention, wherein the memory allocation device is configured in a CPU. Figure 6 As shown, the device comprises:

[0145] A memory allocation request acquisition module 61 is used to acquire a memory allocation request sent by the GPU and determine memory request amount information according to the memory allocation request;

[0146] A target start address information determination module 62, used to determine the target start address information of the memory to be allocated from the host end memory according to the memory request amount information;

[0147] The target start address information sending module 63 is used to send the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information.

[0148] Optionally, when the memory request amount information is greater than or equal to a preset memory amount threshold, the target start address information determination module 62 is specifically configured to:

[0149] Obtaining a target linked list including at least one candidate node; wherein each candidate node stores first occupancy status information, start address information, and first memory quantity information of a corresponding candidate memory block;

[0150] Determine a target node from candidate nodes according to the first occupancy state information and the first memory amount information;

[0151] The candidate memory block corresponding to the target node is used as the memory to be allocated, and the starting address information stored in the target node is used as the target starting address information.

[0152] Optionally, the target start address information determination module 62 is further configured to:

[0153] At least one candidate node whose first occupancy state information is unoccupied and whose first memory amount information is greater than or equal to the memory request amount information is selected as a candidate node;

[0154] The first memory amount information stored in each candidate node is used as the target memory amount information, and the memory amount difference information between each target memory amount information and the memory request amount information is respectively determined;

[0155] The target node is determined from the candidate nodes according to the memory difference information.

[0156] Optionally, when the memory request amount information is less than a preset memory amount threshold, the target start address information determination module 62 is specifically configured to:

[0157] Obtain at least one candidate memory page; wherein each candidate memory page corresponds to a memory fragment, and the memory fragment is obtained by evenly dividing the host-side memory;

[0158] Determine the required number of segments of the memory segment according to the second memory amount information of the memory segment and the memory request amount information as the required number of memory pages of the candidate memory page;

[0159] Determine a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy state information of each candidate memory page;

[0160] The memory segment corresponding to the target memory page is used as the memory to be allocated, and the starting address information of the memory segment corresponding to the first memory page is used as the target starting address information; wherein the first memory page is the candidate memory page with the first order in the target memory page.

[0161] Optionally, the target start address information determination module 62 is further configured to:

[0162] Using the candidate memory page whose second occupation state information is unoccupied as an available memory page;

[0163] Select an available memory page that satisfies the number of memory pages and has a continuous relationship from the available memory pages as the target memory page.

[0164] Optionally, the device further includes a memory release module, which is specifically used to:

[0165] Obtain a memory release request sent by the GPU, and determine the starting address information of the memory to be released according to the memory release request as auxiliary starting address information;

[0166] The amount of memory to be released corresponding to the memory to be released is determined according to the auxiliary starting address information, and the memory to be released is released according to the auxiliary starting address information and the amount of memory to be released.

[0167] Optional, memory release module, specifically used for:

[0168] Determine the memory segment corresponding to the auxiliary start address information as the start memory segment;

[0169] The candidate memory page corresponding to the starting memory fragment is used as the starting memory page, and a hash calculation is performed according to the page identification information of the starting memory page to generate a target hash value;

[0170] Using the target hash value as an index to search in the hash table, determining at least one candidate data node associated with the target hash value, and determining the target data node from the candidate data nodes according to the page identification information and the node identification information of each candidate data node;

[0171] The number of memory segments to be released is obtained from the target data node, and the amount of memory to be released is determined according to the number of memory segments to be released and the second memory amount information; wherein the memory segments to be released are memory segments to be released.

[0172] The memory allocation device provided in the embodiment of the present invention can execute the memory allocation method provided in embodiments 1 to 4 of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Embodiment 7

[0173] Figure 7This is a schematic diagram of the structure of a memory allocation device provided in Embodiment 7 of the present invention, wherein the memory allocation device is configured in a GPU. Figure 7 As shown, the device comprises:

[0174] A memory allocation request acquisition module 71 is used to acquire a memory allocation request generated by at least one thread block; wherein the memory allocation request generated by any thread block is formed by aggregating the memory allocation sub-requests of each thread included in the thread block;

[0175] A memory allocation request sending module 72, used to send a memory allocation request to the CPU, so that the CPU determines target start address information of the memory to be allocated according to the memory allocation request;

[0176] The target start address information acquisition module 73 is used to acquire the target start address information sent by the CPU, and call the memory to be allocated for each thread block according to the target start address information.

[0177] Optionally, the device further includes a thread registration module, which is specifically used to:

[0178] After sending the memory allocation request to the CPU and before obtaining the target start address information sent by the CPU, thread registration is performed for each thread included in each thread block.

[0179] The memory allocation device provided in the embodiment of the present invention can execute the memory allocation method provided in the fifth embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Embodiment 8

[0180] Figure 8 A schematic diagram of an electronic device 80 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0181] like Figure 8As shown, the electronic device 80 includes at least one processor 81, and a memory connected to the at least one processor 81 in communication, such as a read-only memory (ROM) 82, a random access memory (RAM) 83, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 81 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 82 or the computer program loaded from the storage unit 88 to the random access memory (RAM) 83. In the RAM 83, various programs and data required for the operation of the electronic device 80 can also be stored. The processor 81, ROM 82 and RAM 83 are connected to each other through a bus 84. An input / output (I / O) interface 85 is also connected to the bus 84.

[0182] A number of components in the electronic device 80 are connected to the I / O interface 85, including: an input unit 86, such as a keyboard, a mouse, etc.; an output unit 87, such as various types of displays, speakers, etc.; a storage unit 88, such as a disk, an optical disk, etc.; and a communication unit 89, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 89 allows the electronic device 80 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0183] The processor 81 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 81 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 81 executes the various methods and processes described above, such as a memory allocation method.

[0184] In some embodiments, the memory allocation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 88. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 80 via the ROM 82 and / or the communication unit 89. When the computer program is loaded into the RAM 83 and executed by the processor 81, one or more steps of the memory allocation method described above may be performed. Alternatively, in other embodiments, the processor 81 may be configured to execute the memory allocation method in any other appropriate manner (e.g., by means of firmware).

[0185] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0186] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0187] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0188] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0189] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0190] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0191] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0192] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A memory allocation method, characterized in that: Executed by the CPU, including: Obtaining a memory allocation request sent by the GPU, and determining memory request amount information according to the memory allocation request; Determining target starting address information of memory to be allocated from the host-side memory according to the memory request amount information; Sending the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information; Wherein, when the memory request amount information is greater than or equal to a preset memory amount threshold, determining the target starting address information of the memory to be allocated from the host-side memory according to the memory request amount information includes: Acquire a target linked list including at least one candidate node; wherein each candidate node stores first occupancy status information, start address information, and first memory amount information of a corresponding candidate memory block; Determine a target node from the candidate nodes according to the first occupancy status information and the first memory amount information; Using the candidate memory block corresponding to the target node as the memory to be allocated, and using the starting address information stored in the target node as the target starting address information; In a case where the memory request amount information is less than a preset memory amount threshold, determining target start address information of the memory to be allocated from the host-side memory according to the memory request amount information includes: Acquire at least one candidate memory page; wherein each of the candidate memory pages corresponds to a memory segment, and the memory segment is obtained by evenly dividing the host-side memory; Determining the required number of segments of the memory segment according to the second memory amount information of the memory segment and the memory request amount information as the required number of memory pages of the candidate memory page; Determining a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy status information of each of the candidate memory pages; The memory segment corresponding to the target memory page is used as the memory to be allocated, and the starting address information of the memory segment corresponding to the first memory page is used as the target starting address information; wherein the first memory page is the candidate memory page with the first order in the target memory page.

2. The method according to claim 1, characterized in that The determining the target node from the candidate nodes according to the first occupancy status information and the first memory amount information includes: At least one of the candidate nodes whose first occupation state information is unoccupied and whose first memory amount information is greater than or equal to the memory request amount information is used as a candidate node; Using the first memory amount information stored in each of the candidate nodes as the target memory amount information, and respectively determining the memory amount difference information between each of the target memory amount information and the memory request amount information; The target node is determined from the candidate nodes according to the memory amount difference information.

3. The method according to claim 1, characterized in that The step of determining a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy status information of each candidate memory page comprises: Using the candidate memory page whose second occupation status information is unoccupied as an available memory page; The available memory pages that meet the number of memory pages and have a continuous relationship are selected from the available memory pages as the target memory pages.

4. The method according to claim 1, after sending the target start address information to the GPU, further comprising: Obtaining a memory release request sent by the GPU, and determining starting address information of the memory to be released according to the memory release request as auxiliary starting address information; The amount of memory to be released corresponding to the memory to be released is determined according to the auxiliary starting address information, and the memory to be released is released according to the auxiliary starting address information and the amount of memory to be released.

5. The method according to claim 4, characterized in that The determining, according to the auxiliary starting address information, the amount of memory to be released corresponding to the memory to be released comprises: Determine the memory segment corresponding to the auxiliary starting address information as the starting memory segment; Taking the candidate memory page corresponding to the starting memory fragment as the starting memory page, and performing hash calculation according to the page identification information of the starting memory page to generate a target hash value; Using the target hash value as an index to search in a hash table, determining at least one candidate data node associated with the target hash value, and determining a target data node from each of the candidate data nodes according to the page identification information and the node identification information of each of the candidate data nodes; The number of memory segments to be released is obtained from the target data node, and the amount of memory to be released is determined according to the number of memory segments to be released and the second memory amount information; wherein the memory segments to be released are the memory segments to be released.

6. A memory allocation method, characterized in that: Executed by the GPU, including: Obtaining a memory allocation request generated by at least one thread block; wherein the memory allocation request generated by any thread block is formed by aggregating memory allocation sub-requests of each thread included in the thread block; Sending the memory allocation request to a CPU so that the CPU determines target starting address information of the memory to be allocated according to the memory allocation request; Acquire the target start address information sent by the CPU, and call the memory to be allocated for each thread block according to the target start address information; The target start address information is determined in the following manner: When the memory request amount information is greater than or equal to a preset memory amount threshold, a target linked list including at least one candidate node is obtained; wherein each candidate node stores first occupancy state information, start address information, and first memory amount information of a corresponding candidate memory block; Determine a target node from the candidate nodes according to the first occupancy status information and the first memory amount information; Using the candidate memory block corresponding to the target node as the memory to be allocated, and using the starting address information stored in the target node as the target starting address information; When the memory request amount information is less than a preset memory amount threshold, obtaining at least one candidate memory page; wherein each of the candidate memory pages corresponds to a memory fragment, and the memory fragment is obtained by evenly dividing the host-side memory; Determining the required number of segments of the memory segment according to the second memory amount information of the memory segment and the memory request amount information as the required number of memory pages of the candidate memory page; Determining a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy status information of each of the candidate memory pages; The memory segment corresponding to the target memory page is used as the memory to be allocated, and the starting address information of the memory segment corresponding to the first memory page is used as the target starting address information; wherein the first memory page is the candidate memory page with the first order in the target memory page.

7. The method according to claim 6, after sending the memory allocation request to the CPU and before obtaining the target start address information sent by the CPU, further comprising: Thread registration is performed for each thread included in each thread block.

8. A memory allocation device, characterized in that: Configured on the CPU, including: A memory allocation request acquisition module, used to acquire a memory allocation request sent by the GPU, and determine memory request amount information according to the memory allocation request; A target start address information determination module, used to determine the target start address information of the memory to be allocated from the host end memory according to the memory request amount information; a target start address information sending module, used to send the target start address information to the GPU, so that the GPU calls the memory to be allocated according to the target start address information; Wherein, when the memory request amount information is greater than or equal to a preset memory amount threshold, the target start address information determination module is specifically used to: Acquire a target linked list including at least one candidate node; wherein each candidate node stores first occupancy status information, start address information, and first memory amount information of a corresponding candidate memory block; Determine a target node from the candidate nodes according to the first occupancy status information and the first memory amount information; Using the candidate memory block corresponding to the target node as the memory to be allocated, and using the starting address information stored in the target node as the target starting address information; When the memory request amount information is less than a preset memory amount threshold, the target start address information determination module is specifically used to: Acquire at least one candidate memory page; wherein each of the candidate memory pages corresponds to a memory segment, and the memory segment is obtained by evenly dividing the host-side memory; Determining the required number of segments of the memory segment according to the second memory amount information of the memory segment and the memory request amount information as the required number of memory pages of the candidate memory page; Determining a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy status information of each of the candidate memory pages; The memory segment corresponding to the target memory page is used as the memory to be allocated, and the starting address information of the memory segment corresponding to the first memory page is used as the target starting address information; wherein the first memory page is the candidate memory page with the first order in the target memory page.

9. A memory allocation device, characterized in that: Configured on GPU, including: A memory allocation request acquisition module, used to acquire a memory allocation request generated by at least one thread block; wherein the memory allocation request generated by any thread block is formed by aggregating the memory allocation sub-requests of each thread included in the thread block; A memory allocation request sending module, used to send the memory allocation request to the CPU, so that the CPU determines the target starting address information of the memory to be allocated according to the memory allocation request; A target start address information acquisition module, used to acquire the target start address information sent by the CPU, and call the memory to be allocated for each thread block according to the target start address information; The target start address information is determined in the following manner: When the memory request amount information is greater than or equal to a preset memory amount threshold, a target linked list including at least one candidate node is obtained; wherein each candidate node stores first occupancy state information, start address information, and first memory amount information of a corresponding candidate memory block; Determine a target node from the candidate nodes according to the first occupancy status information and the first memory amount information; Using the candidate memory block corresponding to the target node as the memory to be allocated, and using the starting address information stored in the target node as the target starting address information; When the memory request amount information is less than a preset memory amount threshold, obtaining at least one candidate memory page; wherein each of the candidate memory pages corresponds to a memory fragment, and the memory fragment is obtained by evenly dividing the host-side memory; Determine, according to the second memory amount information of the memory segment and the memory request amount information, the required number of segments of the memory segment as the required number of memory pages of the candidate memory page; Determining a target memory page from the candidate memory pages according to the number of memory pages and the second occupancy status information of each of the candidate memory pages; The memory segment corresponding to the target memory page is used as the memory to be allocated, and the starting address information of the memory segment corresponding to the first memory page is used as the target starting address information; wherein the first memory page is the candidate memory page with the first order in the target memory page.

10. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the memory allocation method described in any one of claims 1-5 and / or 6-7.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute the memory allocation method described in any one of claims 1-5 and / or 6-7.

12. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the memory allocation method according to any one of claims 1-5 and / or 6-7.