Memory data read-write method and device, computer equipment and storage medium
By transferring data from low-speed memory to cache memory and using flag bit management, the problem of low-speed memory data transmission efficiency is solved, and more efficient data read and write operations are achieved.
Patent Information
- Application Number
- CN202410944181.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-12-03
AI Technical Summary
During the memory data reading and writing process, due to the low-speed memory and the controller, the data reading and writing efficiency is not high.
Transfer all data in the low-speed memory to the cache memory, and manage the reading and writing of data by setting read and write bits in the cache memory, reducing the space usage of data transmission and improving read efficiency.
Direct data reading and writing operations in cache memory reduces the space occupied by data transmission, improves data reading efficiency, and improves data reading and writing efficiency.
Smart Images

Figure CN119065597A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of memory technology, and more specifically, to a memory data reading and writing method, device, computer equipment and storage medium. Background Art
[0002] When the memory performs data reading and writing operations from an external low-speed memory, it is limited by the communication rate of the memory or by the performance of the central processing unit (CPU).
[0003] Currently, when executing data reading and writing, if the controller needs to read and write the contents inside the low-speed register, the controller will directly obtain the storage information from the low-speed register to ensure that the information locally stored by the slave controller is consistent with the information of the master controller.
[0004] However, a large amount of data needs to be transmitted between the controller and the low-speed memory in the above method, resulting in low data reading and writing efficiency. Summary of the invention
[0005] The main purpose of the present application is to provide a memory data reading and writing method, device, computer equipment and storage medium, which can improve the efficiency of data reading and writing.
[0006] In order to achieve the above objectives, in a first aspect, the present application provides a method for reading and writing memory data, comprising:
[0007] Transferring all data in the low-speed memory to the cache memory, wherein the low-speed memory stores all data through N storage units, wherein N is an integer greater than 1;
[0008] If data is to be read from any one of the N memory cells, data in the memory cell corresponding to any one of the memory cells in the cache memory is read, and if data is to be written to any one of the N memory cells, data is written to the memory cell corresponding to any one of the memory cells in the cache memory.
[0009] In one embodiment, if data in any one of N storage units is to be read, the data in the storage unit corresponding to the one of the storage units in the cache memory is read, including:
[0010] If you want to read data in any storage unit among the N storage units, set the read flag bit of any storage unit among the N storage units to 0;
[0011] Check whether the first read flag bit of the upper level storage unit of the storage unit corresponding to any storage unit in the cache memory is 0;
[0012] If so, read the data in the storage unit corresponding to any storage unit in the cache memory.
[0013] In one embodiment, if data in any one of N storage units is to be read, the data in the storage unit corresponding to the one of the storage units in the cache memory is read, including:
[0014] If data in any storage unit among the N storage units is to be read, check whether the read flag bit of each storage unit in the M-level storage units of the storage unit corresponding to the any storage unit in the cache memory is 0, where M is an integer greater than 1;
[0015] If the read flag bit of any level of storage unit in the M-level storage units is 0, the data in the storage unit corresponding to any storage unit in the cache memory is read.
[0016] In one embodiment, the method further includes:
[0017] If the read flag bits of each level of storage cells in the M-level storage cells are not 0, read the data in any storage cell, write the data in any storage cell to the storage cell corresponding to any storage cell in the cache memory, and set the read flag bits of the storage cell corresponding to any storage cell in the cache memory to 0.
[0018] In one embodiment, if data is to be written into any one of the N storage units, the data is written into a storage unit corresponding to any one of the storage units in the cache memory, further comprising:
[0019] If data is to be written into any storage unit among the N storage units, the write flag bit of any storage unit among the N storage units is set to 0;
[0020] Receive write instruction;
[0021] Based on the write instruction, the data is written into a storage unit corresponding to any storage unit in the cache memory, and the write flag bit of the storage unit corresponding to any storage unit in the cache memory is set to 1.
[0022] In one embodiment, the method further includes:
[0023] Based on the flag bits of the N storage units in the cache memory, the storage data in the low-speed memory and the storage data in the cache memory are synchronized.
[0024] In one embodiment, the N storage units correspond one-to-one to the N first-level storage units, and the N storage units are configured with M-level storage units;
[0025] Based on the flag bits of N storage units in the cache memory, the storage data in the low-speed memory and the storage data in the cache memory are synchronized, including:
[0026] If the processor is idle, traverse the N first-level storage units in the cache memory;
[0027] If the read flag of any one of the N first-level storage units is not 0, and there are storage units at all levels of storage units in the M-1 level storage units under any first-level storage unit whose read flags are not 0, then the data in the storage unit corresponding to any one of the first-level storage units in the low-speed memory is read, the data in the storage unit corresponding to any one of the first-level storage units in the low-speed memory is written into any one of the first-level storage units, and the write flag of the M-level storage units under any one of the first-level storage units is set to 0.
[0028] In one embodiment, the N storage units correspond one-to-one to the N first-level storage units, and the N storage units are configured with M-level storage units;
[0029] Based on the flag bits of N storage units in the cache memory, the storage data in the low-speed memory and the storage data in the cache memory are synchronized, including:
[0030] If the processor is idle, traverse the N first-level storage units in the cache memory;
[0031] If the write flag of any one of the N first-level storage units is not 0, and there are storage units at all levels of storage units in the M-1 level storage units under any first-level storage unit whose write flags are not 0, then the data in any one of the first-level storage units is written to the storage unit corresponding to any one of the first-level storage units in the low-speed memory, and the write flag of the M-1 level storage units under any one of the first-level storage units is set to 0.
[0032] In one embodiment, the N storage units correspond one-to-one to the N primary storage units;
[0033] The method also includes:
[0034] Calculate the number of primary storage units N:
[0035] Get the communication rate, maximum communication duration per second, synchronization frequency per second, and preset threshold;
[0036] Determine a first calculation result based on the communication rate, the maximum communication duration per second, the synchronization frequency per second and the preset threshold;
[0037] The minimum integer of the first calculation result is used as the number N of the primary storage units.
[0038] In one embodiment, based on the communication rate, the maximum communication duration per second, the synchronization frequency per second and the preset threshold, the first calculation result is determined, including:
[0039] Calculate the product of the communication rate and the maximum communication duration per second to obtain a first product;
[0040] Calculate the product of the synchronization frequency per second and the preset threshold to obtain a second product;
[0041] A quotient of the first product and the second product is calculated to obtain a first calculation result.
[0042] In one embodiment, N memory cells are configured with M levels of memory cells;
[0043] The method also includes:
[0044] Calculate the product of the number of storage units at each level in the M-level storage unit:
[0045] Get the synchronization information size, synchronization frequency per second, number of primary storage units N, communication rate and maximum communication duration per second;
[0046] Determine a second calculation result based on the synchronization information size, the synchronization frequency per second, the number N of primary storage units, the communication rate, and the maximum communication duration per second;
[0047] The maximum integer of the second calculation result is taken as the product of the number of each level of storage cells in the M level storage cells.
[0048] In one embodiment, the second calculation result is determined based on the synchronization information size, the synchronization frequency per second, the number N of primary storage units, the communication rate, and the maximum communication duration per second, including:
[0049] Calculate the product of the synchronization information size and the synchronization frequency per second to obtain a third product;
[0050] Calculate the product of the number N of primary storage units, the communication rate, and the maximum communication duration per second to obtain a fourth product;
[0051] A quotient of the third product and the fourth product is calculated to obtain a second calculation result.
[0052] In a second aspect, an embodiment of the present application provides a memory data reading and writing device, comprising:
[0053] A data transfer module, used to transfer all data in the low-speed memory to the cache memory, wherein the low-speed memory stores all data through N storage units, wherein N is an integer greater than 1;
[0054] A data reading and writing module is used to read data from any storage unit among the N storage units, read data from a storage unit corresponding to any storage unit in the cache memory, and to write data to a storage unit corresponding to any storage unit in the cache memory if data is to be written to any storage unit among the N storage units.
[0055] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.
[0056] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0057] The embodiments of the present application provide a memory data reading and writing method, device, computer equipment and storage medium, including: transferring all data in a low-speed memory to a cache memory, wherein the low-speed memory stores all data through N storage units, wherein N is an integer greater than 1, and if data in any of the N storage units is to be read, data in a storage unit corresponding to any storage unit in the cache memory is read, and if data is to be written to any of the N storage units, data is written to a storage unit corresponding to any storage unit in the cache memory. The present application directly transfers data in a low-speed memory to a cache memory, so that a controller directly reads and writes data in the cache memory, which not only reduces the space occupied by reading data, but also improves data reading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The drawings constituting a part of this application are used to provide a further understanding of this application, so that other features, purposes and advantages of this application become more obvious. The schematic embodiment drawings and their descriptions of this application are used to explain this application and do not constitute an improper limitation on this application. In the drawings:
[0059] Figure 1 This is an application scenario of a memory data reading and writing method provided by an embodiment of the present application;
[0060] Figure 2 It is a flowchart of a method for reading and writing memory data provided by an embodiment of the present application;
[0061] Figure 3 It is a flowchart of a memory data reading method provided in an embodiment of the present application;
[0062] Figure 4It is a flowchart of a method for writing data into a memory provided by an embodiment of the present application;
[0063] Figure 5 It is a flowchart of a memory data synchronization method provided by an embodiment of the present application;
[0064] Figure 6 It is a flowchart of another memory data synchronization method provided by an embodiment of the present application;
[0065] Figure 7 It is a structural schematic diagram of a memory data reading and writing device provided in an embodiment of the present application;
[0066] Figure 8 It is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0068] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the application described herein can be implemented in an order other than those illustrated or described herein.
[0069] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0070] It should be understood that in the present application, "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0071] It should be understood that in the present application, "plurality" refers to two or more than two. "And / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "Contains A, B and C", "Contains A, B, C" means that A, B, and C are all included, "Contains A, B or C" means that one of A, B, and C is included, and "Contains A, B and / or C" means that any one, any two, or any three of A, B, and C are included.
[0072] It should be understood that in this application, "B corresponding to A", "B corresponding to A", "A corresponds to B" or "B corresponds to A" means that B is associated with A and B can be determined based on A. Determining B based on A does not mean determining B based only on A, but B can also be determined based on A and / or other information. A and B match when the similarity between A and B is greater than or equal to a preset threshold.
[0073] Depending on the context, "if" as used herein may be interpreted as "when" or "when" or "in response to determining" or "in response to detecting."
[0074] The data involved in this application may be data authorized by the tester or fully authorized by all parties. The collection, dissemination, and use of the data shall comply with the relevant laws, regulations, and standards of the relevant countries and regions. The implementation methods / examples of this application may be combined with each other.
[0075] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0076] Next, the present application scheme will be described through specific embodiments in conjunction with the accompanying drawings.
[0077] See also Figure 1 , Figure 1 A schematic diagram of the structure of memory data reading and writing provided in an embodiment of the present application.
[0078] like Figure 1 As shown, it includes a controller, a cache memory and a low-speed memory. The low-speed memory and the cache memory perform data transmission. For example, the low-speed memory transfers all data to the cache memory, and then the controller can read and write the transferred data in the low-speed memory by reading and writing the transferred data in the cache memory.
[0079] The storage data in the low-speed memory is stored in N storage units, and each storage unit is divided into M-level storage blocks (units), such as primary storage units, secondary storage units, tertiary storage units, etc., where M and N are both integers greater than 1. In addition, each primary storage unit and secondary storage unit is configured with a corresponding read (Dirty) flag bit and a write (Write) flag bit.
[0080] Exemplarily, as shown in Table 1 below, the right side is the first-level storage unit 1...the first-level storage unit N, and each level of storage unit is configured with a corresponding Dirty flag, such as the first-level storage unit 1 corresponds to the read flag 1 and the write flag 1...the first-level storage unit N corresponds to the read flag N and the write flag N.
[0081] Furthermore, in the case of M=2, the storage unit is divided into 2 levels, and each primary storage unit is configured with a corresponding secondary storage unit, and each secondary storage unit is also configured with a corresponding read flag and write flag. For example, primary storage unit 1 is configured with secondary storage unit 1, secondary storage unit 2, and secondary storage unit 3, and secondary storage unit 1 is configured with Dirty flag 1A and Write flag 1B, and secondary storage unit 2 is configured with Dirty flag 2A and Dirty flag 2B, etc.
[0082] Table 1 Storage unit examples
[0083]
[0084]
[0085] See also Figure 2 , Figure 2 A flowchart of a method for reading and writing memory data provided by an embodiment of the present application is shown in FIG. Figure 2 As shown, applied to Figure 1 The controller in includes the following steps:
[0086] Step S201: transfer all data in the low-speed memory to the cache memory.
[0087] The low-speed memory stores all data via N storage units, where N is an integer greater than 1.
[0088] Step S202: If data in any storage unit among the N storage units is to be read, the data in the storage unit corresponding to any storage unit in the cache memory is read, and if data is to be written to any storage unit among the N storage units, the data is written to the storage unit corresponding to any storage unit in the cache memory.
[0089] In one embodiment, if data in any one of N storage cells is to be read, data in a storage cell corresponding to any one of the storage cells in the cache memory is read, including: if data in any one of the N storage cells is to be read, setting a read flag of any one of the N storage cells to 0; checking whether a first read flag of an upper-level storage cell of a storage cell corresponding to any one of the storage cells in the cache memory is 0; if so, reading data in a storage cell corresponding to any one of the storage cells in the cache memory.
[0090] In another embodiment, if data in any one of N storage cells is to be read, data in a storage cell corresponding to any one of the storage cells in the cache memory is read, including: if data in any one of the N storage cells is to be read, checking whether a read flag bit of each level of storage cells in M levels of storage cells corresponding to any one of the storage cells in the cache memory is 0, where M is an integer greater than 1; if the read flag bit of any one level of storage cells in the M levels of storage cells is 0, reading data in the storage cell corresponding to any one of the storage cells in the cache memory.
[0091] In addition, it also includes: if the read flag bits of each level of storage cells in the M-level storage cells are not 0, read the data in any storage cell, write the data in any storage cell to the storage cell corresponding to any storage cell in the cache memory, and set the read flag bit of the storage cell corresponding to any storage cell in the cache memory to 0.
[0092] Combination Figure 3 , when M=2, if you want to read the data in the storage cell P among the N storage cells in the low-speed cache, you need to check whether the first read flag of the first-level storage cell on the storage cell Q corresponding to the storage cell P in the cache memory is 0. If so, read the data in the storage cell Q corresponding to the storage cell P in the cache memory; if not, check whether the read flag of the second-level storage cell L is 0. If the read flag of the second-level storage cell L is 0, read the data in the storage cell Q corresponding to the storage cell P in the cache memory; if the read flag of the second-level storage cell L is not 0, write the data in the storage cell P to the storage cell Q corresponding to the storage cell P in the cache memory, and set the read flag of the storage cell Q corresponding to the storage cell P in the cache memory to 0.
[0093] In one embodiment, if data is to be written to any one of N storage cells, the data is written to a storage cell in a cache memory corresponding to any one of the storage cells, including: if data is to be written to any one of the N storage cells, the write flag of any one of the N storage cells is set to 0; a write instruction is received; based on the write instruction, the data is written to a storage cell in the cache memory corresponding to any one of the storage cells, and the write flag of the storage cell in the cache memory corresponding to any one of the storage cells is set to 1.
[0094] Combination Figure 4 , if the data in the low-speed memory is to be written into the storage unit P, a write instruction is received, and based on the write instruction, the data is written into the storage unit Q corresponding to the storage unit P in the cache memory, and the write flag bit of the storage unit Q is set to 1
[0095] In one embodiment, the present application also synchronizes the storage data in the low-speed memory and the storage data in the cache memory based on the flag bits of N storage units in the cache memory.
[0096] In the case where N storage units correspond one-to-one to N first-level storage units and the N storage units are configured with M-level storage units, based on the flag bits of the N storage units in the cache memory, the storage data in the low-speed memory and the storage data in the cache memory are synchronized, including: if the processor is idle, traverse the N first-level storage units in the cache memory; if the read flag bit of any first-level storage unit in the N first-level storage units is not 0, and there are storage units with read flag bits not 0 in all levels of storage units in the M-1-level storage units under any first-level storage unit, then read the data in the storage unit corresponding to any first-level storage unit in the low-speed memory, write the data in the storage unit corresponding to any first-level storage unit in the low-speed memory into any first-level storage unit, and set the write flag bit of the M-level storage unit under any first-level storage unit to 0.
[0097] Combination Figure 5, assuming that the storage unit level is set to a primary storage unit and a secondary storage unit. First check whether the processor CPU is in an idle state. If the processor is idle, traverse the N primary storage units in the cache memory. If the read flag of any of the N primary storage units is not 0, traverse each storage unit in the secondary storage unit under any primary storage unit in the cache memory. If there is a storage unit with a read flag not 0 in each storage unit in the secondary storage unit under any primary storage unit, assuming that any storage unit is Q, read the data in the storage unit P corresponding to the storage unit Q in the low-speed memory, write the data in the storage unit P into the storage unit Q, and set the write flag of the secondary storage unit under the storage unit Q to 0. Repeat the above method until all primary storage units and secondary storage units are traversed.
[0098] In the case where N storage units correspond one-to-one to N first-level storage units and the N storage units are configured with M-level storage units, based on the flag bits of the N storage units in the cache memory, the storage data in the low-speed memory and the storage data in the cache memory are synchronized, including: if the processor is idle, traverse the N first-level storage units in the cache memory; if the write flag bit of any first-level storage unit in the N first-level storage units is not 0, and there are storage units with write flag bits not 0 in all levels of storage units in the M-1-level storage units under any first-level storage unit, then the data in any first-level storage unit is written to the storage unit corresponding to any first-level storage unit in the low-speed memory, and the write flag bit of the M-level storage unit under any first-level storage unit is set to 0.
[0099] Combination Figure 6 , assuming that the storage unit level is set to a primary storage unit and a secondary storage unit. First check whether the processor CPU is in an idle state. If the processor is idle, traverse the N primary storage units in the cache memory. If the write flag of any of the N primary storage units is not 0, traverse each storage unit in the secondary storage unit under any primary storage unit. If there is a storage unit with a write flag not 0 in each storage unit in the secondary storage unit under any primary storage unit, assuming that any storage unit is Q, then write the data in the storage unit Q to the storage unit P corresponding to the storage unit Q in the low-speed memory, and set the write flag of the secondary storage unit under the storage unit Q to 0. Repeat the above method until all primary storage units and secondary storage units are traversed.
[0100] Based on the data that needs to be synchronized, the application can divide the levels and numbers of storage units storing the data that needs to be synchronized, as follows:
[0101] Assume that the present application is configured to have N storage units for data to be synchronized, and the N storage units correspond one to one to the N primary storage units. Then, to calculate the number N of primary storage units, it is necessary to first obtain the communication rate, the maximum communication duration per second, the synchronization frequency per second, and the preset threshold, and then determine the first calculation result based on the communication rate, the maximum communication duration per second, the synchronization frequency per second, and the preset threshold, and then use the minimum integer of the first calculation result as the number N of primary storage units. The preset threshold can be set according to the specific situation and is not specifically limited here.
[0102] Among them, based on the communication rate, the maximum communication time per second, the synchronization frequency per second and the preset threshold, the first calculation result is determined, including: calculating the product of the communication rate and the maximum communication time per second to obtain the first product; calculating the product of the synchronization frequency per second and the preset threshold to obtain the second product; calculating the quotient of the first product and the second product to obtain the first calculation result.
[0103] For example, if the capacity of the data to be synchronized for positioning is M bits, the communication rate is V bps, and the frequency of information synchronization is f cycle / s, then the relevant communication indicators are shown in Table 2.
[0104] Table 2 Synchronous data communication indicators
[0105]
[0106]
[0107] The number N of primary storage units is calculated as follows:
[0108] N = minimum integer [V*△t / 8f]
[0109] Furthermore, the present application limits the product of the number of each storage unit in the divided level corresponding to the level of storage unit division, and based on the product of the number of each storage unit, the number of each storage unit can be flexibly adjusted.
[0110] To calculate the product of the number of storage units at each level in the M-level storage unit, it is necessary to first obtain the synchronization information size, the synchronization frequency per second, the number of first-level storage units N, the communication rate and the maximum communication duration per second, and then determine the second calculation result based on the synchronization information size, the synchronization frequency per second, the number of first-level storage units N, the communication rate and the maximum communication duration per second, and then use the maximum integer of the second calculation result as the product of the number of storage units at each level in the M-level storage unit.
[0111] Among them, based on the synchronization information size, the synchronization frequency per second, the number of primary storage units N, the communication rate and the maximum communication time per second, the second calculation result is determined, including: calculating the product of the synchronization information size and the synchronization frequency per second to obtain a third product; calculating the product of the number of primary storage units N, the communication rate and the maximum communication time per second to obtain a fourth product; calculating the quotient of the third product and the fourth product to obtain the second calculation result.
[0112] The product calculation formula of the number of storage units at each level in the M-level storage unit is as follows:
[0113] Z = maximum integer [M*f / (P*V*△t)]
[0114] For example, suppose there are four levels of storage units, and the number of storage units in each level is N, A, B, and C respectively. Then:
[0115] N*A*B*C = maximum integer [M*f / (P*V*△t)]
[0116] The present application not only improves the flexibility of storage unit division, but also improves the utilization rate of storage units by dividing the storage unit levels and the number of storage units at each level according to the data that needs to be synchronized.
[0117] The embodiment of the present application provides a method for reading and writing memory data, including: transferring all data in a low-speed memory to a cache memory, wherein the low-speed memory stores all data through N storage units, wherein N is an integer greater than 1, and if data in any of the N storage units is to be read, data in a storage unit corresponding to any storage unit in the cache memory is read, and if data is to be written to any of the N storage units, data is written to a storage unit corresponding to any storage unit in the cache memory. The present application directly transfers data in a low-speed memory to a cache memory, so that a controller directly reads and writes data in the cache memory, which not only reduces the space occupied by reading data, but also improves data reading efficiency.
[0118] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0119] The following is an embodiment of the device of the present application. For details not described in detail, please refer to the corresponding method embodiment described above.
[0120] Figure 7A schematic diagram of the structure of a memory data reading and writing device provided in an embodiment of the present application is shown. For the convenience of explanation, only the part related to the embodiment of the present application is shown. A memory data reading and writing device includes a data transfer module 701 and a data reading and writing module 702, which are as follows:
[0121] The data transfer module 701 is used to transfer all data in the low-speed memory to the cache memory, wherein the low-speed memory stores all data through N storage units, wherein N is an integer greater than 1;
[0122] The data reading and writing module 702 is used to read the data in any storage unit among the N storage units, read the data in the storage unit corresponding to any storage unit in the cache memory, and to write the data in any storage unit among the N storage units, write the data in the storage unit corresponding to any storage unit in the cache memory.
[0123] In one embodiment, the data reading and writing module 702 is further used to set the read flag bit of any storage unit in the N storage units to 0 if data in any storage unit in the N storage units is to be read;
[0124] Check whether the first read flag bit of the upper level storage unit of the storage unit corresponding to any storage unit in the cache memory is 0;
[0125] If so, read the data in the storage unit corresponding to any storage unit in the cache memory.
[0126] In one embodiment, the data reading and writing module 702 is further used to check whether the read flag bit of each level of storage cells in the M-level storage cells of the storage cells corresponding to the any storage cell in the cache memory is 0 if data in any storage cell among the N storage cells is to be read, where M is an integer greater than 1;
[0127] If the read flag bit of any level of storage unit in the M-level storage units is 0, the data in the storage unit corresponding to any storage unit in the cache memory is read.
[0128] In one embodiment, the device also includes: a data writing module, which is used to read data in any storage unit if the read flag bits of each level of storage units in the M-level storage units are not 0, write the data in any storage unit to the storage unit corresponding to any storage unit in the cache memory, and set the read flag bit of the storage unit corresponding to any storage unit in the cache memory to 0.
[0129] In one embodiment, the data reading and writing module 702 is further used to set the write flag bit of any storage unit in the N storage units to 0 if data is to be written into any storage unit in the N storage units;
[0130] Receive write instruction;
[0131] Based on the write instruction, the data is written into a storage unit corresponding to any storage unit in the cache memory, and the write flag bit of the storage unit corresponding to any storage unit in the cache memory is set to 1.
[0132] In one embodiment, the device further includes: a data synchronization module, which is used to synchronize the storage data in the low-speed memory and the storage data in the cache memory based on the flag bits of the N storage units in the cache memory.
[0133] In one embodiment, the N storage units correspond one-to-one to the N first-level storage units, and the N storage units are configured with M-level storage units;
[0134] The data synchronization module is also used to traverse N primary storage units in the cache memory if the processor is idle;
[0135] If the read flag of any one of the N first-level storage units is not 0, and there are storage units at all levels of storage units in the M-1 level storage units under any first-level storage unit whose read flags are not 0, then the data in the storage unit corresponding to any one of the first-level storage units in the low-speed memory is read, the data in the storage unit corresponding to any one of the first-level storage units in the low-speed memory is written into any one of the first-level storage units, and the write flag of the M-level storage units under any one of the first-level storage units is set to 0.
[0136] In one embodiment, the N storage units correspond one-to-one to the N first-level storage units, and the N storage units are configured with M-level storage units;
[0137] The data synchronization module is also used to traverse N primary storage units in the cache memory if the processor is idle;
[0138] If the write flag of any one of the N first-level storage units is not 0, and there are storage units at all levels of storage units in the M-1 level storage units under any first-level storage unit whose write flags are not 0, then the data in any one of the first-level storage units is written to the storage unit corresponding to any one of the first-level storage units in the low-speed memory, and the write flag of the M-1 level storage units under any one of the first-level storage units is set to 0.
[0139] In one embodiment, the N storage units correspond one-to-one to the N primary storage units;
[0140] The device also includes: a first calculation module, the first calculation module is used to calculate the number N of primary storage units:
[0141] Get the communication rate, maximum communication duration per second, synchronization frequency per second, and preset threshold;
[0142] Determine a first calculation result based on the communication rate, the maximum communication duration per second, the synchronization frequency per second and the preset threshold;
[0143] The minimum integer of the first calculation result is used as the number N of the primary storage units.
[0144] In one embodiment, the first calculation module is further used to calculate the product of the communication rate and the maximum communication duration per second to obtain a first product;
[0145] Calculate the product of the synchronization frequency per second and the preset threshold to obtain a second product;
[0146] A quotient of the first product and the second product is calculated to obtain a first calculation result.
[0147] In one embodiment, N memory cells are configured with M levels of memory cells;
[0148] The device also includes: a second calculation module, the second calculation module is used to calculate the product of the number of storage units at each level in the M-level storage unit:
[0149] Get the synchronization information size, synchronization frequency per second, number of primary storage units N, communication rate and maximum communication duration per second;
[0150] Determine a second calculation result based on the synchronization information size, the synchronization frequency per second, the number N of primary storage units, the communication rate, and the maximum communication duration per second;
[0151] The maximum integer of the second calculation result is taken as the product of the number of each level of storage cells in the M level storage cells.
[0152] In one embodiment, the second calculation module is further used to calculate the product of the synchronization information size and the synchronization frequency per second to obtain a third product;
[0153] Calculate the product of the number N of primary storage units, the communication rate, and the maximum communication duration per second to obtain a fourth product;
[0154] A quotient of the third product and the fourth product is calculated to obtain a second calculation result.
[0155] This application Figure 8 A schematic diagram of a computer device is provided. Figure 8As shown, the computer device 8 of this embodiment includes: a processor 801, a memory 802, and a computer program 803 stored in the memory 802 and executable on the processor 801. When the processor 801 executes the computer program 803, the steps in the above-mentioned memory data reading and writing method embodiments are implemented, for example Figure 1 Alternatively, when the processor 801 executes the computer program 803, the functions of each module / unit in the above-mentioned memory data reading and writing device embodiments are realized, for example Figure 7 Functionality of modules / units 701 to 702 shown.
[0156] The present application also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the memory data reading and writing methods provided in the above-mentioned various embodiments.
[0157] Among them, the readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The computer storage medium can be any available medium that can be accessed by a general or special-purpose computer. For example, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application-specific integrated circuit (ASIC). In addition, the ASIC can be located in a user device. Of course, the processor and the readable storage medium can also exist in a communication device as discrete components. The readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0158] The present application also provides a program product, which includes an execution instruction, which is stored in a readable storage medium. At least one processor of the device can read the execution instruction from the readable storage medium, and at least one processor executes the execution instruction so that the device implements the memory data reading and writing method provided by the various embodiments described above.
[0159] In the embodiments of the above-mentioned devices, it should be understood that the processor may be a central processing unit, or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0160] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for reading and writing memory data, characterized in that: include: Transferring all data in the low-speed memory to the cache memory, wherein the low-speed memory stores all the data through N storage units, wherein N is an integer greater than 1; If data is to be read from any one of the N storage units, data is read from the storage unit corresponding to the any one of the storage units in the cache memory, and if data is to be written to any one of the N storage units, the data is written to the storage unit corresponding to the any one of the storage units in the cache memory.
2. The memory data reading and writing method according to claim 1, wherein: If data in any one of the N storage units is to be read, reading data in a storage unit corresponding to the any one of the storage units in the cache memory includes: If data in any one of the N storage units is to be read, a read flag bit of any one of the N storage units is set to 0; Check whether the first read flag bit of the upper-level storage unit of the storage unit corresponding to any storage unit in the cache memory is 0; If so, read the data in the storage unit corresponding to any one of the storage units in the cache memory.
3. The memory data reading and writing method according to claim 1, wherein: If data in any one of the N storage units is to be read, reading data in a storage unit corresponding to the any one of the storage units in the cache memory includes: If data in any one of the N storage units is to be read, checking whether a read flag bit of each level of storage units in M levels of storage units corresponding to the any one of the storage units in the cache memory is 0, where M is an integer greater than 1; If the read flag of any level-one storage unit in the M-level storage units is 0, data in the storage unit corresponding to the any storage unit in the cache memory is read.
4. The memory data reading and writing method according to claim 3, wherein: The method further comprises: If the read flag of each level of storage cells in the M-level storage cells is not 0, read the data in any of the storage cells, write the data in any of the storage cells into the storage cells corresponding to any of the storage cells in the cache memory, and set the read flag of the storage cells corresponding to any of the storage cells in the cache memory to 0.
5. The memory data reading and writing method according to claim 1, wherein: If data is to be written into any one of the N storage units, the data is written into a storage unit in the cache memory corresponding to the any one storage unit, further comprising: If data is to be written into any one of the N storage units, the write flag of any one of the N storage units is set to 0; Receive write instruction; Based on the write instruction, the data is written into the storage unit corresponding to the any storage unit in the cache memory, and the write flag of the storage unit corresponding to the any storage unit in the cache memory is set to 1.
6. The memory data reading and writing method according to claim 1, wherein: The method further comprises: Based on the flag bits of the N storage units in the cache memory, the storage data in the low-speed memory and the storage data in the cache memory are synchronized.
7. The memory data reading and writing method according to claim 6, wherein: The N storage units correspond one-to-one to the N first-level storage units, and the N storage units are configured with M-level storage units; The step of synchronizing the stored data in the low-speed memory and the stored data in the cache memory based on the flag bits of the N storage units in the cache memory comprises: If the processor is idle, traverse N first-level storage units in the cache memory; If the read flag of any one of the N first-level storage units is not 0, and there are storage units at all levels of storage units in the M-1 level storage units under any one of the first-level storage units whose read flags are not 0, then the data in the storage unit corresponding to any one of the first-level storage units in the low-speed memory is read, the data in the storage unit corresponding to any one of the first-level storage units in the low-speed memory is written into the any one of the first-level storage units, and the write flag of the M level storage units under the any one of the first-level storage units is set to 0.
8. The memory data reading and writing method according to claim 6, wherein: The N storage units correspond one-to-one to the N first-level storage units, and the N storage units are configured with M-level storage units; The step of synchronizing the stored data in the low-speed memory and the stored data in the cache memory based on the flag bits of the N storage units in the cache memory comprises: If the processor is idle, traverse N first-level storage units in the cache memory; If the write flag of any one of the N first-level storage units is not 0, and there are storage units with write flags that are not 0 in all levels of storage units in the M-1 level storage units under any one of the first-level storage units, then the data in any one of the first-level storage units is written into the storage unit corresponding to any one of the first-level storage units in the low-speed memory, and the write flag of the M level storage units under any one of the first-level storage units is set to 0.
9. The memory data reading and writing method according to claim 1, wherein: The N storage units correspond one-to-one to the N primary storage units; The method further comprises: Calculate the number of primary storage units N: Get the communication rate, maximum communication duration per second, synchronization frequency per second, and preset thresholds; Determining a first calculation result based on the communication rate, the maximum communication duration per second, the synchronization frequency per second, and a preset threshold; The minimum integer of the first calculation result is used as the number N of the first-level storage units.
10. The memory data reading and writing method according to claim 9, wherein: The determining of a first calculation result based on the communication rate, the maximum communication duration per second, the synchronization frequency per second, and the preset threshold value includes: Calculating the product of the communication rate and the maximum communication duration per second to obtain a first product; Calculating the product of the synchronization frequency per second and the preset threshold to obtain a second product; Calculate the quotient of the first product and the second product to obtain the first calculation result.
11. The memory data reading and writing method according to claim 1, wherein: The N storage units are configured with M levels of storage units; The method further comprises: Calculate the product of the number of storage cells at each level in the M-level storage cell: Get the synchronization information size, synchronization frequency per second, number of primary storage units N, communication rate and maximum communication duration per second; Determining a second calculation result based on the synchronization information size, the synchronization frequency per second, the number N of primary storage units, the communication rate, and the maximum communication duration per second; The maximum integer of the second calculation result is used as the product of the number of storage units of each level in the M levels of storage units.
12. The memory data reading and writing method according to claim 11, wherein: The determining of the second calculation result based on the synchronization information size, the synchronization frequency per second, the number N of primary storage units, the communication rate, and the maximum communication duration per second includes: Calculating the product of the synchronization information size and the synchronization frequency per second to obtain a third product; Calculating the product of the number N of the primary storage units, the communication rate, and the maximum communication duration per second to obtain a fourth product; Calculate the quotient of the third product and the fourth product to obtain the second calculation result.
13. A memory data reading and writing device, characterized in that: include: a data transfer module, configured to transfer all data in the low-speed memory to the cache memory, wherein the low-speed memory stores all the data via N storage units, where N is an integer greater than 1; A data reading and writing module is used to read data from any one of the N storage units, read data from a storage unit corresponding to the any one of the N storage units, and to write data to a storage unit corresponding to the any one of the N storage units in the cache memory.
14. A computer device, characterized in that: comprising a memory, and one or more processors communicatively connected to the memory; The memory stores instructions that can be executed by the one or more processors. The instructions are executed by the one or more processors to enable the one or more processors to implement the memory data reading and writing method according to claims 1 to 12.
15. A computer-readable storage medium, characterized in that The method comprises a program or an instruction, which, when executed on a computer, implements the memory data reading and writing method according to claims 1 to 12.
