A GPU memory allocation processing method

By pre-applying for a memory pool when a process starts executing and allocating memory according to the request size, the problem of frequent GPU creation of page tables that affects performance is solved, achieving efficient memory management and performance improvement.

CN118349361BActive Publication Date: 2024-10-18沐曦集成电路(南京)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410765439.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-18
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

In the existing technology, processes frequently apply for small memory space from the GPU and quickly release it, causing the GPU to frequently establish and restore page tables, affecting performance.

Method used

When a process starts executing, a set of memory pools are requested from the GPU memory in advance, and whether to allocate memory from the GPU memory or the memory pool is determined based on the size of the memory application request to avoid unnecessary page table creation.

Benefits of technology

By pre-establishing page tables and rationally allocating memory pools, the number of times the GPU frequently establishes page tables is reduced, performance is improved, and the needs of different memory application requests are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118349361B_ABST
    Figure CN118349361B_ABST
Patent Text Reader

Abstract

The present application relates to the field of electronic digital data processing technology, and in particular to a method for processing GPU memory allocation. The method comprises: in response to the start of execution of a first process, applying for a first memory pool mp1 from the GPU memory for a memory application request of the first process; in response to a first memory application request req of the first process 1,1 If req 1,1 If the memory space to be applied for is less than or equal to the second preset storage space, then obtain the memory space in mp1 that matches req 1,1 Matching mp 1,i , and get the same as req 1,1 Matching mp 1,i The remaining memory space rm 1,i If rm 1,i Greater than or equal to req 1,1 If the memory space to be applied is 1,i Medium size for spa 1,1 The memory space is used for req 1,1 The present invention can solve the problem that the GPU performance is affected due to the process frequently applying for a small memory space from the GPU.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a processing method for GPU memory allocation. Background Art

[0002] In the prior art, every time a process sends a request to the GPU (such as HBM) to apply for memory space, the GPU will have a process of establishing a page table. The page table records the mapping relationship between the virtual address and the physical address corresponding to the memory space allocated by the GPU for the process. If the process frequently sends requests to the GPU for small memory spaces, and these small memory spaces are quickly released, the GPU will frequently establish page tables and restore memory, which makes the GPU busy and affects the performance of the GPU. Summary of the invention

[0003] The present invention aims to provide a method for processing GPU memory allocation to solve the above-mentioned problem that GPU performance is affected due to the frequent requests of processes for small memory spaces from the GPU.

[0004] According to the present invention, a method for processing GPU memory allocation is provided, the method comprising the following steps:

[0005] S100, in response to the first process starting to execute, applying for a first memory pool mp1 from the GPU memory for a memory application request of the first process; mp1=(mp 1,1 ,mp 1,2 ,…,mp 1,i ,…,mp 1,n ), mp 1,i is the i-th memory pool applied for the first process from the GPU memory, i ranges from 1 to n, and n is the number of preset memory pools; different mp 1,i The properties of each mp 1,i The memory space is less than or equal to the first preset storage space.

[0006] S200, responding to a first memory application request req of a first process 1,1 , execute S300.

[0007] S300, if req 1,1 If the memory space to be applied for is larger than the second preset storage space, the process proceeds to S400 ; otherwise, the process proceeds to S500 .

[0008] S400, apply for memory space from GPU memory for req 1,1 .

[0009] S500, get the value in mp1 and req 1,1 Matching mp1,i , and enter S600.

[0010] S600, get and req 1,1 Matching mp 1,i The remaining memory space rm 1,i If rm 1,i Greater than or equal to req 1,1 If the memory space to be applied is 1,i Medium size for spa 1,1 The memory space is used for req 1,1 ; Otherwise, apply for memory space from GPU memory for req 1,1 ; spa 1,1 For req 1,1 The size of the memory space to be applied for.

[0011] Compared with the prior art, the present invention has at least the following beneficial effects:

[0012] The present invention applies for a first memory pool from the GPU memory for a memory application request of the first process when the first process starts to execute. The first memory pool includes a plurality of memory pools, and the process of applying for the first memory pool has established a page table. Thereafter, when the first process sends the first memory application request to the GPU, it does not apply directly from the GPU memory as in the prior art, but first determines whether the size of the memory space to be applied for by the first memory application request is greater than the second preset storage space. If it is greater, it applies to the GPU memory. If it is less than or equal to the second preset storage space, it does not apply to the GPU memory, but applies from the first memory pool. Since the first memory pool is the memory space applied from the GPU memory when the first process starts to execute, a page table has been established, and the mapping relationship between the corresponding virtual address and the physical address is known. Therefore, when applying from the first memory pool, there is no need to establish a page table, which saves the time for establishing the page table. It is only necessary to send the corresponding address to the first process, thereby solving the problem of affecting GPU performance due to frequent establishment of page tables by the GPU in the prior art.

[0013] Moreover, the different memory pools included in the first memory pool of the present invention have different properties. When the size of the memory space to be applied for by the first memory application request is less than or equal to the second preset storage space, it is determined whether the remaining memory space of the memory pool matching the first memory application request can meet the needs of the first memory application. If so, memory space is allocated from the remaining memory space of the memory pool matching the first memory application request for the first memory application request. The different memory pools included in the first memory pool of the present invention have different properties and can meet the needs of different memory application requests of the first process. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] 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.

[0015] Figure 1 A flowchart of a method for processing GPU memory allocation provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0017] According to this embodiment, Figure 1 As shown, a method for processing GPU memory allocation is provided, and the method comprises the following steps:

[0018] S100, in response to the first process starting to execute, applying for a first memory pool mp1 from the GPU memory for a memory application request of the first process; mp1=(mp 1,1 ,mp 1,2 ,…,mp 1,i ,…,mp 1,n ), mp 1,i is the i-th memory pool applied for the first process from the GPU memory, i ranges from 1 to n, and n is the number of preset memory pools; different mp 1,i The properties of each mp 1,i The memory space is less than or equal to the first preset storage space.

[0019] As an optional specific implementation, the GPU memory is HBM (High Bandwidth Memory), that is, high bandwidth memory.

[0020] In this embodiment, the first preset storage space is an empirical value, which is a smaller value than the storage space of the GPU memory, such as 10M. 1,i The memory space of the present application is less than or equal to the first preset storage space. 1,i The storage space is also a smaller value relative to the storage space of the GPU memory, so as to be used for the smaller memory application request of the first process.

[0021] As an optional specific implementation, mp 1,i The memory size is an empirical value, for example, mp 1,i The memory space size is 2M or 10M; in this embodiment, different mp 1,i The memory space size is the same or different, for example, each mp 1,i The memory space size is the same, for example, both are 2M; or any two mp 1,i The memory space size is different, for example, n=4, mp 1,1 The memory space size is 2M, mp 1,2 The memory space size is 3M, mp 1,3 The memory space size is 5M, mp 1,4 The memory space size is 10M; or all mp 1,i Only part of the memory space size exists in mp 1,i The memory space size is the same, for example, n=4, mp 1,1 The memory space size is 2M, mp 1,2 The memory space size is 2M, mp 1,3 The memory space size is 5M, mp 1,4 The memory space size is 10M.

[0022] As a preferred embodiment, mp 1,i The process of obtaining the memory space size includes:

[0023] S110, obtaining a memory application request hreq issued by the first process in the target historical time period, hreq=(hreq1, hreq2, ..., hreq a ,…,hreq b ), hreq a is the ath memory application request issued by the first process within the target historical time period, where a ranges from 1 to b, and b is the number of memory application requests issued by the first process within the target historical time period.

[0024] In this embodiment, the length of the target historical time period is an empirical value.

[0025] S120, traverse hreq, if hreq a If the memory space to be applied for is less than or equal to the second preset storage space, hreq a Append to the first request sequence, and we get C=(creq1,creq2,…,creq f ,…,creq d ), creq fis the fth memory request appended to C, where f ranges from 1 to d, and d is the number of memory requests appended to C. C is initialized to an empty sequence.

[0026] In this embodiment, the size of the second preset storage space is an empirical value, and the second preset storage space is smaller than the first preset storage space. For example, the first preset storage space is 10M, and the second preset storage space is 100kb.

[0027] S130, traverse C, if creq f If it matches the i-th preset attribute set, then creq f Append to the i-th subsequence G i , and get G i =(greq i,1 ,greq i,2 ,…,greq i,v ,…,greq i,m ),greq i,v is the vth one added to G i The memory request of v ranges from 1 to m, where m is the memory to be added to G i The number of memory application requests; G i is initialized to an empty sequence.

[0028] In this embodiment, the attributes included in different preset attribute sets are not completely the same or are completely different, and the value range of i is 1 to n.

[0029] In this embodiment, when creq f When the memory space to be applied for has all the attributes included in the i-th preset attribute set, it is determined that creq f Matches the i-th preset attribute set. For example, if the i-th preset attribute set includes attributes that can be accessed by the CPU and attributes used for caching, then when creq f When the memory space to be applied for has the property of being accessible by the CPU and used for cache, the creq f matches the i-th preset attribute set; otherwise, determine creq f does not match the i-th preset attribute set. For another example, if the i-th preset attribute set includes attributes that cannot be accessed by the CPU and attributes that are not used for caching, then when creq f When the memory space to be applied for has the properties of being inaccessible to the CPU and not used for cache, the creq f matches the i-th preset attribute set; otherwise, determine creq f Does not match the i-th preset attribute set.

[0030] S140, Get G iThe total memory space u to be requested in the memory application request i ,u i =∑ m v=1 u i,v ,u i,v for greq i,v The size of the memory space to be applied for.

[0031] S150, will u i Determined as mp 1,i The size of the memory space.

[0032] Based on S110-S150, a better mp can be determined according to the memory application request of the first process in the target historical time period. 1,i The memory space size of the better mp 1,i The memory space size can ensure that there is enough memory space for small memory application requests when there is no significant increase in memory application requests in the first process, thereby avoiding the situation where small memory application requests are directly applied from the GPU memory, reducing the situation where the GPU frequently creates page tables and restores memory, and avoiding affecting the performance of the GPU.

[0033] S200, responding to a first memory application request req of a first process 1,1 , execute S300.

[0034] S300, if req 1,1 If the memory space to be applied for is larger than the second preset storage space, the process proceeds to S400 ; otherwise, the process proceeds to S500 .

[0035] S400, apply for memory space from GPU memory for req 1,1 .

[0036] In this embodiment, if req 1,1 The memory space to be applied for is larger than the second preset storage space, then req 1,1 The memory space to be applied for is a relatively large memory space. In order to avoid 1,i The remaining storage space is divided into req 1,1 The memory space to be applied for causes mp 1,i It is quickly used up, which leads to the problem that subsequent small memory requests are all directly requested from the GPU memory. 1,1 If the memory space to be applied for is larger than the second preset storage space, apply for memory space from the GPU memory for request 1,1 In this embodiment, applying for memory space from the GPU memory involves a process of establishing a page table.

[0037] S500, get the value in mp1 and req 1,1 Matching mp 1,i , and enter S600.

[0038] As a specific implementation, mp 1,i The attributes include a first attribute and a second attribute, wherein the first attribute is used to characterize mp 1,i Whether it can be accessed by the CPU, the second attribute is used to characterize the mp 1,i Whether to use it for caching. 1,1 Matching mp 1,i The acquisition process includes:

[0039] S510, if req 1,1 The memory space to be requested can be accessed by the CPU, then the process proceeds to S520; if req 1,1 If the memory space to be applied for cannot be accessed by the CPU, the process proceeds to S530.

[0040] S520, if req 1,1 If the memory space to be applied for is used for caching, the mp1 with the first attribute of being accessible by the CPU and the second attribute of being used for caching will be 1,i Determined to be consistent with req 1,1 Matching mp 1,i Otherwise, the mp1 with the first attribute of being accessible by the CPU and the second attribute of being not used for cache is 1,i Determined to be consistent with req 1,1 Matching mp 1,i .

[0041] S530, if req 1,1 If the memory space to be applied for is used for caching, the mp1 with the first attribute of being inaccessible to the CPU and the second attribute of being used for caching will be 1,i Determined to be consistent with req 1,1 Matching mp 1,i Otherwise, the mp1 with the first attribute of "cannot be accessed by the CPU" and the second attribute of "not used for cache" is 1,i Determined to be consistent with req 1,1 Matching mp 1,i .

[0042] S600, get and req 1,1 Matching mp 1,i The remaining memory space rm 1,i If rm 1,i Greater than or equal to req 1,1 If the memory space to be applied is 1,i Medium size for spa 1,1 The memory space is used for req1,1 ; Otherwise, allocate memory space from the GPU memory for req 1,1 ; spa 1,1 For req 1,1 The size of the memory space to be allocated

[0043] In this embodiment, rm 1,i =(rm 1 1,i , rm 2 1,i , …, rm x 1,i , …, rm y 1,i ), rm x 1,i Is the x - th consecutive memory space in rm 1,i , where the value range of x is from 1 to y, and y is the number of consecutive memory spaces in rm 1,i ; Then use the memory space with size spa 1,i In rm 1,1 For req 1,1 Includes:

[0044] S610, Initialize the first variable k to 1

[0045] S620, Determine whether rm k 1,i Is greater than or equal to the memory space required by req 1,1 To be allocated

[0046] S630, If rm k 1,i Is greater than or equal to the memory space required by req 1,1 To be allocated, enter S640; If rm k 1,i Is less than the memory space required by req 1,1 To be allocated, and k < y, then update k to k + 1, repeat S620 until rm k 1,i Is greater than or equal to the memory space required by req 1,1 To be allocated, and enter S640

[0047] In this embodiment, if k = y and rm k 1,i Is less than the memory space required by req 1,1 To be allocated, then send the corresponding multiple groups of starting addresses and ending addresses in rm 1,i To the first process, and the memory space between the starting address and the ending address of each group is rm 1,iThe memory space in each group, the memory space between the start address and the end address is used for req 1,1 , and the sum of the memory space corresponding to the multiple groups is equal to req 1,1 The memory space to be applied for.

[0048] S640, rm k 1,i The starting address is determined as req 1,1 The starting address of the requested memory space is sent to the first process.

[0049] In this embodiment, if rm k 1,i Greater than or equal to req 1,1 If the memory space to be applied is k 1,i The starting address is used as req 1,1 The starting address of the requested memory space will be rm k 1,i The size after the starting address is req 1,1 The memory space to be applied for is the memory space as req 1,1 Memory space requested.

[0050] In this embodiment, rm 1,i Medium size for spa 1,1 The memory space is used for req 1,1 The process of establishing the page table is no longer included. It only needs to send the address to the first process, which can solve the problem of GPU busyness caused by applying from GPU memory.

[0051] In this embodiment, when the first process starts to execute, the first memory pool is first applied for from the GPU memory for the memory application request of the first process. The first memory pool includes several memory pools, and the process of applying for the first memory pool has established a page table. Thereafter, when the first process sends the first memory application request to the GPU, it is not applied directly from the GPU memory as in the prior art, but first determines whether the size of the memory space to be applied for by the first memory application request is greater than the second preset storage space. If it is greater, it applies to the GPU memory. If it is less than or equal to, it does not apply to the GPU memory, but applies from the first memory pool. Since the first memory pool is the memory space applied from the GPU memory when the first process starts to execute, the page table has been established, and the mapping relationship between the corresponding virtual address and the physical address is known. Therefore, when applying from the first memory pool, there is no need to establish a page table, which saves the time of establishing the page table. It only needs to send the corresponding address to the first process, which solves the problem of affecting GPU performance due to frequent establishment of page tables by the GPU in the prior art.

[0052] Moreover, the different memory pools included in the first memory pool in this embodiment have different properties. When the size of the memory space to be applied for by the first memory application request is less than or equal to the second preset storage space, it is determined whether the remaining memory space of the memory pool matching the first memory application request can meet the needs of the first memory application. If so, memory space is allocated from the remaining memory space of the memory pool matching the first memory application request for the first memory application request. The different memory pools included in the first memory pool in this embodiment have different properties, which can meet the needs of different memory application requests of the first process.

[0053] In this embodiment, different processes correspond to different memory pools. For example, there is also a second process, and the GPU memory allocation processing method of this embodiment further includes the following steps:

[0054] S10, in response to the second process starting to execute, applying for a second memory pool mp2 from the GPU memory for a memory application request of the second process; mp2=(mp 2,1 ,mp 2,2 ,…,mp 2,j ,…,mp 2,n ), mp 2,j is the jth memory pool requested from the GPU memory for the second process, and the value of j ranges from 1 to n; different mp 2,j The properties of each mp 2,j The memory space is less than or equal to the first preset storage space.

[0055] In this embodiment, the number of memory pools included in the second memory pool is equal to the number of memory pools included in the first memory pool. 2,j can find mp with the same attributes in the first memory pool 1,i , however, the mp with the same attributes 1,i The memory size may be different from mp 2,j The memory space sizes are the same or different.

[0056] S20, responding to the first memory application request req of the second process 2,1 , execute S30.

[0057] S30, if req 2,1 If the memory space to be applied for is larger than the second preset storage space, the process proceeds to S40; otherwise, the process proceeds to S50.

[0058] S40, apply for memory space from GPU memory for req 2,1 .

[0059] S50, get the content of mp2 and req 2,1 Matching mp 2,j, and enter S60.

[0060] S60, get and req 2,1 Matching mp 2,j The remaining memory space rm 2,j If rm 2,j Greater than or equal to req 2,1 If the memory space to be applied is 2,j Medium size for spa 2,1 The memory space is used for req 2,1 ; Otherwise, apply for memory space from GPU memory for req 2,1 ; spa 2,1 For req 21 The size of the memory space to be applied for.

[0061] In this embodiment, S200-S600 is a method for processing a first memory application request of a first process. If the first process also sends a second memory application request to the GPU, then the method for processing GPU memory allocation in this embodiment further includes the following steps:

[0062] S700, responding to the second memory application request req of the first process 1,2 , execute S710.

[0063] S710, if req 1,2 If the memory space to be applied for is larger than the second preset storage space, the process proceeds to S720 ; otherwise, the process proceeds to S730 .

[0064] S720, apply for memory space from GPU memory for req 1,2 .

[0065] S730, obtain the content in mp1 and req 1,2 Matching mp 1,i , and enter S740.

[0066] S740, get and req 1,2 Matching mp 1,i The remaining memory space rm' 1,i If rm' 1,i Greater than or equal to req 1,2 If the memory space to be applied for is rm' 1,i Medium size for spa' 1,1 The memory space is used for req 1,2 ; Otherwise, apply for memory space from GPU memory for req 1,2 ; spa' 1,1 For req 1,2 The size of the memory space to be applied for.

[0067] In this embodiment, if the first process issues other memory application requests after issuing the second memory application request, the processing method for these other memory application requests is similar to S700-S740, which will not be repeated here.

[0068] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A method for processing GPU memory allocation, characterized in that: The method comprises the following steps: S100, in response to the first process starting to execute, applying for a first memory pool mp1 from the GPU memory for a memory application request of the first process; mp1=(mp 1,1 ,mp 1,2 ,…,mp 1,i ,…,mp 1,n ), mp 1,i is the i-th memory pool applied for the first process from the GPU memory, i ranges from 1 to n, and n is the number of preset memory pools; different mp 1,i The properties of each mp 1,i The memory space is less than or equal to the first preset storage space; S200, responding to a first memory application request req of a first process 1,1 , execute S300; S300, if req 1,1 If the memory space to be applied for is larger than the second preset storage space, then the process proceeds to S400; otherwise, the process proceeds to S500; S400, apply for memory space from GPU memory for req 1,1 ; S500, get the value in mp1 and req 1,1 Matching mp 1,i , and enter S600; S600, get and req 1,1 Matching mp 1,i The remaining memory space rm 1,i If rm 1,i Greater than or equal to req 1,1 If the memory space to be applied is 1,i Medium size for spa 1,1 The memory space is used for req 1,1 ; Otherwise, apply for memory space from GPU memory for req 1,1 ; spa 1,1 For req 1,1 The size of the memory space to be applied for; mp 1,i The attributes include a first attribute and a second attribute, wherein the first attribute is used to characterize mp 1,i Whether it can be accessed by the CPU, the second attribute is used to characterize the mp 1,i Whether to use for caching.

2. The method for processing GPU memory allocation according to claim 1, characterized in that: mp1 and req 1,1 Matching mp 1,i The acquisition process includes: S510, if req 1,1 The memory space to be requested can be accessed by the CPU, then the process proceeds to S520; if req 1,1 If the memory space to be applied for cannot be accessed by the CPU, the process proceeds to S530; S520, if req 1,1 If the memory space to be applied for is used for caching, the mp1 with the first attribute of being accessible by the CPU and the second attribute of being used for caching will be 1,i Determined to be consistent with req 1,1 Matching mp 1,i Otherwise, the mp1 with the first attribute of being accessible by the CPU and the second attribute of being not used for cache is 1,i Determined to be consistent with req 1,1 Matching mp 1,i ; S530, if req 1,1 If the memory space to be applied for is used for caching, the mp1 with the first attribute of being inaccessible to the CPU and the second attribute of being used for caching will be 1,i Determined to be consistent with req 1,1 Matching mp 1,i Otherwise, the mp1 with the first attribute of "cannot be accessed by the CPU" and the second attribute of "not used for cache" is 1,i Determined to be consistent with req 1,1 Matching mp 1,i .

3. The method for processing GPU memory allocation according to claim 1, characterized in that: The method further comprises the following steps: S10, in response to the second process starting to execute, applying for a second memory pool mp2 from the GPU memory for a memory application request of the second process; mp2=(mp 2,1 ,mp 2,2 ,…,mp 2,j ,…,mp 2,n ), mp 2,j is the jth memory pool requested from the GPU memory for the second process, where j ranges from 1 to n; different mp 2,j The properties of each mp 2,j The memory space is less than or equal to the first preset storage space; S20, responding to the first memory application request req of the second process 2,1 , execute S30; S30, if req 2,1 If the memory space to be applied for is larger than the second preset storage space, then the process goes to S40; otherwise, the process goes to S50; S40, apply for memory space from GPU memory for req 2,1 ; S50, get the content of mp2 and req 2,1 Matching mp 2,j , and enter S60; S60, get and req 2,1 Matching mp 2,j The remaining memory space rm 2,j If rm 2,j Greater than or equal to req 2,1 If the memory space to be applied is 2,j Medium size for spa 2,1 The memory space is used for req 2,1 ; Otherwise, apply for memory space from GPU memory for req 2,1 ; spa 2,1 For req 2,1 The size of the memory space to be applied for.

4. The method for processing GPU memory allocation according to claim 1, characterized in that: rm 1,i =(rm 1 1,i ,rm 2 1,i ,…,rm x 1,i ,…,rm y 1,i ), rm x 1,i For rm 1,i The xth address of the continuous memory space, the value range of x is 1 to y, y is rm 1,i The number of memory spaces with consecutive addresses in the 1,i Medium size for spa 1,1 The memory space is used for req 1,1 include: S610, initializing a first variable k to 1; S620, determine rm k 1,i Is it greater than or equal to req 1,1 The memory space to be applied for; S630, if rm k 1,i is greater than or equal to req 1,1 the memory space to be applied for, then enter S640; if rm k 1,i is less than req 1,1 the memory space to be applied for, and k < y, then update k to k + 1, repeat S620 until rm k 1,i is greater than or equal to req 1,1 the memory space to be applied for, enter S640; S640, rm k 1,i The starting address is determined as req 1,1 The starting address of the requested memory space is sent to the first process.

5. The method for processing GPU memory allocation according to claim 1, characterized in that: mp 1,i The process of obtaining the memory space size includes: S110, obtaining a memory application request hreq issued by the first process in the target historical time period, hreq=(hreq1, hreq2, ..., hreq a ,…,hreq b ), hreq a is the ath memory application request issued by the first process in the target historical time period, where a ranges from 1 to b, and b is the number of memory application requests issued by the first process in the target historical time period; S120, traverse hreq, if hreq a If the memory space to be applied for is less than or equal to the second preset storage space, hreq a Append to the first request sequence, and we get C=(creq1,creq2,…,creq f ,…,creq d ), creq f is the fth memory request appended to C, where f ranges from 1 to d, and d is the number of memory requests appended to C; C is initialized to an empty sequence; S130, traverse C, if creq f If it matches the i-th preset attribute set, then creq f Append to the i-th subsequence G i , and get G i =(greq i,1 ,greq i,2 ,…,greq i,v ,…,greq i,m ),greq i,v is the vth one added to G i The memory request of v ranges from 1 to m, where m is the memory to be added to G i The number of memory application requests; G i is initialized to an empty sequence; S140, Get G i The total memory space u to be requested in the memory application request i ,u i =∑ m v=1 u i,v ,u i,v for greq i,v The size of the memory space to be applied for; S150, will u i Determined as mp 1,i The size of the memory space.

6. The method for processing GPU memory allocation according to claim 5, characterized in that: If the i-th preset attribute set includes being accessible by the CPU and being used for caching, then when creq f When the memory space to be applied for can be accessed by the CPU and used for cache, the creq f matches the i-th preset attribute set; otherwise, determine creq f Does not match the i-th preset attribute set.

7. The method for processing GPU memory allocation according to claim 1, characterized in that: The GPU memory is HBM.

Citation Information

Patent Citations

  • Memory access system and method and medium

    CN115827502A

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

    CN117311997A