CN112860423A - Video memory management method and related product - Google Patents
Video memory management method and related product Download PDFInfo
- Publication number
- CN112860423A CN112860423A CN201911190181.8A CN201911190181A CN112860423A CN 112860423 A CN112860423 A CN 112860423A CN 201911190181 A CN201911190181 A CN 201911190181A CN 112860423 A CN112860423 A CN 112860423A
- Authority
- CN
- China
- Prior art keywords
- video memory
- memory block
- target
- memory capacity
- display
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000015654 memory Effects 0.000 title claims abstract description 599
- 238000007726 management method Methods 0.000 title claims abstract description 62
- 238000000034 method Methods 0.000 claims abstract description 43
- 238000004364 calculation method Methods 0.000 claims description 26
- 238000004590 computer program Methods 0.000 claims description 10
- 238000004891 communication Methods 0.000 claims description 5
- 230000009286 beneficial effect Effects 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 10
- 239000012634 fragment Substances 0.000 description 7
- 230000006978 adaptation Effects 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5011—Pool
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
Abstract
The embodiment of the application discloses a video memory management method and a related product, wherein the method comprises the following steps: receiving a video memory application, and acquiring initial video memory capacity required by the video memory application; determining the required target video memory capacity according to the initial video memory capacity; obtaining a target video memory block corresponding to the video memory application according to the target video memory capacity; and caching the file to be cached corresponding to the video memory application to the target video memory block. The embodiment of the application is beneficial to improving the utilization rate of the video memory block.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a video memory management method and a related product.
Background
With the development of artificial intelligence technology, the requirement on the computing performance is higher and higher, and adaptive caching of data required in the computing process is an important way for improving the computing performance. In the process of image Processing, image data is cached in a display and storage block managed by a Graphics Processing Unit (GPU), and in order to improve the use efficiency of the display and storage and improve the overall performance of system operation, a display and storage management module is adopted to complete the distribution and recovery of the display and storage block.
The method comprises the following steps that (1) aiming at the video memory application of a system, a fixed-size video memory block is allocated for the system each time to cache file data corresponding to the video memory application, but the size of the video memory block is set in advance by a user, if the size is too small, when a larger video memory application is met, the video memory block cannot meet the cache requirement, if the size is too large, and when a smaller video memory application is met, fragments in the allocated video memory block are too large; (2) the method can distribute the display and memory blocks with various sizes when the application sizes of the display and memory are different according to the application requests of the system, and when a new display and memory application is received, the distributed display and memory blocks cannot be reused, and the new display and memory blocks need to be redistributed every time, so that the display and memory blocks are utilized.
The existing video memory has single allocation mode and low utilization rate of video memory blocks.
Disclosure of Invention
The embodiment of the application provides a video memory management method and a related product, wherein a video memory block container pool is established in advance, and released video memory blocks are managed through the video memory block container pool, so that the reuse probability of the allocated video memory blocks is improved, the sizes of the video memory blocks are allocated through a calculation rule, and the sizes of fragments in the blocks of the allocated video memory blocks are reduced.
In a first aspect, an embodiment of the present application provides a video memory management method, including:
receiving a video memory application, and acquiring initial video memory capacity required by the video memory application;
determining the required target video memory capacity according to the initial video memory capacity;
obtaining a target video memory block corresponding to the video memory application according to the target video memory capacity;
and caching the file to be cached corresponding to the video memory application to the target video memory block.
In a second aspect, an embodiment of the present application provides a video memory management device, including:
the device comprises an acquisition unit, a storage unit and a display unit, wherein the acquisition unit is used for receiving a video memory application and acquiring the initial video memory capacity required by the video memory application;
the video memory capacity determining unit is used for determining the required target video memory capacity according to the initial video memory capacity;
a display and storage block determining unit, configured to obtain a target display and storage block corresponding to the display and storage application according to the target display and storage capacity;
and the cache unit is used for caching the file to be cached corresponding to the video memory application to the target video memory block.
In a third aspect, embodiments of the present application provide an electronic device, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for performing the steps in the method according to the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium, which stores a computer program, where the computer program makes a computer execute the method according to the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising a non-transitory computer-readable storage medium storing a computer program, the computer being operable to cause a computer to perform the method according to the first aspect.
The embodiment of the application has the following beneficial effects:
it can be seen that, in the embodiment of the present application, when a video memory application is received, a target video memory capacity is obtained according to the video memory application, and then a target video memory block corresponding to the target video memory capacity is searched for, because the target video memory capacity is matched with the video memory application, it is further ensured that a cache space (target video memory capacity) of the found target video memory block is matched with the video memory application, so that when a cache file corresponding to the video memory application is cached by using the target video memory block, the cache space of the target video memory block is adapted to the cache file, it is ensured as much as possible that fragments in the cache file to be cached are smaller when the target video memory block is used to cache the file to be cached, and the utilization rate of the target video memory block is improved
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1A is a schematic flowchart of a video memory management method according to an embodiment of the present disclosure;
fig. 1B is a schematic structural diagram of a video memory block container pool according to an embodiment of the present disclosure;
FIG. 1C is a schematic diagram of another container pool of display blocks according to an embodiment of the present disclosure;
FIG. 1D is a schematic diagram of another container pool of display blocks according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of another video memory management method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another video memory management method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a video memory management device according to an embodiment of the present disclosure;
fig. 5 is a block diagram illustrating functional units of a video memory management device according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, result, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
Referring to fig. 1A, fig. 1A is a video memory management method according to an embodiment of the present application, where the method is applied to a video memory management device, and the method includes, but is not limited to, the following steps:
101: the video memory management device receives a video memory application initiated by a user, and acquires an initial video memory capacity required by the video memory application.
The video memory management device according to the embodiment of the present application may include a smart Phone (such as an Android Phone, an iOS Phone, a Windows Phone, etc.), a tablet computer, a palm computer, a notebook computer, a Mobile Internet device MID (MID) or a wearable device, and the electronic Devices are merely examples, but not exhaustive, and include but are not limited to the electronic Devices, and in practical applications, the electronic Devices may further include: the application does not only limit the specific form of the video memory management device.
Optionally, the user may directly submit a video memory capacity application to the operating system, that is, the user directly inputs a video memory application of a specific video memory capacity, and directly requests the operating system to allocate a video memory block; or, the user submits a file caching application to the operating system, the operating system determines the caching size of the file to be cached, then the caching size is used as the initial video memory capacity, and a target video memory block corresponding to the initial video memory capacity is allocated.
102: and the video memory management device determines the required target video memory capacity according to the initial video memory capacity.
When the initial video memory capacity is less than or equal to the first threshold K, determining a target video memory capacity corresponding to the initial video memory capacity by using a first calculation rule (a first calculation formula), where the first calculation rule is as follows:
wherein F (x) is the target video memory capacity, x is the initial video memory capacity,for rounding-up operation, K is the first threshold, and K is 2nAnd n is a positive integer.
When the initial video memory capacity is greater than the first threshold but less than or equal to the second threshold, determining a target video memory capacity corresponding to the initial video memory capacity by using a second calculation rule (a second calculation formula), wherein the second calculation formula is as follows:
wherein F (x) is the target video memory capacity, x is the initial video memory capacity,for rounding-up operation, K is the first threshold, and K is 2nH is a second threshold, and H is 2mN and m are positive integers, and n is less than m.
103: and the video memory management device obtains a target video memory block corresponding to the video memory application according to the target video memory capacity.
Optionally, after obtaining the target video memory capacity, the video memory management device first searches whether a video memory block corresponding to the target video memory capacity exists in the video memory block container pool, if so, uses the video memory block as the target video memory block, and if not, invokes an Application Programming Interface (API) of a runtime library of the graphics processor GPU to divide the target video memory block corresponding to the target video memory capacity from the video memory of the video memory device.
The calling of the API to dynamically partition the video memory is prior art and will not be described.
104: and the video memory management device caches the file to be stored corresponding to the video memory application to the target video memory block.
It can be seen that, in the embodiment of the present application, when a video memory application is received, a target video memory capacity required by the video memory application is determined according to a calculation rule, then, whether a matched released video memory block exists is firstly queried from a video memory block container pool, if so, the released video memory block is used to cache a file to be cached corresponding to the video memory application, so as to improve a reuse probability of the released video memory block, and if not, the target video memory block corresponding to the target video memory capacity is dynamically partitioned from the video memory because the target video memory capacity is calculated from the video memory application, so as to improve a degree of adaptation of the target video memory block to the video memory application, thereby reducing intra-block fragments of the target video memory block, and improving a utilization rate of the video memory block.
In some possible embodiments, before receiving the video memory application, the method further includes: receiving a first threshold value and a second threshold value which are input, and creating a display block container pool according to the first threshold value and the second threshold value; the video memory block container pool is used for managing one or more video memory block groups, each video memory block group comprises one or more released video memory blocks with the same video memory capacity, each video memory block group corresponds to one index identifier, and the index identifier is used for representing the video memory capacity corresponding to each video memory block group.
Specifically, n first video memory block groups are determined according to a first calculation rule and a first threshold, and the video memory capacity corresponding to each first video memory block group of the n first video memory block groups is determined; determining p second video memory block groups according to the second calculation rule and the second threshold, and determining a video memory capacity corresponding to each second video memory block group in the p second video memory block groups; initializing the number of the video memory block groups managed by the video memory block container pool according to the n first video memory block groups and the p second video memory block groups, initializing the index identifier corresponding to each first video memory block group according to the video memory capacity corresponding to each first video memory block group, and initializing the index identifier corresponding to each second video memory block group according to the video memory capacity corresponding to each second video memory block group.
Specifically, when x is more than 0 and less than or equal to 21When the temperature of the water is higher than the set temperature,is 1, F (x) 21When 2 is present1<x≤22When the temperature of the water is higher than the set temperature,is 2, F (x) 22Therefore, when x is more than 0 and less than or equal to 2n(K) In the meantime, n video memory blocks (i.e. n first video memory blocks) are required to cache the file to be cached, which belongs to the video memory capacity range, and the video memory capacities corresponding to the n video memory blocks are 2 respectively1、22……2n(ii) a When 2 is inn<x≤2n+1When the temperature of the water is higher than the set temperature,f (x) (n +1-n +1) × K ═ 2 × K, when 2n+1<x≤2n+2Then, thenThe value of (a) is n +2, f (x) ═ K +2-n +1) ═ K is 3 × K, so when K is less than x and less than or equal to H, and the value range of f (x) is 2 × K … … (m-n +1) × K, the corresponding p (m-n) second video memory block groups are determined, and the video memory capacities of the p (m-n) second video memory block groups are respectively 2 × K … … (m-n +1) × K, so that, in summary, the video memory block container pool is used for managing m (n + m-n) video memory block groups, and the video memory capacities corresponding to the m video memory block groups are respectively 2 × K … … (m-n +1) × K1、22……2n(K),2*K……(m-n+1)*K。
Referring to fig. 1B, fig. 1B is a schematic structural diagram of a video memory block container pool provided in an embodiment of the present application, where the vector _0 is an index identifier of the container pool, and is used to indicate a first container pool vector _0 created according to a first threshold and a second threshold, where size _0, and size _0,size _1 and size _2 … size _ m are index identifiers corresponding to the video memory block group managed by the container pool vector _0, and when the first threshold and the second threshold input by the user are respectively K and H, the index identifiers size _0, size _1 and size _2 … size _ m may be initialized to 21、22……2n(K) 2 × K … … (m-n +1) × K, where each element in vector _1 is a display block in the display block group size _0, and the display capacity of the display block is the index identification size _ 0.
Optionally, based on the video memory block container pool established as described above, the implementation process of obtaining the target video memory block corresponding to the video memory application according to the target video memory capacity may be as follows: acquiring a target index identifier corresponding to the target video memory capacity from a pre-established video memory block container pool, wherein the video memory block container pool is used for managing one or more video memory block groups, each video memory block group comprises one or more released video memory blocks with the same video memory capacity, each video memory block group corresponds to one index identifier, and the index identifiers are used for representing the video memory capacity corresponding to each video memory block group; determining whether a target video memory block group corresponding to the target index identifier has an idle video memory block or not; and if the idle display memory blocks exist, selecting a target display memory block corresponding to the display memory application from the idle display memory blocks, wherein the target display memory block is any one of the idle display memory blocks.
In this example, a display and storage block container pool is established in advance, released display and storage blocks are managed in a unified manner, when a display and storage application is received, whether a corresponding target display and storage block exists in the display and storage block container pool is firstly inquired, if yes, the display and storage blocks are not divided, a file to be cached corresponding to the display and storage application is cached by using the released display and storage blocks, and the probability that the released display and storage blocks are used again is improved; moreover, the video memory block container pool establishes corresponding index identification for each video memory block group, and the efficiency of searching the target video memory block is improved.
Optionally, if there is no idle display memory block, calling an application program interface API of the runtime library of the image processor GPU to divide a target display memory block corresponding to the target display memory capacity from the display memory.
In this example, the video memory is divided according to the target video memory capacity, and since the target video memory capacity is calculated from the initial video memory capacity and the size difference between the target video memory capacity and the initial video memory capacity is small, fragments in the divided target video memory blocks are small when the files to be cached corresponding to the video memory application are cached, so that the utilization rate of the target video memory blocks is improved, and the waste of the video memory blocks is avoided.
In some possible embodiments, the method further comprises: and after releasing the target video memory block, storing the target video memory block in a storage position corresponding to the target index identifier in the video memory block container pool.
Specifically, if the target display block is a released display block in the display block container, the display block is released from the container pool by calling a runtime library API interface of the GPU, and the release process is consistent with the existing process of releasing the display, and will not be described in detail; if the target display block is a new display block divided by the GPU, releasing the target display block, acquiring the memory size of a file released from the target display block, calculating the display capacity corresponding to the target display block according to the memory size, inquiring an index identifier corresponding to the target display block in the display block container pool according to the display capacity, inquiring the storage position corresponding to the target display block according to the index identifier, and storing the target display block at the storage position.
It should be noted that, after the first initialization, there is no released display and memory block in the display and memory block container pool, so that when receiving a display and memory application, a target display and memory block can be directly partitioned from a display and memory through an API of a runtime library of a GPU, and it is not necessary to query whether there is a corresponding target display and memory block in the display and memory block container pool; in addition, as time goes on, a large number of released display blocks will be stored in each display block container pool, and if a user changes the first threshold and the second threshold, a new display block container pool needs to be created again, a large number of display block container pools are created, which is extremely not beneficial to the management of the display block container pools.
The following provides a method for managing a video memory block container pool, which includes, but is not limited to, the following steps:
a1: the video memory management device acquires a first threshold value and a second threshold value which are input for the first time.
A2: the video memory management device creates a first video memory container management pool according to a first threshold value and a second threshold value input for the first time.
Optionally, after the first video memory block container pool is created, the identification information of the working state of each video memory block group is added to the index identification corresponding to each video memory block group, where the working state of each video memory block group includes working state work and idle, as shown in fig. 1C, size _0_ work indicates that the working state of the 0 th video memory block group is work.
A3: and the video memory management device acquires the first threshold value and the second threshold value input for the second time to adjust the first video memory container management pool to obtain a second video memory container pool.
Optionally, adjusting the first video memory container pool based on the first threshold and the second threshold input for the second time includes expanding or reducing the first container pool, specifically, when the first threshold input for the second time is smaller than the first threshold input for the first time, it is determined that the number of the first video memory blocks required for the second time is less than the first time, then the n first video memory blocks required for the first time may be reduced, that is, the working state of the first video memory blocks required to be reduced for the n first video memory blocks is set to idle, as shown in fig. 1C, when the first threshold K input for the second time is 2rWhen r is 2, the operating states of the 3 rd to n th first video memory block groups may be set to idle, and when the first threshold value input for the second time is greater than the first threshold value input for the first time, it is determined that the number of the first video memory block groups required for the second time is greater than that of the first time, the n first video memory block groups input for the first time may be expanded, as shown in fig. 1D, and when the first threshold value K input for the second time is 2n+1If the number of the first video memory block groups needed for the second time is n +1, as shown in fig. 1, extending a first video memory block group size _ n +1 after size _ n _ working, and marking the working state as working, that is, obtaining size _ n +1_ working.
The management mode of the second video memory block group is consistent with that of the first video memory block group, and detailed description is omitted.
A4: and the video memory management device acquires the number of video memory blocks corresponding to each video memory group in each container management pool, and if the number is larger than a third threshold, deletes part of the video memory blocks larger than the third threshold.
Wherein the third threshold may be 5, 10, or other values.
In this example, the established video memory block container pool is managed, so that the number of the video memory block container pools is effectively reduced, and the efficiency of querying the target video memory block is improved.
Referring to fig. 2, fig. 2 is a diagram of another video memory management method according to an embodiment of the present application, where the method is applied to a video memory management device, and the method includes, but is not limited to, the following steps:
201: the video memory management device receives a first threshold value and a second threshold value which are input.
202: and the video memory management device creates a video memory block container pool according to the first threshold and the second threshold.
203: and the video memory management device receives the video memory application and acquires the initial video memory capacity required by the video memory application.
204: and the video memory management device determines the required target video memory capacity according to the initial video memory capacity.
205: and the video memory management device acquires a target index identifier corresponding to the target video memory capacity from the video memory block container pool.
206: the video memory management device determines whether a target video memory block group corresponding to the target index identifier has an idle video memory block or not;
if yes, go to step 207;
if not, go to step 208.
207: and the video memory management device selects a target video memory block corresponding to the video memory application from the idle video memory blocks, and caches the file to be cached corresponding to the video memory application to the target video memory block.
208: and calling an application program interface API of a runtime library of the GPU (graphics processing Unit) from the video memory by the video memory management device to divide a target video memory block corresponding to the target video memory capacity, and caching a file to be cached corresponding to the video memory application to the target video memory block.
It can be seen that, in the embodiment of the present application, a display block container pool is established in advance to manage released display blocks, so that when a display application is received, whether a matched released display block exists is firstly inquired from the display block container pool, and if the matched released display block exists, the released display block is adopted to cache a file to be cached corresponding to the display application, thereby improving the reuse probability of the released display block; if the target video memory capacity needed by the video memory application is determined according to the calculation rule, the target video memory block corresponding to the target video memory capacity is dynamically divided from the video memory according to the target video memory capacity calculated by the video memory application, so that the adaptation degree of the target video memory block and the video memory application is improved, the intra-block fragments of the target video memory block are reduced, and the utilization rate of the video memory block is improved.
It should be noted that, for the specific implementation of the steps of the method shown in fig. 2, reference may be made to the specific implementation of the method described in fig. 1A, and a description thereof is omitted here.
Referring to fig. 3, fig. 3 is a diagram of another video memory management method according to an embodiment of the present application, where the method is applied to a video memory management device, and the method includes, but is not limited to, the following steps:
301: the video memory management device receives a first threshold value and a second threshold value which are input.
302: and the video memory management device creates a video memory block container pool according to the first threshold and the second threshold.
303: and the video memory management device receives the video memory application and acquires the initial video memory capacity required by the video memory application.
304: and the video memory management device determines the required target video memory capacity according to the initial video memory capacity.
305: and the video memory management device acquires a target index identifier corresponding to the target video memory capacity from the video memory block container pool.
306: the video memory management device determines whether a target video memory block group corresponding to the target index identifier has an idle video memory block or not;
if yes, go to step 307;
if not, go to step 309.
307: and the video memory management device selects a target video memory block corresponding to the video memory application from the idle video memory blocks, and caches the file to be cached corresponding to the video memory application to the target video memory block.
308: and the video memory device calls an Application Program Interface (API) of a runtime library of the Graphics Processing Unit (GPU) to release the target video memory block, and stores the target video memory block in a storage position corresponding to the target index identifier in the video memory block container pool.
309: and calling an application program interface API of a runtime library of the GPU (graphics processing Unit) from the video memory by the video memory management device to divide a target video memory block corresponding to the target video memory capacity, and caching a file to be cached corresponding to the video memory application to the target video memory block.
310: and the video memory device calls an Application Program Interface (API) of a runtime library of the Graphics Processing Unit (GPU) to release the target video memory block, calculates the target video memory capacity corresponding to the target video memory block, and stores the target video memory block in a storage position corresponding to the target video memory capacity in the video memory block container pool.
It can be seen that, in this example, a display block container pool is established in advance to manage released display blocks, so that when a display application is received, whether matched released display blocks exist is firstly inquired from the display block container pool, and if matched released display blocks exist, the released display blocks are adopted to cache files to be cached corresponding to the display application, so that the reuse probability of the released display blocks is improved; if the target video memory capacity needed by the video memory application is determined according to the calculation rule, the target video memory block corresponding to the target video memory capacity is dynamically divided from the video memory according to the target video memory capacity calculated by the video memory application, so that the adaptation degree of the target video memory block and the video memory application is improved, the intra-block fragments of the target video memory block are reduced, and the utilization rate of the video memory block is improved; and no matter the target display and storage block is obtained from the display and storage block container pool or the newly divided target display and storage block is uniformly put into the display and storage block container pool for aggregate management after being released, so that the utilization rate of the released display and storage block is improved.
It should be noted that, for the specific implementation of the steps of the method shown in fig. 3, reference may be made to the specific implementation of the method described in fig. 1A, and a description thereof is omitted here.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a video memory management apparatus 400 according to an embodiment of the present disclosure, as shown in fig. 4, the video memory management apparatus 400 includes a processor, a memory, a communication interface, and one or more programs, and the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the following steps:
receiving a video memory application, and acquiring initial video memory capacity required by the video memory application;
determining the required target video memory capacity according to the initial video memory capacity;
obtaining a target video memory block corresponding to the video memory application according to the target video memory capacity;
and caching the file to be cached corresponding to the video memory application to the target video memory block.
In some possible embodiments, in determining the required target video memory capacity according to the initial video memory capacity, the program is specifically configured to execute the following instructions:
when the initial video memory capacity is smaller than or equal to a first threshold value, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a first preset calculation rule;
and when the initial video memory capacity is larger than the first threshold but smaller than or equal to a second threshold, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a second preset calculation rule.
In some possible embodiments, in terms of obtaining the target video memory block corresponding to the video memory application according to the target video memory capacity, the program is specifically configured to execute the following instructions:
acquiring a target index identifier corresponding to the target video memory capacity from a pre-established video memory block container pool, wherein the video memory block container pool is used for managing one or more video memory block groups, each video memory block group comprises one or more released video memory blocks with the same video memory capacity, each video memory block group corresponds to one index identifier, and the index identifiers are used for representing the video memory capacity corresponding to each video memory block group;
determining whether an idle display memory block exists in a target display memory block group corresponding to the target index identifier;
and if the idle display memory blocks exist, selecting a target display memory block corresponding to the display memory application from the idle display memory blocks, wherein the target display memory block is any one of the idle display memory blocks.
In some possible embodiments, the program is further for executing the instructions of:
and if the idle display memory block does not exist, calling an application program interface of the runtime library of the image processor to divide a target display memory block corresponding to the target display memory capacity from the display memory.
In some possible embodiments, the program is further for executing the instructions of:
and after releasing the target video memory block, storing the target video memory block in a storage position corresponding to the target index identifier in the video memory block container pool.
In some possible embodiments, before receiving the video memory application, the program is further configured to execute the following steps:
determining n first video memory block groups according to the first calculation rule and the first threshold value, and determining a video memory capacity corresponding to each first video memory block group of the n first video memory block groups;
determining p second video memory block groups according to the second calculation rule and the second threshold, and determining a video memory capacity corresponding to each second video memory block group in the p second video memory block groups;
initializing the number of the video memory block groups managed by the video memory block container pool according to the n first video memory block groups and the p second video memory block groups, initializing the index identifier corresponding to each first video memory block group according to the video memory capacity corresponding to each first video memory block group, and initializing the index identifier corresponding to each second video memory block group according to the video memory capacity corresponding to each second video memory block group.
Referring to fig. 5, fig. 5 is a block diagram illustrating functional units of a video memory management device according to an embodiment of the present disclosure. The video memory management device 500 includes: an obtaining unit 510, a video memory capacity determining unit 520, a video memory block determining unit 530, and a buffer unit 540, wherein:
an obtaining unit 510, configured to receive a video memory application, and obtain an initial video memory capacity required by the video memory application;
a video memory capacity determining unit 520, configured to determine a required target video memory capacity according to the initial video memory capacity;
a video memory block determining unit 530, configured to obtain, according to the target video memory capacity, a target video memory block corresponding to the video memory application;
and the caching unit 540 is configured to cache the file to be cached corresponding to the video memory application to the target video memory block.
In some possible embodiments, in determining the required target video memory capacity according to the initial video memory capacity, the video memory capacity determining unit 520 is specifically configured to:
when the initial video memory capacity is smaller than or equal to a first threshold value, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a first preset calculation rule;
and when the initial video memory capacity is larger than the first threshold but smaller than or equal to a second threshold, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a second preset calculation rule.
In some possible embodiments, in terms of obtaining the target video memory block corresponding to the video memory application according to the target video memory capacity, the video memory block determining unit 530 is specifically configured to:
acquiring a target index identifier corresponding to the target video memory capacity from a pre-established video memory block container pool, wherein the video memory block container pool is used for managing one or more video memory block groups, each video memory block group comprises one or more released video memory blocks with the same video memory capacity, each video memory block group corresponds to one index identifier, and the index identifiers are used for representing the video memory capacity corresponding to each video memory block group;
determining whether an idle display memory block exists in a target display memory block group corresponding to the target index identifier;
and if the idle display memory blocks exist, selecting a target display memory block corresponding to the display memory application from the idle display memory blocks, wherein the target display memory block is any one of the idle display memory blocks.
In some possible embodiments, the video memory block determining unit 530 is further configured to:
and if the idle display memory block does not exist, calling an application program interface of the runtime library of the image processor to divide a target display memory block corresponding to the target display memory capacity from the display memory.
In some possible embodiments, the video memory block management apparatus 500 further includes a releasing unit 550;
and a releasing unit 550, configured to, after releasing the target video memory block, store the target video memory block in a storage location corresponding to the target index identifier in the video memory block container pool.
In some possible embodiments, the video memory block management apparatus 500 further includes an initialization unit 560, before receiving the video memory application, the initialization unit 560 is configured to:
determining n first video memory block groups according to the first calculation rule and the first threshold value, and determining a video memory capacity corresponding to each first video memory block group of the n first video memory block groups;
determining p second video memory block groups according to the second calculation rule and the second threshold, and determining a video memory capacity corresponding to each second video memory block group in the p second video memory block groups;
initializing the number of the video memory block groups managed by the video memory block container pool according to the n first video memory block groups and the p second video memory block groups, initializing the index identifier corresponding to each first video memory block group according to the video memory capacity corresponding to each first video memory block group, and initializing the index identifier corresponding to each second video memory block group according to the video memory capacity corresponding to each second video memory block group.
The present application further provides a computer storage medium, where the computer storage medium stores a computer program, and the computer program is executed by a processor to implement part or all of the steps of any one of the video memory management methods described in the above method embodiments.
Embodiments of the present application further provide a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, where the computer program is operable to cause a computer to perform part or all of the steps of any one of the video memory management methods as described in the above method embodiments.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are exemplary embodiments and that the acts and modules referred to are not necessarily required in this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implementing, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may be implemented in the form of a software program module.
The integrated units, if implemented in the form of software program modules and sold or used as stand-alone products, may be stored in a computer readable memory. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, which may include: flash Memory disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the method and the core concept of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.
Claims (10)
1. A video memory management method is characterized by comprising the following steps:
receiving a video memory application, and acquiring initial video memory capacity required by the video memory application;
determining the required target video memory capacity according to the initial video memory capacity;
obtaining a target video memory block corresponding to the video memory application according to the target video memory capacity;
and caching the file to be cached corresponding to the video memory application to the target video memory block.
2. The method of claim 1, wherein determining the required target video memory capacity according to the initial video memory capacity comprises:
when the initial video memory capacity is smaller than or equal to a first threshold value, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a first preset calculation rule;
and when the initial video memory capacity is larger than the first threshold but smaller than or equal to a second threshold, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a second preset calculation rule.
3. The method of claim 2, wherein obtaining the target video memory block corresponding to the video memory application according to the target video memory capacity comprises:
acquiring a target index identifier corresponding to the target video memory capacity from a pre-established video memory block container pool, wherein the video memory block container pool is used for managing one or more video memory block groups, each video memory block group comprises one or more released video memory blocks with the same video memory capacity, each video memory block group corresponds to one index identifier, and the index identifiers are used for representing the video memory capacity corresponding to each video memory block group;
determining whether an idle display memory block exists in a target display memory block group corresponding to the target index identifier;
and if the idle display memory blocks exist, selecting a target display memory block corresponding to the display memory application from the idle display memory blocks, wherein the target display memory block is any one of the idle display memory blocks.
4. The method of claim 3, further comprising:
and if the idle display memory block does not exist, calling an application program interface of the runtime library of the image processor to divide a target display memory block corresponding to the target display memory capacity from the display memory.
5. The method according to claim 3 or 4, characterized in that the method further comprises:
and after releasing the target video memory block, storing the target video memory block in a storage position corresponding to the target index identifier in the video memory block container pool.
6. The method of claim 3 or 4, wherein before receiving the video memory application, the method further comprises:
determining n first video memory block groups according to the first calculation rule and the first threshold value, and determining a video memory capacity corresponding to each first video memory block group of the n first video memory block groups;
determining p second video memory block groups according to the second calculation rule and the second threshold, and determining a video memory capacity corresponding to each second video memory block group in the p second video memory block groups;
initializing the number of the video memory block groups managed by the video memory block container pool according to the n first video memory block groups and the p second video memory block groups, initializing the index identifier corresponding to each first video memory block group according to the video memory capacity corresponding to each first video memory block group, and initializing the index identifier corresponding to each second video memory block group according to the video memory capacity corresponding to each second video memory block group.
7. A video memory management device, comprising:
the device comprises an acquisition unit, a storage unit and a display unit, wherein the acquisition unit is used for receiving a video memory application and acquiring the initial video memory capacity required by the video memory application;
the video memory capacity determining unit is used for determining the required target video memory capacity according to the initial video memory capacity;
a display and storage block determining unit, configured to obtain a target display and storage block corresponding to the display and storage application according to the target display and storage capacity;
and the cache unit is used for caching the file to be cached corresponding to the video memory application to the target video memory block.
8. The apparatus of claim 7,
in terms of determining the required target video memory capacity according to the initial video memory capacity, the video memory capacity determining unit is specifically configured to:
when the initial video memory capacity is smaller than or equal to a first threshold value, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a first preset calculation rule;
and when the initial video memory capacity is larger than the first threshold but smaller than or equal to a second threshold, determining a target video memory capacity corresponding to the initial video memory capacity by adopting a second preset calculation rule.
9. An electronic device comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps of the method of any of claims 1-6.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which is executed by a processor to implement the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911190181.8A CN112860423A (en) | 2019-11-28 | 2019-11-28 | Video memory management method and related product |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911190181.8A CN112860423A (en) | 2019-11-28 | 2019-11-28 | Video memory management method and related product |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112860423A true CN112860423A (en) | 2021-05-28 |
Family
ID=75995403
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911190181.8A Pending CN112860423A (en) | 2019-11-28 | 2019-11-28 | Video memory management method and related product |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112860423A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
AT5729U1 (en) * | 2000-11-08 | 2002-10-25 | Kapsch Ag | METHOD AND PROGRAM LOGIC FOR THE DYNAMICALLY REQUIRED ALLOCATION AND RELEASE OF MEMORY BLOCKS |
CN101414281A (en) * | 2007-10-19 | 2009-04-22 | 大唐移动通信设备有限公司 | Internal memory management method and system |
US20090254731A1 (en) * | 2008-04-02 | 2009-10-08 | Qualcomm Incorporated | System and method for memory allocation in embedded or wireless communication systems |
CN105302738A (en) * | 2015-12-09 | 2016-02-03 | 北京东土科技股份有限公司 | Method and device for distributing memory |
CN105354147A (en) * | 2014-08-20 | 2016-02-24 | 腾讯科技(深圳)有限公司 | Memory pool management method and management system |
CN106327419A (en) * | 2015-06-24 | 2017-01-11 | 龙芯中科技术有限公司 | Distribution method and device of video random access memory blocks in graphic processing unit (GPU) display list |
CN109447253A (en) * | 2018-10-26 | 2019-03-08 | 杭州比智科技有限公司 | The method, apparatus of video memory distribution calculates equipment and computer storage medium |
CN109992422A (en) * | 2019-04-11 | 2019-07-09 | 北京朗镜科技有限责任公司 | A kind of method for scheduling task towards GPU resource, device and system |
CN110321448A (en) * | 2019-06-27 | 2019-10-11 | 腾讯科技(深圳)有限公司 | A kind of image search method, device and storage medium |
-
2019
- 2019-11-28 CN CN201911190181.8A patent/CN112860423A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
AT5729U1 (en) * | 2000-11-08 | 2002-10-25 | Kapsch Ag | METHOD AND PROGRAM LOGIC FOR THE DYNAMICALLY REQUIRED ALLOCATION AND RELEASE OF MEMORY BLOCKS |
CN101414281A (en) * | 2007-10-19 | 2009-04-22 | 大唐移动通信设备有限公司 | Internal memory management method and system |
US20090254731A1 (en) * | 2008-04-02 | 2009-10-08 | Qualcomm Incorporated | System and method for memory allocation in embedded or wireless communication systems |
CN105354147A (en) * | 2014-08-20 | 2016-02-24 | 腾讯科技(深圳)有限公司 | Memory pool management method and management system |
CN106327419A (en) * | 2015-06-24 | 2017-01-11 | 龙芯中科技术有限公司 | Distribution method and device of video random access memory blocks in graphic processing unit (GPU) display list |
CN105302738A (en) * | 2015-12-09 | 2016-02-03 | 北京东土科技股份有限公司 | Method and device for distributing memory |
CN109447253A (en) * | 2018-10-26 | 2019-03-08 | 杭州比智科技有限公司 | The method, apparatus of video memory distribution calculates equipment and computer storage medium |
CN109992422A (en) * | 2019-04-11 | 2019-07-09 | 北京朗镜科技有限责任公司 | A kind of method for scheduling task towards GPU resource, device and system |
CN110321448A (en) * | 2019-06-27 | 2019-10-11 | 腾讯科技(深圳)有限公司 | A kind of image search method, device and storage medium |
Non-Patent Citations (2)
Title |
---|
AMIT KUMAR: "A low overhead dynamic memory management system for constrained memory embedded systems", 《2015 2ND INTERNATIONAL CONFERENCE ON COMPUTING FOR SUSTAINABLE GLOBAL DEVELOPMENT (INDIACOM)》, 4 May 2015 (2015-05-04), pages 809 - 815 * |
张宇: "基于GPGPU技术的大规模地理数据的处理和分析", 《中国优秀硕士学位论文全文数据库 (信息科技辑)》, vol. 2014, no. 05, 15 May 2014 (2014-05-15), pages 140 - 615 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11656763B2 (en) | File management method, distributed storage system, and management node | |
EP3333718B1 (en) | Task allocation method and task allocation apparatus for distributed data calculation | |
US9798655B2 (en) | Managing a cache on storage devices supporting compression | |
EP3376393B1 (en) | Data storage method and apparatus | |
CN110297680B (en) | Method and device for transmitting virtual desktop image | |
CN109508235B (en) | Memory pool management method and device and computer readable storage medium | |
TWI627534B (en) | Method, computer readable storage medium and system for data caching | |
US9727479B1 (en) | Compressing portions of a buffer cache using an LRU queue | |
CN107533435B (en) | Storage space allocation method and storage equipment | |
CN111679921A (en) | Memory sharing method, memory sharing device and terminal equipment | |
EP3276494B1 (en) | Memory space management | |
CN106250061A (en) | File download processing method and processing device | |
CN107168891B (en) | I/O feature identification method and device | |
CN109086141B (en) | Memory management method and device and computer readable storage medium | |
CN105183399A (en) | Data writing and reading method and device based on elastic block storage | |
WO2024099448A1 (en) | Memory release method and apparatus, memory recovery method and apparatus, and computer device and storage medium | |
CN111475108A (en) | Distributed storage method, computer equipment and computer readable storage medium | |
CN109508304A (en) | A kind of processing method and processing device of memory management metadata | |
US8751724B2 (en) | Dynamic memory reconfiguration to delay performance overhead | |
CN104484132A (en) | Data reduction method and device | |
CN112269665B (en) | Memory processing method and device, electronic equipment and storage medium | |
CN112860423A (en) | Video memory management method and related product | |
US20190266191A1 (en) | Graph partitioning method and apparatus | |
CN110674086A (en) | Data merging method and device, electronic equipment and storage medium | |
CN110688223A (en) | Data processing method and related product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |