A method and apparatus for allocating storage addresses for data in a memory

By building a tree structure in memory and separating the storage space and address allocation process, the problems of low storage space utilization and fragmentation are solved, and more efficient storage space management and data access are achieved.

CN113688063BActive Publication Date: 2025-07-29CAMBRICON TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010421439.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-18
Publication Date
2025-07-29
Estimated Expiration
2040-12-17

AI Technical Summary

Technical Problem

In the prior art, the utilization rate of storage space is low, which easily leads to the problem of fragmentation of storage space.

Method used

By a method of allocating storage addresses for data in memory, multiple storage blocks are formed and a tree-like structure is constructed to separate the allocation process of storage space and addresses, and the management of storage space is optimized.

Benefits of technology

It significantly improves the utilization rate of storage space, reduces the fragmentation of storage space, and improves data access efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113688063B_ABST
    Figure CN113688063B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, an apparatus, and a computing device for allocating storage addresses for data in a memory, where the computing device may be included in a combined processing device, and the combined processing device may further include a general-purpose interconnection interface and other processing devices. The computing device interacts with other processing devices to jointly complete a computing operation specified by a user. The combined processing device may further include a storage device, which is respectively connected to the computing device and other processing devices and is used for the data of the computing device and other processing devices. The technical solution of the present disclosure can improve the utilization rate of the storage space of the memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and more particularly, to the management of storage space. Background Art

[0002] Deep neural networks (DNNs) have been widely used in various applications such as computer vision, speech recognition, machine translation, and robotics because of their significantly improved accuracy compared to traditional machine learning methods. However, the performance advantages of DNNs come at the cost of extremely high computational and memory complexity, posing challenges to the underlying hardware architecture. To improve the efficiency of DNN processing, various dedicated accelerators have been proposed to provide better performance and efficiency than general-purpose architectures such as CPUs and GPUs.

[0003] Dedicated neural network accelerators typically require various novel architectural components, including control logic (e.g., DianNao uses a control processor with dedicated control instructions, while Eyeriss uses a two-level control hierarchy), computing units (e.g., DianNao uses 16 fixed functional units to exploit the fault-tolerant features of intelligent applications), and application programs), and memory hierarchies (e.g., DianNao proposes using separate on-chip storage for neurons and weights).

[0004] The scratchpad memory (SPM) of the prior art is crucial for flexibly controlling expensive data transfers. There are three reasons for using SPM in neural network accelerators: 1) in terms of performance, power, and area, the hardware overhead of SPM is lower than that of hardware-managed caches; 2) the programming flexibility of SPM can provide more opportunities for performance and energy exploration; 3) the additional programming effort does not impose too much burden on programmers because the execution pattern of neural network applications is relatively regular compared to general-purpose applications with complex control flows.

[0005] However, the management of SPM is not specifically targeted at neural network acceleration. The key idea of the existing work is to express the management of SPM as a register allocation problem, and various techniques have been used, such as memory coloring, graph coloring, integer linear programming (ILP), and extensions of ILP.

[0006] Such techniques are very suitable for register allocation but are inefficient for SPM management in NN accelerators. The main reason is that the lengths of registers (including scalar and vector registers) are fixed, while the memory requests of SPM in NN accelerators usually have variable lengths to achieve high efficiency. Therefore, if the prior art is applied to SPM management in NN accelerators, the different functions between registers and SPM will lead to inefficiency.

[0007] As can be seen, the problems existing in the prior art are low space utilization rate and easy generation of more storage space fragmentation. Summary of the Invention

[0008] One of the objectives of the present disclosure is to solve the problems of low space utilization rate and storage space fragmentation in the prior art.

[0009] According to a first aspect of the present disclosure, there is provided a method for allocating a storage address for data in a memory, including: receiving a space allocation request for a storage space in the memory, where the space allocation request carries the data size; allocating a target storage space for the data according to the received space allocation request; and allocating a storage address for the data based on the allocated target storage space.

[0010] According to a second aspect of the present disclosure, there is provided a method for managing a storage space, including: forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; forming a tree-like structure with the plurality of storage blocks as nodes, the tree-like structure including multiple levels of nodes, where the total storage space of the upper-level node is the sum of the total storage spaces of the lower-level nodes.

[0011] According to a third aspect of the present disclosure, there is provided a method for allocating a storage space for data in a memory, including: receiving a space allocation request for a storage space in the memory, where the space allocation request carries the data size; forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block;

[0012] According to a fourth aspect of the present disclosure, there is provided an electronic device, including: one or more processors; and a memory, where computer-executable instructions are stored in the memory, and when the computer-executable instructions are run by the one or more processors, the electronic device executes the method as described above.

[0013] According to a fifth aspect of the present disclosure, there is provided a computer-readable storage medium, including computer-executable instructions, and when the computer-executable instructions are run by one or more processors, the method as described above is executed.

[0014] One of the technical effects achieved by the technical solution of the present disclosure includes: being able to greatly improve the utilization rate of the storage space in the memory and reduce the memory consumption. Brief Description of the Drawings

[0015] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features, and advantages of the exemplary embodiments of the present disclosure will become readily understandable. In the drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals denote the same or corresponding parts, wherein:

[0016] Figure 1a Shows a schematic diagram of general neural network operations;

[0017] Figure 1b Shows an example of allocating storage space according to the Figure 1a operation process;

[0018] Figure 1c Shows another example of allocating storage space according to the Figure 1a operation process;

[0019] Figure 1d Gives an ideal method for allocating storage space;

[0020] Figure 2a Shows a flowchart of a method for allocating storage addresses for data in a memory according to an embodiment of the present disclosure;

[0021] Figure 2b Shows an exemplary instruction set for allocating and releasing storage space for data according to an embodiment of the present disclosure;

[0022] Figure 3 Shows a flowchart of a method for establishing the tree structure;

[0023] Figures 4a - 4d Shows a schematic diagram of a tree structure according to an embodiment of the present disclosure;

[0024] Figure 5 Shows a schematic diagram of allocating target storage space for data according to a preferred embodiment of the present disclosure;

[0025] Figure 6a Shows a flowchart of a method for creating a new node according to an embodiment of the present disclosure;

[0026] Figure 6b Shows according to Figure 6a the schematic diagram of the new node created according to the method flowchart shown;

[0027] Figure 6c Shows according to Figure 6a the schematic diagram of the new node created according to the method flowchart shown;

[0028] Figure 7Shows a schematic diagram of allocating addresses for storage space according to an embodiment of the present disclosure;

[0029] Figure 8 Shows a method for managing storage space according to an embodiment of the present disclosure;

[0030] Figure 9 Shows a method for allocating storage space for data in a memory according to an embodiment of the present disclosure;

[0031] Figure 10 Shows a comparison of the amount of space used by the technical solution of the present disclosure and three other technical solutions (BF solution, GC solution, and ideal solution) in different application scenarios;

[0032] Figure 11 Shows a schematic block diagram of a combined processing device; and

[0033] Figure 12 Shows a schematic block diagram of a board card. Detailed implementation manners

[0034] The following will clearly and completely describe the technical solutions in the embodiments of the present disclosure in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present disclosure.

[0035] It should be understood that the terms "first", "second", "third", and "fourth", etc. in the claims, the description, and the drawings of the present disclosure are used to distinguish different objects, rather than to describe a specific order. The terms "including" and "comprising" used in the description and claims of the present disclosure indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.

[0036] It should also be understood that the terms used in the description of the present disclosure herein are only for the purpose of describing specific embodiments, and are not intended to limit the present disclosure. As used in the description and claims of the present disclosure, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms. It should also be further understood that the term " / and / " used in the description and claims of the present disclosure refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0037] As used in this specification and the claims, the term "if" can be interpreted, depending on the context, as "when" or "once" or "in response to determining" or "in response to detecting". Similarly, the phrase "if determined" or "if [described condition or event] is detected" can be interpreted, depending on the context, to mean "once determined" or "in response to determining" or "once [described condition or event] is detected" or "in response to detecting [described condition or event]".

[0038] Figures 1a - 1d FIG. shows a schematic diagram of a variety of different memory allocation methods, where Figure 1a FIG. shows a schematic diagram of general neural network operations.

[0039] As Figure 1a shown, the convolutional neural network includes data D1 - D4, and the symbol Conv represents a convolutional operation, whereby D2 = Conv(D1), D3 = Conv(D2), and D4 = Conv(D3). For example, D1 is 16 bits, D2 is 8 bits, D3 is 24 bits, and D4 is 32 bits. During the continuous convolutional operation process, it is necessary to allocate storage space for the data participating in the operation and release the space occupied by the historical data.

[0040] Figure 1b FIG. shows an example of allocating storage space according to the Figure 1a operation process, and this example is called the best fit (BF) method.

[0041] In Figure 1b , first, addresses are allocated for data D1 and D2; when the second convolutional operation is performed, the space occupied by D1 can be released, and storage space is allocated for data D3; similarly, when the third convolutional operation is performed, the space of D2 can be released, and further storage space is allocated for D4. In the scheme shown in 1b, a large amount of space fragmentation will be generated, thus reducing the utilization rate of the storage space.

[0042] Figure 1c FIG. shows another example of allocating storage space according to the Figure 1a operation process, and this example is called graph coloring (GC).

[0043] As Figure 1cAs shown, the storage space is divided into multiple classes. Regclass32 represents a space with a capacity of 32 bits, Regclass24 represents a space with a capacity of 24 bits, Regclass16 represents a space with a capacity of 16 bits, and Regclass8 represents a space with a capacity of 8 bits. In this case, data D1 - D4 will be classified into different categories according to their sizes. For example, data D1 is stored in the R in Regclass16 16,0 space, data D2 is stored in the R in Regclass8 8,4 space, data D3 is stored in the R in Regclass24 24,0 space, and data D4 is stored in the R in Regclass32 32,1 space. In this allocation method, a large amount of fragmentation will still occur. Especially when the size of a certain data is smaller than one class and larger than another class, the fragmentation of the storage space is more obvious. For example, if the size of a certain data is 20 bits, it should be stored in Regclass24, resulting in a waste of 4 - bit space.

[0044] Figure 1d A method for ideal storage space allocation is given, and this ideal allocation method is the limit of space allocation.

[0045] As Figure 1d shown, first, storage space is allocated for data D1 and D2, and these two storage spaces are adjacent to each other as in other methods. Next, the space occupied by data D1 is released, and data D3 needs to be stored. In the ideal state, the storage space for data D3 should be as Figure 1d shown, and corresponding space is reserved for data D4; when data D4 needs to be stored, the space reserved for data D4 is just adjacent to the space of data D3, thus reducing the occurrence of fragmentation and reducing the jump of data addressing. However, it is very difficult to achieve the ideal state because it requires predicting the sizes of future data

[0046] Furthermore, regarding SPM management as a traditional memory allocation problem, in such a scheme, space and address are determined and allocated to data simultaneously, which also determines the limitations of the prior art in terms of space utilization.

[0047] Figure 2a FIG. shows a flowchart of a method for allocating storage addresses for data in a memory according to an embodiment of the present disclosure. Figure 2b FIG. shows an exemplary instruction set for allocating storage space and releasing storage space for data according to an embodiment of the present disclosure.

[0048] As Figure 2aAs shown, the method of the present disclosure includes: in operation S210, receiving a space allocation request for a storage space in a memory, the space allocation request carrying a data size; in operation S220, allocating a target storage space for the data according to the received space allocation request; and in operation S230, allocating a storage address for the data based on the allocated target storage space.

[0049] It should be understood that in the above, in addition to the data size, the space allocation request may carry other information, such as the lifespan of the resource, which indicates when the resource is applied for, when it is released, and the order of application and release, etc. Different orders may lead to different results.

[0050] As Figure 2b shown, a plurality of instructions are shown in chronological order, where the instruction "alloc" represents allocating a storage space, and the instruction "dealloc" represents releasing a storage space. For example, the operations "alloc D1 400", "alloc D2 100", and "alloc D3 400" respectively represent allocating a storage space of size 400 for data D1, allocating a storage space of size 100 for data D2, and allocating a storage space of size 400 for data D3. Similarly, the operations "dealloc D3", "deallocD1", "dealloc D4", "dealloc D5" respectively represent releasing the spaces occupied by data D3, D1, D4, and D5, and thus these released spaces can become available storage spaces. These available storage spaces can be allocated to other data again.

[0051] Next, after receiving the space allocation request, an appropriate part or all of the available storage space can be selected as the target storage space to be allocated to the above-mentioned data. It should be explained that the above term "target storage space" refers to the space actually allocated to the data. For example, if the current available storage space is 400 and a space allocation request is to allocate a data of size 300 for a data Dx, then the space allocated for data Dx can be called the target storage space. Such a description is only used to distinguish different spaces referred to in the context for easy understanding, and does not impose any limitation on the technical solution of the present disclosure. It should be understood that the above "available storage space" and "target storage space" are virtual storage spaces, and these virtual storage spaces can be corresponded to the corresponding data, and then these virtual storage spaces are mapped to the actual physical space and address. However, in the context, different names are used to represent the meanings of these virtual storage spaces.

[0052] After determining the storage space, the corresponding storage address is allocated to the data. The storage address may include a starting address and an offset, and the offset may be determined by the size of the data.

[0053] In the above, when allocating the target storage space for the data, the existing available storage space is searched to allocate an appropriate part of the storage space to the data. During the process of allocating the storage space, the specific storage address is not allocated temporarily. This method of separating space allocation and address allocation is significantly different from the existing technology of allocating the storage space and the storage address to the data in one step.

[0054] According to an embodiment of the present disclosure, a tree structure can be established. The tree structure may include multiple nodes, and each node represents a storage space. The appropriate node or combination of nodes for storing the data can be found by traversing the storage space. The "appropriate node" described here can be a single node or a combination of multiple nodes.

[0055] It should be understood that the establishment of the tree relationship between the storage blocks can be achieved before the above operation S210, that is, the tree structure to be described in detail below can be established in advance, or it can be achieved after operation S210 and before operation S220, that is, this tree structure is established in real time through operations such as space allocation requests and space releases.

[0056] Figure 3 The flowchart showing a method for establishing this tree structure is shown.

[0057] As Figure 3 shown, the method of the present disclosure further includes: in operation S310, forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; and, in operation S320, forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, where the total storage space of the upper-level node is the sum of the total storage spaces of the lower-level nodes.

[0058] For the convenience of understanding the Figure 3 method in, the following describes the establishment process of the tree structure in detail with the following series of operations and in combination with Figures 4a - 4c .

[0059] Operation 1: alloc D1 400

[0060] Operation 2: alloc D2 100

[0061] Operation 3: alloc D3 400

[0062] Operation 4: dealloc D3

[0063] Operation 5: alloc D4 300

[0064] Operation 6: dealloc D2

[0065] As Figure 4a shown, initialization is first performed, with node 0 as the initial node. Each node represents a storage block with a total storage space of 0 and an available storage space of 0. For ease of description, its storage attribute can be represented as 0(0).

[0066] Next, when the instruction "alloc D1 400" of operation 1 is received, node 1 is created under node 0 to store data D1. Therefore, the total storage space of this node 1 is 400 and the available storage space is 0, and its storage attribute can be represented as 400(0).

[0067] When the instruction "alloc D2 100" of operation 2 is received, node 2 is created under node 0 to store data D2. Therefore, the total storage space of this node 2 is 100 and the available storage space is 0, and its storage attribute can be represented as 100(0).

[0068] When the instruction "alloc D3 400" of operation 3 is received, node 3 is created under node 0 to store data D3. Therefore, the total storage space of this node 3 is 400 and the available storage space is 0, and its storage attribute can be represented as 400(0).

[0069] At this time, the total storage space of the initial node 0 is 900, its available storage space is 0, and its storage attribute can be represented as 900(0).

[0070] It can be understood that the storage space can also be released. According to an embodiment of the present disclosure, in response to receiving a space release request, the corresponding node is released; the available storage space identifier of the released node is updated.

[0071] Take Figure 4b as an example for description. When the instruction "dealloc D3" of operation 4 is received, the space of node 3 is released, so that the available storage space of node 3 is 400, and its storage attribute can be represented as 400(400), as Figure 4b shown. At this time, the total storage space of the initial node 0 is 900, its available storage space identifier is still 0, and its storage attribute can be represented as 900(0).

[0072] In the present disclosure, the released space can be reused to achieve the purpose of fully utilizing the space. Thus, according to an embodiment of the present disclosure, allocating a target storage space for data according to the received space allocation request includes: retrieving available storage space in the nodes of the tree structure; in response to finding available storage space not less than the size of the data in the nodes of the tree structure, allocating a target storage space for the data according to the received space allocation request.

[0073] Take Figure 4c as an example. When the instruction "alloc D4 300" of operation 5 is received, it means that a storage space with a size of 300 is requested to be allocated for data D4. At this time, only node 3 has sufficient available storage space of 400, which is not less than the size of the storage space to be allocated.

[0074] In this case, data D4 can be directly stored in the storage space of node 3. This method does not require creating a new node. However, since the storage space originally allocated to data D3 in node 3 is allocated to data D4, the original corresponding relationship between node 3 and data D3 will be erased, which is not conducive to the preservation of subsequent storage relationships.

[0075] According to an embodiment of the present disclosure, in response to finding available storage space not less than the size of the data in the nodes of the tree structure, allocating a target storage space for the data according to the received space allocation request may include: creating a new node under the node where the available storage space is not less than the size of the data, so that the total storage space of the new node is equal to the size of the data.

[0076] For example, a new node 4 can be established at the lower level of node 3, and its storage attribute can be expressed as 300(0). At this time, the available storage space of node 3 is 100, so the storage attribute of node 3 can be expressed as 400(100), as Figure 4c shown.

[0077] Thus, according to an embodiment of the present disclosure, at the logical level, the same node can only be allocated once to ensure that each node corresponds to one data, so as to ensure that the entire allocation process is completely recorded and it is also convenient for further splitting sub-nodes subsequently. For example, since node 3 has been previously allocated to data D3, even if the space occupied by data D3 is released, when new data (such as data D4) needs to occupy the space originally occupied by data D3, logically a new node (such as node 4) still needs to be created. Of course, physically, the newly created node 4 is still within the physical space range of node 3.

[0078] Figure 4cA special case is shown where the available storage space of a certain node is greater than the space to be allocated. Figure 4d A schematic diagram for allocating space for data according to another embodiment of the present disclosure is shown.

[0079] In Figure 4d Among them, the total storage space of Node 1 is 600, and the available storage space is 500; the total storage space of Node 2 is 700, and the available storage space is 600; the total storage space of Node 3 is 800, and the available storage space is 0; the total storage space of Node 4 is 1000, and the available storage space is 1000. At this time, a request to allocate a storage space of size 700 for data is received. In this case, there are various situations to store this data.

[0080] The first solution is to use Node 4 to allocate 700 of storage space for this data. After the allocation, there will be 300 of available storage space in Node 4.

[0081] The second solution is to occupy 500 of the available storage space in Node 1, and then allocate 200 of storage space from Node 2 or Node 4.

[0082] The third solution is to occupy 600 of the available storage space in Node 2, and then allocate 100 of storage space from Node 1 or Node 4.

[0083] The fourth solution is that a total of 700 of storage space can be allocated from Node 1, Node 2, and Node 4 respectively. For example, 200 of storage space can be allocated from Node 1, 300 of storage space can be allocated from Node 2, and 200 of storage space can be allocated from Node 4.

[0084] The beneficial effect of adopting the first solution is that it is easier to keep the newly allocated space continuous in address, reduce the address jump during data access, and thus improve the efficiency of data access.

[0085] The beneficial effects of adopting the second and third solutions are that the existence of fragmented space can be minimized. In addition, the method of using Node 1 and Node 2 to allocate storage space for data is also beneficial to make the data stored in continuous space, thus reducing the address jump during data access.

[0086] In addition, in the case where the available storage spaces of Node 1 and Node 2 cannot form a continuous address, the third solution is more beneficial than the second solution because more data is stored in Node 2, which is also beneficial to reduce the address jump during data access.

[0087] According to an embodiment of the present disclosure, in response to not finding a single node in the nodes of the tree structure whose available storage space is not less than the data size, a new node is created such that the sum of the available storage spaces of the single node and the new node is not less than the data.

[0088] Still taking Figure 4d as an example for illustration.

[0089] In the fifth solution, the available storage space of 500 in node 1 is occupied, and then a new node with an available storage space of 200 is applied for. The sum of the available storage spaces of node 1 and the new node is 700, which can accommodate the data.

[0090] In the sixth solution, the available storage space of 600 in node 2 is occupied, and then a new node with an available storage space of 100 is applied for. The sum of the available storage spaces of node 2 and the new node is 700, which can accommodate the data.

[0091] Preferably, the new node can form a continuous space with the above-mentioned single node.

[0092] Compared with the second and third solutions, the beneficial effects of the fifth and sixth solutions are that if the spaces in node 1 and node 2 cannot be continuous, the space jump during the data access process is likely to cause low efficiency, while the fifth and sixth solutions can form a continuous space by directly creating a new node before or after the node.

[0093] More preferably, select the single node with the largest available storage space so that the available storage space of the created new node is as small as possible.

[0094] Compared with the fifth and sixth solutions, since the storage space of the created new node is smaller, this is beneficial to reducing space fragmentation. Next, still as Figure 4c shown, when the instruction dealloc D2 of operation 6 is received, the space of node 2 is released, so that the available storage space of node 2 is 100, and its storage attribute can be represented as 100(100), as Figure 4c shown.

[0095] It can be seen from the above description that once a node (or storage block) is created, it will not be deleted even if an instruction to release the storage space is received within a certain period, but its available storage space identifier is adjusted to indicate the current available storage space.

[0096] Figure 5 FIG. shows a schematic diagram of allocating target storage space for data according to a preferred embodiment of the present disclosure.

[0097] According to an embodiment of the present disclosure, in response to searching for available storage space with the smallest difference from the data size among the nodes of the tree structure, target storage space is allocated for the data according to the received space allocation request.

[0098] As Figure 5 shown, node 0 has four subordinate nodes, namely node 1 (600(500)), node 2 (700(600)), node 3 (800(0)), and node 4 (1000(1000)). At this time, an operation instruction alloc D5 1000 is received. Among the above four nodes, the sum of the available spaces of node 1 and node 2 is 1100, which is sufficient to accommodate data D5; the available storage space of node 3 is 0, which is not sufficient to accommodate data D5; the available storage space of node 4 is 1000, which can just accommodate data D5. According to an embodiment of the present disclosure, when both the combination of node 1 and node 2 and node 4 are sufficient to accommodate data D5, node 4 is preferentially selected to accommodate data D5 because the difference between its available storage space and the size of data D5 is the smallest. The above preferred embodiment is beneficial to reducing the fragmentation of storage space and improving the utilization efficiency of storage space.

[0099] It should be understood that the above expression "the difference between the available storage space and the size of data D5 is the smallest" not only applies to the case where the available storage space of a single node in the above text is not greater than the data, but also applies to the case where the available storage space of a single node is greater than the data.

[0100] For example, still as Figure 5 shown, the available storage space of node 1 is 500, the available storage space of node 2 is 600, and the available storage space of node 4 is 1000. At this time, a data allocation request is received, and 400 of storage space needs to be allocated for data D5'. In one embodiment, 400 of the corresponding space can be allocated for this data D5' in node 1, node 2, or node 4. In another preferred embodiment of the present disclosure, 400 of the corresponding space can be allocated for data D5' in node 1 because the difference between the available storage space of node 1 and the size of this data D5' is the smallest. This helps to reduce space fragmentation, so that the space is fully utilized.

[0101] The case of creating a tree structure is introduced above. There is also a case where the sum of the available storage nodes of all current nodes is not sufficient to store the data. According to an embodiment of the present disclosure, further including allocating target storage space for the data according to the received space allocation request: in response to not searching for available storage space not less than the data size among the nodes of the tree structure, creating a new node so that the available storage space can accommodate the data.

[0102] It is understandable that, preferably, the storage space of the newly created node is as small as possible, which helps to reduce the occurrence of space fragmentation.

[0103] The following will introduce in detail various implementation manners of creating a new node.

[0104] Figure 6a A method flowchart for creating a new node according to an embodiment of the present disclosure is shown;

[0105] Figure 6b As shown in Figure 6a A schematic diagram of a new node created according to the method flowchart shown is shown.

[0106] As Figure 6a shown, creating a new node may include: in operation S610, adjusting a node with available storage space to a subordinate node of the new node; in operation S620, creating a new subordinate node under the new node so that the available storage space of the subordinate nodes of the new node can accommodate the data.

[0107] Combined with the 6 operations described above with reference to Figures 4a - 4b the following further describes with reference to operations 7-10.

[0108] Operation 7: alloc D5 300

[0109] Operation 8: dealloc D1

[0110] Operation 9: dealloc D4

[0111] Operation 10: dealloc D5

[0112] First, it can be seen from Figure 4c that after operation 6 is executed, the available storage space of node 1 is 0, the available storage space of node 2 is 100, the available storage space of node 3 is 100, the available storage space of node 4 is 0, and the current available storage space is 200 in total.

[0113] When operation 7 is executed, it is necessary to allocate a storage space of size 300 for data D5, but the current available storage space is only 200, which is not enough to accommodate data D5. In this case, a new node needs to be created.

[0114] Thus, a node 8 at the same level as node 1 is created, and the original node 2 and node 3 are moved to be the child nodes of the new node 8 as its subordinates. In this case, a new child node 6 can be created, which has a total storage space identifier of 100, so that the child node 2, the new child node 6, and the child node 3 together have an available storage space of 300, so that data D5 can be accommodated.

[0115] Furthermore, for child node 3, since data D3 was previously stored therein, child node 3 needs to be further divided into grandchild node 7 and grandchild node 4, where grandchild node 4 was originally a lower-level node of child node 3, and grandchild node 7 is a newly created grandchild node.

[0116] Furthermore, as described above, preferably, the same node can only be allocated the same data. Therefore, although node 2 has available storage space of size 100, since node 2 has already been allocated to data D2, a new node 5 can be created under node 2 as a child node of node 2. It should be understood that physically in the memory space, node 2 and node 5 are the same, but in the tree structure, the two are different nodes.

[0117] After the above creation process, node 5 can provide storage space of size 100, node 6 can provide storage space of size 100, and node 7 can provide storage space of size 100, so as to be able to accommodate data D5 of size 300.

[0118] In the above description for Figure 6b it can be seen that the same data can occupy different nodes. For example, data D5 can occupy node 5, node 6, and node 7, but the same node can only correspond to one data. For example, node 3 has already been allocated to data D3. Although the space occupied by data D3 has been released (operation 4), if new data such as data D4 and data D5 need to occupy the space originally occupied by data D3, then node D3 still needs to be further divided into sub-nodes 4 and node 7. The above solution is beneficial to maintaining the correspondence between the entire node and the data.

[0119] For operations 8-10, the storage spaces allocated to data D1, D4, and D5 can be released, as Figure 6c shown. In Figure 6c this case, the available storage space of node 1 becomes 400, the available storage spaces of node 6, node 5, and node 7 all become 100, and the available storage space of node 4 becomes 300.

[0120] According to an embodiment of the present disclosure, creating a new node so that the available storage space can accommodate the data may further include: in response to the available storage spaces of all nodes in the tree structure being zero, creating a new node so that the available storage space of the new node can accommodate the data.

[0121] In this embodiment, since there is no available storage space in the existing nodes, a new node for storing this data can be completely created. Figure 4a The situation in

[0122] According to another embodiment of the present disclosure, creating a new node such that the available storage space can accommodate the data may include: in response to not finding current available storage space not less than the data size in the nodes of the tree structure, and the data size included in the next space allocation request being not greater than the current available storage space, creating a new node such that the available storage space of the new node can accommodate the data.

[0123] In this embodiment, the timing of the space allocation request can be taken into account. For example, if the existing available storage space is 300, and at this time the first space allocation request for allocating 400 of storage space is received, then it can be considered whether the second space allocation request after this space allocation request is less than 300 or equal to 300. If so, a new node can be first created and allocated to the first space allocation request, while reserving the existing available storage space for the second space allocation request. This embodiment is beneficial for periodic or predictable space allocation requests.

[0124] After the tree structure is established and a new space allocation request is received, the tree structure can be traversed to find the desired available storage space. According to one embodiment of the present disclosure, when traversing the tree structure, a depth-first strategy can be adopted, that is, after retrieving a parent node and all its child nodes, then retrieving another node at the same level as the parent node.

[0125] Take Figure 6c as an example. For example, when a space allocation request is received, first node 1 is searched. When sufficient available storage space is not found in node 1, node 8 is searched, and then nodes 2 and 5 are searched in sequence; node 6 is searched; nodes 3, 7, and 4 are searched. The depth-first method is beneficial for storing the same data in continuous space as much as possible, reducing the jump of space addressing in the operation process.

[0126] According to one embodiment of the present disclosure, it further includes: adjusting the positions of the nodes so that the spaces of the multiple storage blocks are continuous.

[0127] It should be understood that the node actually corresponds to a virtual storage space. Therefore, it is desired that the same piece of data can be stored in continuous space to reduce the jump of space addressing in the operation process and improve the operation efficiency.

[0128] Such as Figure 6bAs shown, node 6 for storing data D5 is inserted between node 2 and node 3, and node 7 is established adjacent to node 6. Thus, data D5 can be continuously stored in the continuous space adjacent to node 5, node 6, and node 7. Node 6 can also be set after node 3, and node 7 can be set after node 4, but such a way is prone to space jumps.

[0129] Thus, in order to ensure continuous space, according to an embodiment of the present disclosure, it further includes: fixing the arrangement order of nodes in the tree structure.

[0130] The order of fixed nodes can be marked in the upper-level nodes of the nodes. For example, as Figure 6b shown, a mark "ordered" can be made in node 8, then the arrangement order of all child nodes under this node 8 will be fixed. For another example, a mark "ordered" can be given to node 3, then the arrangement order of node 7 and node 4 under this node 3 will be fixed.

[0131] Fixing the arrangement order of nodes helps to store the same data in continuous space and reduces the jump of space addressing.

[0132] Different from the prior art, in the above process, only storage space is allocated, and no address is allocated for the data. Therefore, space allocation and address allocation are separated; while in the prior art, address allocation and storage space allocation are simultaneous, which is also a difference between the technical solution of the present disclosure and the prior art solution.

[0133] After allocating storage space for the data based on the above process, according to an embodiment of the present disclosure, allocating a storage address for the data based on the allocated target storage space may include: after allocating a storage address for a node, sequentially allocating addresses for other nodes at the same level, where the address of each node covers the addresses of all its lower-level nodes.

[0134] Furthermore, when the sum of the available storage spaces of all nodes is less than the data to be accommodated, the fifth and sixth solutions described in Figure 4d are equally applicable. In this case, new nodes will inevitably be created. Similar to the fifth and sixth solutions, one of the nodes can be selected to accommodate a part of the data, and then new nodes can be created to accommodate the remaining part of the data. The newly created nodes can form a continuous space with the node that accommodates a part of the data, thereby reducing the space jump during data access.

[0135] Figure 7 shows a schematic diagram of allocating addresses for storage space according to an embodiment of the present disclosure.

[0136] AsFigure 7 The tree structure shown includes node 0, node 1, node 2, node 3, node 4, and node 5. Node 0 is the root node, with a total storage space of 31 and an available storage space of 0, and the storage attribute is represented as 31(0); Nodes 1, 2, 3, and 4 are the child nodes of node 0, and their storage attributes are represented as 5(5), 6(6), 10(0), and 11(0) respectively; Node 5 is the child node of node 3, and its storage attribute is represented as 10(0).

[0137] When allocating addresses for these nodes, a width-first strategy is adopted, that is, first allocate addresses to nodes at the same level, and then more specifically allocate addresses to the lower-level nodes of each node.

[0138] As shown in Figure 7 the starting address of node 0 is 0x0000, and its offset can be 31; then as the first child node of node 0, the starting address of node 1 can also be 0x0000, and its offset is 5, so its ending address is 0x0004. Similarly, the starting address of node 2 can be 0x0005, with an offset of 6; the starting address of node 3 can be 0x000B, with an offset of 10; and the starting address of node 4 is 0x0015, with an offset of 11; as the child node of node 3, the starting address of node 5 is also 0x000B, with an offset of 10.

[0139] It can be seen that through the above arrangements, the space for the same data can be kept continuous, and thus continuous addresses can also be allocated, which greatly improves the space utilization rate in the memory and reduces the occurrence of fragmentation, especially for memories with a relatively small storage capacity; in addition, through the technical solution of the present disclosure, the continuity of data storage can also be maintained, thus avoiding jumps during the addressing process, thereby improving the data throughput speed; another beneficial effect is that since all node information is retained, all records of data storage during the space allocation and release process are retained, facilitating subsequent data tracking and retention of storage records.

[0140] Figure 8 A method for managing storage space according to an embodiment of the present disclosure is shown, including: in operation S810, forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; and, in operation S820, forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, where the total storage space of the upper-level node is the sum of the total storage spaces of the lower-level nodes.

[0141] Figure 9 A method for allocating storage space for data in a memory according to an embodiment of the present disclosure is shown, including: in operation S910, receiving a space allocation request for the storage space in the memory, where the space allocation request carries the data size; in operation S920, forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; in operation S930, forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, where the total storage space of the upper-level node is the sum of the total storage spaces of the lower-level nodes; and, in operation S940, allocating a target storage space for the data according to the received space allocation request and according to the tree structure.

[0142] The above Figure 8 and Figure 9 The specific implementation manners of each operation in Figure 7 have been explained in detail according to FIG. 2-

[0143] Figure 10 shows a comparison of the space usage amounts of the technical solution of the present disclosure and three other technical solutions (BF solution, GC solution, and ideal solution) in different application scenarios. In each group of comparisons, the data on the left end represents the BF solution, the data in the second column represents the GC solution, the data in the third column represents the solution of the present disclosure, and the data in the last column represents the ideal solution.

[0144] Figure 10 Eight common application scenarios are selected in Figure 10 and are respectively represented as the abscissa, ResNet-18, ResNet-50, MobileNet-V2, SE-ResNet-50, GoogleNet, Inception21k, DPN131, and DenseNet-201; the ordinate represents the usage amount of the SPM space, which is a key metric for evaluating the memory management method. In

[0145] On average, compared with the BF scheme and the GC scheme, the technical solution of the present invention reduces the usage of the SPM space by 31.6% and 13.3. Compared with the BF scheme, the technical solution of the present invention reduces the usage of the SPM space by up to 47.9% (for example, in the SE-ResNet-50 scenario) and at least 10% (for example, in the Inception21k scenario). Compared with the GC scheme, the solution of the present invention reduces the usage of the SPM space by approximately 1% (ResNet-50) - 30.1% (DenseNet-201).

[0146] Furthermore, in six of the application scenarios, such as ResNet-18, ResNet-50, MobileNet-V2, SE-ResNet-50, GoogleNet, and Inception21k, the technical solution of the present invention almost achieves the same effect as the ideal solution.

[0147] The present disclosure also provides an electronic device, including: one or more processors; and a memory storing computer-executable instructions, which, when run by the one or more processors, cause the electronic device to execute the method as described above.

[0148] The present disclosure also provides a computer-readable storage medium including computer-executable instructions, which, when run by one or more processors, execute the method as described above.

[0149] The technical solution of the present disclosure can be applied to the field of artificial intelligence, implemented in a host, a server, or implemented as or in an artificial intelligence chip. The chip can exist alone or be included in a computing device.

[0150] Figure 11 A combined processing device 1100 is shown, which includes the above-mentioned computing device 1102, a general interconnection interface 1104, and other processing devices 1106. The computing device according to the present disclosure interacts with other processing devices to jointly complete the operations specified by the user. Figure 11 Schematic diagram of the combined processing device.

[0151] The other processing devices include one or more processor types such as a central processing unit (CPU), a graphics processing unit (GPU), and a neural network processor in general-purpose / special-purpose processors. The number of processors included in the other processing devices is not limited. The other processing devices serve as an interface for the machine learning computing device with external data and control, including data transfer, and complete basic controls such as starting and stopping the machine learning computing device; the other processing devices can also cooperate with the machine learning computing device to jointly complete computing tasks.

[0152] A general interconnection interface is used to transfer data and control instructions between a computing device (including, for example, a machine learning computing device) and other processing devices. The computing device obtains the required input data from other processing devices and writes it into the storage device on the chip of the computing device; it can obtain control instructions from other processing devices and write them into the control cache on the chip of the computing device; it can also read the data in the storage module of the computing device and transfer it to other processing devices.

[0153] Optionally, the structure may further include a storage device 1108, which is respectively connected to the computing device and the other processing device. The storage device is used to store the data in the computing device and the other processing device, and is particularly suitable for the data that needs to be calculated and cannot be fully stored in the internal storage of the computing device or other processing devices.

[0154] The combined processing device can be used as the system on a chip (SOC) of devices such as mobile phones, robots, drones, video surveillance devices, etc., effectively reducing the core area of the control part, improving the processing speed, and reducing the overall power consumption. In this case, the general interconnection interface of the combined processing device is connected to some components of the device. Some components such as cameras, displays, mice, keyboards, network cards, and wifi interfaces.

[0155] In some embodiments, the present disclosure also discloses a board, which includes the above chip packaging structure. Refer to Figure 12 , which provides an exemplary board. In addition to including the above chip 1202, the above board may further include other supporting components, and the supporting components include but are not limited to: a storage device 1204, an interface device 1206, and a control device 1208.

[0156] The storage device is connected to the chip in the chip packaging structure through a bus and is used to store data. The storage device may include multiple groups of storage units 1210. Each group of the storage units is connected to the chip through a bus. It can be understood that each group of the storage units may be a DDR SDRAM (English: Double Data Rate SDRAM, double data rate synchronous dynamic random access memory).

[0157] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read on both the rising and falling edges of the clock pulse. The speed of DDR is twice that of standard SDRAM. In one embodiment, the storage device may include 4 groups of the storage cells. Each group of the storage cells may include multiple DDR4 dies (chips). In one embodiment, the interior of the die may include 4 72-bit DDR4 controllers, where 64 bits of the 72-bit DDR4 controllers are used for data transmission and 8 bits are used for ECC checking. In one embodiment, each group of the storage cells includes multiple double data rate synchronous dynamic random access memories arranged in parallel. DDR can transfer data twice within one clock cycle. A controller for controlling DDR is provided in the die to control data transmission and data storage of each of the storage cells.

[0158] The interface device is electrically connected to the die within the chip package structure. The interface device is used to implement data transmission between the die and an external device 1212 (such as a server or a computer). For example, in one embodiment, the interface device may be a standard PCIE interface. For instance, the data to be processed is transmitted from the server to the die through the standard PCIE interface to achieve data transfer. In another embodiment, the interface device may also be other interfaces. The present disclosure does not limit the specific forms of the above other interfaces, as long as the interface unit can achieve the transfer function. Additionally, the calculation result of the die is still transmitted back to the external device (such as a server) by the interface device.

[0159] The control device is electrically connected to the die. The control device is used to monitor the state of the die. Specifically, the die and the control device may be electrically connected through an SPI interface. The control device may include a microcontroller unit (MCU). For example, the die may include multiple processing chips, multiple processing cores, or multiple processing circuits and can drive multiple loads. Therefore, the die may be in different working states such as multi-load and light-load. Through the control device, the working states of multiple processing chips, multiple processes, and / or multiple processing circuits in the die can be regulated.

[0160] In some embodiments, the present disclosure also discloses an electronic device or apparatus, which includes the above-mentioned board.

[0161] The electronic device or apparatus includes a data processing device, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, a video camera, a projector, a watch, headphones, a mobile storage, a wearable device, a vehicle, a household appliance, and / or a medical device.

[0162] The means of transportation include airplanes, ships, and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical devices include magnetic resonance imaging (MRI) machines, B-ultrasound machines, and / or electrocardiogram (ECG) machines.

[0163] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this disclosure is not limited by the described action sequence, because according to this disclosure, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this disclosure.

[0164] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0165] In the several embodiments provided by this disclosure, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, optical, acoustic, magnetic, or other forms.

[0166] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0167] In addition, in each embodiment of this disclosure, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software program modules.

[0168] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, when the technical solution of the present disclosure can be embodied in the form of a software product, the computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present disclosure. The aforementioned memory includes: various media such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), external hard drives, magnetic disks, or optical discs that can store program codes.

[0169] The above has introduced the embodiments of the present disclosure in detail. Specific examples are used in this article to elaborate on the principles and implementation manners of the present disclosure. The description of the above embodiments is only used to help understand the method and its core idea of the present disclosure; at the same time, for those of ordinary skill in the art, according to the idea of the present disclosure, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present disclosure.

[0170] The foregoing content can be better understood according to the following terms:

[0171] Clause 1. A method for allocating storage addresses for data in a memory, including:

[0172] Receiving a space allocation request for the storage space in the memory, the space allocation request carrying the data size;

[0173] Allocating a target storage space for the data according to the received space allocation request; and

[0174] Based on the allocated target storage space, allocating a storage address for the data.

[0175] Clause 2. The method according to Clause 1, further including:

[0176] Forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block;

[0177] Forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, where the total storage space of the upper-level node is the sum of the total storage spaces of the lower-level nodes.

[0178] Clause 3. The method according to Clause 2, wherein allocating target storage space for data according to the received space allocation request includes:

[0179] Retrieving available storage space in the nodes of the tree structure;

[0180] In response to finding available storage space not less than the size of the data in the nodes of the tree structure, allocating target storage space for the data according to the received space allocation request.

[0181] Clause 4. The method according to Clause 3, wherein in response to finding available storage space with the smallest difference from the size of the data in the nodes of the tree structure, allocating target storage space for the data according to the received space allocation request.

[0182] Clause 5. The method according to Clause 3, wherein further allocating target storage space for the data according to the received space allocation request includes:

[0183] In response to not finding available storage space not less than the size of the data in the nodes of the tree structure, creating a new node so that the available storage space can accommodate the data.

[0184] Clause 6. The method according to Clause 5, wherein creating a new node so that the available storage space can accommodate the data includes:

[0185] Adjusting the node with available storage space to a subordinate node of the new node;

[0186] Creating new subordinate nodes under the new node so that the available storage space of the subordinate nodes of the new node can accommodate the data; or

[0187] Creating a new node so that the available storage space can accommodate the data includes:

[0188] In response to the available storage space of all nodes in the tree structure being zero, creating a new node so that the available storage space of the new node can accommodate the data; or

[0189] Creating a new node so that the available storage space can accommodate the data includes:

[0190] In response to not finding current available storage space not less than the size of the data in the nodes of the tree structure, and the data size included in the next space allocation request not being greater than the current available storage space, creating a new node so that the available storage space of the new node can accommodate the data.

[0191] Clause 7. The method according to any one of Clauses 3-6, wherein retrieving available storage space in a node of the tree structure includes:

[0192] After retrieving a parent node and all its child nodes, retrieve another node at the same level as the parent node.

[0193] Clause 8. The method according to any one of Clauses 2-7, further comprising:

[0194] Adjust the positions of the nodes so that the spaces of the multiple storage blocks are contiguous.

[0195] Clause 9. The method according to any one of Clauses 2-8, further comprising:

[0196] Fix the arrangement order of the nodes in the tree structure.

[0197] Clause 10. The method according to any one of Clauses 2-9, further comprising:

[0198] In response to receiving a space release request, release the corresponding node;

[0199] Update the available storage space identifier of the released node.

[0200] Clause 11. The method according to any one of Clauses 2-10, wherein allocating a storage address for the data based on the allocated target storage space includes:

[0201] After allocating a storage address for a node, sequentially allocate addresses for other nodes at the same level, where the address of each node covers the addresses of all its child nodes.

[0202] Clause 12. A method for managing storage space, comprising:

[0203] Form a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, wherein the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block;

[0204] Form the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, wherein the total storage space of a parent node is the sum of the total storage spaces of its child nodes.

[0205] Clause 13. A method for allocating storage space for data in a memory, comprising:

[0206] Receive a space allocation request for storage space in the memory, the space allocation request carrying the data size;

[0207] Form multiple storage blocks, each storage block having a total storage space identifier and an available storage space identifier, where the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block;

[0208] Form a tree structure with the multiple storage blocks as nodes, the tree structure including multiple levels of nodes, where the total storage space of a superior node is the sum of the total storage spaces of its inferior nodes;

[0209] According to the received space allocation request, allocate a target storage space for the data based on the tree structure.

[0210] Clause 14. The method according to clause 12 or 13 further includes:

[0211] In response to receiving a space allocation request for allocating a target storage space for data, retrieve the available storage space among the nodes of the tree structure;

[0212] In response to finding available storage space not less than the data size among the nodes of the tree structure, allocate a target storage space for the data according to the received space allocation request.

[0213] Clause 15. The method according to clause 14, wherein, in response to finding available storage space with the smallest difference from the data size among the nodes of the tree structure, allocate a target storage space for the data according to the received space allocation request.

[0214] Clause 16. The method according to clause 14, wherein, in response to not finding available storage space not less than the data size among the nodes of the tree structure, create a new node so that the available storage space can accommodate the data.

[0215] Clause 17. The method according to clause 16, wherein creating a new node so that the available storage space can accommodate the data includes:

[0216] Adjust a node with available storage space to be a subordinate node of the new node;

[0217] Create new subordinate nodes under the new node so that the available storage space of the new node can accommodate the data; or

[0218] Creating a new node so that the available storage space can accommodate the data includes:

[0219] In response to the available storage space of all nodes in the tree structure being zero, create a new node so that the available storage space of the subordinate nodes of the new node can accommodate the data; or

[0220] Creating a new node to enable the available storage space to accommodate the data includes:

[0221] In response to not finding current available storage space not less than the data size in the nodes of the tree structure and the data size included in the next space allocation request not being greater than the current available storage space, a new node is created to enable the available storage space of the new node to accommodate the data.

[0222] Clause 18. The method according to any one of Clauses 14-17, wherein retrieving available storage space in the nodes of the tree structure includes:

[0223] After retrieving a parent node and all its child nodes, another node at the same level as the parent node is retrieved.

[0224] Clause 19. The method according to any one of Clauses 12-18, further comprising:

[0225] Adjusting the positions of the nodes so that the spaces of the multiple storage blocks are continuous.

[0226] Clause 20. The method according to any one of Clauses 12-19, further comprising:

[0227] Fixing the arrangement order of the nodes in the tree structure.

[0228] Clause 21. An electronic device, comprising:

[0229] One or more processors; and

[0230] A memory storing computer-executable instructions that, when run by the one or more processors, cause the electronic device to perform the method according to any one of Clauses 1-20.

[0231] Clause 22. A computer-readable storage medium comprising computer-executable instructions that, when run by one or more processors, perform the method according to any one of Clauses 1-20.

Claims

1. A method for allocating storage addresses for data in a memory, comprising: Receiving a space allocation request for a storage space in the memory, the space allocation request carrying a data size; Allocating a target storage space for the data according to the received space allocation request; And Based on the allocated target storage space, allocating a storage address for the data; Further comprising: Forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, wherein the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; Forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, wherein the total storage space of a superior node is the sum of the total storage spaces of its subordinate nodes.

2. The method according to claim 1, wherein Allocating a target storage space for the data according to the received space allocation request includes: Retrieving available storage space among the nodes of the tree structure; In response to finding available storage space not less than the data size among the nodes of the tree structure, allocating a target storage space for the data according to the received space allocation request.

3. The method according to claim 2, wherein In response to finding available storage space having the smallest difference from the data size among the nodes of the tree structure, allocating a target storage space for the data according to the received space allocation request.

4. The method according to claim 2, wherein Allocating a target storage space for the data according to the received space allocation request further includes: In response to not finding available storage space not less than the data size among the nodes of the tree structure, creating a new node so that the available storage space can accommodate the data.

5. The method according to claim 4, wherein Creating a new node so that the available storage space can accommodate the data includes: Adjusting a node having available storage space to be a subordinate node of the new node; Creating a new subordinate node under the new node so that the available storage space of the subordinate nodes of the new node can accommodate the data; or Creating a new node so that the available storage space can accommodate the data includes: In response to the available storage space of all nodes in the tree structure being zero, creating a new node so that the available storage space of the new node can accommodate the data; or Creating a new node so that the available storage space can accommodate the data includes: In response to not finding current available storage space not less than the data size among the nodes of the tree structure, and the data size included in the next space allocation request being not greater than the current available storage space, creating a new node so that the available storage space of the new node can accommodate the data.

6. The method according to any one of claims 2-5, wherein, Retrieving available storage space among the nodes of the tree structure includes: After retrieving a superior node and all its subordinate nodes, retrieving another node at the same level as the superior node.

7. The method according to claim 1, further comprising: Adjusting the positions of the nodes so that the spaces of the plurality of storage blocks are continuous.

8. The method according to claim 1, further comprising: Fixing the arrangement order of the nodes in the tree structure.

9. The method according to claim 1, further comprising: releasing a corresponding node in response to receiving a space release request; updating the available storage space identifier of the released node.

10. The method according to claim 1, wherein allocating a storage address for the data based on the allocated target storage space comprises: after allocating a storage address for one node, sequentially allocating addresses for other nodes at the same level, wherein the address of each node covers the addresses of all its subordinate nodes.

11. A method for managing storage space, comprising: forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, wherein the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, wherein the total storage space of a superior node is the sum of the total storage spaces of its subordinate nodes.

12. A method for allocating storage space for data in a memory, comprising: receiving a space allocation request for storage space in the memory, the space allocation request carrying the data size; forming a plurality of storage blocks, each storage block having a total storage space identifier and an available storage space identifier, wherein the total storage space identifier is used to indicate the total storage space of the storage block, and the available storage space identifier is used to indicate the available storage space of the storage block; forming the plurality of storage blocks into a tree structure as nodes, the tree structure including multiple levels of nodes, wherein the total storage space of a superior node is the sum of the total storage spaces of its subordinate nodes; allocating a target storage space for the data according to the received space allocation request and based on the tree structure.

13. The method according to claim 11 or 12, further comprising: retrieving available storage space in the nodes of the tree structure in response to receiving a space allocation request for allocating a target storage space for data; allocating a target storage space for the data according to the received space allocation request in response to finding available storage space not less than the data size in the nodes of the tree structure.

14. The method according to claim 13, wherein, allocating a target storage space for the data according to the received space allocation request in response to finding available storage space having the smallest difference from the data size in the nodes of the tree structure.

15. The method according to claim 13, wherein, creating a new node in response to not finding available storage space not less than the data size in the nodes of the tree structure so that the available storage space can accommodate the data.

16. The method according to claim 15, wherein, Creating a new node so that the available storage space can accommodate the data includes: adjusting a node having available storage space to be a subordinate node of the new node; creating new subordinate nodes under the new node so that the available storage space of the new node can accommodate the data; or Creating a new node so that the available storage space can accommodate the data includes: creating a new node in response to the available storage space of all nodes in the tree structure being zero so that the available storage space of the subordinate nodes of the new node can accommodate the data; or Creating a new node to enable the available storage space to accommodate the data includes: In response to not finding current available storage space not less than the size of the data in the nodes of the tree structure, and the data size included in the next space allocation request not being greater than the current available storage space, creating a new node to enable the available storage space of the new node to accommodate the data.

17. The method according to claim 13, wherein Retrieving available storage space in the nodes of the tree structure includes: After retrieving a parent node and all its child nodes, retrieving another node at the same level as the parent node.

18. The method according to claim 13, further comprising: Adjusting the positions of the nodes so that the spaces of the multiple storage blocks are continuous.

19. The method according to claim 13, further comprising: Fixing the arrangement order of the nodes in the tree structure.

20. An electronic device, comprising: One or more processors; And A memory storing computer-executable instructions that, when run by the one or more processors, cause the electronic device to perform the method according to any one of claims 1-19.

21. A computer-readable storage medium comprising computer-executable instructions that, when run by one or more processors, perform the method according to any one of claims 1-19.

Citation Information

Patent Citations

  • Methods and apparatuses to allocate file storage via tree representations of a bitmap

    US20110153976A1

  • Management method and device of file system

    WO2016191964A1